github.com/gophercloud/gophercloud@v1.11.0/openstack/identity/v3/extensions/projectendpoints/results.go (about) 1 package projectendpoints 2 3 import ( 4 "github.com/gophercloud/gophercloud" 5 "github.com/gophercloud/gophercloud/pagination" 6 ) 7 8 // CreateResult is the response from a Create operation. Call its Extract 9 // method to interpret it as an Endpoint. 10 type CreateResult struct { 11 gophercloud.ErrResult 12 } 13 14 // DeleteResult is the response from a Delete operation. Call its ExtractErr 15 // method to determine if the call succeeded or failed. 16 type DeleteResult struct { 17 gophercloud.ErrResult 18 } 19 20 // Endpoint describes the entry point for another service's API. 21 type Endpoint struct { 22 // ID is the unique ID of the endpoint. 23 ID string `json:"id"` 24 25 // Availability is the interface type of the Endpoint (admin, internal, 26 // or public), referenced by the gophercloud.Availability type. 27 Availability gophercloud.Availability `json:"interface"` 28 29 // Region is the region the Endpoint is located in. 30 Region string `json:"region"` 31 32 // ServiceID is the ID of the service the Endpoint refers to. 33 ServiceID string `json:"service_id"` 34 35 // URL is the url of the Endpoint. 36 URL string `json:"url"` 37 } 38 39 // EndpointPage is a single page of Endpoint results. 40 type EndpointPage struct { 41 pagination.LinkedPageBase 42 } 43 44 // IsEmpty returns true if no Endpoints were returned. 45 func (r EndpointPage) IsEmpty() (bool, error) { 46 if r.StatusCode == 204 { 47 return true, nil 48 } 49 50 es, err := ExtractEndpoints(r) 51 return len(es) == 0, err 52 } 53 54 // ExtractEndpoints extracts an Endpoint slice from a Page. 55 func ExtractEndpoints(r pagination.Page) ([]Endpoint, error) { 56 var s struct { 57 Endpoints []Endpoint `json:"endpoints"` 58 } 59 err := (r.(EndpointPage)).ExtractInto(&s) 60 return s.Endpoints, err 61 }