Method: Fog::Identity::OpenStack::Ec2Credentials#find_by_access_key

Defined in:
lib/fog/openstack/models/identity/ec2_credentials.rb

#find_by_access_key(access_key) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fog/openstack/models/identity/ec2_credentials.rb', line 34

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::EC2Credential.new(body)
  end

  ec2_credential
end