github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/elb/v3/members/results.go (about) 1 package members 2 3 import ( 4 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/pagination" 6 ) 7 8 // Member represents the application running on a backend server. 9 type Member struct { 10 // Name of the Member. 11 Name string `json:"name"` 12 13 // Weight of Member. 14 Weight int `json:"weight"` 15 16 // The administrative state of the member, which is up (true) or down (false). 17 AdminStateUp bool `json:"admin_state_up"` 18 19 // Owner of the Member. 20 ProjectID string `json:"project_id"` 21 22 // Parameter value for the subnet UUID. 23 SubnetID string `json:"subnet_cidr_id"` 24 25 // The Pool to which the Member belongs. 26 PoolID string `json:"pool_id"` 27 28 // The IP address of the Member. 29 Address string `json:"address"` 30 31 // The port on which the application is hosted. 32 ProtocolPort int `json:"protocol_port"` 33 34 // The unique ID for the Member. 35 ID string `json:"id"` 36 37 IpVersion string `json:"ip_version"` 38 39 // The operating status of the member. 40 OperatingStatus string `json:"operating_status"` 41 } 42 43 // MemberPage is the page returned by a pager when traversing over a 44 // collection of Members in a Pool. 45 type MemberPage struct { 46 pagination.PageWithInfo 47 } 48 49 func (p MemberPage) IsEmpty() (bool, error) { 50 l, err := ExtractMembers(p) 51 if err != nil { 52 return false, err 53 } 54 return len(l) == 0, nil 55 } 56 57 // ExtractMembers accepts a Page struct, specifically a MemberPage struct, 58 // and extracts the elements into a slice of Members structs. In other words, 59 // a generic collection is mapped into a relevant slice. 60 func ExtractMembers(r pagination.Page) ([]Member, error) { 61 var s []Member 62 err := (r.(MemberPage)).ExtractIntoSlicePtr(&s, "members") 63 if err != nil { 64 return nil, err 65 } 66 return s, err 67 } 68 69 type commonResult struct { 70 golangsdk.Result 71 } 72 73 // Extract is a function that accepts a result and extracts a Member. 74 func (r commonResult) Extract() (*Member, error) { 75 s := new(Member) 76 err := r.ExtractIntoStructPtr(s, "member") 77 if err != nil { 78 return nil, err 79 } 80 return s, nil 81 } 82 83 // CreateResult represents the result of a Create operation. 84 // Call its Extract method to interpret it as a Member. 85 type CreateResult struct { 86 commonResult 87 } 88 89 // GetResult represents the result of a Get operation. 90 // Call its Extract method to interpret it as a Member. 91 type GetResult struct { 92 commonResult 93 } 94 95 // UpdateResult represents the result of an Update operation. 96 // Call its Extract method to interpret it as a Member. 97 type UpdateResult struct { 98 commonResult 99 } 100 101 // DeleteResult represents the result of a Delete operation. 102 // Call its ExtractErr method to determine if the request succeeded or failed. 103 type DeleteResult struct { 104 golangsdk.ErrResult 105 }