From 3e7e76a191e6ac2fe50afc967c22bce9c6f6da77 Mon Sep 17 00:00:00 2001 From: SergeyRyabinin Date: Tue, 13 Aug 2024 21:59:07 +0000 Subject: [PATCH] Add account id to the built-in endpoint parameters --- .../aws/dynamodb/DynamoDBEndpointProvider.h | 31 ++++++++++++++-- .../source/DynamoDBEndpointProvider.cpp | 21 +++++++++++ .../TimestreamQueryEndpointProvider.h | 31 ++++++++++++++-- .../TimestreamQueryEndpointProvider.cpp | 21 +++++++++++ .../TimestreamWriteEndpointProvider.h | 31 ++++++++++++++-- .../TimestreamWriteEndpointProvider.cpp | 21 +++++++++++ .../domainmodels/c2j/C2jServiceModel.java | 4 ++- .../codegeneration/EndpointRuleSetModel.java | 36 +++++++++++++++++++ .../codegeneration/ServiceModel.java | 11 +++++- .../generators/DirectFromC2jGenerator.java | 15 ++++++++ .../generators/cpp/CppClientGenerator.java | 5 +-- .../C2jModelToGeneratorModelTransformer.java | 1 + .../ServiceClientConfigurationHeader.vm | 12 +++++++ .../ServiceClientConfigurationSource.vm | 13 +++++++ .../cpp/endpoint/EndpointProviderHeader.vm | 10 +++--- .../cpp/endpoint/EndpointProviderSource.vm | 14 ++++++-- 16 files changed, 255 insertions(+), 22 deletions(-) create mode 100644 tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/EndpointRuleSetModel.java diff --git a/generated/src/aws-cpp-sdk-dynamodb/include/aws/dynamodb/DynamoDBEndpointProvider.h b/generated/src/aws-cpp-sdk-dynamodb/include/aws/dynamodb/DynamoDBEndpointProvider.h index 18d9f5d9455..2752af94a8f 100644 --- a/generated/src/aws-cpp-sdk-dynamodb/include/aws/dynamodb/DynamoDBEndpointProvider.h +++ b/generated/src/aws-cpp-sdk-dynamodb/include/aws/dynamodb/DynamoDBEndpointProvider.h @@ -5,7 +5,7 @@ #pragma once #include -#include +#include #include #include #include @@ -20,14 +20,20 @@ namespace DynamoDB { namespace Endpoint { +using DynamoDBClientConfiguration = Aws::DynamoDB::DynamoDBClientConfiguration; using EndpointParameters = Aws::Endpoint::EndpointParameters; using Aws::Endpoint::EndpointProviderBase; using Aws::Endpoint::DefaultEndpointProvider; using DynamoDBClientContextParameters = Aws::Endpoint::ClientContextParameters; -using DynamoDBClientConfiguration = Aws::Client::GenericClientConfiguration; -using DynamoDBBuiltInParameters = Aws::Endpoint::BuiltInParameters; +class AWS_DYNAMODB_API DynamoDBBuiltInParameters : public Aws::Endpoint::BuiltInParameters +{ +public: + virtual ~DynamoDBBuiltInParameters(){}; + using Aws::Endpoint::BuiltInParameters::SetFromClientConfiguration; + virtual void SetFromClientConfiguration(const DynamoDBClientConfiguration& config); +}; /** * The type for the DynamoDB Client Endpoint Provider. @@ -40,6 +46,25 @@ using DynamoDBEndpointProviderBase = using DynamoDBDefaultEpProviderBase = DefaultEndpointProvider; +} // namespace Endpoint +} // namespace DynamoDB + +namespace Endpoint +{ +/** + * Export endpoint provider symbols for Windows DLL, otherwise declare as extern + */ +AWS_DYNAMODB_EXTERN template class AWS_DYNAMODB_API + Aws::Endpoint::EndpointProviderBase; + +AWS_DYNAMODB_EXTERN template class AWS_DYNAMODB_API + Aws::Endpoint::DefaultEndpointProvider; +} // namespace Endpoint + +namespace DynamoDB +{ +namespace Endpoint +{ /** * Default endpoint provider used for this service */ diff --git a/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBEndpointProvider.cpp b/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBEndpointProvider.cpp index fb5c5087ff3..345928a70f8 100644 --- a/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBEndpointProvider.cpp +++ b/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBEndpointProvider.cpp @@ -7,10 +7,31 @@ namespace Aws { +#ifndef AWS_DYNAMODB_EXPORTS // Except for Windows DLL +namespace Endpoint +{ +/** + * Instantiate endpoint providers + */ +template class Aws::Endpoint::EndpointProviderBase; + +template class Aws::Endpoint::DefaultEndpointProvider; +} // namespace Endpoint +#endif + namespace DynamoDB { namespace Endpoint { + void DynamoDBBuiltInParameters::SetFromClientConfiguration(const DynamoDBClientConfiguration& config) + { + SetFromClientConfiguration(static_cast(config)); + + } } // namespace Endpoint } // namespace DynamoDB } // namespace Aws diff --git a/generated/src/aws-cpp-sdk-timestream-query/include/aws/timestream-query/TimestreamQueryEndpointProvider.h b/generated/src/aws-cpp-sdk-timestream-query/include/aws/timestream-query/TimestreamQueryEndpointProvider.h index aed62982e2c..00a9ac83a95 100644 --- a/generated/src/aws-cpp-sdk-timestream-query/include/aws/timestream-query/TimestreamQueryEndpointProvider.h +++ b/generated/src/aws-cpp-sdk-timestream-query/include/aws/timestream-query/TimestreamQueryEndpointProvider.h @@ -5,7 +5,7 @@ #pragma once #include -#include +#include #include #include #include @@ -20,14 +20,20 @@ namespace TimestreamQuery { namespace Endpoint { +using TimestreamQueryClientConfiguration = Aws::TimestreamQuery::TimestreamQueryClientConfiguration; using EndpointParameters = Aws::Endpoint::EndpointParameters; using Aws::Endpoint::EndpointProviderBase; using Aws::Endpoint::DefaultEndpointProvider; using TimestreamQueryClientContextParameters = Aws::Endpoint::ClientContextParameters; -using TimestreamQueryClientConfiguration = Aws::Client::GenericClientConfiguration; -using TimestreamQueryBuiltInParameters = Aws::Endpoint::BuiltInParameters; +class AWS_TIMESTREAMQUERY_API TimestreamQueryBuiltInParameters : public Aws::Endpoint::BuiltInParameters +{ +public: + virtual ~TimestreamQueryBuiltInParameters(){}; + using Aws::Endpoint::BuiltInParameters::SetFromClientConfiguration; + virtual void SetFromClientConfiguration(const TimestreamQueryClientConfiguration& config); +}; /** * The type for the TimestreamQuery Client Endpoint Provider. @@ -40,6 +46,25 @@ using TimestreamQueryEndpointProviderBase = using TimestreamQueryDefaultEpProviderBase = DefaultEndpointProvider; +} // namespace Endpoint +} // namespace TimestreamQuery + +namespace Endpoint +{ +/** + * Export endpoint provider symbols for Windows DLL, otherwise declare as extern + */ +AWS_TIMESTREAMQUERY_EXTERN template class AWS_TIMESTREAMQUERY_API + Aws::Endpoint::EndpointProviderBase; + +AWS_TIMESTREAMQUERY_EXTERN template class AWS_TIMESTREAMQUERY_API + Aws::Endpoint::DefaultEndpointProvider; +} // namespace Endpoint + +namespace TimestreamQuery +{ +namespace Endpoint +{ /** * Default endpoint provider used for this service */ diff --git a/generated/src/aws-cpp-sdk-timestream-query/source/TimestreamQueryEndpointProvider.cpp b/generated/src/aws-cpp-sdk-timestream-query/source/TimestreamQueryEndpointProvider.cpp index 0e63b2e72a4..369c6b3cdf8 100644 --- a/generated/src/aws-cpp-sdk-timestream-query/source/TimestreamQueryEndpointProvider.cpp +++ b/generated/src/aws-cpp-sdk-timestream-query/source/TimestreamQueryEndpointProvider.cpp @@ -7,10 +7,31 @@ namespace Aws { +#ifndef AWS_TIMESTREAMQUERY_EXPORTS // Except for Windows DLL +namespace Endpoint +{ +/** + * Instantiate endpoint providers + */ +template class Aws::Endpoint::EndpointProviderBase; + +template class Aws::Endpoint::DefaultEndpointProvider; +} // namespace Endpoint +#endif + namespace TimestreamQuery { namespace Endpoint { + void TimestreamQueryBuiltInParameters::SetFromClientConfiguration(const TimestreamQueryClientConfiguration& config) + { + SetFromClientConfiguration(static_cast(config)); + + } } // namespace Endpoint } // namespace TimestreamQuery } // namespace Aws diff --git a/generated/src/aws-cpp-sdk-timestream-write/include/aws/timestream-write/TimestreamWriteEndpointProvider.h b/generated/src/aws-cpp-sdk-timestream-write/include/aws/timestream-write/TimestreamWriteEndpointProvider.h index 6fb43fee6e7..354e96366c3 100644 --- a/generated/src/aws-cpp-sdk-timestream-write/include/aws/timestream-write/TimestreamWriteEndpointProvider.h +++ b/generated/src/aws-cpp-sdk-timestream-write/include/aws/timestream-write/TimestreamWriteEndpointProvider.h @@ -5,7 +5,7 @@ #pragma once #include -#include +#include #include #include #include @@ -20,14 +20,20 @@ namespace TimestreamWrite { namespace Endpoint { +using TimestreamWriteClientConfiguration = Aws::TimestreamWrite::TimestreamWriteClientConfiguration; using EndpointParameters = Aws::Endpoint::EndpointParameters; using Aws::Endpoint::EndpointProviderBase; using Aws::Endpoint::DefaultEndpointProvider; using TimestreamWriteClientContextParameters = Aws::Endpoint::ClientContextParameters; -using TimestreamWriteClientConfiguration = Aws::Client::GenericClientConfiguration; -using TimestreamWriteBuiltInParameters = Aws::Endpoint::BuiltInParameters; +class AWS_TIMESTREAMWRITE_API TimestreamWriteBuiltInParameters : public Aws::Endpoint::BuiltInParameters +{ +public: + virtual ~TimestreamWriteBuiltInParameters(){}; + using Aws::Endpoint::BuiltInParameters::SetFromClientConfiguration; + virtual void SetFromClientConfiguration(const TimestreamWriteClientConfiguration& config); +}; /** * The type for the TimestreamWrite Client Endpoint Provider. @@ -40,6 +46,25 @@ using TimestreamWriteEndpointProviderBase = using TimestreamWriteDefaultEpProviderBase = DefaultEndpointProvider; +} // namespace Endpoint +} // namespace TimestreamWrite + +namespace Endpoint +{ +/** + * Export endpoint provider symbols for Windows DLL, otherwise declare as extern + */ +AWS_TIMESTREAMWRITE_EXTERN template class AWS_TIMESTREAMWRITE_API + Aws::Endpoint::EndpointProviderBase; + +AWS_TIMESTREAMWRITE_EXTERN template class AWS_TIMESTREAMWRITE_API + Aws::Endpoint::DefaultEndpointProvider; +} // namespace Endpoint + +namespace TimestreamWrite +{ +namespace Endpoint +{ /** * Default endpoint provider used for this service */ diff --git a/generated/src/aws-cpp-sdk-timestream-write/source/TimestreamWriteEndpointProvider.cpp b/generated/src/aws-cpp-sdk-timestream-write/source/TimestreamWriteEndpointProvider.cpp index a4d23ab849d..7b8ed27b307 100644 --- a/generated/src/aws-cpp-sdk-timestream-write/source/TimestreamWriteEndpointProvider.cpp +++ b/generated/src/aws-cpp-sdk-timestream-write/source/TimestreamWriteEndpointProvider.cpp @@ -7,10 +7,31 @@ namespace Aws { +#ifndef AWS_TIMESTREAMWRITE_EXPORTS // Except for Windows DLL +namespace Endpoint +{ +/** + * Instantiate endpoint providers + */ +template class Aws::Endpoint::EndpointProviderBase; + +template class Aws::Endpoint::DefaultEndpointProvider; +} // namespace Endpoint +#endif + namespace TimestreamWrite { namespace Endpoint { + void TimestreamWriteBuiltInParameters::SetFromClientConfiguration(const TimestreamWriteClientConfiguration& config) + { + SetFromClientConfiguration(static_cast(config)); + + } } // namespace Endpoint } // namespace TimestreamWrite } // namespace Aws diff --git a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/c2j/C2jServiceModel.java b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/c2j/C2jServiceModel.java index c3dfd5600b6..b444bc774d0 100644 --- a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/c2j/C2jServiceModel.java +++ b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/c2j/C2jServiceModel.java @@ -6,6 +6,7 @@ package com.amazonaws.util.awsclientgenerator.domainmodels.c2j; import com.amazonaws.util.awsclientgenerator.domainmodels.codegeneration.ClientContextParams; +import com.amazonaws.util.awsclientgenerator.domainmodels.codegeneration.EndpointRuleSetModel; import com.amazonaws.util.awsclientgenerator.domainmodels.endpoints.EndpointTests; import lombok.Data; @@ -19,7 +20,8 @@ public class C2jServiceModel { Map shapes; Map operations; String serviceName; - String endpointRules; + String endpointRules; // as a blob + EndpointRuleSetModel endpointRuleSetModel; EndpointTests endpointTests; ClientContextParams clientContextParams; } diff --git a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/EndpointRuleSetModel.java b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/EndpointRuleSetModel.java new file mode 100644 index 00000000000..9475b295970 --- /dev/null +++ b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/EndpointRuleSetModel.java @@ -0,0 +1,36 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +package com.amazonaws.util.awsclientgenerator.domainmodels.codegeneration; + +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Data +public class EndpointRuleSetModel { + @Data + public static class Parameter { + @Data + public static class Deprecated { + private String message; + private String since; + + } + + private String type; // required in schema + private String builtIn; + private boolean required; + private String documentation; + private Deprecated deprecated; + + } + + private String version; + private String serviceId; + private Map parameters; + // private List rules; // ignored by this SDK code gen at the moment +} \ No newline at end of file diff --git a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/ServiceModel.java b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/ServiceModel.java index 71a08450ec2..876f1e11bdd 100644 --- a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/ServiceModel.java +++ b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/ServiceModel.java @@ -61,6 +61,14 @@ public boolean hasOnlyBearerAuth() { return operations.values().parallelStream().allMatch(operation -> operation.getSignerName().equals("Aws::Auth::BEARER_SIGNER")); } + public boolean hasServiceSpecificClientConfig() { + return metadata.getServiceId().equalsIgnoreCase("S3") || + metadata.getServiceId().equalsIgnoreCase("S3-CRT") || + metadata.getServiceId().equalsIgnoreCase("S3 Control") || + metadata.isHasEndpointDiscoveryTrait() || + endpointRuleSetModel.getParameters().containsKey("AccountId") || endpointRuleSetModel.getParameters().containsKey("AccountIdEndpointMode"); + } + public Operation getOperationForRequestShapeName(String requestShapeName) { for (Map.Entry opEntry : operations.entrySet()) { Operation op = opEntry.getValue(); @@ -71,7 +79,8 @@ public Operation getOperationForRequestShapeName(String requestShapeName) { return null; } - String endpointRules; + String endpointRules; // as a blob + EndpointRuleSetModel endpointRuleSetModel; EndpointTests endpointTests; ClientContextParams clientContextParams; } diff --git a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/DirectFromC2jGenerator.java b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/DirectFromC2jGenerator.java index 19fe94431da..d055eb66092 100644 --- a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/DirectFromC2jGenerator.java +++ b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/DirectFromC2jGenerator.java @@ -6,6 +6,7 @@ package com.amazonaws.util.awsclientgenerator.generators; import com.amazonaws.util.awsclientgenerator.domainmodels.c2j.C2jServiceModel; +import com.amazonaws.util.awsclientgenerator.domainmodels.codegeneration.EndpointRuleSetModel; import com.amazonaws.util.awsclientgenerator.domainmodels.codegeneration.PartitionsModel; import com.amazonaws.util.awsclientgenerator.domainmodels.defaults.BaseOption; import com.amazonaws.util.awsclientgenerator.domainmodels.defaults.BaseOptionModifier; @@ -42,6 +43,8 @@ public ByteArrayOutputStream generateServiceSourceFromJson(String rawJson, Strin C2jServiceModel c2jServiceModel = gson.fromJson(rawJson, C2jServiceModel.class); c2jServiceModel.setServiceName(serviceName); c2jServiceModel.setEndpointRules(endpointRuleSet); + EndpointRuleSetModel endpointRuleSetBom = parseEndpointRuleSet(endpointRuleSet); + c2jServiceModel.setEndpointRuleSetModel(endpointRuleSetBom); if (endpointRulesTests != null) { EndpointTests endpointTestsModel = gson.fromJson(endpointRulesTests, EndpointTests.class); c2jServiceModel.setEndpointTests(endpointTestsModel); @@ -127,6 +130,18 @@ public PartitionsModel parsePartitions(final String rawJson) { return gson.fromJson(rawJson, PartitionsModel.class); } + /** + * Parse rawJson into a structured EndpointRuleSet object + * + * @param rawJson the raw json representation of the partitions object. + * @return a parsed object of partitions. + */ + public EndpointRuleSetModel parseEndpointRuleSet(final String rawJson) { + Gson gson = new Gson(); + return gson.fromJson(rawJson, EndpointRuleSetModel.class); + } + + /** * A function to generate C++ source for service client tests * diff --git a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/cpp/CppClientGenerator.java b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/cpp/CppClientGenerator.java index 3017534537c..a9c52d9ca41 100644 --- a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/cpp/CppClientGenerator.java +++ b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/cpp/CppClientGenerator.java @@ -113,10 +113,7 @@ public SdkFileEntry[] generateSourceFiles(ServiceModel serviceModel) throws Exce fileList.add(generateEndpointProviderHeaderFile(serviceModel)); fileList.add(generateEndpointProviderSourceFile(serviceModel)); - if (serviceModel.getMetadata().getServiceId().equalsIgnoreCase("S3") || - serviceModel.getMetadata().getServiceId().equalsIgnoreCase("S3-CRT") || - serviceModel.getMetadata().getServiceId().equalsIgnoreCase("S3 Control") || - serviceModel.getMetadata().isHasEndpointDiscoveryTrait()) { + if (serviceModel.hasServiceSpecificClientConfig()) { fileList.add(generateServiceClientConfigurationHeaderFile(serviceModel)); fileList.add(generateServiceClientConfigurationSourceFile(serviceModel)); } diff --git a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/transform/C2jModelToGeneratorModelTransformer.java b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/transform/C2jModelToGeneratorModelTransformer.java index 0c95e6c8cc2..b2e2a8e5e1a 100644 --- a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/transform/C2jModelToGeneratorModelTransformer.java +++ b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/transform/C2jModelToGeneratorModelTransformer.java @@ -176,6 +176,7 @@ public ServiceModel convert() { shortenedRules += "\0"; serviceModel.setEndpointRules(shortenedRules); } + serviceModel.setEndpointRuleSetModel(c2jServiceModel.getEndpointRuleSetModel()); serviceModel.setEndpointTests(c2jServiceModel.getEndpointTests()); serviceModel.setClientContextParams(c2jServiceModel.getClientContextParams()); diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/common/ServiceClientConfigurationHeader.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/common/ServiceClientConfigurationHeader.vm index bc19a50cf43..0844362de0a 100644 --- a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/common/ServiceClientConfigurationHeader.vm +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/common/ServiceClientConfigurationHeader.vm @@ -115,6 +115,18 @@ namespace ${rootNamespace} */ Aws::Crt::Optional& enableEndpointDiscovery; +#end +#if($serviceModel.endpointRuleSetModel.parameters.containsKey("AccountId")) + /** + * $serviceModel.endpointRuleSetModel.parameters["AccountId"].documentation + */ + Aws::String accountId; +#end +#if($serviceModel.endpointRuleSetModel.parameters.containsKey("AccountIdEndpointMode")) + /** + * $serviceModel.endpointRuleSetModel.parameters["AccountIdEndpointMode"].documentation + */ + Aws::String accountIdEndpointMode = "preferred"; #end private: void Load${serviceNamespace}SpecificConfig(const Aws::String& profileName); diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/common/ServiceClientConfigurationSource.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/common/ServiceClientConfigurationSource.vm index 5f270e570ea..3ae0eb9b970 100644 --- a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/common/ServiceClientConfigurationSource.vm +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/common/ServiceClientConfigurationSource.vm @@ -119,6 +119,19 @@ void ${metadata.classNamePrefix}ClientConfiguration::Load${serviceNamespace}Spec enableEndpointDiscovery = IsEndpointDiscoveryEnabled(this->endpointOverride, inputProfileName); } #end +#if($serviceModel.endpointRuleSetModel.parameters.containsKey("AccountId")) + // accountId is intentionally not set here: AWS_ACCOUNT_ID env variable may not match the provided credentials. + // it must be set by an auth provider / identity resolver or by an SDK user. +#end +#if($serviceModel.endpointRuleSetModel.parameters.containsKey("AccountIdEndpointMode")) + static const char AWS_ACCOUNT_ID_ENDPOINT_MODE_ENVIRONMENT_VARIABLE[] = "AWS_ACCOUNT_ID_ENDPOINT_MODE"; + static const char AWS_ACCOUNT_ID_ENDPOINT_MODE_CONFIG_FILE_OPTION[] = "account_id_endpoint_mode"; + accountIdEndpointMode = ClientConfiguration::LoadConfigFromEnvOrProfile(AWS_ACCOUNT_ID_ENDPOINT_MODE_ENVIRONMENT_VARIABLE, + inputProfileName, + AWS_ACCOUNT_ID_ENDPOINT_MODE_CONFIG_FILE_OPTION, + {"required", "disabled", "preferred"}, /* allowed values */ + "preferred" /* default value */); +#end } ${metadata.classNamePrefix}ClientConfiguration::${metadata.classNamePrefix}ClientConfiguration(const Client::ClientConfigurationInitValues &configuration) diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/endpoint/EndpointProviderHeader.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/endpoint/EndpointProviderHeader.vm index 61f79c9ff0d..b3887260672 100644 --- a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/endpoint/EndpointProviderHeader.vm +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/endpoint/EndpointProviderHeader.vm @@ -10,7 +10,7 @@ #set($externMacro = "AWS_${metadata.classNamePrefix.toUpperCase()}_EXTERN") #pragma once \#include -#if($serviceModel.metadata.serviceId == "S3" || $serviceModel.metadata.serviceId == "S3 Control") +#if($serviceModel.hasServiceSpecificClientConfig()) \#include #else \#include @@ -31,7 +31,7 @@ namespace ${serviceNamespace} { namespace Endpoint { -#if($serviceModel.metadata.serviceId == "S3" || $serviceModel.metadata.serviceId == "S3 Control") +#if($serviceModel.hasServiceSpecificClientConfig()) using ${metadata.classNamePrefix}ClientConfiguration = Aws::${serviceNamespace}::${metadata.classNamePrefix}ClientConfiguration; #end using EndpointParameters = Aws::Endpoint::EndpointParameters; @@ -65,10 +65,10 @@ public: using ${epContextClassName} = Aws::Endpoint::ClientContextParameters; #end -#if($serviceModel.metadata.serviceId != "S3" && $serviceModel.metadata.serviceId != "S3 Control") +#if(!$serviceModel.hasServiceSpecificClientConfig()) using ${metadata.classNamePrefix}ClientConfiguration = Aws::Client::GenericClientConfiguration; #end -#if($serviceModel.metadata.serviceId == "S3" || $serviceModel.metadata.serviceId == "S3 Control") +#if($serviceModel.hasServiceSpecificClientConfig()) class ${exportMacro} ${epBuiltInClassName} : public Aws::Endpoint::BuiltInParameters { public: @@ -91,7 +91,7 @@ using ${metadata.classNamePrefix}EndpointProviderBase = using ${metadata.classNamePrefix}DefaultEpProviderBase = DefaultEndpointProvider<${metadata.classNamePrefix}ClientConfiguration, ${epBuiltInClassName}, ${epContextClassName}>; -#if($serviceModel.metadata.serviceId == "S3" || $serviceModel.metadata.serviceId == "S3 Control" || $serviceModel.clientContextParams) +#if($serviceModel.hasServiceSpecificClientConfig() || $serviceModel.clientContextParams) } // namespace Endpoint } // namespace ${serviceNamespace} diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/endpoint/EndpointProviderSource.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/endpoint/EndpointProviderSource.vm index 0486b0a56e9..76864fcbe38 100644 --- a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/endpoint/EndpointProviderSource.vm +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/endpoint/EndpointProviderSource.vm @@ -10,7 +10,7 @@ namespace ${rootNamespace} { -#if($serviceModel.metadata.serviceId == "S3" || $serviceModel.metadata.serviceId == "S3 Control" || $serviceModel.clientContextParams) +#if($serviceModel.hasServiceSpecificClientConfig() || $serviceModel.clientContextParams) #ifndef AWS_${metadata.classNamePrefix.toUpperCase()}_EXPORTS // Except for Windows DLL namespace Endpoint { @@ -54,7 +54,7 @@ namespace Endpoint } #end #end -#if($serviceModel.metadata.serviceId == "S3" || $serviceModel.metadata.serviceId == "S3 Control") +#if($serviceModel.hasServiceSpecificClientConfig()) void ${epBuiltInClassName}::SetFromClientConfiguration(const ${metadata.classNamePrefix}ClientConfiguration& config) { SetFromClientConfiguration(static_cast(config)); @@ -88,6 +88,16 @@ namespace Endpoint #if($serviceModel.metadata.serviceId == "S3 Control") static const char* AWS_S3_USE_ARN_REGION = "UseArnRegion"; SetBooleanParameter(AWS_S3_USE_ARN_REGION, config.useArnRegion); +#end +#if($serviceModel.endpointRuleSetModel.parameters.containsKey("AccountId")) + if(!config.accountId.empty()) { + SetStringParameter("AccountId", config.accountId); + } +#end +#if($serviceModel.endpointRuleSetModel.parameters.containsKey("AccountIdEndpointMode")) + if(!config.accountIdEndpointMode.empty()) { + SetStringParameter("AccountIdEndpointMode", config.accountIdEndpointMode); + } #end } #end