class Fog::AWS::IAM::Policies
Public Instance Methods
all(options={})
click to toggle source
# 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)
click to toggle source
# 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 = {})
click to toggle source
Calls superclass method
# File lib/fog/aws/models/iam/policies.rb, line 40 def new(attributes = {}) super(self.attributes.merge(attributes)) end
Private Instance Methods
all_by_group(group_name, options={})
click to toggle source
AWS
method get_user_policy and list_group_policies only returns an array of policy names, this is kind of useless, that's why it has to loop through the list to get the details of each element. I don't like it because it makes this method slow
# File lib/fog/aws/models/iam/policies.rb, line 49 def all_by_group(group_name, options={}) response = service.list_group_policies(group_name, page_params(options)) merge_attributes(response.body) response.body['PolicyNames'].map do |policy_name| service.get_group_policy(policy_name, group_name).body['Policy'] end end
all_by_user(username, options={})
click to toggle source
# File lib/fog/aws/models/iam/policies.rb, line 58 def all_by_user(username, options={}) response = service.list_user_policies(username, page_params(options)) merge_attributes(response.body) response.body['PolicyNames'].map do |policy_name| service.get_user_policy(policy_name, username).body['Policy'] end end