From a550c5440719a90344f58a790e883d034c55a590 Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Sat, 22 Dec 2012 23:30:34 +0000 Subject: [PATCH] [aws|iam] Updates reference to service --- lib/fog/aws/models/iam/access_key.rb | 16 ++++++++-------- lib/fog/aws/models/iam/access_keys.rb | 14 +++++++------- lib/fog/aws/models/iam/policies.rb | 20 ++++++++++---------- lib/fog/aws/models/iam/policy.rb | 16 ++++++++-------- lib/fog/aws/models/iam/user.rb | 20 ++++++++++---------- lib/fog/aws/models/iam/users.rb | 4 ++-- 6 files changed, 45 insertions(+), 45 deletions(-) diff --git a/lib/fog/aws/models/iam/access_key.rb b/lib/fog/aws/models/iam/access_key.rb index 96ae35bbb..00caa8139 100644 --- a/lib/fog/aws/models/iam/access_key.rb +++ b/lib/fog/aws/models/iam/access_key.rb @@ -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 \ No newline at end of file +end diff --git a/lib/fog/aws/models/iam/access_keys.rb b/lib/fog/aws/models/iam/access_keys.rb index db0e93698..4ab4b7d6f 100644 --- a/lib/fog/aws/models/iam/access_keys.rb +++ b/lib/fog/aws/models/iam/access_keys.rb @@ -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 \ No newline at end of file +end diff --git a/lib/fog/aws/models/iam/policies.rb b/lib/fog/aws/models/iam/policies.rb index c948a0a50..87d05be1f 100644 --- a/lib/fog/aws/models/iam/policies.rb +++ b/lib/fog/aws/models/iam/policies.rb @@ -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 \ No newline at end of file +end diff --git a/lib/fog/aws/models/iam/policy.rb b/lib/fog/aws/models/iam/policy.rb index c2f67b542..11b4d698c 100644 --- a/lib/fog/aws/models/iam/policy.rb +++ b/lib/fog/aws/models/iam/policy.rb @@ -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 \ No newline at end of file +end diff --git a/lib/fog/aws/models/iam/user.rb b/lib/fog/aws/models/iam/user.rb index 7969d5157..8b8dbfa55 100644 --- a/lib/fog/aws/models/iam/user.rb +++ b/lib/fog/aws/models/iam/user.rb @@ -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 \ No newline at end of file +end diff --git a/lib/fog/aws/models/iam/users.rb b/lib/fog/aws/models/iam/users.rb index f5b5dc1a7..343ded06c 100644 --- a/lib/fog/aws/models/iam/users.rb +++ b/lib/fog/aws/models/iam/users.rb @@ -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