Class: DeltacloudVM::Client::Driver::Provider
- Inherits:
-
Object
- Object
- DeltacloudVM::Client::Driver::Provider
- Defined in:
- lib/deltacloud_vm/client/models/driver.rb
Instance Attribute Summary collapse
-
#entrypoints ⇒ Object
readonly
Returns the value of attribute entrypoints.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#[](entrypoint_id) ⇒ Object
Syntax sugar for retrieving list of endpoints available for the provider.
-
#initialize(name, entrypoints = []) ⇒ Provider
constructor
A new instance of Provider.
-
#valid_credentials?(api_user, api_password) ⇒ Boolean
Method to check if given credentials can be used to authorize connection to current provider:.
Constructor Details
#initialize(name, entrypoints = []) ⇒ Provider
Returns a new instance of Provider.
47 48 49 50 |
# File 'lib/deltacloud_vm/client/models/driver.rb', line 47 def initialize(name, entrypoints=[]) @name = name @entrypoints = entrypoints end |
Instance Attribute Details
#entrypoints ⇒ Object (readonly)
Returns the value of attribute entrypoints.
45 46 47 |
# File 'lib/deltacloud_vm/client/models/driver.rb', line 45 def entrypoints @entrypoints end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
44 45 46 |
# File 'lib/deltacloud_vm/client/models/driver.rb', line 44 def name @name end |
Class Method Details
.parse(p) ⇒ Object
78 79 80 81 82 83 |
# File 'lib/deltacloud_vm/client/models/driver.rb', line 78 def self.parse(p) new( p['id'], p.xpath('entrypoint').inject({}) { |r, e| r[e['kind']] = e.text.strip; r } ) end |
Instance Method Details
#[](entrypoint_id) ⇒ Object
Syntax sugar for retrieving list of endpoints available for the provider
-
entrypoint_id -> Entrypoint ID, like ‘s3’
57 58 59 60 61 |
# File 'lib/deltacloud_vm/client/models/driver.rb', line 57 def [](entrypoint_id) @entrypoints ||= [] ent_point = @entrypoints.find { |name, _| name == entrypoint_id } ent_point ? ent_point.last : nil end |
#valid_credentials?(api_user, api_password) ⇒ Boolean
Method to check if given credentials can be used to authorize connection to current provider:
client.driver(:ec2).valid_credentials? ‘user’, ‘password’
-
api_user -> API key
-
api_password -> API secret
71 72 73 74 75 76 |
# File 'lib/deltacloud_vm/client/models/driver.rb', line 71 def valid_credentials?(api_user, api_password) unless @client raise error.new('Please use driver("ec2")[API_PROVIDER].valid_credentials?') end @client.use(@client.current_driver, api_user, api_password, @name).valid_credentials? end |