Jamie Hannaford | 0ca076c | 2014-10-30 13:12:35 +0100 | [diff] [blame] | 1 | package roles |
| 2 | |
| 3 | import ( |
Jon Perritt | 27249f4 | 2016-02-18 10:35:59 -0600 | [diff] [blame] | 4 | "github.com/gophercloud/gophercloud" |
| 5 | "github.com/gophercloud/gophercloud/pagination" |
Jamie Hannaford | 0ca076c | 2014-10-30 13:12:35 +0100 | [diff] [blame] | 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 { |
Jon Perritt | db0ae14 | 2016-03-13 00:33:41 -0600 | [diff] [blame^] | 11 | return pagination.NewPager(client, rootURL(client), func(r pagination.PageResult) pagination.Page { |
Jamie Hannaford | 0ca076c | 2014-10-30 13:12:35 +0100 | [diff] [blame] | 12 | return RolePage{pagination.SinglePageBase(r)} |
Jon Perritt | db0ae14 | 2016-03-13 00:33:41 -0600 | [diff] [blame^] | 13 | }) |
Jamie Hannaford | 0ca076c | 2014-10-30 13:12:35 +0100 | [diff] [blame] | 14 | } |
Jamie Hannaford | 9b642e0 | 2014-10-30 13:20:06 +0100 | [diff] [blame] | 15 | |
Jon Perritt | db0ae14 | 2016-03-13 00:33:41 -0600 | [diff] [blame^] | 16 | // AddUser is the operation responsible for assigning a particular role to |
Jamie Hannaford | ede3671 | 2014-10-30 13:43:42 +0100 | [diff] [blame] | 17 | // a user. This is confined to the scope of the user's tenant - so the tenant |
| 18 | // ID is a required argument. |
Jon Perritt | db0ae14 | 2016-03-13 00:33:41 -0600 | [diff] [blame^] | 19 | func 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 Hannaford | 9b642e0 | 2014-10-30 13:20:06 +0100 | [diff] [blame] | 23 | } |
Jamie Hannaford | b15878a | 2014-10-30 13:26:32 +0100 | [diff] [blame] | 24 | |
Jon Perritt | db0ae14 | 2016-03-13 00:33:41 -0600 | [diff] [blame^] | 25 | // DeleteUser is the operation responsible for deleting a particular role |
Jamie Hannaford | ede3671 | 2014-10-30 13:43:42 +0100 | [diff] [blame] | 26 | // from a user. This is confined to the scope of the user's tenant - so the |
| 27 | // tenant ID is a required argument. |
Jon Perritt | db0ae14 | 2016-03-13 00:33:41 -0600 | [diff] [blame^] | 28 | func 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 Hannaford | b15878a | 2014-10-30 13:26:32 +0100 | [diff] [blame] | 32 | } |