Skip to content

Commit

Permalink
merge from main
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianyi Wang committed Jun 14, 2024
1 parent b0e0b9f commit 5ceabb7
Show file tree
Hide file tree
Showing 421 changed files with 16,284 additions and 3,519 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import software.amazon.smithy.go.codegen.GoDelegator;
import software.amazon.smithy.go.codegen.GoSettings;
import software.amazon.smithy.go.codegen.GoWriter;
import software.amazon.smithy.go.codegen.SmithyGoTypes;
import software.amazon.smithy.go.codegen.integration.GoIntegration;
import software.amazon.smithy.go.codegen.integration.RuntimeClientPlugin;
import software.amazon.smithy.model.Model;
import software.amazon.smithy.rulesengine.traits.EndpointRuleSetTrait;
import software.amazon.smithy.utils.ListUtils;
import software.amazon.smithy.utils.MapUtils;

import java.util.List;

Expand Down Expand Up @@ -36,6 +39,8 @@ public class AwsEndpointBuiltins implements GoIntegration {
goTemplate("$T(options.UseARNRegion)", SdkGoTypes.Aws.Bool);
private static final GoWriter.Writable BindAwsS3DisableMultiRegionAccessPoints =
goTemplate("$T(options.DisableMultiRegionAccessPoints)", SdkGoTypes.Aws.Bool);
private static final GoWriter.Writable BindAccountID =
goTemplate("resolveAccountID(getIdentity(ctx), options.AccountIDEndpointMode)");

@Override
public List<RuntimeClientPlugin> getClientPlugins() {
Expand All @@ -49,12 +54,38 @@ public List<RuntimeClientPlugin> getClientPlugins() {
.addEndpointBuiltinBinding("AWS::S3::UseArnRegion", BindAwsS3UseArnRegion)
.addEndpointBuiltinBinding("AWS::S3::DisableMultiRegionAccessPoints", BindAwsS3DisableMultiRegionAccessPoints)
.addEndpointBuiltinBinding("AWS::S3Control::UseArnRegion", BindAwsS3UseArnRegion)
.addEndpointBuiltinBinding("AWS::Auth::AccountId", BindAccountID)
.build());
}

@Override
public void writeAdditionalFiles(GoSettings settings, Model model, SymbolProvider symbolProvider, GoDelegator goDelegator) {
goDelegator.useFileWriter("endpoints.go", settings.getModuleName(), builtinBindingSource());
if (!settings.getService(model).hasTrait(EndpointRuleSetTrait.class)) {
return;
}
goDelegator.useShapeWriter(settings.getService(model), goTemplate("""
func resolveAccountID(identity $auth:T, mode $accountIDEndpointMode:T) *string {
if mode == $aidModeDisabled:T {
return nil
}
if ca, ok := identity.(*$credentialsAdapter:T); ok && ca.Credentials.AccountID != "" {
return $string:T(ca.Credentials.AccountID)
}
return nil
}
""",
MapUtils.of(
"auth", SmithyGoTypes.Auth.Identity,
"accountIDEndpointMode", SdkGoTypes.Aws.AccountIDEndpointMode,
"aidModeUnset", SdkGoTypes.Aws.AccountIDEndpointModeUnset,
"aidModeDisabled", SdkGoTypes.Aws.AccountIDEndpointModeDisabled,
"credentialsAdapter", SdkGoTypes.Internal.Auth.Smithy.CredentialsAdapter,
"string", SdkGoTypes.Aws.String
)
));
}

private GoWriter.Writable builtinBindingSource() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@ software.amazon.smithy.aws.go.codegen.customization.CloudFrontKVSSigV4a
software.amazon.smithy.aws.go.codegen.customization.BackfillProtocolTestServiceTrait
software.amazon.smithy.go.codegen.integration.MiddlewareStackSnapshotTests
software.amazon.smithy.aws.go.codegen.customization.s3.S3ExpiresShapeCustomization
software.amazon.smithy.aws.go.codegen.ClockSkewGenerator
software.amazon.smithy.aws.go.codegen.ClockSkewGenerator
software.amazon.smithy.aws.go.codegen.customization.AccountIDEndpointRouting

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions internal/protocoltest/awsrestjson/auth.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions internal/protocoltest/ec2query/auth.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions internal/protocoltest/jsonrpc10/auth.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions internal/protocoltest/query/auth.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions internal/protocoltest/restxml/auth.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions internal/protocoltest/restxmlwithnamespace/api_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions internal/protocoltest/restxmlwithnamespace/auth.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions internal/protocoltest/smithyrpcv2cbor/api_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions internal/protocoltest/smithyrpcv2cbor/auth.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions internal/protocoltest/smithyrpcv2cbor/options.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 42 additions & 9 deletions service/accessanalyzer/api_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5ceabb7

Please sign in to comment.