Class: Fog::Identity::OpenStack::V2::Ec2Credentials
- Inherits:
-
Collection
- Object
- Collection
- Fog::Identity::OpenStack::V2::Ec2Credentials
- Defined in:
- lib/fog/openstack/models/identity_v2/ec2_credentials.rb
Instance Method Summary collapse
- #all(options = {}) ⇒ Object (also: #summary)
- #create(attributes = {}) ⇒ Object
- #destroy(access_key) ⇒ Object
- #find_by_access_key(access_key) ⇒ Object
Instance Method Details
#all(options = {}) ⇒ Object Also known as: summary
13 14 15 16 17 18 19 20 |
# File 'lib/fog/openstack/models/identity_v2/ec2_credentials.rb', line 13 def all( = {}) user_id = user ? user.id : nil [:user_id] = user_id ec2_credentials = service.list_ec2_credentials() load(ec2_credentials.body['credentials']) end |
#create(attributes = {}) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/fog/openstack/models/identity_v2/ec2_credentials.rb', line 24 def create(attributes = {}) if user then attributes[:user_id] ||= user.id attributes[:tenant_id] ||= user.tenant_id end super attributes end |
#destroy(access_key) ⇒ Object
33 34 35 36 |
# File 'lib/fog/openstack/models/identity_v2/ec2_credentials.rb', line 33 def destroy(access_key) ec2_credential = self.find_by_access_key(access_key) ec2_credential.destroy end |
#find_by_access_key(access_key) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fog/openstack/models/identity_v2/ec2_credentials.rb', line 38 def find_by_access_key(access_key) user_id = user ? user.id : nil ec2_credential = self.find { |ec2_credential| ec2_credential.access == access_key } unless ec2_credential then response = service.get_ec2_credential(user_id, access_key) body = response.body['credential'] body = body.merge 'service' => service ec2_credential = Fog::Identity::OpenStack::V2::EC2Credential.new(body) end ec2_credential end |