1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00
fog--fog-aws/lib/fog/aws/models/iam/roles.rb

34 lines
765 B
Ruby
Raw Normal View History

require 'fog/aws/models/iam/role'
module Fog
module AWS
class IAM
2015-09-01 17:31:13 -04:00
class Roles < Fog::AWS::IAM::PagedCollection
2015-09-01 17:31:13 -04:00
model Fog::AWS::IAM::Role
2015-09-01 18:13:58 -04:00
def all(options={})
body = service.list_roles(page_params(options)).body
merge_attributes(body)
load(body["Roles"])
end
def get(identity)
2015-09-01 17:31:13 -04:00
new(service.get_role(identity).body["Role"])
2015-09-01 18:13:58 -04:00
rescue Excon::Errors::NotFound, Fog::AWS::IAM::NotFound
2015-09-01 17:31:13 -04:00
nil
end
def new(attributes = {})
2015-09-01 17:31:13 -04:00
unless attributes.key?(:assume_role_policy_document)
attributes[:assume_role_policy_document] = Fog::AWS::IAM::EC2_ASSUME_ROLE_POLICY.to_s
end
2015-09-01 17:31:13 -04:00
super
end
end
end
end
end