github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/dms/v1/queues/results.go (about) 1 package queues 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 "github.com/huaweicloud/golangsdk/pagination" 6 ) 7 8 // QueueCreate response 9 type QueueCreate struct { 10 ID string `json:"id"` 11 Name string `json:"name"` 12 KafkaTopic string `json:"kafka_topic"` 13 } 14 15 // CreateResult is a struct that contains all the return parameters of creation 16 type CreateResult struct { 17 golangsdk.Result 18 } 19 20 // Extract from CreateResult 21 func (r CreateResult) Extract() (*QueueCreate, error) { 22 var s QueueCreate 23 err := r.Result.ExtractInto(&s) 24 return &s, err 25 } 26 27 // DeleteResult is a struct which contains the result of deletion 28 type DeleteResult struct { 29 golangsdk.ErrResult 30 } 31 32 // Queue response 33 type Queue struct { 34 ID string `json:"id"` 35 Name string `json:"name"` 36 Created float64 `json:"created"` 37 Description string `json:"description"` 38 QueueMode string `json:"queue_mode"` 39 Reservation int `json:"reservation"` 40 MaxMsgSizeByte int `json:"max_msg_size_byte"` 41 ProducedMessages int `json:"produced_messages"` 42 RedrivePolicy string `json:"redrive_policy"` 43 MaxConsumeCount int `json:"max_consume_count"` 44 GroupCount int `json:"group_count"` 45 } 46 47 // GetResult contains the body of getting detailed 48 type GetResult struct { 49 golangsdk.Result 50 } 51 52 // Extract from GetResult 53 func (r GetResult) Extract() (*Queue, error) { 54 var s Queue 55 err := r.Result.ExtractInto(&s) 56 return &s, err 57 } 58 59 // QueuePage may be embedded in a Page 60 // that contains all of the results from an operation at once. 61 type QueuePage struct { 62 pagination.SinglePageBase 63 } 64 65 // IsEmpty returns true if a ListResult contains no queues. 66 func (r QueuePage) IsEmpty() (bool, error) { 67 rs, err := ExtractQueues(r) 68 return len(rs) == 0, err 69 } 70 71 // ExtractQueues from List 72 func ExtractQueues(r pagination.Page) ([]Queue, error) { 73 var s struct { 74 Queues []Queue `json:"queues"` 75 } 76 err := (r.(QueuePage)).ExtractInto(&s) 77 return s.Queues, err 78 }