github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/identity/v3/federation/protocols/results.go (about) 1 package protocols 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/pagination" 6 ) 7 8 type Protocol struct { 9 ID string `json:"id"` 10 MappingID string `json:"mapping_id"` 11 Links map[string]string `json:"links"` 12 } 13 14 type ProtocolPage struct { 15 pagination.LinkedPageBase 16 } 17 18 func (p ProtocolPage) IsEmpty() (bool, error) { 19 protocols, err := ExtractProtocols(p) 20 return len(protocols) == 0, err 21 } 22 23 func ExtractProtocols(p pagination.Page) ([]Protocol, error) { 24 var protocols []Protocol 25 err := p.(ProtocolPage).ExtractIntoSlicePtr(&protocols, "protocols") 26 return protocols, err 27 } 28 29 type commonResult struct { 30 golangsdk.Result 31 } 32 33 func (r commonResult) Extract() (*Protocol, error) { 34 protocol := new(Protocol) 35 err := r.ExtractIntoStructPtr(protocol, "protocol") 36 if err != nil { 37 return nil, err 38 } 39 return protocol, nil 40 } 41 42 type GetResult struct { 43 commonResult 44 } 45 46 type CreateResult struct { 47 commonResult 48 } 49 50 type UpdateResult struct { 51 commonResult 52 } 53 54 type DeleteResult struct { 55 golangsdk.ErrResult 56 }