Class: Fog::AWS::IAM::Roles

Inherits:
Collection show all
Defined in:
lib/fog/aws/models/iam/roles.rb

Instance Attribute Summary

Attributes inherited from Collection

#service

Instance Method Summary collapse

Methods inherited from Collection

#clear, #create, #destroy, #inspect, #load, model, #model, #reload, #table, #to_json

Methods included from Fog::Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Fog::Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

#initialize(attributes = {}) ⇒ Roles

Returns a new instance of Roles.



12
13
14
# File 'lib/fog/aws/models/iam/roles.rb', line 12

def initialize(attributes = {})
  super
end

Instance Method Details

#allObject



16
17
18
19
# File 'lib/fog/aws/models/iam/roles.rb', line 16

def all
  data = service.list_roles.body['Roles']
  load(data)
end

#get(identity) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/fog/aws/models/iam/roles.rb', line 21

def get(identity)
  role = nil
  begin
    role = service.roles.new( service.get_role( identity ).data[:body]["Role"] )
  rescue Excon::Errors::NotFound # ignore not found error
  end
  role
end

#new(attributes = {}) ⇒ Object



30
31
32
33
34
35
# File 'lib/fog/aws/models/iam/roles.rb', line 30

def new(attributes = {})
  if not attributes.has_key?(:assume_role_policy_document)
    attributes[:assume_role_policy_document] = Fog::AWS::IAM::EC2_ASSUME_ROLE_POLICY.to_s
  end
  super
end