1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[aws|iam] adding access key create/delete

This commit is contained in:
geemus 2010-11-16 16:31:38 -08:00
parent b9c1c7f72c
commit 73d85415be
5 changed files with 125 additions and 4 deletions

View file

@ -6,8 +6,10 @@ module Fog
request_path 'fog/aws/requests/iam'
request :add_user_to_group
request :create_access_key
request :create_group
request :create_user
request :delete_access_key
request :delete_group
request :delete_group_policy
request :delete_user

View file

@ -0,0 +1,26 @@
module Fog
module Parsers
module AWS
module IAM
class CreateAccessKey < Fog::Parsers::Base
def reset
@response = { 'AccessKey' => {} }
end
def end_element(name)
case name
when 'AccessKey', 'UserName', 'SecretAccessKey', 'Status'
@response['User'][name] = @value
when 'RequestId'
@response[name] = @value
end
end
end
end
end
end
end

View file

@ -0,0 +1,48 @@
module Fog
module AWS
class IAM
class Real
require 'fog/aws/parsers/iam/create_access_key'
# Create a access keys for user (by default detects user from access credentials)
#
# ==== Parameters
# * user_name<~String> - optional: name of the user to create (do not include path)
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'User'<~Hash>:
# * 'AccessKey'<~String> -
# * 'Username'<~String> -
# * 'SecretAccessKey'<~String> -
# * 'Status'<~String> -
# * 'RequestId'<~String> - Id of the request
#
# ==== See Also
# http://docs.amazonwebservices.com/IAM/latest/APIReference/API_CreateAccessKey.html
#
def create_access_key(user_name = nil)
params = {
'Action' => 'CreateAccessKey',
:parser => Fog::Parsers::AWS::IAM::CreateAccessKey.new
}
if user_name
params['UserName'] = user_name
end
request(params)
end
end
class Mock
def create_access_key(user_name = nil)
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -15,10 +15,10 @@ module Fog
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'User'<~Hash>:
# * Arn<~String> -
# * GroupId<~String> -
# * GroupName<~String> -
# * Path<~String> -
# * 'Arn'<~String> -
# * 'GroupId'<~String> -
# * 'GroupName'<~String> -
# * 'Path'<~String> -
# * 'RequestId'<~String> - Id of the request
#
# ==== See Also

View file

@ -0,0 +1,45 @@
module Fog
module AWS
class IAM
class Real
require 'fog/aws/parsers/iam/basic'
# Delete an access key
#
# ==== Parameters
# * access_key_id<~String> - Access key id to delete
# * user_name<~String> - optional: name of the user to delete access key from
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'RequestId'<~String> - Id of the request
#
# ==== See Also
# http://docs.amazonwebservices.com/IAM/latest/APIReference/API_DeleteAccessKey.html
#
def delete_access_key(access_key_id, user_name = nil)
params = {
'AccessKeyId' => access_key_id,
'Action' => 'DeleteUser',
:parser => Fog::Parsers::AWS::IAM::Basic.new
}
if user_name
params['UserName'] = user_name
end
request(params)
end
end
class Mock
def delete_access_key(access_key_id, user_name = nil)
Fog::Mock.not_implemented
end
end
end
end
end