github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/dms/v1/groups/results.go (about) 1 package groups 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 "github.com/huaweicloud/golangsdk/pagination" 6 ) 7 8 // GroupCreate response 9 type GroupCreate struct { 10 ID string `json:"id"` 11 Name string `json:"name"` 12 } 13 14 // CreateResult is a struct that contains all the return parameters of creation 15 type CreateResult struct { 16 golangsdk.Result 17 } 18 19 // Extract from CreateResult 20 func (r CreateResult) Extract() ([]GroupCreate, error) { 21 var s struct { 22 GroupsCreate []GroupCreate `json:"groups"` 23 } 24 err := r.Result.ExtractInto(&s) 25 return s.GroupsCreate, err 26 } 27 28 // DeleteResult is a struct which contains the result of deletion 29 type DeleteResult struct { 30 golangsdk.ErrResult 31 } 32 33 // Group response 34 type Group struct { 35 ID string `json:"id"` 36 Name string `json:"name"` 37 ConsumedMessages int `json:"consumed_messages"` 38 AvailableMessages int `json:"available_messages"` 39 ProducedMessages int `json:"produced_messages"` 40 ProducedDeadletters int `json:"produced_deadletters"` 41 AvailableDeadletters int `json:"available_deadletters"` 42 } 43 44 type Groups struct { 45 QueueId string `json:"queue_id"` 46 QueueName string `json:"queue_name"` 47 Details []Group `json:"groups"` 48 } 49 50 // GroupPage may be embedded in a Page 51 // that contains all of the results from an operation at once. 52 type GroupPage struct { 53 pagination.SinglePageBase 54 } 55 56 // IsEmpty returns true if a ListResult contains no groups. 57 func (r GroupPage) IsEmpty() (bool, error) { 58 rs, err := ExtractGroups(r) 59 return len(rs) == 0, err 60 } 61 62 // ExtractGroups from List 63 func ExtractGroups(r pagination.Page) ([]Group, error) { 64 var s struct { 65 Groups []Group `json:"groups"` 66 } 67 err := (r.(GroupPage)).ExtractInto(&s) 68 return s.Groups, err 69 }