blob: ba19fd462a12e1f732a992c77373cd5cb036d787 [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 Perritt3860b512016-03-29 12:01:48 -050019func AddUser(client *gophercloud.ServiceClient, tenantID, userID, roleID string) (r UserRoleResult) {
Jon Perrittdb0ae142016-03-13 00:33:41 -060020 _, r.Err = client.Put(userRoleURL(client, tenantID, userID, roleID), nil, nil, nil)
Jamie Hannaford9b642e02014-10-30 13:20:06 +010021}
Jamie Hannafordb15878a2014-10-30 13:26:32 +010022
Jon Perrittdb0ae142016-03-13 00:33:41 -060023// DeleteUser is the operation responsible for deleting a particular role
Jamie Hannafordede36712014-10-30 13:43:42 +010024// from a user. This is confined to the scope of the user's tenant - so the
25// tenant ID is a required argument.
Jon Perritt3860b512016-03-29 12:01:48 -050026func DeleteUser(client *gophercloud.ServiceClient, tenantID, userID, roleID string) (r UserRoleResult) {
Jon Perrittdb0ae142016-03-13 00:33:41 -060027 _, r.Err = client.Delete(userRoleURL(client, tenantID, userID, roleID), nil)
Jamie Hannafordb15878a2014-10-30 13:26:32 +010028}