Skip to content

PUT/POST Requests for XML endpoints (e.g. S3 CreateBucket) #12

@deevus

Description

@deevus

It's currently not possible to call any XML endpoints that require a struct for their payload such as S3 CreateBucket.

pub const create_bucket: struct {
    // ...
    Request: type = struct {
        // ...
        create_bucket_configuration: ?struct {
            location_constraint: ?[]const u8 = null,
            location: ?struct {
                type: ?[]const u8 = null,
                name: ?[]const u8 = null,

                pub fn fieldNameFor(_: @This(), comptime field_name: []const u8) []const u8 {
                    const mappings = .{
                        .type = "Type",
                        .name = "Name",
                    };
                    return @field(mappings, field_name);
                }
            } = null,
            bucket: ?struct {
                // ...
            } = null,

            // ...

        } = null,

        // ...

        pub const http_payload: []const u8 = "create_bucket_configuration";

        // ...

    },
    
    // ...
} = .{};

Code in question:

aws-sdk-for-zig/src/aws.zig

Lines 241 to 245 in ebb727c

// We will assign the body to the value of the field denoted by
// the http_payload declaration on the request type.
// Hopefully these will always be ?[]const u8, otherwise
// we should see a compile error on this line
aws_request.body = @field(request, ActionRequest.http_payload).?;

It seems like it needs a way to convert the parameters into an XML string. Did you have any plans for that?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions