mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|iam] Updates reference to service
This commit is contained in:
parent
13733d01dc
commit
a550c54407
6 changed files with 45 additions and 45 deletions
|
@ -10,29 +10,29 @@ module Fog
|
|||
attribute :username, :aliases => 'UserName'
|
||||
attribute :secret_access_key, :aliases => 'SecretAccessKey'
|
||||
attribute :status, :aliases => 'Status'
|
||||
|
||||
|
||||
def save
|
||||
requires :username
|
||||
|
||||
data = connection.create_access_key('UserName'=> username).body["AccessKey"]
|
||||
data = service.create_access_key('UserName'=> username).body["AccessKey"]
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
requires :username
|
||||
|
||||
connection.delete_access_key(id,'UserName'=> username)
|
||||
service.delete_access_key(id,'UserName'=> username)
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
def user
|
||||
requires :username
|
||||
connection.users.get(username)
|
||||
service.users.get(username)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,17 +6,17 @@ module Fog
|
|||
class IAM
|
||||
|
||||
class AccessKeys < Fog::Collection
|
||||
|
||||
|
||||
model Fog::AWS::IAM::AccessKey
|
||||
|
||||
|
||||
def initialize(attributes = {})
|
||||
@username = attributes[:username]
|
||||
raise ArgumentError.new("Can't get an access_key's user without a username") unless @username
|
||||
super
|
||||
end
|
||||
|
||||
def all
|
||||
data = connection.list_access_keys('UserName'=> @username).body['AccessKeys']
|
||||
|
||||
def all
|
||||
data = service.list_access_keys('UserName'=> @username).body['AccessKeys']
|
||||
# AWS response doesn't contain the UserName, this injects it
|
||||
data.each {|access_key| access_key['UserName'] = @username }
|
||||
load(data)
|
||||
|
@ -25,7 +25,7 @@ module Fog
|
|||
def get(identity)
|
||||
self.all.select {|access_key| access_key.id == identity}.first
|
||||
end
|
||||
|
||||
|
||||
def new(attributes = {})
|
||||
super({ :username => @username }.merge!(attributes))
|
||||
end
|
||||
|
@ -33,4 +33,4 @@ module Fog
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,39 +6,39 @@ module Fog
|
|||
class IAM
|
||||
|
||||
class Policies < Fog::Collection
|
||||
|
||||
|
||||
model Fog::AWS::IAM::Policy
|
||||
|
||||
|
||||
def initialize(attributes = {})
|
||||
@username = attributes[:username]
|
||||
raise ArgumentError.new("Can't get a policy's user without a username") unless @username
|
||||
super
|
||||
end
|
||||
|
||||
|
||||
|
||||
def all
|
||||
# AWS method get_user_policy only returns an array of policy names, this is kind of useless,
|
||||
# AWS method get_user_policy 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
|
||||
policy_names = connection.list_user_policies(@username).body['PolicyNames'] # it returns an array
|
||||
policy_names = service.list_user_policies(@username).body['PolicyNames'] # it returns an array
|
||||
policies = []
|
||||
policy_names.each do |policy_name|
|
||||
policies << connection.get_user_policy(policy_name,@username).body['Policy']
|
||||
policies << service.get_user_policy(policy_name,@username).body['Policy']
|
||||
end
|
||||
load(policies) # data is an array of attribute hashes
|
||||
end
|
||||
|
||||
def get(identity)
|
||||
data = connection.get_user_policy(identity,@username).body['Policy']
|
||||
data = service.get_user_policy(identity,@username).body['Policy']
|
||||
new(data) # data is an attribute hash
|
||||
rescue Fog::AWS::IAM::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
|
||||
def new(attributes = {})
|
||||
super({ :username => @username }.merge!(attributes))
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,31 +9,31 @@ module Fog
|
|||
identity :id, :aliases => 'PolicyName'
|
||||
attribute :username, :aliases => 'UserName'
|
||||
attribute :document, :aliases => 'PolicyDocument'
|
||||
|
||||
|
||||
def save
|
||||
requires :id
|
||||
requires :username
|
||||
requires :document
|
||||
|
||||
data = connection.put_user_policy(username, id, document).body
|
||||
data = service.put_user_policy(username, id, document).body
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
requires :username
|
||||
|
||||
connection.delete_user_policy(username, id)
|
||||
service.delete_user_policy(username, id)
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
def user
|
||||
requires :username
|
||||
connection.users.get(username)
|
||||
service.users.get(username)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,31 +10,31 @@ module Fog
|
|||
attribute :path, :aliases => 'Path'
|
||||
attribute :arn, :aliases => 'Arn'
|
||||
attribute :user_id, :aliases => 'UserId'
|
||||
|
||||
|
||||
def save
|
||||
requires :id
|
||||
data = connection.create_user(id, path || '/').body['User']
|
||||
data = service.create_user(id, path || '/').body['User']
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.delete_user(id)
|
||||
service.delete_user(id)
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
def policies
|
||||
requires :id
|
||||
connection.policies(:username => id)
|
||||
service.policies(:username => id)
|
||||
end
|
||||
|
||||
|
||||
def access_keys
|
||||
requires :id
|
||||
connection.access_keys(:username => id)
|
||||
service.access_keys(:username => id)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,13 +14,13 @@ module Fog
|
|||
|
||||
def all(options = {})
|
||||
merge_attributes(options)
|
||||
data = connection.list_users(options).body
|
||||
data = service.list_users(options).body
|
||||
merge_attributes('IsTruncated' => data['IsTruncated'], 'Marker' => data['Marker'])
|
||||
load(data['Users']) # data is an array of attribute hashes
|
||||
end
|
||||
|
||||
def get(identity)
|
||||
data = connection.get_user(identity).body['User']
|
||||
data = service.get_user(identity).body['User']
|
||||
new(data) # data is an attribute hash
|
||||
rescue Fog::AWS::IAM::NotFound
|
||||
nil
|
||||
|
|
Loading…
Reference in a new issue