1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/core/client/GenericClientConfiguration.h>
#include <aws/core/platform/Environment.h>
#include <aws/core/utils/memory/AWSMemory.h>
#include <aws/core/utils/threading/Executor.h>
namespace Aws
{
namespace Client
{
template struct AWS_CORE_API GenericClientConfiguration<false>;
bool IsEndpointDiscoveryEnabled(const Aws::String& endpointOverride, const Aws::String &profileName)
{
bool enabled = true; // default value for AWS Services with enabled discovery trait
if (!endpointOverride.empty())
{
enabled = false;
}
else
{
static const char* AWS_ENABLE_ENDPOINT_DISCOVERY_ENV_KEY = "AWS_ENABLE_ENDPOINT_DISCOVERY";
static const char* AWS_ENABLE_ENDPOINT_DISCOVERY_PROFILE_KEY = "AWS_ENABLE_ENDPOINT_DISCOVERY";
static const char* AWS_ENABLE_ENDPOINT_ENABLED = "true";
static const char* AWS_ENABLE_ENDPOINT_DISABLED = "false";
Aws::String enableEndpointDiscovery = ClientConfiguration::LoadConfigFromEnvOrProfile(AWS_ENABLE_ENDPOINT_DISCOVERY_ENV_KEY,
profileName,
AWS_ENABLE_ENDPOINT_DISCOVERY_PROFILE_KEY,
{AWS_ENABLE_ENDPOINT_ENABLED, AWS_ENABLE_ENDPOINT_DISABLED},
AWS_ENABLE_ENDPOINT_ENABLED);
if (AWS_ENABLE_ENDPOINT_DISABLED == enableEndpointDiscovery)
{
// enabled by default unless explicitly disabled in ENV, profile config file, or programmatically later
enabled = false;
}
}
return enabled;
}
GenericClientConfiguration<true>::GenericClientConfiguration()
: ClientConfiguration(),
enableHostPrefixInjection(ClientConfiguration::enableHostPrefixInjection),
enableEndpointDiscovery(ClientConfiguration::enableEndpointDiscovery)
{
enableEndpointDiscovery = IsEndpointDiscoveryEnabled(this->endpointOverride, this->profileName);
enableHostPrefixInjection = false; // disabled by default in the SDK
}
GenericClientConfiguration<true>::GenericClientConfiguration(const char* inputProfileName, bool shouldDisableIMDS)
: ClientConfiguration(inputProfileName, shouldDisableIMDS),
enableHostPrefixInjection(ClientConfiguration::enableHostPrefixInjection),
enableEndpointDiscovery(ClientConfiguration::enableEndpointDiscovery)
{
enableEndpointDiscovery = IsEndpointDiscoveryEnabled(this->endpointOverride, this->profileName);
enableHostPrefixInjection = false; // disabled by default in the SDK
}
GenericClientConfiguration<true>::GenericClientConfiguration(bool useSmartDefaults, const char* inputDefaultMode, bool shouldDisableIMDS)
: ClientConfiguration(useSmartDefaults, inputDefaultMode, shouldDisableIMDS),
enableHostPrefixInjection(ClientConfiguration::enableHostPrefixInjection),
enableEndpointDiscovery(ClientConfiguration::enableEndpointDiscovery)
{
enableEndpointDiscovery = IsEndpointDiscoveryEnabled(this->endpointOverride, this->profileName);
enableHostPrefixInjection = false; // disabled by default in the SDK
}
GenericClientConfiguration<true>::GenericClientConfiguration(const ClientConfiguration& config)
: ClientConfiguration(config),
enableHostPrefixInjection(ClientConfiguration::enableHostPrefixInjection),
enableEndpointDiscovery(ClientConfiguration::enableEndpointDiscovery)
{
enableEndpointDiscovery = IsEndpointDiscoveryEnabled(this->endpointOverride, this->profileName);
enableHostPrefixInjection = false; // disabled by default in the SDK
}
GenericClientConfiguration<true>::GenericClientConfiguration(const GenericClientConfiguration<true>& other)
: ClientConfiguration(static_cast<ClientConfiguration>(other)),
enableHostPrefixInjection(ClientConfiguration::enableHostPrefixInjection),
enableEndpointDiscovery(ClientConfiguration::enableEndpointDiscovery)
{
if (other.enableEndpointDiscovery) {
enableEndpointDiscovery = other.enableEndpointDiscovery.value();
}
enableHostPrefixInjection = other.enableHostPrefixInjection;
}
GenericClientConfiguration<true>& GenericClientConfiguration<true>::operator=(const GenericClientConfiguration<true>& other)
{
if (this != &other) {
*static_cast<ClientConfiguration*>(this) = static_cast<ClientConfiguration>(other);
}
return *this;
}
} // namespace Client
} // namespace Aws
|