AWS SDK for C++  0.14.3
AWS SDK for C++
AWSProfileConfigLoader.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #pragma once
17 
21 
22 namespace Aws
23 {
24  namespace Internal
25  {
26  class EC2MetadataClient;
27  }
28 
29  namespace Config
30  {
34  class Profile
35  {
36  public:
37  inline const Aws::String& GetName() const { return m_name; }
38  inline void SetName(const Aws::String& value) { m_name = value; }
39  inline const Aws::Auth::AWSCredentials& GetCredentials() const { return m_credentials; }
40  inline void SetCredentials(const Aws::Auth::AWSCredentials& value) { m_credentials = value; }
41  inline const Aws::String& GetRegion() const { return m_region; }
42  inline void SetRegion(const Aws::String& value) { m_region = value; }
43  inline const Aws::String& GetRoleArn() const { return m_roleArn; }
44  inline void SetRoleArn(const Aws::String& value) { m_roleArn = value; }
45  inline const Aws::String& GetSourceProfile() const { return m_sourceProfile; }
46  inline void SetSourceProfile(const Aws::String& value ) { m_sourceProfile = value; }
47 
48  private:
49  Aws::String m_name;
50  Aws::String m_region;
51  Aws::Auth::AWSCredentials m_credentials;
52  Aws::String m_roleArn;
53  Aws::String m_sourceProfile;
54  };
55 
60  {
61  public:
62  virtual ~AWSProfileConfigLoader() = default;
63 
67  bool Load();
68 
72  bool PersistProfiles(const Aws::Map<Aws::String, Aws::Config::Profile>& profiles);
73 
77  inline const Aws::Map<Aws::String, Aws::Config::Profile>& GetProfiles() const { return m_profiles; };
78 
82  inline const Aws::Utils::DateTime& LastLoadTime() const { return m_lastLoadTime; }
83 
84  protected:
88  virtual bool LoadInternal() = 0;
89 
93  virtual bool PersistInternal(const Aws::Map<Aws::String, Aws::Config::Profile>&) { return false; }
94 
97  };
98 
103  {
104  public:
110  AWSConfigFileProfileConfigLoader(const Aws::String& fileName, bool useProfilePrefix = false);
111 
112  virtual ~AWSConfigFileProfileConfigLoader() = default;
113 
117  const Aws::String& GetFileName() const { return m_fileName; }
118 
119  protected:
120  virtual bool LoadInternal() override;
121  virtual bool PersistInternal(const Aws::Map<Aws::String, Aws::Config::Profile>&) override;
122 
123  private:
124  Aws::String m_fileName;
125  bool m_useProfilePrefix;
126  };
127 
128  static const char* const INSTANCE_PROFILE_KEY = "InstanceProfile";
129 
134  {
135  public:
139  EC2InstanceProfileConfigLoader(const std::shared_ptr<Aws::Internal::EC2MetadataClient>& = nullptr);
140 
141  virtual ~EC2InstanceProfileConfigLoader() = default;
142 
143  protected:
144  virtual bool LoadInternal() override;
145 
146  private:
147  std::shared_ptr<Aws::Internal::EC2MetadataClient> m_metadataClient;
148  };
149  }
150 }
Aws::Map< Aws::String, Aws::Config::Profile > m_profiles
const Aws::String & GetRegion() const
std::map< K, V, std::less< K >, Aws::Allocator< std::pair< const K, V > > > Map
Definition: AWSMap.h:28
const Aws::Utils::DateTime & LastLoadTime() const
void SetSourceProfile(const Aws::String &value)
static const char *const INSTANCE_PROFILE_KEY
void SetName(const Aws::String &value)
const Aws::String & GetRoleArn() const
void SetRoleArn(const Aws::String &value)
void SetRegion(const Aws::String &value)
void SetCredentials(const Aws::Auth::AWSCredentials &value)
const Aws::String & GetSourceProfile() const
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition: AWSString.h:97
const Aws::String & GetName() const
virtual bool PersistInternal(const Aws::Map< Aws::String, Aws::Config::Profile > &)
const Aws::Map< Aws::String, Aws::Config::Profile > & GetProfiles() const
#define AWS_CORE_API
Definition: Core_EXPORTS.h:35
JSON (JavaScript Object Notation).
const Aws::Auth::AWSCredentials & GetCredentials() const