mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[openstack|identity] Added function to add user to a tenant
This commit is contained in:
parent
df54e750a3
commit
e38799fc50
3 changed files with 34 additions and 0 deletions
|
@ -37,6 +37,7 @@ module Fog
|
|||
request :delete_user
|
||||
request :get_user_by_id
|
||||
request :get_user_by_name
|
||||
request :add_user_to_tenant
|
||||
|
||||
request :list_endpoints_for_token
|
||||
request :list_roles_for_user_on_tenant
|
||||
|
|
|
@ -43,6 +43,10 @@ module Fog
|
|||
connection.create_tenant(attributes).body['tenant'])
|
||||
self
|
||||
end
|
||||
|
||||
def add_user(user_id, role_id)
|
||||
connection.add_user_to_tenant(self.id, user_id, role_id)
|
||||
end
|
||||
end # class Tenant
|
||||
end # class OpenStack
|
||||
end # module Identity
|
||||
|
|
29
lib/fog/openstack/requests/identity/add_user_to_tenant.rb
Normal file
29
lib/fog/openstack/requests/identity/add_user_to_tenant.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
module Fog
|
||||
module Identity
|
||||
class OpenStack
|
||||
class Real
|
||||
def add_user_to_tenant(tenant_id, user_id, role_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'PUT',
|
||||
:path => "/tenants/#{tenant_id}/users/#{user_id}/roles/OS-KSADM/#{role_id}"
|
||||
)
|
||||
end
|
||||
end # class Real
|
||||
|
||||
class Mock
|
||||
def add_user_to_tenant(tenant_id, user_id, role_id)
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'role' => {
|
||||
'id' => '503df61a99d6461fb247cdb6a3f3a4dd',
|
||||
'name' => 'admin'
|
||||
}
|
||||
}
|
||||
response
|
||||
end # def add_user_to_tenant
|
||||
end # class Mock
|
||||
end # class OpenStack
|
||||
end # module Identity
|
||||
end
|
Loading…
Add table
Reference in a new issue