Compare commits
2 Commits
81cc6a8cde
...
5c29120a44
Author | SHA1 | Date | |
---|---|---|---|
5c29120a44 | |||
f21ce40186 |
|
@ -101,7 +101,8 @@ TODO List:
|
||||||
(new 2021-05-29. I will proceed in this order unless I get other requests)
|
(new 2021-05-29. I will proceed in this order unless I get other requests)
|
||||||
* ✓ Implement [AWS query protocol](https://awslabs.github.io/smithy/1.0/spec/aws/aws-query-protocol.html). This is the protocol in use by sts.getcalleridentity. Total service count 18
|
* ✓ Implement [AWS query protocol](https://awslabs.github.io/smithy/1.0/spec/aws/aws-query-protocol.html). This is the protocol in use by sts.getcalleridentity. Total service count 18
|
||||||
* ✓ Implement [AWS Json 1.0 protocol](https://awslabs.github.io/smithy/1.0/spec/aws/aws-json-1_0-protocol.html). Includes dynamodb. Total service count 18
|
* ✓ Implement [AWS Json 1.0 protocol](https://awslabs.github.io/smithy/1.0/spec/aws/aws-json-1_0-protocol.html). Includes dynamodb. Total service count 18
|
||||||
* Implement [AWS Json 1.1 protocol](https://awslabs.github.io/smithy/1.0/spec/aws/aws-json-1_1-protocol.html). Includes ecs. Total service count 105
|
* ✓ Implement [AWS Json 1.1 protocol](https://awslabs.github.io/smithy/1.0/spec/aws/aws-json-1_1-protocol.html). Includes ecs. Total service count 105
|
||||||
|
* Implement [AWS Rest Json 1 protocol](https://awslabs.github.io/smithy/1.0/spec/aws/aws-restjson1-protocol.html). Includes lambda. Total service count 127
|
||||||
* Implement [AWS restXml protocol](https://awslabs.github.io/smithy/1.0/spec/aws/aws-restxml-protocol.html). Includes S3. Total service count 4. This may be blocked due to the same issue as EC2.
|
* Implement [AWS restXml protocol](https://awslabs.github.io/smithy/1.0/spec/aws/aws-restxml-protocol.html). Includes S3. Total service count 4. This may be blocked due to the same issue as EC2.
|
||||||
* Implement [AWS EC2 query protocol](https://awslabs.github.io/smithy/1.0/spec/aws/aws-ec2-query-protocol.html). Includes EC2. Total service count 1. This is currently blocked, probably on self-hosted compiler coming in zig 0.9.0 (January 2022) due to compiler bug discovered. More details and llvm ir log can be found in the [XML branch](https://git.lerch.org/lobo/aws-sdk-for-zig/src/branch/xml).
|
* Implement [AWS EC2 query protocol](https://awslabs.github.io/smithy/1.0/spec/aws/aws-ec2-query-protocol.html). Includes EC2. Total service count 1. This is currently blocked, probably on self-hosted compiler coming in zig 0.9.0 (January 2022) due to compiler bug discovered. More details and llvm ir log can be found in the [XML branch](https://git.lerch.org/lobo/aws-sdk-for-zig/src/branch/xml).
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,7 @@ fn generateServices(allocator: *std.mem.Allocator, comptime _: []const u8, file:
|
||||||
for (services.items) |service| {
|
for (services.items) |service| {
|
||||||
var sdk_id: []const u8 = undefined;
|
var sdk_id: []const u8 = undefined;
|
||||||
var version: []const u8 = service.shape.service.version;
|
var version: []const u8 = service.shape.service.version;
|
||||||
|
var name: []const u8 = service.name;
|
||||||
var arn_namespace: []const u8 = undefined;
|
var arn_namespace: []const u8 = undefined;
|
||||||
var sigv4_name: []const u8 = undefined;
|
var sigv4_name: []const u8 = undefined;
|
||||||
var endpoint_prefix: []const u8 = undefined;
|
var endpoint_prefix: []const u8 = undefined;
|
||||||
|
@ -114,6 +115,7 @@ fn generateServices(allocator: *std.mem.Allocator, comptime _: []const u8, file:
|
||||||
try writer.print("pub const arn_namespace: []const u8 = \"{s}\";\n", .{arn_namespace});
|
try writer.print("pub const arn_namespace: []const u8 = \"{s}\";\n", .{arn_namespace});
|
||||||
try writer.print("pub const endpoint_prefix: []const u8 = \"{s}\";\n", .{endpoint_prefix});
|
try writer.print("pub const endpoint_prefix: []const u8 = \"{s}\";\n", .{endpoint_prefix});
|
||||||
try writer.print("pub const sigv4_name: []const u8 = \"{s}\";\n", .{sigv4_name});
|
try writer.print("pub const sigv4_name: []const u8 = \"{s}\";\n", .{sigv4_name});
|
||||||
|
try writer.print("pub const name: []const u8 = \"{s}\";\n", .{name});
|
||||||
// TODO: This really should just be ".whatevs". We're fully qualifying here, which isn't typical
|
// TODO: This really should just be ".whatevs". We're fully qualifying here, which isn't typical
|
||||||
try writer.print("pub const aws_protocol: smithy.AwsProtocol = smithy.{s};\n\n", .{aws_protocol});
|
try writer.print("pub const aws_protocol: smithy.AwsProtocol = smithy.{s};\n\n", .{aws_protocol});
|
||||||
_ = try writer.write("pub const service_metadata : struct {\n");
|
_ = try writer.write("pub const service_metadata : struct {\n");
|
||||||
|
@ -122,6 +124,7 @@ fn generateServices(allocator: *std.mem.Allocator, comptime _: []const u8, file:
|
||||||
try writer.print(" arn_namespace: []const u8 = \"{s}\",\n", .{arn_namespace});
|
try writer.print(" arn_namespace: []const u8 = \"{s}\",\n", .{arn_namespace});
|
||||||
try writer.print(" endpoint_prefix: []const u8 = \"{s}\",\n", .{endpoint_prefix});
|
try writer.print(" endpoint_prefix: []const u8 = \"{s}\",\n", .{endpoint_prefix});
|
||||||
try writer.print(" sigv4_name: []const u8 = \"{s}\",\n", .{sigv4_name});
|
try writer.print(" sigv4_name: []const u8 = \"{s}\",\n", .{sigv4_name});
|
||||||
|
try writer.print(" name: []const u8 = \"{s}\",\n", .{name});
|
||||||
// TODO: This really should just be ".whatevs". We're fully qualifying here, which isn't typical
|
// TODO: This really should just be ".whatevs". We're fully qualifying here, which isn't typical
|
||||||
try writer.print(" aws_protocol: smithy.AwsProtocol = smithy.{s},\n", .{aws_protocol});
|
try writer.print(" aws_protocol: smithy.AwsProtocol = smithy.{s},\n", .{aws_protocol});
|
||||||
_ = try writer.write("} = .{};\n");
|
_ = try writer.write("} = .{};\n");
|
||||||
|
|
20
src/aws.zig
20
src/aws.zig
|
@ -72,19 +72,9 @@ pub const Aws = struct {
|
||||||
|
|
||||||
/// Calls using one of the json protocols (rest_json_1, json_1_0, json_1_1
|
/// Calls using one of the json protocols (rest_json_1, json_1_0, json_1_1
|
||||||
fn callJson(self: Self, comptime request: anytype, comptime service_meta: anytype, action: anytype, options: Options) !FullResponse(request) {
|
fn callJson(self: Self, comptime request: anytype, comptime service_meta: anytype, action: anytype, options: Options) !FullResponse(request) {
|
||||||
// Target might be a problem. The smithy docs differ fairly significantly
|
|
||||||
// from the REST API examples. Here I'm following the REST API examples
|
|
||||||
// as they have not yet led me astray. Whether they're consistent
|
|
||||||
// across other services is another matter...
|
|
||||||
var version = try self.allocator.alloc(u8, service_meta.version.len);
|
|
||||||
defer self.allocator.free(version);
|
|
||||||
const replacements = std.mem.replace(u8, service_meta.version, "-", "", version);
|
|
||||||
// Resize the version, otherwise the junk at the end will mess with allocPrint
|
|
||||||
version = try self.allocator.resize(version, version.len - replacements);
|
|
||||||
const target =
|
const target =
|
||||||
try std.fmt.allocPrint(self.allocator, "{s}_{s}.{s}", .{
|
try std.fmt.allocPrint(self.allocator, "{s}.{s}", .{
|
||||||
service_meta.sdk_id,
|
service_meta.name,
|
||||||
version,
|
|
||||||
action.action_name,
|
action.action_name,
|
||||||
});
|
});
|
||||||
defer self.allocator.free(target);
|
defer self.allocator.free(target);
|
||||||
|
@ -96,7 +86,11 @@ pub const Aws = struct {
|
||||||
// can guarantee we don't need the memory after this call completes,
|
// can guarantee we don't need the memory after this call completes,
|
||||||
// so we'll use an arena allocator to whack everything.
|
// so we'll use an arena allocator to whack everything.
|
||||||
// TODO: Determine if sending in null values is ok, or if we need another
|
// TODO: Determine if sending in null values is ok, or if we need another
|
||||||
// tweak to the stringify function to exclude
|
// tweak to the stringify function to exclude. According to the
|
||||||
|
// smithy spec, "A null value MAY be provided or omitted
|
||||||
|
// for a boxed member with no observable difference." But we're
|
||||||
|
// seeing a lot of differences here between spec and reality
|
||||||
|
//
|
||||||
var nameAllocator = std.heap.ArenaAllocator.init(self.allocator);
|
var nameAllocator = std.heap.ArenaAllocator.init(self.allocator);
|
||||||
defer nameAllocator.deinit();
|
defer nameAllocator.deinit();
|
||||||
try json.stringify(request, .{ .whitespace = .{}, .allocator = &nameAllocator.allocator, .nameTransform = pascalTransformer }, buffer.writer());
|
try json.stringify(request, .{ .whitespace = .{}, .allocator = &nameAllocator.allocator, .nameTransform = pascalTransformer }, buffer.writer());
|
||||||
|
|
19
src/main.zig
19
src/main.zig
|
@ -29,6 +29,8 @@ const Tests = enum {
|
||||||
ec2_query_no_input,
|
ec2_query_no_input,
|
||||||
json_1_0_query_with_input,
|
json_1_0_query_with_input,
|
||||||
json_1_0_query_no_input,
|
json_1_0_query_no_input,
|
||||||
|
json_1_1_query_with_input,
|
||||||
|
json_1_1_query_no_input,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn main() anyerror!void {
|
pub fn main() anyerror!void {
|
||||||
|
@ -67,7 +69,7 @@ pub fn main() anyerror!void {
|
||||||
var client = aws.Aws.init(allocator);
|
var client = aws.Aws.init(allocator);
|
||||||
defer client.deinit();
|
defer client.deinit();
|
||||||
|
|
||||||
const services = aws.Services(.{ .sts, .ec2, .dynamo_db }){};
|
const services = aws.Services(.{ .sts, .ec2, .dynamo_db, .ecs }){};
|
||||||
|
|
||||||
for (tests.items) |t| {
|
for (tests.items) |t| {
|
||||||
std.log.info("===== Start Test: {s} =====", .{@tagName(t)});
|
std.log.info("===== Start Test: {s} =====", .{@tagName(t)});
|
||||||
|
@ -89,7 +91,6 @@ pub fn main() anyerror!void {
|
||||||
std.log.info("access key: {s}", .{access.response.credentials.?.access_key_id});
|
std.log.info("access key: {s}", .{access.response.credentials.?.access_key_id});
|
||||||
},
|
},
|
||||||
.json_1_0_query_with_input => {
|
.json_1_0_query_with_input => {
|
||||||
// TODO: Find test without sensitive info
|
|
||||||
const tables = try client.call(services.dynamo_db.list_tables.Request{
|
const tables = try client.call(services.dynamo_db.list_tables.Request{
|
||||||
.limit = 1,
|
.limit = 1,
|
||||||
}, options);
|
}, options);
|
||||||
|
@ -102,6 +103,20 @@ pub fn main() anyerror!void {
|
||||||
defer limits.deinit();
|
defer limits.deinit();
|
||||||
std.log.info("account read capacity limit: {d}", .{limits.response.account_max_read_capacity_units});
|
std.log.info("account read capacity limit: {d}", .{limits.response.account_max_read_capacity_units});
|
||||||
},
|
},
|
||||||
|
.json_1_1_query_with_input => {
|
||||||
|
const clusters = try client.call(services.ecs.list_clusters.Request{
|
||||||
|
.max_results = 1,
|
||||||
|
}, options);
|
||||||
|
defer clusters.deinit();
|
||||||
|
std.log.info("request id: {s}", .{clusters.response_metadata.request_id});
|
||||||
|
std.log.info("account has clusters: {b}", .{clusters.response.cluster_arns.?.len > 0});
|
||||||
|
},
|
||||||
|
.json_1_1_query_no_input => {
|
||||||
|
const clusters = try client.call(services.ecs.list_clusters.Request{}, options);
|
||||||
|
defer clusters.deinit();
|
||||||
|
std.log.info("request id: {s}", .{clusters.response_metadata.request_id});
|
||||||
|
std.log.info("account has clusters: {b}", .{clusters.response.cluster_arns.?.len > 0});
|
||||||
|
},
|
||||||
.ec2_query_no_input => {
|
.ec2_query_no_input => {
|
||||||
std.log.err("EC2 Test disabled due to compiler bug", .{});
|
std.log.err("EC2 Test disabled due to compiler bug", .{});
|
||||||
// const instances = try client.call(services.ec2.describe_instances.Request{}, options);
|
// const instances = try client.call(services.ec2.describe_instances.Request{}, options);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user