2014-12-30 17:25:09 -05:00
|
|
|
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
|
2014-12-30 17:25:09 -05:00
|
|
|
|
2015-09-01 17:31:13 -04:00
|
|
|
model Fog::AWS::IAM::Role
|
2014-12-30 17:25:09 -05:00
|
|
|
|
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"])
|
2014-12-30 17:25:09 -05:00
|
|
|
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
|
2014-12-30 17:25:09 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def new(attributes = {})
|
2015-09-01 17:31:13 -04:00
|
|
|
unless attributes.key?(:assume_role_policy_document)
|
2014-12-30 17:25:09 -05:00
|
|
|
attributes[:assume_role_policy_document] = Fog::AWS::IAM::EC2_ASSUME_ROLE_POLICY.to_s
|
|
|
|
end
|
2015-09-01 17:31:13 -04:00
|
|
|
|
2014-12-30 17:25:09 -05:00
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|