upgrade smithy to 4187d899 (enables optional service version)
This commit is contained in:
		
							parent
							
								
									57a7cf3190
								
							
						
					
					
						commit
						c6a1bb2418
					
				
					 4 changed files with 19 additions and 13 deletions
				
			
		| 
						 | 
				
			
			@ -14,8 +14,8 @@
 | 
			
		|||
 | 
			
		||||
    .dependencies = .{
 | 
			
		||||
        .smithy = .{
 | 
			
		||||
            .url = "https://git.lerch.org/lobo/smithy/archive/a4c6ec6dfe552c57bab601c7d99e8de02bbab1fe.tar.gz",
 | 
			
		||||
            .hash = "smithy-1.0.0-uAyBgS_MAgC4qgc9QaEy5Y5Nf7kv32buQZBYugqNQsAn",
 | 
			
		||||
            .url = "https://git.lerch.org/lobo/smithy/archive/4187d8995112bfa2a071ea04f27a1da7c2259aab.tar.gz",
 | 
			
		||||
            .hash = "smithy-1.0.0-uAyBgXrRAgB7bdZwFdSwAVSzfmXSu_DZyjh0MlQUdinw",
 | 
			
		||||
        },
 | 
			
		||||
        .models = .{
 | 
			
		||||
            .url = "https://github.com/aws/aws-sdk-go-v2/archive/58cf6509525a12d64fd826da883bfdbacbd2f00e.tar.gz",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -373,7 +373,7 @@ fn generateServices(allocator: std.mem.Allocator, comptime _: []const u8, file:
 | 
			
		|||
    };
 | 
			
		||||
    for (services.items) |service| {
 | 
			
		||||
        var sdk_id: []const u8 = undefined;
 | 
			
		||||
        const version: []const u8 = service.shape.service.version;
 | 
			
		||||
        const version: ?[]const u8 = service.shape.service.version;
 | 
			
		||||
        const name: []const u8 = service.name;
 | 
			
		||||
        var arn_namespace: ?[]const u8 = undefined;
 | 
			
		||||
        var sigv4_name: ?[]const u8 = null;
 | 
			
		||||
| 
						 | 
				
			
			@ -404,7 +404,10 @@ fn generateServices(allocator: std.mem.Allocator, comptime _: []const u8, file:
 | 
			
		|||
        const constant_name = try constantName(allocator, sdk_id);
 | 
			
		||||
        try constant_names.append(constant_name);
 | 
			
		||||
        try writer.print("const Self = @This();\n", .{});
 | 
			
		||||
        try writer.print("pub const version: []const u8 = \"{s}\";\n", .{version});
 | 
			
		||||
        if (version) |v|
 | 
			
		||||
            try writer.print("pub const version: ?[]const u8 = \"{s}\";\n", .{v})
 | 
			
		||||
        else
 | 
			
		||||
            try writer.print("pub const version: ?[]const u8 = null;\n", .{});
 | 
			
		||||
        try writer.print("pub const sdk_id: []const u8 = \"{s}\";\n", .{sdk_id});
 | 
			
		||||
        if (arn_namespace) |a| {
 | 
			
		||||
            try writer.print("pub const arn_namespace: ?[]const u8 = \"{s}\";\n", .{a});
 | 
			
		||||
| 
						 | 
				
			
			@ -415,7 +418,10 @@ fn generateServices(allocator: std.mem.Allocator, comptime _: []const u8, file:
 | 
			
		|||
        // 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 = {};\n\n", .{aws_protocol});
 | 
			
		||||
        _ = try writer.write("pub const service_metadata: struct {\n");
 | 
			
		||||
        try writer.print("    version: []const u8 = \"{s}\",\n", .{version});
 | 
			
		||||
        if (version) |v|
 | 
			
		||||
            try writer.print("    version: ?[]const u8 = \"{s}\",\n", .{v})
 | 
			
		||||
        else
 | 
			
		||||
            try writer.print("    version: ?[]const u8 = null,\n", .{});
 | 
			
		||||
        try writer.print("    sdk_id: []const u8 = \"{s}\",\n", .{sdk_id});
 | 
			
		||||
        if (arn_namespace) |a| {
 | 
			
		||||
            try writer.print("    arn_namespace: ?[]const u8 = \"{s}\",\n", .{a});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										10
									
								
								src/aws.zig
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/aws.zig
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -157,7 +157,7 @@ pub fn Request(comptime request_action: anytype) type {
 | 
			
		|||
            // every codegenned request object includes a metaInfo function to get
 | 
			
		||||
            // pointers to service and action
 | 
			
		||||
 | 
			
		||||
            log.debug("call: prefix {s}, sigv4 {s}, version {s}, action {s}", .{
 | 
			
		||||
            log.debug("call: prefix {s}, sigv4 {s}, version {?s}, action {s}", .{
 | 
			
		||||
                Self.service_meta.endpoint_prefix,
 | 
			
		||||
                Self.service_meta.sigv4_name,
 | 
			
		||||
                Self.service_meta.version,
 | 
			
		||||
| 
						 | 
				
			
			@ -274,8 +274,8 @@ pub fn Request(comptime request_action: anytype) type {
 | 
			
		|||
                            const attrs = try std.fmt.allocPrint(
 | 
			
		||||
                                options.client.allocator,
 | 
			
		||||
                                "xmlns=\"http://{s}.amazonaws.com/doc/{s}/\"",
 | 
			
		||||
                                .{ sm.endpoint_prefix, sm.version },
 | 
			
		||||
                            );
 | 
			
		||||
                                .{ sm.endpoint_prefix, sm.version.? },
 | 
			
		||||
                            ); // Version required for the protocol, we should panic if it is not present
 | 
			
		||||
                            defer options.client.allocator.free(attrs); // once serialized, the value should be copied over
 | 
			
		||||
 | 
			
		||||
                            // Need to serialize this
 | 
			
		||||
| 
						 | 
				
			
			@ -366,7 +366,7 @@ pub fn Request(comptime request_action: anytype) type {
 | 
			
		|||
            else // EC2
 | 
			
		||||
                try std.fmt.allocPrint(options.client.allocator, "?Action={s}&Version={s}", .{
 | 
			
		||||
                    action.action_name,
 | 
			
		||||
                    Self.service_meta.version,
 | 
			
		||||
                    Self.service_meta.version.?, // Version required for the protocol, we should panic if it is not present
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
            defer if (Self.service_meta.aws_protocol != .query) {
 | 
			
		||||
| 
						 | 
				
			
			@ -379,7 +379,7 @@ pub fn Request(comptime request_action: anytype) type {
 | 
			
		|||
            const body =
 | 
			
		||||
                try std.fmt.allocPrint(options.client.allocator, "Action={s}&Version={s}{s}{s}", .{
 | 
			
		||||
                    action.action_name,
 | 
			
		||||
                    Self.service_meta.version,
 | 
			
		||||
                    Self.service_meta.version.?, // Version required for the protocol, we should panic if it is not present
 | 
			
		||||
                    continuation,
 | 
			
		||||
                    buffer.items,
 | 
			
		||||
                });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,7 +39,7 @@ fn serviceCount(desired_services: anytype) usize {
 | 
			
		|||
pub const services = service_list;
 | 
			
		||||
 | 
			
		||||
test "services includes sts" {
 | 
			
		||||
    try expectEqualStrings("2011-06-15", services.sts.version);
 | 
			
		||||
    try expectEqualStrings("2011-06-15", services.sts.version.?);
 | 
			
		||||
}
 | 
			
		||||
test "sts includes get_caller_identity" {
 | 
			
		||||
    try expectEqualStrings("GetCallerIdentity", services.sts.get_caller_identity.action_name);
 | 
			
		||||
| 
						 | 
				
			
			@ -47,9 +47,9 @@ test "sts includes get_caller_identity" {
 | 
			
		|||
test "can get service and action name from request" {
 | 
			
		||||
    // get request object. This call doesn't have parameters
 | 
			
		||||
    const metadata = services.sts.get_caller_identity.Request.metaInfo();
 | 
			
		||||
    try expectEqualStrings("2011-06-15", metadata.service_metadata.version);
 | 
			
		||||
    try expectEqualStrings("2011-06-15", metadata.service_metadata.version.?);
 | 
			
		||||
}
 | 
			
		||||
test "can filter services" {
 | 
			
		||||
    const filtered_services = Services(.{ .sts, .wafv2 }){};
 | 
			
		||||
    try expectEqualStrings("2011-06-15", filtered_services.sts.version);
 | 
			
		||||
    try expectEqualStrings("2011-06-15", filtered_services.sts.version.?);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue