github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/smn/v2/topics/results.go (about) 1 package topics 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 ) 6 7 type Topic struct { 8 RequestId string `json:"request_id"` 9 TopicUrn string `json:"topic_urn"` 10 } 11 12 type TopicGet struct { 13 TopicUrn string `json:"topic_urn"` 14 DisplayName string `json:"display_name"` 15 Name string `json:"name"` 16 PushPolicy int `json:"push_policy"` 17 UpdateTime string `json:"update_time"` 18 CreateTime string `json:"create_time"` 19 } 20 21 // Extract will get the topic object out of the commonResult object. 22 func (r commonResult) Extract() (*Topic, error) { 23 var s Topic 24 err := r.ExtractInto(&s) 25 return &s, err 26 } 27 28 func (r commonResult) ExtractGet() (*TopicGet, error) { 29 var s TopicGet 30 err := r.ExtractInto(&s) 31 return &s, err 32 } 33 34 func (r commonResult) ExtractInto(v interface{}) error { 35 return r.Result.ExtractIntoStructPtr(v, "") 36 } 37 38 type commonResult struct { 39 golangsdk.Result 40 } 41 42 // CreateResult contains the response body and error from a Create request. 43 type CreateResult struct { 44 commonResult 45 } 46 47 type DeleteResult struct { 48 golangsdk.ErrResult 49 } 50 51 type GetResult struct { 52 commonResult 53 } 54 55 type UpdateResult struct { 56 commonResult 57 } 58 59 type ListResult struct { 60 golangsdk.Result 61 } 62 63 func (lr ListResult) Extract() ([]TopicGet, error) { 64 var a struct { 65 Topics []TopicGet `json:"topics"` 66 } 67 err := lr.Result.ExtractInto(&a) 68 return a.Topics, err 69 }