blob: d80c53f760d367d12fe2d98145c59074057f85ae [file] [log] [blame]
Jamie Hannaford0ca076c2014-10-30 13:12:35 +01001package roles
2
3import (
Jon Perritt27249f42016-02-18 10:35:59 -06004 "github.com/gophercloud/gophercloud"
5 "github.com/gophercloud/gophercloud/pagination"
Jamie Hannaford0ca076c2014-10-30 13:12:35 +01006)
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 {
Jon Perrittdb0ae142016-03-13 00:33:41 -060011 return pagination.NewPager(client, rootURL(client), func(r pagination.PageResult) pagination.Page {
Jamie Hannaford0ca076c2014-10-30 13:12:35 +010012 return RolePage{pagination.SinglePageBase(r)}
Jon Perrittdb0ae142016-03-13 00:33:41 -060013 })
Jamie Hannaford0ca076c2014-10-30 13:12:35 +010014}
Jamie Hannaford9b642e02014-10-30 13:20:06 +010015
Jon Perrittdb0ae142016-03-13 00:33:41 -060016// AddUser is the operation responsible for assigning a particular role to
Jamie Hannafordede36712014-10-30 13:43:42 +010017// a user. This is confined to the scope of the user's tenant - so the tenant
18// ID is a required argument.
Jon Perrittdb0ae142016-03-13 00:33:41 -060019func AddUser(client *gophercloud.ServiceClient, tenantID, userID, roleID string) UserRoleResult {
20 var r UserRoleResult
21 _, r.Err = client.Put(userRoleURL(client, tenantID, userID, roleID), nil, nil, nil)
22 return r
Jamie Hannaford9b642e02014-10-30 13:20:06 +010023}
Jamie Hannafordb15878a2014-10-30 13:26:32 +010024
Jon Perrittdb0ae142016-03-13 00:33:41 -060025// DeleteUser is the operation responsible for deleting a particular role
Jamie Hannafordede36712014-10-30 13:43:42 +010026// from a user. This is confined to the scope of the user's tenant - so the
27// tenant ID is a required argument.
Jon Perrittdb0ae142016-03-13 00:33:41 -060028func DeleteUser(client *gophercloud.ServiceClient, tenantID, userID, roleID string) UserRoleResult {
29 var r UserRoleResult
30 _, r.Err = client.Delete(userRoleURL(client, tenantID, userID, roleID), nil)
31 return r
Jamie Hannafordb15878a2014-10-30 13:26:32 +010032}