allow different endpoing/sigv4 service names
This seems silly, but I guess in AWS it is a thing that these two values may be different. Consumers of awshttp have the option of ignoring this, which should be correct most of the time. Aws.zig will, however, use the service metadata to do the right thing
This commit is contained in:
parent
bd5d509665
commit
c6dbbf33af
16
src/aws.zig
16
src/aws.zig
|
@ -6,7 +6,10 @@ const servicemodel = @import("servicemodel.zig");
|
|||
|
||||
const log = std.log.scoped(.aws);
|
||||
|
||||
pub const Options = awshttp.Options;
|
||||
pub const Options = struct {
|
||||
region: []const u8 = "aws-global",
|
||||
dualstack: bool = false,
|
||||
};
|
||||
|
||||
pub const services = servicemodel.services;
|
||||
|
||||
|
@ -39,7 +42,16 @@ pub const Aws = struct {
|
|||
log.debug("service sigv4 name {s}", .{service.sigv4_name});
|
||||
log.debug("version {s}", .{service.version});
|
||||
log.debug("action {s}", .{action.action_name});
|
||||
const response = try self.aws_http.callApi(action_info.service, service.version, action.action_name, options);
|
||||
const response = try self.aws_http.callApi(
|
||||
service.endpoint_prefix,
|
||||
service.version,
|
||||
action.action_name,
|
||||
.{
|
||||
.region = options.region,
|
||||
.dualstack = options.dualstack,
|
||||
.sigv4_service_name = service.sigv4_name,
|
||||
},
|
||||
);
|
||||
defer response.deinit();
|
||||
// TODO: Check status code for badness
|
||||
var stream = json.TokenStream.init(response.body);
|
||||
|
|
|
@ -67,9 +67,10 @@ pub const AwsError = error{
|
|||
pub const Options = struct {
|
||||
region: []const u8 = "aws-global",
|
||||
dualstack: bool = false,
|
||||
sigv4_service_name: ?[]const u8 = null,
|
||||
};
|
||||
|
||||
pub const SigningOptions = struct {
|
||||
const SigningOptions = struct {
|
||||
region: []const u8 = "aws-global",
|
||||
service: []const u8,
|
||||
};
|
||||
|
@ -240,7 +241,7 @@ pub const AwsHttp = struct {
|
|||
httplog.debug("Calling {s}.{s}, endpoint {s}", .{ service, action, endpoint.uri });
|
||||
const signing_options: SigningOptions = .{
|
||||
.region = options.region,
|
||||
.service = service,
|
||||
.service = if (options.sigv4_service_name) |name| name else service,
|
||||
};
|
||||
return try self.makeRequest(endpoint, "POST", "/", body, signing_options);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user