blob: 9a333140b2b604b7f8be586e760be09c59b6755c [file] [log] [blame]
Jamie Hannaford0ca076c2014-10-30 13:12:35 +01001package roles
2
3import (
4 "github.com/rackspace/gophercloud"
5 "github.com/rackspace/gophercloud/pagination"
6)
7
Jamie Hannafordede36712014-10-30 13:43:42 +01008// List is the operation responsible for listing all available global roles
9// that a user can adopt.
Jamie Hannaford0ca076c2014-10-30 13:12:35 +010010func List(client *gophercloud.ServiceClient) pagination.Pager {
11 createPage := func(r pagination.PageResult) pagination.Page {
12 return RolePage{pagination.SinglePageBase(r)}
13 }
14 return pagination.NewPager(client, rootURL(client), createPage)
15}
Jamie Hannaford9b642e02014-10-30 13:20:06 +010016
Jamie Hannafordede36712014-10-30 13:43:42 +010017// AddUserRole is the operation responsible for assigning a particular role to
18// a user. This is confined to the scope of the user's tenant - so the tenant
19// ID is a required argument.
Jamie Hannafordb15878a2014-10-30 13:26:32 +010020func AddUserRole(client *gophercloud.ServiceClient, tenantID, userID, roleID string) UserRoleResult {
21 var result UserRoleResult
Jamie Hannaford562a7d52015-03-24 16:20:16 +010022 _, result.Err = client.Put(userRoleURL(client, tenantID, userID, roleID), nil, nil, nil)
Jamie Hannaford9b642e02014-10-30 13:20:06 +010023 return result
24}
Jamie Hannafordb15878a2014-10-30 13:26:32 +010025
Jamie Hannafordede36712014-10-30 13:43:42 +010026// DeleteUserRole is the operation responsible for deleting a particular role
27// from a user. This is confined to the scope of the user's tenant - so the
28// tenant ID is a required argument.
Jamie Hannafordb15878a2014-10-30 13:26:32 +010029func DeleteUserRole(client *gophercloud.ServiceClient, tenantID, userID, roleID string) UserRoleResult {
30 var result UserRoleResult
Jamie Hannaford562a7d52015-03-24 16:20:16 +010031 _, result.Err = client.Delete(userRoleURL(client, tenantID, userID, roleID), nil)
Jamie Hannafordb15878a2014-10-30 13:26:32 +010032 return result
33}