AWS SDK for C++  1.8.182
AWS SDK for C++
AWSProfileConfigLoader.h
Go to the documentation of this file.
1 
6 #pragma once
7 
13 
14 namespace Aws
15 {
16  namespace Internal
17  {
18  class EC2MetadataClient;
19  }
20 
21  namespace Config
22  {
26  class Profile
27  {
28  public:
29  inline const Aws::String& GetName() const { return m_name; }
30  inline void SetName(const Aws::String& value) { m_name = value; }
31  inline const Aws::Auth::AWSCredentials& GetCredentials() const { return m_credentials; }
32  inline void SetCredentials(const Aws::Auth::AWSCredentials& value) { m_credentials = value; }
33  inline const Aws::String& GetRegion() const { return m_region; }
34  inline void SetRegion(const Aws::String& value) { m_region = value; }
35  inline const Aws::String& GetRoleArn() const { return m_roleArn; }
36  inline void SetRoleArn(const Aws::String& value) { m_roleArn = value; }
37  inline const Aws::String& GetExternalId() const { return m_externalId; }
38  inline void SetExternalId(const Aws::String& value) { m_externalId = value; }
39  inline const Aws::String& GetSsoStartUrl() const { return m_ssoStartUrl; }
40  inline void SetSsoStartUrl(const Aws::String& value) { m_ssoStartUrl = value; }
41  inline const Aws::String& GetSsoRegion() const { return m_ssoRegion; }
42  inline void SetSsoRegion(const Aws::String& value) { m_ssoRegion = value; }
43  inline const Aws::String& GetSsoAccountId() const { return m_ssoAccountId; }
44  inline void SetSsoAccountId(const Aws::String& value) { m_ssoAccountId = value; }
45  inline const Aws::String& GetSsoRoleName() const { return m_ssoRoleName; }
46  inline void SetSsoRoleName(const Aws::String& value) { m_ssoRoleName = value; }
47  inline const Aws::String& GetSourceProfile() const { return m_sourceProfile; }
48  inline void SetSourceProfile(const Aws::String& value ) { m_sourceProfile = value; }
49  inline const Aws::String& GetCredentialProcess() const { return m_credentialProcess; }
50  inline void SetCredentialProcess(const Aws::String& value ) { m_credentialProcess = value; }
51  inline void SetAllKeyValPairs(const Aws::Map<Aws::String, Aws::String>& map) { m_allKeyValPairs = map; }
52  inline const Aws::String GetValue(const Aws::String& key) const
53  {
54  auto iter = m_allKeyValPairs.find(key);
55  if (iter == m_allKeyValPairs.end()) return {};
56  return iter->second;
57  }
58 
59  private:
60  Aws::String m_name;
61  Aws::String m_region;
62  Aws::Auth::AWSCredentials m_credentials;
63  Aws::String m_roleArn;
64  Aws::String m_externalId;
65  Aws::String m_sourceProfile;
66  Aws::String m_credentialProcess;
67  Aws::String m_ssoStartUrl;
68  Aws::String m_ssoRegion;
69  Aws::String m_ssoAccountId;
70  Aws::String m_ssoRoleName;
71  Aws::Map<Aws::String, Aws::String> m_allKeyValPairs;
72  };
73 
78  {
79  public:
80  virtual ~AWSProfileConfigLoader() = default;
81 
85  bool Load();
86 
91 
95  inline const Aws::Map<Aws::String, Aws::Config::Profile>& GetProfiles() const { return m_profiles; };
96 
100  inline const Aws::Utils::DateTime& LastLoadTime() const { return m_lastLoadTime; }
101 
103 
104  protected:
108  virtual bool LoadInternal() = 0;
109 
113  virtual bool PersistInternal(const Aws::Map<Aws::String, Aws::Config::Profile>&) { return false; }
114 
117  };
118 
123  {
124  public:
130  AWSConfigFileProfileConfigLoader(const Aws::String& fileName, bool useProfilePrefix = false);
131 
133 
137  const Aws::String& GetFileName() const { return m_fileName; }
138 
143  void SetFileName(const Aws::String& fileName) { m_fileName = fileName; }
144 
145  protected:
146  virtual bool LoadInternal() override;
148 
149  private:
150  Aws::String m_fileName;
151  bool m_useProfilePrefix;
152  };
153 
154  static const char* const INSTANCE_PROFILE_KEY = "InstanceProfile";
155 
160  {
161  public:
165  EC2InstanceProfileConfigLoader(const std::shared_ptr<Aws::Internal::EC2MetadataClient>& = nullptr);
166 
167  virtual ~EC2InstanceProfileConfigLoader() = default;
168 
169  protected:
170  virtual bool LoadInternal() override;
171  private:
172  std::shared_ptr<Aws::Internal::EC2MetadataClient> m_ec2metadataClient;
173  };
174 
180  {
181  public:
183 
185 
187 
188  bool HasConfigProfile(const Aws::String& profileName) const;
189 
195 
201 
206  Aws::String GetConfig(const Aws::String& profileName, const Aws::String& key) const;
207 
208  bool HasCredentialsProfile(const Aws::String& profileName) const;
214 
220 
226 
227  private:
228  mutable Aws::Utils::Threading::ReaderWriterLock m_credentialsLock;
229  Aws::Config::AWSConfigFileProfileConfigLoader m_credentialsFileLoader;
230  mutable Aws::Utils::Threading::ReaderWriterLock m_configLock;
232  };
233 
235 
237 
239 
241 
243 
245 
247 
249 
251 
253 
255 
257 
259 
260  }
261 }
Aws::Utils::DateTime
Definition: DateTime.h:55
AWS_CORE_API
#define AWS_CORE_API
Definition: Core_EXPORTS.h:25
Aws::Config::ConfigAndCredentialsCacheManager::GetCredentials
Aws::Auth::AWSCredentials GetCredentials(const Aws::String &profileName) const
Aws::Internal::EC2MetadataClient
Definition: AWSHttpResourceClient.h:98
Aws::Config::GetCachedCredentials
AWS_CORE_API Aws::Auth::AWSCredentials GetCachedCredentials(const Aws::String &profileName)
Aws::Config::ReloadCachedCredentialsFile
AWS_CORE_API void ReloadCachedCredentialsFile()
Aws::Config::Profile
Definition: AWSProfileConfigLoader.h:27
Aws::Config::Profile::GetSsoAccountId
const Aws::String & GetSsoAccountId() const
Definition: AWSProfileConfigLoader.h:43
Aws::Config::Profile::SetAllKeyValPairs
void SetAllKeyValPairs(const Aws::Map< Aws::String, Aws::String > &map)
Definition: AWSProfileConfigLoader.h:51
DateTime.h
Aws::Config::ConfigAndCredentialsCacheManager
Definition: AWSProfileConfigLoader.h:180
Aws::Config::Profile::GetRoleArn
const Aws::String & GetRoleArn() const
Definition: AWSProfileConfigLoader.h:35
AWSCredentials.h
Aws::Config::ConfigAndCredentialsCacheManager::GetCredentialsProfile
Aws::Config::Profile GetCredentialsProfile(const Aws::String &profileName) const
Aws::Config::GetCachedCredentialsProfile
AWS_CORE_API Aws::Config::Profile GetCachedCredentialsProfile(const Aws::String &profileName)
Aws::Config::GetCachedConfigProfile
AWS_CORE_API Aws::Config::Profile GetCachedConfigProfile(const Aws::String &profileName)
Aws::Config::ConfigAndCredentialsCacheManager::HasConfigProfile
bool HasConfigProfile(const Aws::String &profileName) const
Aws::Config::Profile::SetCredentialProcess
void SetCredentialProcess(const Aws::String &value)
Definition: AWSProfileConfigLoader.h:50
Aws::Config::HasCachedConfigProfile
AWS_CORE_API bool HasCachedConfigProfile(const Aws::String &profileName)
Aws::Config::Profile::SetSsoStartUrl
void SetSsoStartUrl(const Aws::String &value)
Definition: AWSProfileConfigLoader.h:40
Aws::Config::AWSProfileConfigLoader::LastLoadTime
const Aws::Utils::DateTime & LastLoadTime() const
Definition: AWSProfileConfigLoader.h:100
Aws::Config::Profile::SetExternalId
void SetExternalId(const Aws::String &value)
Definition: AWSProfileConfigLoader.h:38
Aws::Config::AWSConfigFileProfileConfigLoader
Definition: AWSProfileConfigLoader.h:123
ReaderWriterLock.h
Aws::Config::AWSProfileConfigLoader::ProfilesContainer
Aws::Map< Aws::String, Aws::Config::Profile > ProfilesContainer
Definition: AWSProfileConfigLoader.h:102
Aws::Config::ConfigAndCredentialsCacheManager::ReloadConfigFile
void ReloadConfigFile()
Aws::Config::INSTANCE_PROFILE_KEY
static const char *const INSTANCE_PROFILE_KEY
Definition: AWSProfileConfigLoader.h:154
Aws::Config::ConfigAndCredentialsCacheManager::GetConfigProfiles
Aws::Map< Aws::String, Aws::Config::Profile > GetConfigProfiles() const
Aws::Config::ConfigAndCredentialsCacheManager::ReloadCredentialsFile
void ReloadCredentialsFile()
Aws::Config::AWSProfileConfigLoader::m_lastLoadTime
Aws::Utils::DateTime m_lastLoadTime
Definition: AWSProfileConfigLoader.h:116
Aws::Config::ConfigAndCredentialsCacheManager::GetConfigProfile
Aws::Config::Profile GetConfigProfile(const Aws::String &profileName) const
Aws::Auth::AWSCredentials
Definition: AWSCredentials.h:19
Aws::Config::Profile::GetSsoStartUrl
const Aws::String & GetSsoStartUrl() const
Definition: AWSProfileConfigLoader.h:39
Aws::Config::Profile::GetSsoRoleName
const Aws::String & GetSsoRoleName() const
Definition: AWSProfileConfigLoader.h:45
Aws::Config::InitConfigAndCredentialsCacheManager
AWS_CORE_API void InitConfigAndCredentialsCacheManager()
Aws::Config::Profile::SetSsoRoleName
void SetSsoRoleName(const Aws::String &value)
Definition: AWSProfileConfigLoader.h:46
Aws::Config::Profile::GetExternalId
const Aws::String & GetExternalId() const
Definition: AWSProfileConfigLoader.h:37
Aws::Config::GetCachedCredentialsProfiles
AWS_CORE_API Aws::Map< Aws::String, Aws::Config::Profile > GetCachedCredentialsProfiles()
Aws::Config::GetCachedConfigProfiles
AWS_CORE_API Aws::Map< Aws::String, Aws::Config::Profile > GetCachedConfigProfiles()
AWSString.h
Aws::Config::Profile::SetSsoAccountId
void SetSsoAccountId(const Aws::String &value)
Definition: AWSProfileConfigLoader.h:44
Aws::Config::Profile::GetName
const Aws::String & GetName() const
Definition: AWSProfileConfigLoader.h:29
Aws::Config::Profile::GetSourceProfile
const Aws::String & GetSourceProfile() const
Definition: AWSProfileConfigLoader.h:47
Aws::Config::AWSConfigFileProfileConfigLoader::LoadInternal
virtual bool LoadInternal() override
Aws::Config::Profile::GetSsoRegion
const Aws::String & GetSsoRegion() const
Definition: AWSProfileConfigLoader.h:41
Aws::Config::Profile::SetRegion
void SetRegion(const Aws::String &value)
Definition: AWSProfileConfigLoader.h:34
Aws::Config::Profile::SetSsoRegion
void SetSsoRegion(const Aws::String &value)
Definition: AWSProfileConfigLoader.h:42
Aws::Config::Profile::GetCredentials
const Aws::Auth::AWSCredentials & GetCredentials() const
Definition: AWSProfileConfigLoader.h:31
Aws::Utils::Threading::ReaderWriterLock
Definition: ReaderWriterLock.h:26
Aws::Config::Profile::SetCredentials
void SetCredentials(const Aws::Auth::AWSCredentials &value)
Definition: AWSProfileConfigLoader.h:32
Aws::Config::AWSProfileConfigLoader::PersistProfiles
bool PersistProfiles(const Aws::Map< Aws::String, Aws::Config::Profile > &profiles)
Aws::Config::Profile::GetCredentialProcess
const Aws::String & GetCredentialProcess() const
Definition: AWSProfileConfigLoader.h:49
Aws::Config::AWSConfigFileProfileConfigLoader::SetFileName
void SetFileName(const Aws::String &fileName)
Definition: AWSProfileConfigLoader.h:143
Aws::Config::AWSProfileConfigLoader::GetProfiles
const Aws::Map< Aws::String, Aws::Config::Profile > & GetProfiles() const
Definition: AWSProfileConfigLoader.h:95
Aws::Config::AWSConfigFileProfileConfigLoader::GetFileName
const Aws::String & GetFileName() const
Definition: AWSProfileConfigLoader.h:137
Aws::Config::EC2InstanceProfileConfigLoader::LoadInternal
virtual bool LoadInternal() override
Aws::Config::Profile::GetValue
const Aws::String GetValue(const Aws::String &key) const
Definition: AWSProfileConfigLoader.h:52
Aws::Config::AWSProfileConfigLoader::PersistInternal
virtual bool PersistInternal(const Aws::Map< Aws::String, Aws::Config::Profile > &)
Definition: AWSProfileConfigLoader.h:113
Aws
Definition: AccessManagementClient.h:15
Aws::Config::AWSProfileConfigLoader::LoadInternal
virtual bool LoadInternal()=0
Aws::Config::ConfigAndCredentialsCacheManager::GetConfig
Aws::String GetConfig(const Aws::String &profileName, const Aws::String &key) const
Aws::Config::AWSConfigFileProfileConfigLoader::PersistInternal
virtual bool PersistInternal(const Aws::Map< Aws::String, Aws::Config::Profile > &) override
Aws::Config::AWSProfileConfigLoader::Load
bool Load()
Aws::Config::AWSConfigFileProfileConfigLoader::AWSConfigFileProfileConfigLoader
AWSConfigFileProfileConfigLoader(const Aws::String &fileName, bool useProfilePrefix=false)
Aws::Config::Profile::SetName
void SetName(const Aws::String &value)
Definition: AWSProfileConfigLoader.h:30
Aws::Config::ConfigAndCredentialsCacheManager::ConfigAndCredentialsCacheManager
ConfigAndCredentialsCacheManager()
Aws::Config::Profile::SetSourceProfile
void SetSourceProfile(const Aws::String &value)
Definition: AWSProfileConfigLoader.h:48
Aws::Config::HasCachedCredentialsProfile
AWS_CORE_API bool HasCachedCredentialsProfile(const Aws::String &profileName)
Aws::String
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition: AWSString.h:97
Aws::Config::ReloadCachedConfigFile
AWS_CORE_API void ReloadCachedConfigFile()
Aws::Config::GetCachedConfigValue
AWS_CORE_API Aws::String GetCachedConfigValue(const Aws::String &profileName, const Aws::String &key)
Aws::Config::AWSProfileConfigLoader
Definition: AWSProfileConfigLoader.h:78
Aws::Config::Profile::GetRegion
const Aws::String & GetRegion() const
Definition: AWSProfileConfigLoader.h:33
Aws::Config::EC2InstanceProfileConfigLoader::~EC2InstanceProfileConfigLoader
virtual ~EC2InstanceProfileConfigLoader()=default
Aws::Config::ConfigAndCredentialsCacheManager::GetCredentialsProfiles
Aws::Map< Aws::String, Aws::Config::Profile > GetCredentialsProfiles() const
Aws::Config::CleanupConfigAndCredentialsCacheManager
AWS_CORE_API void CleanupConfigAndCredentialsCacheManager()
AWSMap.h
Aws::Config::AWSConfigFileProfileConfigLoader::~AWSConfigFileProfileConfigLoader
virtual ~AWSConfigFileProfileConfigLoader()=default
Aws::Config::AWSProfileConfigLoader::m_profiles
ProfilesContainer m_profiles
Definition: AWSProfileConfigLoader.h:115
Aws::Config::AWSProfileConfigLoader::~AWSProfileConfigLoader
virtual ~AWSProfileConfigLoader()=default
Aws::Config::ConfigAndCredentialsCacheManager::HasCredentialsProfile
bool HasCredentialsProfile(const Aws::String &profileName) const
Aws::Config::EC2InstanceProfileConfigLoader
Definition: AWSProfileConfigLoader.h:160
Aws::Map
std::map< K, V, std::less< K >, Aws::Allocator< std::pair< const K, V > > > Map
Definition: AWSMap.h:19
Aws::Config::Profile::SetRoleArn
void SetRoleArn(const Aws::String &value)
Definition: AWSProfileConfigLoader.h:36
Aws::Config::EC2InstanceProfileConfigLoader::EC2InstanceProfileConfigLoader
EC2InstanceProfileConfigLoader(const std::shared_ptr< Aws::Internal::EC2MetadataClient > &=nullptr)