Ash Wilson | 1f11051 | 2014-10-02 15:43:47 -0400 | [diff] [blame] | 1 | package tenants |
| 2 | |
| 3 | import ( |
| 4 | "github.com/rackspace/gophercloud" |
| 5 | "github.com/rackspace/gophercloud/pagination" |
| 6 | ) |
| 7 | |
| 8 | // ListOpts filters the Tenants that are returned by the List call. |
| 9 | type ListOpts struct { |
| 10 | // Marker is the ID of the last Tenant on the previous page. |
| 11 | Marker string `q:"marker"` |
| 12 | |
| 13 | // Limit specifies the page size. |
| 14 | Limit int `q:"limit"` |
| 15 | } |
| 16 | |
| 17 | // List enumerates the Tenants to which the current token has access. |
| 18 | func List(client *gophercloud.ServiceClient, opts *ListOpts) pagination.Pager { |
Ash Wilson | b8b16f8 | 2014-10-20 10:19:49 -0400 | [diff] [blame] | 19 | createPage := func(r pagination.PageResult) pagination.Page { |
| 20 | return TenantPage{pagination.LinkedPageBase{PageResult: r}} |
Ash Wilson | 1f11051 | 2014-10-02 15:43:47 -0400 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | url := listURL(client) |
| 24 | if opts != nil { |
| 25 | q, err := gophercloud.BuildQueryString(opts) |
| 26 | if err != nil { |
| 27 | return pagination.Pager{Err: err} |
| 28 | } |
| 29 | url += q.String() |
| 30 | } |
| 31 | |
| 32 | return pagination.NewPager(client, url, createPage) |
| 33 | } |