Skip to content

Commit

Permalink
Revert "Cleanup code generation templates by removing if endpointRule…
Browse files Browse the repository at this point in the history
…s checks (#3190)"

This reverts commit 19ff04b.
  • Loading branch information
SergeyRyabinin authored and sbiscigl committed Nov 21, 2024
1 parent 5442225 commit 1abda7f
Show file tree
Hide file tree
Showing 38 changed files with 1,320 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
#set($exportMacro = "${CppViewHelper.computeExportValue($metadata.classNamePrefix)}")
#pragma once
\#include <aws/${metadata.projectName}/${metadata.classNamePrefix}_EXPORTS.h>
#if($serviceModel.endpointRules)
\#include <aws/core/endpoint/AWSEndpoint.h>
#end
\#include <aws/core/AmazonSerializableWebServiceRequest.h>
\#include <aws/core/utils/UnreferencedParam.h>
\#include <aws/core/http/HttpRequest.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,32 @@ void ${typeInfo.className}::AddQueryStringParameters(URI& uri) const
${spaces} uri.AddQueryStringParameter("${memberEntry.value.locationName}", ss.str());
${spaces} ss.str("");
${spaces}}
#else
#if($operation.arnEndpointAllowed && $operation.arnLocation.equals("querystring") && $operation.arnEndpointMemberName.equals($$memberEntry.key) && !$serviceModel.endpointRules))
${spaces}${metadata.classNamePrefix}ARN arn($CppViewHelper.computeMemberVariableName($operation.arnEndpointMemberName));
${spaces}if (arn && arn.Validate().IsSuccess())
${spaces}{
${spaces} if (arn.GetResourceType() == ARNResourceType::BUCKET)
${spaces} {
${spaces} ss << arn.GetResourceId();
${spaces} }
${spaces} else if (arn.GetResourceType() == ARNResourceType::OUTPOST)
${spaces} {
${spaces} ss << arn.GetSubResourceId();
${spaces} }
${spaces} else
${spaces} {
${spaces} // It's a valid ARN, but has incorrect resource type.
${spaces} assert(false);
${spaces} }
${spaces}}
${spaces}else
${spaces}{
${spaces} ss << ${memberVarName};
${spaces}}
#else
${spaces}ss << ${memberVarName};
#end
${spaces}uri.AddQueryStringParameter("${memberEntry.value.locationName}", ss.str());
${spaces}ss.str("");
#end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,27 @@
#end
#end
#end
#if(!$serviceModel.endpointRules)
## Extra headers from ARN: 1. x-amz-account-id for s3control 2. x-amz-outpost-id for s3control.

#if($operation.hasAccountIdInArn || $operation.hasOutpostIdInArn)
${rootNamespace}::${serviceNamespace}::${metadata.classNamePrefix}ARN arn($CppViewHelper.computeMemberVariableName($operation.arnEndpointMemberName));
if (arn && arn.Validate().IsSuccess())
{
#if($operation.hasAccountIdInArn)
ss << arn.GetAccountId();
headers.emplace("x-amz-account-id", ss.str());
ss.str("");
#end
#if($operation.hasOutpostIdInArn)
if (arn.GetResourceType() == ${rootNamespace}::${serviceNamespace}::ARNResourceType::OUTPOST)
{
ss << arn.GetResourceId();
headers.emplace("x-amz-outpost-id", ss.str());
ss.str("");
}
}
#end
#end##-#if(!$serviceModel.endpointRules)

#end
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#if($serviceModel.endpointRules)
typedef ${metadata.classNamePrefix}ClientConfiguration ClientConfigurationType;
typedef ${metadata.classNamePrefix}EndpointProvider EndpointProviderType;

#else
typedef Aws::${clientConfigurationNamespace}::ClientConfiguration ClientConfigurationType;

#end
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
#set($additionalCtorArgs = {})
#if($signPayloadsOptional)
#if(!$serviceModel.endpointRules)
#set($signPayloads = ", Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy signPayloads = Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never")
#set($addArgDummy = $additionalCtorArgs.put("signPayloads", "Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy signPayloads = Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never"))
#end##-#if(!$serviceModel.endpointRules)
#else
#set($signPayloads = "")
#end
#if($virtualAddressingSupported)
#if(!$serviceModel.endpointRules)
#set($virtualAddressing = ", bool useVirtualAddressing = true")
#set($addArgDummy = $additionalCtorArgs.put("useVirtualAddressing", "bool useVirtualAddressing = true"))
#end##-#if($serviceModel.endpointRules)
#else
#set($virtualAddressing = "")
#end
#if(!$USEast1RegionalEndpointArgString)
#set($USEast1RegionalEndpointArgString = "")
#else
#if(!$serviceModel.endpointRules)
#set($addArgDummy = $additionalCtorArgs.put("USEast1RegionalEndpoint", $USEast1RegionalEndpointArgString.replace(", ", "")))
#end##-#if($serviceModel.endpointRules)
#end
#if($serviceNamespace == "S3Crt")
#set($clientConfigurationNamespace = $serviceNamespace)
Expand All @@ -20,8 +31,12 @@
#set($credentialProviderArg = "")
#end
#set($clsWSpace = $className.replaceAll(".", " "))
#if($serviceModel.endpointRules)
#set($endpointsProviderDefaultCtorDummy = "nullptr")
#set($clientConfigurationCls = "Aws::" + ${serviceNamespace} + "::" + ${metadata.classNamePrefix} + "ClientConfiguration")
#else
#set($clientConfigurationCls = "Aws::" + ${clientConfigurationNamespace} + "::ClientConfiguration")
#end
#if($serviceModel.metadata.serviceId == "S3")
/**
* Copy constructor for a ${className}. Copies all members that do not reference self.
Expand Down Expand Up @@ -53,7 +68,7 @@
*/
${className}& operator=(${className} &&rhs) noexcept;
#end
#if($serviceNamespace != "S3Crt")
#if($serviceModel.endpointRules && $serviceNamespace != "S3Crt")
#if($serviceModel.hasOnlyBearerAuth())
#set($bearerAddCtorArgs = {})
#foreach ($ctorKey in ["signPayloads", "useVirtualAddressing", "USEast1RegionalEndpoint"])
Expand All @@ -63,7 +78,9 @@
* Initializes client to use BearerTokenAuthSignerProvider, with default http client factory, and optional client config.
*/
${className}(const Aws::Auth::BearerTokenAuthSignerProvider& bearerTokenProvider,
#if($serviceModel.endpointRules)
${clsWSpace} std::shared_ptr<${metadata.classNamePrefix}EndpointProviderBase> endpointProvider = ${endpointsProviderDefaultCtorDummy},
#end
${clsWSpace} const ${clientConfigurationCls}& clientConfiguration = ${clientConfigurationCls}()#if($bearerAddCtorArgs.isEmpty()));#else,#end

#foreach($ctorArgument in $bearerAddCtorArgs)
Expand All @@ -79,9 +96,12 @@
* Initializes client to use DefaultCredentialProviderChain, with default http client factory, and optional client config. If client config
* is not specified, it will be initialized to default values.
*/
${className}(const ${clientConfigurationCls}& clientConfiguration = ${clientConfigurationCls}(),
${className}(const ${clientConfigurationCls}& clientConfiguration = ${clientConfigurationCls}()#if($defCredsChainCtor.isEmpty() && !$serviceModel.endpointRules));#else,#end

#if($serviceModel.endpointRules)
${clsWSpace} std::shared_ptr<${metadata.classNamePrefix}EndpointProviderBase> endpointProvider = ${endpointsProviderDefaultCtorDummy}#if($defCredsChainCtor.isEmpty()));#else,#end

#end
#foreach($ctorArgument in $defCredsChainCtor)
${clsWSpace} ${ctorArgument}#if( $foreach.hasNext ),#else);#end

Expand All @@ -96,7 +116,9 @@
* is not specified, it will be initialized to default values.
*/
${className}(const Aws::Auth::AWSCredentials& credentials,
#if($serviceModel.endpointRules)
${clsWSpace} std::shared_ptr<${metadata.classNamePrefix}EndpointProviderBase> endpointProvider = ${endpointsProviderDefaultCtorDummy},
#end
${clsWSpace} const ${clientConfigurationCls}& clientConfiguration = ${clientConfigurationCls}()#if($simpleCredsCtor.isEmpty()));#else,#end

#foreach($ctorArgument in $simpleCredsCtor)
Expand All @@ -113,7 +135,9 @@
* the default http client factory will be used
*/
${className}(const std::shared_ptr<Aws::Auth::AWSCredentialsProvider>& credentialsProvider,
#if($serviceModel.endpointRules)
${clsWSpace} std::shared_ptr<${metadata.classNamePrefix}EndpointProviderBase> endpointProvider = ${endpointsProviderDefaultCtorDummy},
#end
${clsWSpace} const ${clientConfigurationCls}& clientConfiguration = ${clientConfigurationCls}()#if($specCredsCtor.isEmpty()));#else,#end

#foreach($ctorArgument in $specCredsCtor)
Expand All @@ -132,7 +156,9 @@
* is not specified, it will be initialized to default values.
*/
${className}(const std::shared_ptr<Aws::Auth::AWSAuthSignerProvider>& signerProvider,
#if($serviceModel.endpointRules)
${clsWSpace} std::shared_ptr<${metadata.classNamePrefix}EndpointProviderBase> endpointProvider = ${endpointsProviderDefaultCtorDummy},
#end
${clsWSpace} const ${clientConfigurationCls}& clientConfiguration = ${clientConfigurationCls}()#if($standaloneCredsCtor.isEmpty()));#else,#end

#foreach($ctorArgument in $specCredsCtor)
Expand All @@ -141,9 +167,11 @@
#end

#end
#end##-#if($serviceNamespace != "S3Crt")
#end##-#if($serviceModel.endpointRules && $serviceNamespace != "S3Crt")

#if($serviceModel.endpointRules)
/* Legacy constructors due deprecation */
#parse("com/amazonaws/util/awsclientgenerator/velocity/cpp/ServiceClientHeaderLegacyConstructors.vm")
/* End of legacy constructors due deprecation */
#end
virtual ~${className}();
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,17 @@
#end

\#include <aws/${metadata.projectName}/${className}.h>
#if(!$serviceModel.endpointRules)
\#include <aws/${metadata.projectName}/${metadata.classNamePrefix}Endpoint.h>
#end
\#include <aws/${metadata.projectName}/${metadata.classNamePrefix}ErrorMarshaller.h>
#if($serviceModel.endpointRules)
\#include <aws/${metadata.projectName}/${metadata.classNamePrefix}EndpointProvider.h>
#else
#if($arnEndpointSupported)
\#include <aws/${metadata.projectName}/${metadata.classNamePrefix}ARN.h>
#end
#end
#if($serviceModel.hasBearerAuth())
\#include <aws/core/auth/signer-provider/BearerTokenAuthSignerProvider.h>
#end
Expand Down
Loading

0 comments on commit 1abda7f

Please sign in to comment.