Class: Fog::OpenStack::Identity::V2::Ec2Credentials
- Inherits:
-
Collection
- Object
- Collection
- Collection
- Fog::OpenStack::Identity::V2::Ec2Credentials
show all
- Defined in:
- lib/fog/openstack/identity/v2/models/ec2_credentials.rb
Instance Attribute Summary
Attributes inherited from Collection
#response
Instance Method Summary
collapse
Methods inherited from Collection
#find_by_id, #get, #load_response, #summary
Instance Method Details
#all(options = {}) ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'lib/fog/openstack/identity/v2/models/ec2_credentials.rb', line 13
def all(options = {})
user_id = user ? user.id : nil
options[:user_id] = user_id
ec2_credentials = service.list_ec2_credentials(options)
load_response(ec2_credentials, 'credentials')
end
|
#create(attributes = {}) ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'lib/fog/openstack/identity/v2/models/ec2_credentials.rb', line 22
def create(attributes = {})
if user
attributes[:user_id] ||= user.id
attributes[:tenant_id] ||= user.tenant_id
end
super attributes
end
|
#destroy(access_key) ⇒ Object
31
32
33
34
|
# File 'lib/fog/openstack/identity/v2/models/ec2_credentials.rb', line 31
def destroy(access_key)
ec2_credential = find_by_access_key(access_key)
ec2_credential.destroy
end
|
#find_by_access_key(access_key) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/fog/openstack/identity/v2/models/ec2_credentials.rb', line 36
def find_by_access_key(access_key)
user_id = user ? user.id : nil
ec2_credential =
find { |ec2_cred| ec2_cred.access == access_key }
unless ec2_credential
response = service.get_ec2_credential(user_id, access_key)
body = response.body['credential']
body = body.merge 'service' => service
ec2_credential = Fog::OpenStack::Identity::V2::EC2Credential.new(body)
end
ec2_credential
end
|