cleanup output/remove one demo due to signature issue
All checks were successful
AWS-Zig Build / build-zig-0.11.0-amd64-host (push) Successful in 6m11s

This commit is contained in:
Emil Lerch 2023-08-29 12:47:22 -07:00
parent 316a388b79
commit 9c403d0e18
Signed by: lobo
GPG Key ID: A7B62D657EF764F8

View File

@ -181,32 +181,35 @@ pub fn main() anyerror!void {
std.log.info("account has functions: {}", .{call.response.functions.?.len > 0}); std.log.info("account has functions: {}", .{call.response.functions.?.len > 0});
}, },
.rest_json_1_work_with_lambda => { .rest_json_1_work_with_lambda => {
const call = try client.call(services.lambda.list_functions.Request{}, options); // const call = try client.call(services.lambda.list_functions.Request{}, options);
defer call.deinit(); // defer call.deinit();
std.log.info("list request id: {s}", .{call.response_metadata.request_id}); // std.log.info("list request id: {s}", .{call.response_metadata.request_id});
if (call.response.functions) |fns| { // if (call.response.functions) |fns| {
if (fns.len > 0) { // if (fns.len > 0) {
const func = fns[0]; // const func = fns[0];
const arn = func.function_arn.?; // const arn = func.function_arn.?;
// This is a bit ugly. Maybe a helper function in the library would help? // // This is a bit ugly. Maybe a helper function in the library would help?
var tags = try std.ArrayList(@typeInfo(try typeForField(services.lambda.tag_resource.Request, "tags")).Pointer.child).initCapacity(allocator, 1); // var tags = try std.ArrayList(@typeInfo(try typeForField(services.lambda.tag_resource.Request, "tags")).Pointer.child).initCapacity(allocator, 1);
defer tags.deinit(); // defer tags.deinit();
tags.appendAssumeCapacity(.{ .key = "Foo", .value = "Bar" }); // tags.appendAssumeCapacity(.{ .key = "Foo", .value = "Bar" });
const req = services.lambda.tag_resource.Request{ .resource = arn, .tags = tags.items }; // const req = services.lambda.tag_resource.Request{ .resource = arn, .tags = tags.items };
const addtag = try aws.Request(services.lambda.tag_resource).call(req, options); // const addtag = try aws.Request(services.lambda.tag_resource).call(req, options);
defer addtag.deinit(); // TODO: Something is up with signature calculation. I believe it's with the encoding, because the url used
// const addtag = try client.call(services.lambda.tag_resource.Request{ .resource = arn, .tags = &.{.{ .key = "Foo", .value = "Bar" }} }, options); // here is totally crazy with the arn of the resource directly in it
std.log.info("add tag request id: {s}", .{addtag.response_metadata.request_id}); // Example: https://lambda.us-west-2.amazonaws.com/2017-03-31/tags/arn%253Aaws%253Alambda%253Aus-west-2%253A550620852718%253Afunction%253ADevelopmentFrontendStack--amplifyassetdeploymentha-aZqB9IbZLIKU
var keys = [_][]const u8{"Foo"}; // Would love to have a way to express this without burning a var here // defer addtag.deinit();
const deletetag = try aws.Request(services.lambda.untag_resource).call(.{ .tag_keys = keys[0..], .resource = arn }, options); // // const addtag = try client.call(services.lambda.tag_resource.Request{ .resource = arn, .tags = &.{.{ .key = "Foo", .value = "Bar" }} }, options);
defer deletetag.deinit(); // std.log.info("add tag request id: {s}", .{addtag.response_metadata.request_id});
std.log.info("delete tag request id: {s}", .{deletetag.response_metadata.request_id}); // var keys = [_][]const u8{"Foo"}; // Would love to have a way to express this without burning a var here
} else { // const deletetag = try aws.Request(services.lambda.untag_resource).call(.{ .tag_keys = keys[0..], .resource = arn }, options);
std.log.err("no functions to work with", .{}); // defer deletetag.deinit();
} // std.log.info("delete tag request id: {s}", .{deletetag.response_metadata.request_id});
} else { // } else {
std.log.err("no functions to work with", .{}); // std.log.err("no functions to work with", .{});
} // }
// } else {
// std.log.err("no functions to work with", .{});
// }
}, },
.ec2_query_no_input => { .ec2_query_no_input => {
// Describe regions is a simpler request and easier to debug // Describe regions is a simpler request and easier to debug
@ -270,7 +273,7 @@ pub fn main() anyerror!void {
defer result.deinit(); defer result.deinit();
const bucket = result.response.buckets.?[result.response.buckets.?.len - 1]; const bucket = result.response.buckets.?[result.response.buckets.?.len - 1];
std.log.info("ListBuckets request id: {s}", .{result.response_metadata.request_id}); std.log.info("ListBuckets request id: {s}", .{result.response_metadata.request_id});
std.log.info("bucket name: {any}", .{bucket.name.?}); std.log.info("bucket name: {s}", .{bucket.name.?});
break :blk try allocator.dupe(u8, bucket.name.?); break :blk try allocator.dupe(u8, bucket.name.?);
}; };
defer allocator.free(bucket); defer allocator.free(bucket);
@ -281,7 +284,7 @@ pub fn main() anyerror!void {
defer result.deinit(); defer result.deinit();
const location = result.response.location_constraint.?; const location = result.response.location_constraint.?;
std.log.info("GetBucketLocation request id: {s}", .{result.response_metadata.request_id}); std.log.info("GetBucketLocation request id: {s}", .{result.response_metadata.request_id});
std.log.info("location: {any}", .{location}); std.log.info("location: {s}", .{location});
break :blk try allocator.dupe(u8, location); break :blk try allocator.dupe(u8, location);
}; };
defer allocator.free(location); defer allocator.free(location);
@ -298,8 +301,8 @@ pub fn main() anyerror!void {
.body = "bar", .body = "bar",
.storage_class = "STANDARD", .storage_class = "STANDARD",
}, s3opts); }, s3opts);
std.log.info("PutObject Request id: {any}", .{result.response_metadata.request_id}); std.log.info("PutObject Request id: {s}", .{result.response_metadata.request_id});
std.log.info("PutObject etag: {any}", .{result.response.e_tag.?}); std.log.info("PutObject etag: {s}", .{result.response.e_tag.?});
defer result.deinit(); defer result.deinit();
} }
{ {
@ -309,9 +312,9 @@ pub fn main() anyerror!void {
.bucket = bucket, .bucket = bucket,
.key = key, .key = key,
}, s3opts); }, s3opts);
std.log.info("GetObject Request id: {any}", .{result.response_metadata.request_id}); std.log.info("GetObject Request id: {s}", .{result.response_metadata.request_id});
std.log.info("GetObject Body: {any}", .{result.response.body}); std.log.info("GetObject Body: {s}", .{result.response.body.?});
std.log.info("GetObject etag: {any}", .{result.response.e_tag.?}); std.log.info("GetObject etag: {s}", .{result.response.e_tag.?});
std.log.info("GetObject last modified (seconds since epoch): {d}", .{result.response.last_modified.?}); std.log.info("GetObject last modified (seconds since epoch): {d}", .{result.response.last_modified.?});
defer result.deinit(); defer result.deinit();
} }
@ -320,14 +323,14 @@ pub fn main() anyerror!void {
.bucket = bucket, .bucket = bucket,
.key = key, .key = key,
}, s3opts); }, s3opts);
std.log.info("DeleteObject Request id: {any}", .{result.response_metadata.request_id}); std.log.info("DeleteObject Request id: {s}", .{result.response_metadata.request_id});
defer result.deinit(); defer result.deinit();
} }
{ {
const result = try aws.Request(services.s3.list_objects).call(.{ const result = try aws.Request(services.s3.list_objects).call(.{
.bucket = bucket, .bucket = bucket,
}, s3opts); }, s3opts);
std.log.info("ListObject Request id: {any}", .{result.response_metadata.request_id}); std.log.info("ListObject Request id: {s}", .{result.response_metadata.request_id});
std.log.info("Object count: {d}", .{result.response.contents.?.len}); std.log.info("Object count: {d}", .{result.response.contents.?.len});
defer result.deinit(); defer result.deinit();
} }