clean compile on 0.11, not yet fully functional
Some checks failed
AWS-Zig Build / build-zig-0.9-amd64-host (push) Failing after 1m41s
Some checks failed
AWS-Zig Build / build-zig-0.9-amd64-host (push) Failing after 1m41s
This commit is contained in:
parent
64dc7b5772
commit
9e02196dd0
|
@ -196,7 +196,7 @@ fn getImdsv2Credentials(allocator: std.mem.Allocator) !?auth.Credentials {
|
|||
defer resp_payload.deinit();
|
||||
try resp_payload.resize(req.response.content_length.?);
|
||||
token = try resp_payload.toOwnedSlice();
|
||||
errdefer allocator.free(token);
|
||||
errdefer if (token) |t| allocator.free(t);
|
||||
_ = try req.readAll(token.?);
|
||||
}
|
||||
std.debug.assert(token != null);
|
||||
|
@ -207,7 +207,7 @@ fn getImdsv2Credentials(allocator: std.mem.Allocator) !?auth.Credentials {
|
|||
return null;
|
||||
}
|
||||
defer allocator.free(role_name.?);
|
||||
log.debug("Got role name '{s}'", .{role_name});
|
||||
log.debug("Got role name '{s}'", .{role_name.?});
|
||||
return getImdsCredentials(allocator, &cl, role_name.?, token.?);
|
||||
}
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ pub const AwsHttp = struct {
|
|||
|
||||
// TODO: Timeout - is this now above us?
|
||||
log.debug(
|
||||
"Request Complete. Response code {d}: {s}",
|
||||
"Request Complete. Response code {d}: {any}",
|
||||
.{ @intFromEnum(req.response.status), req.response.status.phrase() },
|
||||
);
|
||||
log.debug("Response headers:", .{});
|
||||
|
|
72
src/main.zig
72
src/main.zig
|
@ -96,64 +96,64 @@ pub fn main() anyerror!void {
|
|||
const call = try aws.Request(services.sts.get_caller_identity).call(.{}, options);
|
||||
// const call = try client.call(services.sts.get_caller_identity.Request{}, options);
|
||||
defer call.deinit();
|
||||
std.log.info("arn: {s}", .{call.response.arn});
|
||||
std.log.info("id: {s}", .{call.response.user_id});
|
||||
std.log.info("account: {s}", .{call.response.account});
|
||||
std.log.info("requestId: {s}", .{call.response_metadata.request_id});
|
||||
std.log.info("arn: {any}", .{call.response.arn});
|
||||
std.log.info("id: {any}", .{call.response.user_id});
|
||||
std.log.info("account: {any}", .{call.response.account});
|
||||
std.log.info("requestId: {any}", .{call.response_metadata.request_id});
|
||||
},
|
||||
.query_with_input => {
|
||||
const call = try client.call(services.sqs.list_queues.Request{
|
||||
.queue_name_prefix = "s",
|
||||
}, options);
|
||||
defer call.deinit();
|
||||
std.log.info("request id: {s}", .{call.response_metadata.request_id});
|
||||
std.log.info("account has queues with prefix 's': {b}", .{call.response.queue_urls != null});
|
||||
std.log.info("request id: {any}", .{call.response_metadata.request_id});
|
||||
std.log.info("account has queues with prefix 's': {}", .{call.response.queue_urls != null});
|
||||
},
|
||||
.json_1_0_query_with_input => {
|
||||
const call = try client.call(services.dynamo_db.list_tables.Request{
|
||||
.limit = 1,
|
||||
}, options);
|
||||
defer call.deinit();
|
||||
std.log.info("request id: {s}", .{call.response_metadata.request_id});
|
||||
std.log.info("account has tables: {b}", .{call.response.table_names.?.len > 0});
|
||||
std.log.info("request id: {any}", .{call.response_metadata.request_id});
|
||||
std.log.info("account has tables: {}", .{call.response.table_names.?.len > 0});
|
||||
},
|
||||
.json_1_0_query_no_input => {
|
||||
const call = try client.call(services.dynamo_db.describe_limits.Request{}, options);
|
||||
defer call.deinit();
|
||||
std.log.info("account read capacity limit: {d}", .{call.response.account_max_read_capacity_units});
|
||||
std.log.info("account read capacity limit: {?d}", .{call.response.account_max_read_capacity_units});
|
||||
},
|
||||
.json_1_1_query_with_input => {
|
||||
const call = try client.call(services.ecs.list_clusters.Request{
|
||||
.max_results = 1,
|
||||
}, options);
|
||||
defer call.deinit();
|
||||
std.log.info("request id: {s}", .{call.response_metadata.request_id});
|
||||
std.log.info("account has clusters: {b}", .{call.response.cluster_arns.?.len > 0});
|
||||
std.log.info("request id: {any}", .{call.response_metadata.request_id});
|
||||
std.log.info("account has clusters: {}", .{call.response.cluster_arns.?.len > 0});
|
||||
},
|
||||
.json_1_1_query_no_input => {
|
||||
const call = try client.call(services.ecs.list_clusters.Request{}, options);
|
||||
defer call.deinit();
|
||||
std.log.info("request id: {s}", .{call.response_metadata.request_id});
|
||||
std.log.info("account has clusters: {b}", .{call.response.cluster_arns.?.len > 0});
|
||||
std.log.info("request id: {any}", .{call.response_metadata.request_id});
|
||||
std.log.info("account has clusters: {}", .{call.response.cluster_arns.?.len > 0});
|
||||
},
|
||||
.rest_json_1_query_with_input => {
|
||||
const call = try client.call(services.lambda.list_functions.Request{
|
||||
.max_items = 1,
|
||||
}, options);
|
||||
defer call.deinit();
|
||||
std.log.info("request id: {s}", .{call.response_metadata.request_id});
|
||||
std.log.info("account has functions: {b}", .{call.response.functions.?.len > 0});
|
||||
std.log.info("request id: {any}", .{call.response_metadata.request_id});
|
||||
std.log.info("account has functions: {}", .{call.response.functions.?.len > 0});
|
||||
},
|
||||
.rest_json_1_query_no_input => {
|
||||
const call = try client.call(services.lambda.list_functions.Request{}, options);
|
||||
defer call.deinit();
|
||||
std.log.info("request id: {s}", .{call.response_metadata.request_id});
|
||||
std.log.info("account has functions: {b}", .{call.response.functions.?.len > 0});
|
||||
std.log.info("request id: {any}", .{call.response_metadata.request_id});
|
||||
std.log.info("account has functions: {}", .{call.response.functions.?.len > 0});
|
||||
},
|
||||
.rest_json_1_work_with_lambda => {
|
||||
const call = try client.call(services.lambda.list_functions.Request{}, options);
|
||||
defer call.deinit();
|
||||
std.log.info("list request id: {s}", .{call.response_metadata.request_id});
|
||||
std.log.info("list request id: {any}", .{call.response_metadata.request_id});
|
||||
if (call.response.functions) |fns| {
|
||||
if (fns.len > 0) {
|
||||
const func = fns[0];
|
||||
|
@ -166,11 +166,11 @@ pub fn main() anyerror!void {
|
|||
const addtag = try aws.Request(services.lambda.tag_resource).call(req, options);
|
||||
defer addtag.deinit();
|
||||
// const addtag = try client.call(services.lambda.tag_resource.Request{ .resource = arn, .tags = &.{.{ .key = "Foo", .value = "Bar" }} }, options);
|
||||
std.log.info("add tag request id: {s}", .{addtag.response_metadata.request_id});
|
||||
std.log.info("add tag request id: {any}", .{addtag.response_metadata.request_id});
|
||||
var keys = [_][]const u8{"Foo"}; // Would love to have a way to express this without burning a var here
|
||||
const deletetag = try aws.Request(services.lambda.untag_resource).call(.{ .tag_keys = keys[0..], .resource = arn }, options);
|
||||
defer deletetag.deinit();
|
||||
std.log.info("delete tag request id: {s}", .{deletetag.response_metadata.request_id});
|
||||
std.log.info("delete tag request id: {any}", .{deletetag.response_metadata.request_id});
|
||||
} else {
|
||||
std.log.err("no functions to work with", .{});
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ pub fn main() anyerror!void {
|
|||
// Describe regions is a simpler request and easier to debug
|
||||
const result = try client.call(services.ec2.describe_regions.Request{}, options);
|
||||
defer result.deinit();
|
||||
std.log.info("request id: {s}", .{result.response_metadata.request_id});
|
||||
std.log.info("request id: {any}", .{result.response_metadata.request_id});
|
||||
std.log.info("region count: {d}", .{result.response.regions.?.len});
|
||||
},
|
||||
.ec2_query_with_input => {
|
||||
|
@ -216,15 +216,15 @@ pub fn main() anyerror!void {
|
|||
.rest_xml_no_input => {
|
||||
const result = try client.call(services.s3.list_buckets.Request{}, options);
|
||||
defer result.deinit();
|
||||
std.log.info("request id: {s}", .{result.response_metadata.request_id});
|
||||
std.log.info("request id: {any}", .{result.response_metadata.request_id});
|
||||
std.log.info("bucket count: {d}", .{result.response.buckets.?.len});
|
||||
},
|
||||
.rest_xml_anything_but_s3 => {
|
||||
const result = try client.call(services.cloudfront.list_key_groups.Request{}, options);
|
||||
defer result.deinit();
|
||||
std.log.info("request id: {s}", .{result.response_metadata.request_id});
|
||||
std.log.info("request id: {any}", .{result.response_metadata.request_id});
|
||||
const list = result.response.key_group_list.?;
|
||||
std.log.info("key group list max: {d}", .{list.max_items});
|
||||
std.log.info("key group list max: {?d}", .{list.max_items});
|
||||
std.log.info("key group quantity: {d}", .{list.quantity});
|
||||
},
|
||||
.rest_xml_work_with_s3 => {
|
||||
|
@ -235,8 +235,8 @@ pub fn main() anyerror!void {
|
|||
const result = try client.call(services.s3.list_buckets.Request{}, options);
|
||||
defer result.deinit();
|
||||
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("bucket name: {s}", .{bucket.name.?});
|
||||
std.log.info("ListBuckets request id: {any}", .{result.response_metadata.request_id});
|
||||
std.log.info("bucket name: {any}", .{bucket.name.?});
|
||||
break :blk try allocator.dupe(u8, bucket.name.?);
|
||||
};
|
||||
defer allocator.free(bucket);
|
||||
|
@ -246,8 +246,8 @@ pub fn main() anyerror!void {
|
|||
}, options);
|
||||
defer result.deinit();
|
||||
const location = result.response.location_constraint.?;
|
||||
std.log.info("GetBucketLocation request id: {s}", .{result.response_metadata.request_id});
|
||||
std.log.info("location: {s}", .{location});
|
||||
std.log.info("GetBucketLocation request id: {any}", .{result.response_metadata.request_id});
|
||||
std.log.info("location: {any}", .{location});
|
||||
break :blk try allocator.dupe(u8, location);
|
||||
};
|
||||
defer allocator.free(location);
|
||||
|
@ -263,8 +263,8 @@ pub fn main() anyerror!void {
|
|||
.body = "bar",
|
||||
.storage_class = "STANDARD",
|
||||
}, s3opts);
|
||||
std.log.info("PutObject Request id: {s}", .{result.response_metadata.request_id});
|
||||
std.log.info("PutObject etag: {s}", .{result.response.e_tag.?});
|
||||
std.log.info("PutObject Request id: {any}", .{result.response_metadata.request_id});
|
||||
std.log.info("PutObject etag: {any}", .{result.response.e_tag.?});
|
||||
defer result.deinit();
|
||||
}
|
||||
{
|
||||
|
@ -274,9 +274,9 @@ pub fn main() anyerror!void {
|
|||
.bucket = bucket,
|
||||
.key = key,
|
||||
}, s3opts);
|
||||
std.log.info("GetObject Request id: {s}", .{result.response_metadata.request_id});
|
||||
std.log.info("GetObject Body: {s}", .{result.response.body});
|
||||
std.log.info("GetObject etag: {s}", .{result.response.e_tag.?});
|
||||
std.log.info("GetObject Request id: {any}", .{result.response_metadata.request_id});
|
||||
std.log.info("GetObject Body: {any}", .{result.response.body});
|
||||
std.log.info("GetObject etag: {any}", .{result.response.e_tag.?});
|
||||
std.log.info("GetObject last modified (seconds since epoch): {d}", .{result.response.last_modified.?});
|
||||
defer result.deinit();
|
||||
}
|
||||
|
@ -285,14 +285,14 @@ pub fn main() anyerror!void {
|
|||
.bucket = bucket,
|
||||
.key = key,
|
||||
}, s3opts);
|
||||
std.log.info("DeleteObject Request id: {s}", .{result.response_metadata.request_id});
|
||||
std.log.info("DeleteObject Request id: {any}", .{result.response_metadata.request_id});
|
||||
defer result.deinit();
|
||||
}
|
||||
{
|
||||
const result = try aws.Request(services.s3.list_objects).call(.{
|
||||
.bucket = bucket,
|
||||
}, s3opts);
|
||||
std.log.info("ListObject Request id: {s}", .{result.response_metadata.request_id});
|
||||
std.log.info("ListObject Request id: {any}", .{result.response_metadata.request_id});
|
||||
std.log.info("Object count: {d}", .{result.response.contents.?.len});
|
||||
defer result.deinit();
|
||||
}
|
||||
|
@ -344,5 +344,5 @@ pub fn jsonFun() !void {
|
|||
.allow_unknown_fields = true, // new option
|
||||
}) catch unreachable;
|
||||
std.log.info("{}", .{res3});
|
||||
std.log.info("{s}", .{res3.getCallerIdentityResponse.getCallerIdentityResult.user_id});
|
||||
std.log.info("{any}", .{res3.getCallerIdentityResponse.getCallerIdentityResult.user_id});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user