Skip to content

Commit

Permalink
chore(middleware-flexible-checksums): add requestAlgorithmMemberHttpH…
Browse files Browse the repository at this point in the history
…eader (#6694)
  • Loading branch information
trivikr authored Nov 26, 2024
1 parent 6c297b7 commit c7fdd8b
Show file tree
Hide file tree
Showing 24 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions clients/client-s3/src/commands/DeleteObjectsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ export class DeleteObjectsCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: true,
}),
getThrow200ExceptionsPlugin(config),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export class PutBucketAccelerateConfigurationCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: false,
}),
];
Expand Down
1 change: 1 addition & 0 deletions clients/client-s3/src/commands/PutBucketAclCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ export class PutBucketAclCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: true,
}),
];
Expand Down
1 change: 1 addition & 0 deletions clients/client-s3/src/commands/PutBucketCorsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export class PutBucketCorsCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: true,
}),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export class PutBucketEncryptionCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: true,
}),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ export class PutBucketLifecycleConfigurationCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: true,
}),
getThrow200ExceptionsPlugin(config),
Expand Down
1 change: 1 addition & 0 deletions clients/client-s3/src/commands/PutBucketLoggingCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ export class PutBucketLoggingCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: true,
}),
];
Expand Down
1 change: 1 addition & 0 deletions clients/client-s3/src/commands/PutBucketPolicyCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export class PutBucketPolicyCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: true,
}),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ export class PutBucketReplicationCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: true,
}),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export class PutBucketRequestPaymentCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: true,
}),
];
Expand Down
1 change: 1 addition & 0 deletions clients/client-s3/src/commands/PutBucketTaggingCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export class PutBucketTaggingCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: true,
}),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export class PutBucketVersioningCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: true,
}),
];
Expand Down
1 change: 1 addition & 0 deletions clients/client-s3/src/commands/PutBucketWebsiteCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export class PutBucketWebsiteCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: true,
}),
];
Expand Down
1 change: 1 addition & 0 deletions clients/client-s3/src/commands/PutObjectAclCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ export class PutObjectAclCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: true,
}),
getThrow200ExceptionsPlugin(config),
Expand Down
1 change: 1 addition & 0 deletions clients/client-s3/src/commands/PutObjectCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ export class PutObjectCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: false,
}),
getCheckContentLengthHeaderPlugin(config),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class PutObjectLegalHoldCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: true,
}),
getThrow200ExceptionsPlugin(config),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export class PutObjectLockConfigurationCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: true,
}),
getThrow200ExceptionsPlugin(config),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export class PutObjectRetentionCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: true,
}),
getThrow200ExceptionsPlugin(config),
Expand Down
1 change: 1 addition & 0 deletions clients/client-s3/src/commands/PutObjectTaggingCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export class PutObjectTaggingCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: true,
}),
getThrow200ExceptionsPlugin(config),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export class PutPublicAccessBlockCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: true,
}),
];
Expand Down
1 change: 1 addition & 0 deletions clients/client-s3/src/commands/RestoreObjectCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ export class RestoreObjectCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: false,
}),
getThrow200ExceptionsPlugin(config),
Expand Down
1 change: 1 addition & 0 deletions clients/client-s3/src/commands/UploadPartCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ export class UploadPartCommand extends $Command
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
requestAlgorithmMember: "ChecksumAlgorithm",
requestAlgorithmMemberHttpHeader: "x-amz-sdk-checksum-algorithm",
requestChecksumRequired: false,
}),
getThrow200ExceptionsPlugin(config),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@
import software.amazon.smithy.codegen.core.SymbolProvider;
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.knowledge.TopDownIndex;
import software.amazon.smithy.model.shapes.MemberShape;
import software.amazon.smithy.model.shapes.OperationShape;
import software.amazon.smithy.model.shapes.ServiceShape;
import software.amazon.smithy.model.shapes.StructureShape;
import software.amazon.smithy.model.traits.HttpHeaderTrait;
import software.amazon.smithy.typescript.codegen.LanguageTarget;
import software.amazon.smithy.typescript.codegen.TypeScriptDependency;
import software.amazon.smithy.typescript.codegen.TypeScriptSettings;
Expand Down Expand Up @@ -201,6 +204,15 @@ private static Map<String, Object> getPluginFunctionParams(
params.put("requestChecksumRequired", httpChecksumTrait.isRequestChecksumRequired());
httpChecksumTrait.getRequestAlgorithmMember().ifPresent(requestAlgorithmMember -> {
params.put("requestAlgorithmMember", requestAlgorithmMember);

// We know that input shape is structure, and contains requestAlgorithmMember.
StructureShape inputShape = model.expectShape(operation.getInput().get(), StructureShape.class);
MemberShape requestAlgorithmMemberShape = inputShape.getAllMembers().get(requestAlgorithmMember);

// Set requestAlgorithmMemberHttpHeader if HttpHeaderTrait is present.
requestAlgorithmMemberShape.getTrait(HttpHeaderTrait.class).ifPresent(httpHeaderTrait -> {
params.put("requestAlgorithmMemberHttpHeader", httpHeaderTrait.getValue());
});
});
httpChecksumTrait.getRequestValidationModeMember().ifPresent(requestValidationModeMember -> {
params.put("requestValidationModeMember", requestValidationModeMember);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ export interface FlexibleChecksumsRequestMiddlewareConfig {
* Defines a top-level operation input member that is used to configure request checksum behavior.
*/
requestAlgorithmMember?: string;

/**
* The {@link httpHeader} value for {@link requestAlgorithmMember}, if present.
* {@link https://smithy.io/2.0/spec/http-bindings.html#httpheader-trait httpHeader}
*/
requestAlgorithmMemberHttpHeader?: string;
}

export const flexibleChecksumsMiddlewareOptions: BuildHandlerOptions = {
Expand Down

0 comments on commit c7fdd8b

Please sign in to comment.