2012-06-02 11:04:17 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class IAM
|
|
|
|
|
|
|
|
class User < Fog::Model
|
|
|
|
|
|
|
|
identity :id, :aliases => 'UserName'
|
|
|
|
attribute :path, :aliases => 'Path'
|
|
|
|
attribute :arn, :aliases => 'Arn'
|
|
|
|
attribute :user_id, :aliases => 'UserId'
|
2013-04-25 11:54:32 -04:00
|
|
|
attribute :created_at, :aliases => 'CreateDate', :type => :time
|
2012-12-22 18:30:34 -05:00
|
|
|
|
2012-06-02 11:04:17 -04:00
|
|
|
def save
|
|
|
|
requires :id
|
2012-12-22 18:30:34 -05:00
|
|
|
data = service.create_user(id, path || '/').body['User']
|
2012-06-02 11:04:17 -04:00
|
|
|
merge_attributes(data)
|
|
|
|
true
|
|
|
|
end
|
2012-12-22 18:30:34 -05:00
|
|
|
|
2012-06-02 11:04:17 -04:00
|
|
|
def destroy
|
|
|
|
requires :id
|
2012-12-22 18:30:34 -05:00
|
|
|
service.delete_user(id)
|
2012-06-02 11:04:17 -04:00
|
|
|
true
|
|
|
|
end
|
2012-12-22 18:30:34 -05:00
|
|
|
|
2012-06-02 11:04:17 -04:00
|
|
|
def policies
|
|
|
|
requires :id
|
2012-12-22 18:30:34 -05:00
|
|
|
service.policies(:username => id)
|
2012-06-02 11:04:17 -04:00
|
|
|
end
|
2012-12-22 18:30:34 -05:00
|
|
|
|
2012-06-04 09:24:02 -04:00
|
|
|
def access_keys
|
|
|
|
requires :id
|
2012-12-22 18:30:34 -05:00
|
|
|
service.access_keys(:username => id)
|
2012-06-04 09:24:02 -04:00
|
|
|
end
|
2012-12-22 18:30:34 -05:00
|
|
|
|
2012-06-02 11:04:17 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-12-22 18:30:34 -05:00
|
|
|
end
|