Jamie Hannaford | 0ca076c | 2014-10-30 13:12:35 +0100 | [diff] [blame] | 1 | package roles |
| 2 | |
| 3 | import ( |
| 4 | "github.com/rackspace/gophercloud" |
| 5 | "github.com/rackspace/gophercloud/pagination" |
| 6 | ) |
| 7 | |
Jamie Hannaford | ede3671 | 2014-10-30 13:43:42 +0100 | [diff] [blame] | 8 | // List is the operation responsible for listing all available global roles |
| 9 | // that a user can adopt. |
Jamie Hannaford | 0ca076c | 2014-10-30 13:12:35 +0100 | [diff] [blame] | 10 | func 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 Hannaford | 9b642e0 | 2014-10-30 13:20:06 +0100 | [diff] [blame] | 16 | |
Jamie Hannaford | ede3671 | 2014-10-30 13:43:42 +0100 | [diff] [blame] | 17 | // 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 Hannaford | b15878a | 2014-10-30 13:26:32 +0100 | [diff] [blame] | 20 | func AddUserRole(client *gophercloud.ServiceClient, tenantID, userID, roleID string) UserRoleResult { |
| 21 | var result UserRoleResult |
Jamie Hannaford | 562a7d5 | 2015-03-24 16:20:16 +0100 | [diff] [blame^] | 22 | _, result.Err = client.Put(userRoleURL(client, tenantID, userID, roleID), nil, nil, nil) |
Jamie Hannaford | 9b642e0 | 2014-10-30 13:20:06 +0100 | [diff] [blame] | 23 | return result |
| 24 | } |
Jamie Hannaford | b15878a | 2014-10-30 13:26:32 +0100 | [diff] [blame] | 25 | |
Jamie Hannaford | ede3671 | 2014-10-30 13:43:42 +0100 | [diff] [blame] | 26 | // 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 Hannaford | b15878a | 2014-10-30 13:26:32 +0100 | [diff] [blame] | 29 | func DeleteUserRole(client *gophercloud.ServiceClient, tenantID, userID, roleID string) UserRoleResult { |
| 30 | var result UserRoleResult |
Jamie Hannaford | 562a7d5 | 2015-03-24 16:20:16 +0100 | [diff] [blame^] | 31 | _, result.Err = client.Delete(userRoleURL(client, tenantID, userID, roleID), nil) |
Jamie Hannaford | b15878a | 2014-10-30 13:26:32 +0100 | [diff] [blame] | 32 | return result |
| 33 | } |