4 "github.com/gophercloud/gophercloud"
5 "github.com/gophercloud/gophercloud/pagination"
8 // Tenant is a grouping of users in the identity service.
10 // ID is a unique identifier for this tenant.
13 // Name is a friendlier user-facing name for this tenant.
14 Name string `json:"name"`
16 // Description is a human-readable explanation of this Tenant's purpose.
17 Description string `json:"description"`
19 // Enabled indicates whether or not a tenant is active.
20 Enabled bool `json:"enabled"`
23 // TenantPage is a single page of Tenant results.
24 type TenantPage struct {
25 pagination.LinkedPageBase
28 // IsEmpty determines whether or not a page of Tenants contains any results.
29 func (r TenantPage) IsEmpty() (bool, error) {
30 tenants, err := ExtractTenants(r)
31 return len(tenants) == 0, err
34 // NextPageURL extracts the "next" link from the tenants_links section of the result.
35 func (r TenantPage) NextPageURL() (string, error) {
37 Links []gophercloud.Link `json:"tenants_links"`
39 err := r.ExtractInto(&s)
43 return gophercloud.ExtractNextURL(s.Links)
46 // ExtractTenants returns a slice of Tenants contained in a single page of
48 func ExtractTenants(r pagination.Page) ([]Tenant, error) {
50 Tenants []Tenant `json:"tenants"`
52 err := (r.(TenantPage)).ExtractInto(&s)
56 type tenantResult struct {
60 // Extract interprets any tenantResults as a Tenant.
61 func (r tenantResult) Extract() (*Tenant, error) {
63 Tenant *Tenant `json:"tenant"`
65 err := r.ExtractInto(&s)
69 // GetResult is the response from a Get request. Call its Extract method to
70 // interpret it as a Tenant.
71 type GetResult struct {
75 // CreateResult is the response from a Create request. Call its Extract method
76 // to interpret it as a Tenant.
77 type CreateResult struct {
81 // DeleteResult is the response from a Get request. Call its ExtractErr method
82 // to determine if the call succeeded or failed.
83 type DeleteResult struct {
87 // UpdateResult is the response from a Update request. Call its Extract method
88 // to interpret it as a Tenant.
89 type UpdateResult struct {