wire Services through to aws.zig and main demo

This commit is contained in:
Emil Lerch 2021-06-10 14:35:22 -07:00
parent 7f8ddd3461
commit ad54596837
Signed by: lobo
GPG Key ID: A7B62D657EF764F8
2 changed files with 11 additions and 2 deletions

View File

@ -11,8 +11,16 @@ pub const Options = struct {
dualstack: bool = false, dualstack: bool = false,
}; };
/// Using this constant may blow up build times. Recommed using Services()
/// function directly, e.g. const services = Services(.{.sts, .ec2, .s3, .ddb}){};
pub const services = servicemodel.services; pub const services = servicemodel.services;
/// Get a service model by importing specific services only. As an example:
/// const services = Services(.{.sts, .ec2, .s3, .ddb}){};
///
/// This will give you a constant with service data for sts, ec2, s3 and ddb only
pub const Services = servicemodel.Services;
pub const Aws = struct { pub const Aws = struct {
allocator: *std.mem.Allocator, allocator: *std.mem.Allocator,
aws_http: awshttp.AwsHttp, aws_http: awshttp.AwsHttp,

View File

@ -45,7 +45,8 @@ pub fn main() anyerror!void {
var client = aws.Aws.init(allocator); var client = aws.Aws.init(allocator);
defer client.deinit(); defer client.deinit();
const resp = try client.call(aws.services.sts.get_caller_identity.Request{}, options); const services = aws.Services(.{.sts}){};
const resp = try client.call(services.sts.get_caller_identity.Request{}, options);
// TODO: This is a bit wonky. Root cause is lack of declarations in // TODO: This is a bit wonky. Root cause is lack of declarations in
// comptime-generated types // comptime-generated types
defer resp.deinit(); defer resp.deinit();
@ -56,7 +57,7 @@ pub fn main() anyerror!void {
var client2 = aws.Aws.init(allocator); var client2 = aws.Aws.init(allocator);
defer client2.deinit(); defer client2.deinit();
const resp2 = try client2.call(aws.services.sts.get_caller_identity.Request{}, options); // catch here and try alloc? const resp2 = try client2.call(services.sts.get_caller_identity.Request{}, options); // catch here and try alloc?
defer resp2.deinit(); defer resp2.deinit();
} }