github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/identity/v3/agency/results.go (about) 1 package agency 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/openstack/identity/v3/roles" 6 "github.com/opentelekomcloud/gophertelekomcloud/pagination" 7 ) 8 9 type Agency struct { 10 ID string `json:"id"` 11 Name string `json:"name"` 12 DomainID string `json:"domain_id"` 13 DelegatedDomainID string `json:"trust_domain_id"` 14 DelegatedDomainName string `json:"trust_domain_name"` 15 Description string `json:"description"` 16 Duration string `json:"duration"` 17 ExpireTime string `json:"expire_time"` 18 CreateTime string `json:"create_time"` 19 } 20 21 type commonResult struct { 22 golangsdk.Result 23 } 24 25 func (r commonResult) Extract() (*Agency, error) { 26 var s struct { 27 Agency *Agency `json:"agency"` 28 } 29 err := r.ExtractInto(&s) 30 return s.Agency, err 31 } 32 33 type GetResult struct { 34 commonResult 35 } 36 37 type CreateResult struct { 38 commonResult 39 } 40 41 type UpdateResult struct { 42 commonResult 43 } 44 45 type ErrResult struct { 46 golangsdk.ErrResult 47 } 48 49 type ListRolesResult struct { 50 golangsdk.Result 51 } 52 53 func (r ListRolesResult) ExtractRoles() ([]roles.Role, error) { 54 var s struct { 55 Roles []roles.Role `json:"roles"` 56 } 57 err := r.ExtractInto(&s) 58 return s.Roles, err 59 } 60 61 type AgenciesPage struct { 62 pagination.SinglePageBase 63 } 64 65 func ExtractAgencies(p pagination.Page) ([]Agency, error) { 66 var agencies []Agency 67 err := p.(AgenciesPage).ExtractIntoSlicePtr(&agencies, "agencies") 68 if err != nil { 69 return nil, err 70 } 71 return agencies, nil 72 } 73 74 func (p AgenciesPage) IsEmpty() (bool, error) { 75 agencies, err := ExtractAgencies(p) 76 return len(agencies) > 0, err 77 }