blob: d4ea632629463bb6f33077dbe6ddffd6f73125a4 [file] [log] [blame]
Ash Wilson1f110512014-10-02 15:43:47 -04001package tenants
2
3import (
Jon Perritt27249f42016-02-18 10:35:59 -06004 "github.com/gophercloud/gophercloud"
5 "github.com/gophercloud/gophercloud/pagination"
Ash Wilson1f110512014-10-02 15:43:47 -04006)
7
8// ListOpts filters the Tenants that are returned by the List call.
9type 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.
18func List(client *gophercloud.ServiceClient, opts *ListOpts) pagination.Pager {
Ash Wilsonb8b16f82014-10-20 10:19:49 -040019 createPage := func(r pagination.PageResult) pagination.Page {
20 return TenantPage{pagination.LinkedPageBase{PageResult: r}}
Ash Wilson1f110512014-10-02 15:43:47 -040021 }
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}