Class: Ros::Sdk::Credential

Inherits:
Object
  • Object
show all
Defined in:
lib/ros_sdk/sdk.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.access_key_idObject

Returns the value of attribute access_key_id.



29
30
31
# File 'lib/ros_sdk/sdk.rb', line 29

def access_key_id
  @access_key_id
end

.authorizationObject

Returns the value of attribute authorization.



29
30
31
# File 'lib/ros_sdk/sdk.rb', line 29

def authorization
  @authorization
end

.partitionObject

Returns the value of attribute partition.



29
30
31
# File 'lib/ros_sdk/sdk.rb', line 29

def partition
  @partition
end

.profileObject

Returns the value of attribute profile.



29
30
31
# File 'lib/ros_sdk/sdk.rb', line 29

def profile
  @profile
end

.regionObject

Returns the value of attribute region.



29
30
31
# File 'lib/ros_sdk/sdk.rb', line 29

def region
  @region
end

.secret_access_keyObject

Returns the value of attribute secret_access_key.



29
30
31
# File 'lib/ros_sdk/sdk.rb', line 29

def secret_access_key
  @secret_access_key
end

Class Method Details

.configure(profile: (ENV["#{partition.upcase}_PROFILE"] || 'default'), access_key_id: , secret_access_key: ) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ros_sdk/sdk.rb', line 31

def configure(profile: (ENV["#{partition.upcase}_PROFILE"] || 'default'),
              access_key_id: ENV["#{partition.upcase}_ACCESS_KEY_ID"],
              secret_access_key: ENV["#{partition.upcase}_SECRET_ACCESS_KEY"])
  return if self.access_key_id = access_key_id and self.secret_access_key = secret_access_key
  credentials_file = "#{Dir.home}/.#{partition}/credentials"
  return unless File.exists?(credentials_file)
  if credentials = IniFile.load(credentials_file)[profile]
    self.profile = profile
    self.access_key_id = credentials["#{partition}_access_key_id"]
    self.secret_access_key = credentials["#{partition}_secret_access_key"]
  end
end