2012-06-23 15:41:53 -04:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/rackspace/models/identity/user'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Rackspace
|
|
|
|
class Identity
|
|
|
|
class Users < Fog::Collection
|
|
|
|
|
|
|
|
model Fog::Rackspace::Identity::User
|
|
|
|
|
|
|
|
def all
|
2012-12-22 18:24:03 -05:00
|
|
|
data = service.list_users.body['users']
|
2012-06-23 15:41:53 -04:00
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(user_id)
|
2012-12-22 18:24:03 -05:00
|
|
|
data = service.get_user_by_id(user_id).body['user']
|
2012-06-23 15:41:53 -04:00
|
|
|
new(data)
|
|
|
|
rescue Excon::Errors::NotFound
|
|
|
|
nil
|
2013-06-20 17:23:19 -04:00
|
|
|
rescue Excon::Errors::Unauthorized
|
2012-06-25 22:56:53 -04:00
|
|
|
nil
|
2012-06-23 15:41:53 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def get_by_name(user_name)
|
2012-12-22 18:24:03 -05:00
|
|
|
data = service.get_user_by_name(user_name).body['user']
|
2012-06-23 15:41:53 -04:00
|
|
|
new(data)
|
|
|
|
rescue Excon::Errors::NotFound
|
|
|
|
nil
|
2013-06-20 17:23:19 -04:00
|
|
|
rescue Excon::Errors::Unauthorized
|
2012-06-25 22:56:53 -04:00
|
|
|
nil
|
2012-06-23 15:41:53 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|