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();
|
defer resp_payload.deinit();
|
||||||
try resp_payload.resize(req.response.content_length.?);
|
try resp_payload.resize(req.response.content_length.?);
|
||||||
token = try resp_payload.toOwnedSlice();
|
token = try resp_payload.toOwnedSlice();
|
||||||
errdefer allocator.free(token);
|
errdefer if (token) |t| allocator.free(t);
|
||||||
_ = try req.readAll(token.?);
|
_ = try req.readAll(token.?);
|
||||||
}
|
}
|
||||||
std.debug.assert(token != null);
|
std.debug.assert(token != null);
|
||||||
|
@ -207,7 +207,7 @@ fn getImdsv2Credentials(allocator: std.mem.Allocator) !?auth.Credentials {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
defer allocator.free(role_name.?);
|
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.?);
|
return getImdsCredentials(allocator, &cl, role_name.?, token.?);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -190,7 +190,7 @@ pub const AwsHttp = struct {
|
||||||
|
|
||||||
// TODO: Timeout - is this now above us?
|
// TODO: Timeout - is this now above us?
|
||||||
log.debug(
|
log.debug(
|
||||||
"Request Complete. Response code {d}: {s}",
|
"Request Complete. Response code {d}: {any}",
|
||||||
.{ @intFromEnum(req.response.status), req.response.status.phrase() },
|
.{ @intFromEnum(req.response.status), req.response.status.phrase() },
|
||||||
);
|
);
|
||||||
log.debug("Response headers:", .{});
|
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 aws.Request(services.sts.get_caller_identity).call(.{}, options);
|
||||||
// const call = try client.call(services.sts.get_caller_identity.Request{}, options);
|
// const call = try client.call(services.sts.get_caller_identity.Request{}, options);
|
||||||
defer call.deinit();
|
defer call.deinit();
|
||||||
std.log.info("arn: {s}", .{call.response.arn});
|
std.log.info("arn: {any}", .{call.response.arn});
|
||||||
std.log.info("id: {s}", .{call.response.user_id});
|
std.log.info("id: {any}", .{call.response.user_id});
|
||||||
std.log.info("account: {s}", .{call.response.account});
|
std.log.info("account: {any}", .{call.response.account});
|
||||||
std.log.info("requestId: {s}", .{call.response_metadata.request_id});
|
std.log.info("requestId: {any}", .{call.response_metadata.request_id});
|
||||||
},
|
},
|
||||||
.query_with_input => {
|
.query_with_input => {
|
||||||
const call = try client.call(services.sqs.list_queues.Request{
|
const call = try client.call(services.sqs.list_queues.Request{
|
||||||
.queue_name_prefix = "s",
|
.queue_name_prefix = "s",
|
||||||
}, options);
|
}, options);
|
||||||
defer call.deinit();
|
defer call.deinit();
|
||||||
std.log.info("request id: {s}", .{call.response_metadata.request_id});
|
std.log.info("request id: {any}", .{call.response_metadata.request_id});
|
||||||
std.log.info("account has queues with prefix 's': {b}", .{call.response.queue_urls != null});
|
std.log.info("account has queues with prefix 's': {}", .{call.response.queue_urls != null});
|
||||||
},
|
},
|
||||||
.json_1_0_query_with_input => {
|
.json_1_0_query_with_input => {
|
||||||
const call = try client.call(services.dynamo_db.list_tables.Request{
|
const call = try client.call(services.dynamo_db.list_tables.Request{
|
||||||
.limit = 1,
|
.limit = 1,
|
||||||
}, options);
|
}, options);
|
||||||
defer call.deinit();
|
defer call.deinit();
|
||||||
std.log.info("request id: {s}", .{call.response_metadata.request_id});
|
std.log.info("request id: {any}", .{call.response_metadata.request_id});
|
||||||
std.log.info("account has tables: {b}", .{call.response.table_names.?.len > 0});
|
std.log.info("account has tables: {}", .{call.response.table_names.?.len > 0});
|
||||||
},
|
},
|
||||||
.json_1_0_query_no_input => {
|
.json_1_0_query_no_input => {
|
||||||
const call = try client.call(services.dynamo_db.describe_limits.Request{}, options);
|
const call = try client.call(services.dynamo_db.describe_limits.Request{}, options);
|
||||||
defer call.deinit();
|
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 => {
|
.json_1_1_query_with_input => {
|
||||||
const call = try client.call(services.ecs.list_clusters.Request{
|
const call = try client.call(services.ecs.list_clusters.Request{
|
||||||
.max_results = 1,
|
.max_results = 1,
|
||||||
}, options);
|
}, options);
|
||||||
defer call.deinit();
|
defer call.deinit();
|
||||||
std.log.info("request id: {s}", .{call.response_metadata.request_id});
|
std.log.info("request id: {any}", .{call.response_metadata.request_id});
|
||||||
std.log.info("account has clusters: {b}", .{call.response.cluster_arns.?.len > 0});
|
std.log.info("account has clusters: {}", .{call.response.cluster_arns.?.len > 0});
|
||||||
},
|
},
|
||||||
.json_1_1_query_no_input => {
|
.json_1_1_query_no_input => {
|
||||||
const call = try client.call(services.ecs.list_clusters.Request{}, options);
|
const call = try client.call(services.ecs.list_clusters.Request{}, options);
|
||||||
defer call.deinit();
|
defer call.deinit();
|
||||||
std.log.info("request id: {s}", .{call.response_metadata.request_id});
|
std.log.info("request id: {any}", .{call.response_metadata.request_id});
|
||||||
std.log.info("account has clusters: {b}", .{call.response.cluster_arns.?.len > 0});
|
std.log.info("account has clusters: {}", .{call.response.cluster_arns.?.len > 0});
|
||||||
},
|
},
|
||||||
.rest_json_1_query_with_input => {
|
.rest_json_1_query_with_input => {
|
||||||
const call = try client.call(services.lambda.list_functions.Request{
|
const call = try client.call(services.lambda.list_functions.Request{
|
||||||
.max_items = 1,
|
.max_items = 1,
|
||||||
}, options);
|
}, options);
|
||||||
defer call.deinit();
|
defer call.deinit();
|
||||||
std.log.info("request id: {s}", .{call.response_metadata.request_id});
|
std.log.info("request id: {any}", .{call.response_metadata.request_id});
|
||||||
std.log.info("account has functions: {b}", .{call.response.functions.?.len > 0});
|
std.log.info("account has functions: {}", .{call.response.functions.?.len > 0});
|
||||||
},
|
},
|
||||||
.rest_json_1_query_no_input => {
|
.rest_json_1_query_no_input => {
|
||||||
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("request id: {s}", .{call.response_metadata.request_id});
|
std.log.info("request id: {any}", .{call.response_metadata.request_id});
|
||||||
std.log.info("account has functions: {b}", .{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: {any}", .{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];
|
||||||
|
@ -166,11 +166,11 @@ pub fn main() anyerror!void {
|
||||||
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();
|
defer addtag.deinit();
|
||||||
// const addtag = try client.call(services.lambda.tag_resource.Request{ .resource = arn, .tags = &.{.{ .key = "Foo", .value = "Bar" }} }, options);
|
// 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
|
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);
|
const deletetag = try aws.Request(services.lambda.untag_resource).call(.{ .tag_keys = keys[0..], .resource = arn }, options);
|
||||||
defer deletetag.deinit();
|
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 {
|
} else {
|
||||||
std.log.err("no functions to work with", .{});
|
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
|
// Describe regions is a simpler request and easier to debug
|
||||||
const result = try client.call(services.ec2.describe_regions.Request{}, options);
|
const result = try client.call(services.ec2.describe_regions.Request{}, options);
|
||||||
defer result.deinit();
|
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});
|
std.log.info("region count: {d}", .{result.response.regions.?.len});
|
||||||
},
|
},
|
||||||
.ec2_query_with_input => {
|
.ec2_query_with_input => {
|
||||||
|
@ -216,15 +216,15 @@ pub fn main() anyerror!void {
|
||||||
.rest_xml_no_input => {
|
.rest_xml_no_input => {
|
||||||
const result = try client.call(services.s3.list_buckets.Request{}, options);
|
const result = try client.call(services.s3.list_buckets.Request{}, options);
|
||||||
defer result.deinit();
|
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});
|
std.log.info("bucket count: {d}", .{result.response.buckets.?.len});
|
||||||
},
|
},
|
||||||
.rest_xml_anything_but_s3 => {
|
.rest_xml_anything_but_s3 => {
|
||||||
const result = try client.call(services.cloudfront.list_key_groups.Request{}, options);
|
const result = try client.call(services.cloudfront.list_key_groups.Request{}, options);
|
||||||
defer result.deinit();
|
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.?;
|
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});
|
std.log.info("key group quantity: {d}", .{list.quantity});
|
||||||
},
|
},
|
||||||
.rest_xml_work_with_s3 => {
|
.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);
|
const result = try client.call(services.s3.list_buckets.Request{}, options);
|
||||||
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: {any}", .{result.response_metadata.request_id});
|
||||||
std.log.info("bucket name: {s}", .{bucket.name.?});
|
std.log.info("bucket name: {any}", .{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);
|
||||||
|
@ -246,8 +246,8 @@ pub fn main() anyerror!void {
|
||||||
}, options);
|
}, options);
|
||||||
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: {any}", .{result.response_metadata.request_id});
|
||||||
std.log.info("location: {s}", .{location});
|
std.log.info("location: {any}", .{location});
|
||||||
break :blk try allocator.dupe(u8, location);
|
break :blk try allocator.dupe(u8, location);
|
||||||
};
|
};
|
||||||
defer allocator.free(location);
|
defer allocator.free(location);
|
||||||
|
@ -263,8 +263,8 @@ pub fn main() anyerror!void {
|
||||||
.body = "bar",
|
.body = "bar",
|
||||||
.storage_class = "STANDARD",
|
.storage_class = "STANDARD",
|
||||||
}, s3opts);
|
}, s3opts);
|
||||||
std.log.info("PutObject Request id: {s}", .{result.response_metadata.request_id});
|
std.log.info("PutObject Request id: {any}", .{result.response_metadata.request_id});
|
||||||
std.log.info("PutObject etag: {s}", .{result.response.e_tag.?});
|
std.log.info("PutObject etag: {any}", .{result.response.e_tag.?});
|
||||||
defer result.deinit();
|
defer result.deinit();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -274,9 +274,9 @@ pub fn main() anyerror!void {
|
||||||
.bucket = bucket,
|
.bucket = bucket,
|
||||||
.key = key,
|
.key = key,
|
||||||
}, s3opts);
|
}, s3opts);
|
||||||
std.log.info("GetObject Request id: {s}", .{result.response_metadata.request_id});
|
std.log.info("GetObject Request id: {any}", .{result.response_metadata.request_id});
|
||||||
std.log.info("GetObject Body: {s}", .{result.response.body});
|
std.log.info("GetObject Body: {any}", .{result.response.body});
|
||||||
std.log.info("GetObject etag: {s}", .{result.response.e_tag.?});
|
std.log.info("GetObject etag: {any}", .{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();
|
||||||
}
|
}
|
||||||
|
@ -285,14 +285,14 @@ pub fn main() anyerror!void {
|
||||||
.bucket = bucket,
|
.bucket = bucket,
|
||||||
.key = key,
|
.key = key,
|
||||||
}, s3opts);
|
}, 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();
|
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: {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});
|
std.log.info("Object count: {d}", .{result.response.contents.?.len});
|
||||||
defer result.deinit();
|
defer result.deinit();
|
||||||
}
|
}
|
||||||
|
@ -344,5 +344,5 @@ pub fn jsonFun() !void {
|
||||||
.allow_unknown_fields = true, // new option
|
.allow_unknown_fields = true, // new option
|
||||||
}) catch unreachable;
|
}) catch unreachable;
|
||||||
std.log.info("{}", .{res3});
|
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