Skip to content

Commit 7e7ed06

Browse files
committed
fix s3 move and copy, assignment operator with custom credentials
1 parent 689f13c commit 7e7ed06

File tree

9 files changed

+214
-3
lines changed

9 files changed

+214
-3
lines changed

generated/src/aws-cpp-sdk-s3-crt/include/aws/s3-crt/S3CrtClient.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,21 @@ namespace Aws
7575
*/
7676
S3CrtClient& operator=(const S3CrtClient &rhs);
7777

78+
/**
79+
* Copy move constructor for a S3Client. Copies all members that do not reference self.
80+
* Recreates member that reference self.
81+
* @param rhs the source object of the copy.
82+
*/
83+
S3CrtClient(S3CrtClient &&rhs);
84+
85+
/**
86+
* Assignment move operator for a S3Client. Copies all members that do not reference self.
87+
* Recreates member that reference self.
88+
* @param rhs the source object of the copy.
89+
* @return the copied client.
90+
*/
91+
S3CrtClient& operator=(S3CrtClient &&rhs);
92+
7893
/* Legacy constructors due deprecation */
7994
/**
8095
* Initializes client to use DefaultCredentialProviderChain, with default http client factory, and optional client config. If client config

generated/src/aws-cpp-sdk-s3-crt/source/S3CrtClient.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,53 @@ S3CrtClient::S3CrtClient(const S3CrtClient &rhs) :
168168
m_identityProvider(rhs.m_identityProvider){}
169169

170170
S3CrtClient& S3CrtClient::operator=(const S3CrtClient &rhs) {
171+
m_signerProvider = Aws::MakeShared<Aws::Auth::S3ExpressSignerProvider>(ALLOCATION_TAG,
172+
rhs.GetCredentialsProvider(),
173+
rhs.m_clientConfiguration.identityProviderSupplier(*this),
174+
SERVICE_NAME,
175+
Aws::Region::ComputeSignerRegion(rhs.m_clientConfiguration.region),
176+
rhs.m_clientConfiguration.payloadSigningPolicy,
177+
/*doubleEncodeValue*/ false);
171178
m_clientConfiguration = rhs.m_clientConfiguration;
172179
m_executor = rhs.m_executor;
173180
m_endpointProvider = rhs.m_endpointProvider;
174181
init(m_clientConfiguration, m_credProvider);
175182
return *this;
176183
}
177184

185+
S3CrtClient::S3CrtClient(S3CrtClient &&rhs) :
186+
BASECLASS(rhs.m_clientConfiguration,
187+
Aws::MakeShared<Aws::Auth::S3ExpressSignerProvider>(ALLOCATION_TAG,
188+
rhs.GetCredentialsProvider(),
189+
rhs.m_clientConfiguration.identityProviderSupplier(*this),
190+
SERVICE_NAME,
191+
Aws::Region::ComputeSignerRegion(rhs.m_clientConfiguration.region),
192+
rhs.m_clientConfiguration.payloadSigningPolicy,
193+
/*doubleEncodeValue*/ false),
194+
Aws::MakeShared<S3CrtErrorMarshaller>(ALLOCATION_TAG)),
195+
Aws::Client::ClientWithAsyncTemplateMethods<S3CrtClient>(),
196+
m_clientConfiguration(std::move(rhs.m_clientConfiguration)),
197+
m_executor(std::move(rhs.m_clientConfiguration.executor)),
198+
m_endpointProvider(std::move(rhs.m_endpointProvider)) {}
199+
200+
S3CrtClient& S3CrtClient::operator=(S3CrtClient &&rhs) {
201+
if (&rhs == this) {
202+
return *this;
203+
}
204+
m_signerProvider = Aws::MakeShared<Aws::Auth::S3ExpressSignerProvider>(ALLOCATION_TAG,
205+
rhs.GetCredentialsProvider(),
206+
rhs.m_clientConfiguration.identityProviderSupplier(*this),
207+
SERVICE_NAME,
208+
Aws::Region::ComputeSignerRegion(rhs.m_clientConfiguration.region),
209+
rhs.m_clientConfiguration.payloadSigningPolicy,
210+
/*doubleEncodeValue*/ false);
211+
m_clientConfiguration = std::move(rhs.m_clientConfiguration);
212+
m_executor = std::move(rhs.m_executor);
213+
m_endpointProvider = std::move(rhs.m_endpointProvider);
214+
init(m_clientConfiguration, m_credProvider);
215+
return *this;
216+
}
217+
178218
S3CrtClient::S3CrtClient(const S3Crt::ClientConfiguration& clientConfiguration, Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy signPayloads, bool useVirtualAddressing, Aws::S3Crt::US_EAST_1_REGIONAL_ENDPOINT_OPTION USEast1RegionalEndPointOption, const Aws::Auth::DefaultAWSCredentialsProviderChain& credentialsProvider) :
179219
BASECLASS(clientConfiguration,
180220
Aws::MakeShared<Aws::Auth::S3ExpressSignerProvider>(ALLOCATION_TAG,

generated/src/aws-cpp-sdk-s3/include/aws/s3/S3Client.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,21 @@ namespace Aws
6363
* @return the copied client.
6464
*/
6565
S3Client& operator=(const S3Client &rhs);
66+
67+
/**
68+
* Copy move constructor for a S3Client. Copies all members that do not reference self.
69+
* Recreates member that reference self.
70+
* @param rhs the source object of the copy.
71+
*/
72+
S3Client(S3Client &&rhs);
73+
74+
/**
75+
* Assignment move operator for a S3Client. Copies all members that do not reference self.
76+
* Recreates member that reference self.
77+
* @param rhs the source object of the copy.
78+
* @return the copied client.
79+
*/
80+
S3Client& operator=(S3Client &&rhs);
6681
/**
6782
* Initializes client to use DefaultCredentialProviderChain, with default http client factory, and optional client config. If client config
6883
* is not specified, it will be initialized to default values.

generated/src/aws-cpp-sdk-s3/source/S3Client.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,56 @@ S3Client::S3Client(const S3Client &rhs) :
153153
m_endpointProvider(rhs.m_endpointProvider) {}
154154

155155
S3Client& S3Client::operator=(const S3Client &rhs) {
156+
if (&rhs == this) {
157+
return *this;
158+
}
159+
m_signerProvider = Aws::MakeShared<Aws::Auth::S3ExpressSignerProvider>(ALLOCATION_TAG,
160+
rhs.GetCredentialsProvider(),
161+
rhs.m_clientConfiguration.identityProviderSupplier(*this),
162+
SERVICE_NAME,
163+
Aws::Region::ComputeSignerRegion(rhs.m_clientConfiguration.region),
164+
rhs.m_clientConfiguration.payloadSigningPolicy,
165+
/*doubleEncodeValue*/ false);
156166
m_clientConfiguration = rhs.m_clientConfiguration;
157167
m_executor = rhs.m_executor;
158168
m_endpointProvider = rhs.m_endpointProvider;
159169
init(m_clientConfiguration);
160170
return *this;
161171
}
162172

173+
S3Client::S3Client(S3Client &&rhs) :
174+
BASECLASS(rhs.m_clientConfiguration,
175+
Aws::MakeShared<Aws::Auth::S3ExpressSignerProvider>(ALLOCATION_TAG,
176+
rhs.GetCredentialsProvider(),
177+
rhs.m_clientConfiguration.identityProviderSupplier(*this),
178+
SERVICE_NAME,
179+
Aws::Region::ComputeSignerRegion(rhs.m_clientConfiguration.region),
180+
rhs.m_clientConfiguration.payloadSigningPolicy,
181+
/*doubleEncodeValue*/ false),
182+
Aws::MakeShared<S3ErrorMarshaller>(ALLOCATION_TAG)),
183+
Aws::Client::ClientWithAsyncTemplateMethods<S3Client>(),
184+
m_clientConfiguration(std::move(rhs.m_clientConfiguration)),
185+
m_executor(std::move(rhs.m_clientConfiguration.executor)),
186+
m_endpointProvider(std::move(rhs.m_endpointProvider)) {}
187+
188+
S3Client& S3Client::operator=(S3Client &&rhs) {
189+
if (&rhs == this) {
190+
return *this;
191+
}
192+
m_signerProvider = Aws::MakeShared<Aws::Auth::S3ExpressSignerProvider>(ALLOCATION_TAG,
193+
rhs.GetCredentialsProvider(),
194+
rhs.m_clientConfiguration.identityProviderSupplier(*this),
195+
SERVICE_NAME,
196+
Aws::Region::ComputeSignerRegion(rhs.m_clientConfiguration.region),
197+
rhs.m_clientConfiguration.payloadSigningPolicy,
198+
/*doubleEncodeValue*/ false);
199+
m_clientConfiguration = std::move(rhs.m_clientConfiguration);
200+
m_executor = std::move(rhs.m_executor);
201+
m_endpointProvider = std::move(rhs.m_endpointProvider);
202+
init(m_clientConfiguration);
203+
return *this;
204+
}
205+
163206
S3Client::S3Client(const S3::S3ClientConfiguration& clientConfiguration,
164207
std::shared_ptr<S3EndpointProviderBase> endpointProvider) :
165208
BASECLASS(clientConfiguration,

src/aws-cpp-sdk-core/include/aws/core/client/AWSClient.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ namespace Aws
328328
static CoreErrors GuessBodylessErrorType(Aws::Http::HttpResponseCode responseCode);
329329
static bool DoesResponseGenerateError(const std::shared_ptr<Aws::Http::HttpResponse>& response);
330330
std::shared_ptr<smithy::components::tracing::TelemetryProvider> m_telemetryProvider;
331+
std::shared_ptr<Aws::Auth::AWSAuthSignerProvider> m_signerProvider;
331332
private:
332333
/**
333334
* Try to adjust signer's clock
@@ -342,7 +343,6 @@ namespace Aws
342343
std::shared_ptr<Aws::IOStream> GetBodyStream(const Aws::AmazonWebServiceRequest& request) const;
343344

344345
std::shared_ptr<Aws::Http::HttpClient> m_httpClient;
345-
std::shared_ptr<Aws::Auth::AWSAuthSignerProvider> m_signerProvider;
346346
std::shared_ptr<AWSErrorMarshaller> m_errorMarshaller;
347347
std::shared_ptr<RetryStrategy> m_retryStrategy;
348348
std::shared_ptr<Aws::Utils::RateLimits::RateLimiterInterface> m_writeRateLimiter;

src/aws-cpp-sdk-core/source/client/AWSClient.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ AWSClient::AWSClient(const Aws::Client::ClientConfiguration& configuration,
119119
const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller) :
120120
m_region(configuration.region),
121121
m_telemetryProvider(configuration.telemetryProvider),
122-
m_httpClient(CreateHttpClient(configuration)),
123122
m_signerProvider(Aws::MakeUnique<Aws::Auth::DefaultAuthSignerProvider>(AWS_CLIENT_LOG_TAG, signer)),
123+
m_httpClient(CreateHttpClient(configuration)),
124124
m_errorMarshaller(errorMarshaller),
125125
m_retryStrategy(configuration.retryStrategy),
126126
m_writeRateLimiter(configuration.writeRateLimiter),
@@ -138,8 +138,8 @@ AWSClient::AWSClient(const Aws::Client::ClientConfiguration& configuration,
138138
const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller) :
139139
m_region(configuration.region),
140140
m_telemetryProvider(configuration.telemetryProvider),
141-
m_httpClient(CreateHttpClient(configuration)),
142141
m_signerProvider(signerProvider),
142+
m_httpClient(CreateHttpClient(configuration)),
143143
m_errorMarshaller(errorMarshaller),
144144
m_retryStrategy(configuration.retryStrategy),
145145
m_writeRateLimiter(configuration.writeRateLimiter),

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/ServiceClientHeaderConstructors.vm

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@
5252
* @return the copied client.
5353
*/
5454
${className}& operator=(const ${className} &rhs);
55+
56+
/**
57+
* Copy move constructor for a S3Client. Copies all members that do not reference self.
58+
* Recreates member that reference self.
59+
* @param rhs the source object of the copy.
60+
*/
61+
${className}(${className} &&rhs);
62+
63+
/**
64+
* Assignment move operator for a S3Client. Copies all members that do not reference self.
65+
* Recreates member that reference self.
66+
* @param rhs the source object of the copy.
67+
* @return the copied client.
68+
*/
69+
${className}& operator=(${className} &&rhs);
5570
#end
5671
#if($serviceModel.endpointRules && $serviceNamespace != "S3Crt")
5772
#if($serviceModel.hasOnlyBearerAuth())

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/ServiceClientSourceInit.vm

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,56 @@ ${className}::${className}(const ${className} &rhs) :
9797
m_endpointProvider(rhs.m_endpointProvider) {}
9898

9999
${className}& ${className}::operator=(const ${className} &rhs) {
100+
if (&rhs == this) {
101+
return *this;
102+
}
103+
m_signerProvider = Aws::MakeShared<Aws::Auth::S3ExpressSignerProvider>(ALLOCATION_TAG,
104+
rhs.GetCredentialsProvider(),
105+
rhs.m_clientConfiguration.identityProviderSupplier(*this),
106+
SERVICE_NAME,
107+
Aws::Region::ComputeSignerRegion(rhs.m_clientConfiguration.region),
108+
rhs.m_clientConfiguration.payloadSigningPolicy,
109+
/*doubleEncodeValue*/ false);
100110
m_clientConfiguration = rhs.m_clientConfiguration;
101111
m_executor = rhs.m_executor;
102112
m_endpointProvider = rhs.m_endpointProvider;
103113
init(m_clientConfiguration);
104114
return *this;
105115
}
106116

117+
S3Client::S3Client(${className} &&rhs) :
118+
BASECLASS(rhs.m_clientConfiguration,
119+
Aws::MakeShared<Aws::Auth::S3ExpressSignerProvider>(ALLOCATION_TAG,
120+
rhs.GetCredentialsProvider(),
121+
rhs.m_clientConfiguration.identityProviderSupplier(*this),
122+
SERVICE_NAME,
123+
Aws::Region::ComputeSignerRegion(rhs.m_clientConfiguration.region),
124+
rhs.m_clientConfiguration.payloadSigningPolicy,
125+
/*doubleEncodeValue*/ false),
126+
Aws::MakeShared<S3ErrorMarshaller>(ALLOCATION_TAG)),
127+
Aws::Client::ClientWithAsyncTemplateMethods<S3Client>(),
128+
m_clientConfiguration(std::move(rhs.m_clientConfiguration)),
129+
m_executor(std::move(rhs.m_clientConfiguration.executor)),
130+
m_endpointProvider(std::move(rhs.m_endpointProvider)) {}
131+
132+
${className}& ${className}::operator=(${className} &&rhs) {
133+
if (&rhs == this) {
134+
return *this;
135+
}
136+
m_signerProvider = Aws::MakeShared<Aws::Auth::S3ExpressSignerProvider>(ALLOCATION_TAG,
137+
rhs.GetCredentialsProvider(),
138+
rhs.m_clientConfiguration.identityProviderSupplier(*this),
139+
SERVICE_NAME,
140+
Aws::Region::ComputeSignerRegion(rhs.m_clientConfiguration.region),
141+
rhs.m_clientConfiguration.payloadSigningPolicy,
142+
/*doubleEncodeValue*/ false);
143+
m_clientConfiguration = std::move(rhs.m_clientConfiguration);
144+
m_executor = std::move(rhs.m_executor);
145+
m_endpointProvider = std::move(rhs.m_endpointProvider);
146+
init(m_clientConfiguration);
147+
return *this;
148+
}
149+
107150
#end
108151
#if($serviceModel.hasOnlyBearerAuth())
109152
##BEARER TOKEN AUTH PROVIDER C-TOR

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/s3/s3-crt/S3CrtServiceClientSourceInit.vm

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,53 @@ ${className}::${className}(const ${className} &rhs) :
7272
m_identityProvider(rhs.m_identityProvider){}
7373

7474
${className}& ${className}::operator=(const ${className} &rhs) {
75+
m_signerProvider = Aws::MakeShared<Aws::Auth::S3ExpressSignerProvider>(ALLOCATION_TAG,
76+
rhs.GetCredentialsProvider(),
77+
rhs.m_clientConfiguration.identityProviderSupplier(*this),
78+
SERVICE_NAME,
79+
Aws::Region::ComputeSignerRegion(rhs.m_clientConfiguration.region),
80+
rhs.m_clientConfiguration.payloadSigningPolicy,
81+
/*doubleEncodeValue*/ false);
7582
m_clientConfiguration = rhs.m_clientConfiguration;
7683
m_executor = rhs.m_executor;
7784
m_endpointProvider = rhs.m_endpointProvider;
7885
init(m_clientConfiguration, m_credProvider);
7986
return *this;
8087
}
8188

89+
${className}::${className}(${className} &&rhs) :
90+
BASECLASS(rhs.m_clientConfiguration,
91+
Aws::MakeShared<Aws::Auth::S3ExpressSignerProvider>(ALLOCATION_TAG,
92+
rhs.GetCredentialsProvider(),
93+
rhs.m_clientConfiguration.identityProviderSupplier(*this),
94+
SERVICE_NAME,
95+
Aws::Region::ComputeSignerRegion(rhs.m_clientConfiguration.region),
96+
rhs.m_clientConfiguration.payloadSigningPolicy,
97+
/*doubleEncodeValue*/ false),
98+
Aws::MakeShared<S3CrtErrorMarshaller>(ALLOCATION_TAG)),
99+
Aws::Client::ClientWithAsyncTemplateMethods<S3CrtClient>(),
100+
m_clientConfiguration(std::move(rhs.m_clientConfiguration)),
101+
m_executor(std::move(rhs.m_clientConfiguration.executor)),
102+
m_endpointProvider(std::move(rhs.m_endpointProvider)) {}
103+
104+
${className}& ${className}::operator=(${className} &&rhs) {
105+
if (&rhs == this) {
106+
return *this;
107+
}
108+
m_signerProvider = Aws::MakeShared<Aws::Auth::S3ExpressSignerProvider>(ALLOCATION_TAG,
109+
rhs.GetCredentialsProvider(),
110+
rhs.m_clientConfiguration.identityProviderSupplier(*this),
111+
SERVICE_NAME,
112+
Aws::Region::ComputeSignerRegion(rhs.m_clientConfiguration.region),
113+
rhs.m_clientConfiguration.payloadSigningPolicy,
114+
/*doubleEncodeValue*/ false);
115+
m_clientConfiguration = std::move(rhs.m_clientConfiguration);
116+
m_executor = std::move(rhs.m_executor);
117+
m_endpointProvider = std::move(rhs.m_endpointProvider);
118+
init(m_clientConfiguration, m_credProvider);
119+
return *this;
120+
}
121+
82122
#if($hasEventStreamInputOperation || $multiRegionAccessPointSupported)
83123
${className}::${className}(const ${clientConfigurationNamespace}::ClientConfiguration& clientConfiguration${signPayloads}${virtualAddressing}${USEast1RegionalEndpointArgString}${credentialProviderArg}) :
84124
BASECLASS(clientConfiguration,

0 commit comments

Comments
 (0)