Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix rule of 5 for client configuration #3314

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ namespace Aws

DynamoDBClientConfiguration(const DynamoDBClientConfiguration& other)
: Aws::Client::GenericClientConfiguration(other),
enableEndpointDiscovery(BaseClientConfigClass::enableEndpointDiscovery)
enableEndpointDiscovery(BaseClientConfigClass::enableEndpointDiscovery),
accountId{other.accountId},
accountIdEndpointMode{other.accountIdEndpointMode}
{
}

DynamoDBClientConfiguration(DynamoDBClientConfiguration&& other) noexcept
: Aws::Client::GenericClientConfiguration(std::move(other)),
enableEndpointDiscovery(BaseClientConfigClass::enableEndpointDiscovery)
enableEndpointDiscovery(BaseClientConfigClass::enableEndpointDiscovery),
accountId{std::move(other.accountId)},
accountIdEndpointMode{std::move(other.accountIdEndpointMode)}
{
}

Expand All @@ -36,6 +40,8 @@ namespace Aws
if (this == &other)
return *this;
Aws::Client::GenericClientConfiguration::operator =(other);
accountId = other.accountId;
accountIdEndpointMode = other.accountIdEndpointMode;
return *this;
}

Expand All @@ -44,6 +50,8 @@ namespace Aws
if (this == &other)
return *this;
Aws::Client::GenericClientConfiguration::operator =(std::move(other));
accountId = std::move(other.accountId);
accountIdEndpointMode = std::move(other.accountIdEndpointMode);
return *this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,36 @@ namespace Aws
{
using BaseClientConfigClass = Aws::Client::GenericClientConfiguration;

S3ControlClientConfiguration(const S3ControlClientConfiguration& other)
: Aws::Client::GenericClientConfiguration(other),
accountId{other.accountId}
{
}

S3ControlClientConfiguration(S3ControlClientConfiguration&& other) noexcept
: Aws::Client::GenericClientConfiguration(std::move(other)),
accountId{std::move(other.accountId)}
{
}

S3ControlClientConfiguration& operator=(const S3ControlClientConfiguration& other)
{
if (this == &other)
return *this;
Aws::Client::GenericClientConfiguration::operator =(other);
accountId = other.accountId;
return *this;
}

S3ControlClientConfiguration& operator=(S3ControlClientConfiguration&& other) noexcept
{
if (this == &other)
return *this;
Aws::Client::GenericClientConfiguration::operator =(std::move(other));
accountId = std::move(other.accountId);
return *this;
}

S3ControlClientConfiguration(const Client::ClientConfigurationInitValues &configuration = {});

/**
Expand Down
26 changes: 26 additions & 0 deletions tests/aws-cpp-sdk-dynamodb-unit-tests/DynamoDBUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,29 @@ TEST_F(DynamoDBUnitTest, ListTablesShouldHaveCorrectUserAgent)
EXPECT_TRUE(crtMetadata < archMetadata);
EXPECT_TRUE(archMetadata < businessMetrics);
}

TEST_F(DynamoDBUnitTest, ShouldUseAccountIDEndpoint)
{
// create client with account id configuration
AWSCredentials credentials{"mock", "credentials"};
const auto epProvider = Aws::MakeShared<DynamoDBEndpointProvider>(LOG_TAG);
DynamoDBClientConfiguration configuration;
configuration.accountId = "123456789012";
configuration.region = "us-east-1";
const auto accountIdClient = Aws::MakeShared<DynamoDBClient>(LOG_TAG, credentials, epProvider, configuration);

// mock response
auto successStream = Aws::MakeShared<StandardHttpRequest>(LOG_TAG, "the_grand_budapest.hotel/zero", HttpMethod::HTTP_GET);
successStream->SetResponseStreamFactory([]() -> IOStream* {
auto listTablesString = R"({"LastEvaluatedTableName": "Hotels","TableNames": ["Hotels"]}))";
return Aws::New<StringStream>(LOG_TAG, listTablesString, std::ios_base::in | std::ios_base::binary);
});
auto successResponse = Aws::MakeShared<StandardHttpResponse>(LOG_TAG, successStream);
successResponse->SetResponseCode(HttpResponseCode::OK);

mock_http_client_->AddResponseToReturn(successResponse);
const auto listTablesOutcome = accountIdClient->ListTables();
EXPECT_TRUE(listTablesOutcome.IsSuccess());
const auto requestSeen = mock_http_client_->GetMostRecentHttpRequest();
EXPECT_EQ("https://123456789012.ddb.us-east-1.amazonaws.com", requestSeen.GetUri().GetURIString());
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,68 @@ namespace ${rootNamespace}
#end
#end

#set($copyCtorStatements = [])
#set($moveCtorStatements = [])
#set($copyAssignmentStatements = [])
#set($moveAssignemntStatements = [])
#if($metadata.hasEndpointDiscoveryTrait)
#set($addArgDummy = $copyCtorStatements.add("enableEndpointDiscovery(BaseClientConfigClass::enableEndpointDiscovery)"))
#set($addArgDummy = $moveCtorStatements.add("enableEndpointDiscovery(BaseClientConfigClass::enableEndpointDiscovery)"))
#end
#if($serviceModel.endpointRuleSetModel.parameters.containsKey("AccountId"))
#set($addArgDummy = $copyCtorStatements.add("accountId{other.accountId}"))
#set($addArgDummy = $moveCtorStatements.add("accountId{std::move(other.accountId)}"))
#set($addArgDummy = $copyAssignmentStatements.add("accountId = other.accountId;"))
#set($addArgDummy = $moveAssignemntStatements.add("accountId = std::move(other.accountId);"))
#end
#if($serviceModel.endpointRuleSetModel.parameters.containsKey("AccountIdEndpointMode"))
#set($addArgDummy = $copyCtorStatements.add("accountIdEndpointMode{other.accountIdEndpointMode}"))
#set($addArgDummy = $moveCtorStatements.add("accountIdEndpointMode{std::move(other.accountIdEndpointMode)}"))
#set($addArgDummy = $copyAssignmentStatements.add("accountIdEndpointMode = other.accountIdEndpointMode;"))
#set($addArgDummy = $moveAssignemntStatements.add("accountIdEndpointMode = std::move(other.accountIdEndpointMode);"))
#end
#if(!$copyCtorStatements.isEmpty())
${metadata.classNamePrefix}ClientConfiguration(const ${metadata.classNamePrefix}ClientConfiguration& other)
: Aws::Client::GenericClientConfiguration(other),
enableEndpointDiscovery(BaseClientConfigClass::enableEndpointDiscovery)
#foreach($statement in $copyCtorStatements)$statement#if($foreach.hasNext),
#end#end

{
}

#end
#if(!$moveCtorStatements.isEmpty())
${metadata.classNamePrefix}ClientConfiguration(${metadata.classNamePrefix}ClientConfiguration&& other) noexcept
: Aws::Client::GenericClientConfiguration(std::move(other)),
enableEndpointDiscovery(BaseClientConfigClass::enableEndpointDiscovery)
#foreach($statement in $moveCtorStatements)$statement#if($foreach.hasNext),
#end#end

{
}

#end
#if(!$copyAssignmentStatements.isEmpty() || $metadata.hasEndpointDiscoveryTrait)
${metadata.classNamePrefix}ClientConfiguration& operator=(const ${metadata.classNamePrefix}ClientConfiguration& other)
{
if (this == &other)
return *this;
Aws::Client::GenericClientConfiguration::operator =(other);
#foreach($statment in ${copyAssignmentStatements})
${statment}
#end
return *this;
}

#end
#if(!$moveAssignemntStatements.isEmpty() || $metadata.hasEndpointDiscoveryTrait)
${metadata.classNamePrefix}ClientConfiguration& operator=(${metadata.classNamePrefix}ClientConfiguration&& other) noexcept
{
if (this == &other)
return *this;
Aws::Client::GenericClientConfiguration::operator =(std::move(other));
#foreach($statment in ${moveAssignemntStatements})
${statment}
#end
return *this;
}

Expand Down
Loading