Daniel Speichert | 44e3b54 | 2015-08-26 20:55:58 -0400 | [diff] [blame^] | 1 | package roles |
| 2 | |
| 3 | import ( |
| 4 | "github.com/rackspace/gophercloud" |
| 5 | "github.com/rackspace/gophercloud/pagination" |
| 6 | ) |
| 7 | |
| 8 | // RoleAssignmentsOpts allows you to query the RoleAssignments method. |
| 9 | type RoleAssignmentsOpts struct { |
| 10 | GroupId string `q:"group.id"` |
| 11 | RoleId string `q:"role.id"` |
| 12 | ScopeDomainId string `q:"scope.domain.id"` |
| 13 | ScopeProjectId string `q:"scope.project.id"` |
| 14 | UserId string `q:"user.id"` |
| 15 | Effective bool `q:"effective"` |
| 16 | } |
| 17 | |
| 18 | // RoleAssignments enumerates the roles assigned to a specified resource. |
| 19 | func RoleAssignments(client *gophercloud.ServiceClient, opts RoleAssignmentsOpts) pagination.Pager { |
| 20 | u := roleAssignmentsURL(client) |
| 21 | q, err := gophercloud.BuildQueryString(opts) |
| 22 | if err != nil { |
| 23 | return pagination.Pager{Err: err} |
| 24 | } |
| 25 | u += q.String() |
| 26 | createPage := func(r pagination.PageResult) pagination.Page { |
| 27 | return RoleAssignmentsPage{pagination.LinkedPageBase{PageResult: r}} |
| 28 | } |
| 29 | |
| 30 | return pagination.NewPager(client, u, createPage) |
| 31 | } |