Class: Fog::AWS::IAM::Policies

Inherits:
PagedCollection show all
Defined in:
lib/fog/aws/models/iam/policies.rb

Instance Method Summary collapse

Methods inherited from PagedCollection

#each, #each_entry, inherited

Instance Method Details

#all(options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/aws/models/iam/policies.rb', line 14

def all(options={})
  requires_one :username, :group_name

  policies = if self.username
               all_by_user(self.username, options)
             else self.group_name
               all_by_group(self.group_name, options)
             end

  load(policies) # data is an array of attribute hashes
end

#get(identity) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/aws/models/iam/policies.rb', line 26

def get(identity)
  requires_one :username, :group_name

  response = if self.username
               service.get_user_policy(identity, self.username)
             else self.group_name
               service.get_group_policy(identity, self.group_name)
             end

  new(response.body['Policy'])
rescue Fog::AWS::IAM::NotFound
  nil
end

#new(attributes = {}) ⇒ Object



40
41
42
# File 'lib/fog/aws/models/iam/policies.rb', line 40

def new(attributes = {})
  super(self.attributes.merge(attributes))
end