github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/smn/v2/topics/results.go (about)

     1  package topics
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     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  	EnterpriseProjectId string `json:"enterprise_project_id"`
    20  }
    21  
    22  // Extract will get the topic object out of the commonResult object.
    23  func (r commonResult) Extract() (*Topic, error) {
    24  	var s Topic
    25  	err := r.ExtractInto(&s)
    26  	return &s, err
    27  }
    28  
    29  func (r commonResult) ExtractGet() (*TopicGet, error) {
    30  	var s TopicGet
    31  	err := r.ExtractInto(&s)
    32  	return &s, err
    33  }
    34  
    35  func (r commonResult) ExtractInto(v interface{}) error {
    36  	return r.Result.ExtractIntoStructPtr(v, "")
    37  }
    38  
    39  type commonResult struct {
    40  	golangsdk.Result
    41  }
    42  
    43  // CreateResult contains the response body and error from a Create request.
    44  type CreateResult struct {
    45  	commonResult
    46  }
    47  
    48  type DeleteResult struct {
    49  	golangsdk.ErrResult
    50  }
    51  
    52  type GetResult struct {
    53  	commonResult
    54  }
    55  
    56  type UpdateResult struct {
    57  	commonResult
    58  }
    59  
    60  type ListResult struct {
    61  	golangsdk.Result
    62  }
    63  
    64  func (lr ListResult) Extract() ([]TopicGet, error) {
    65  	var a struct {
    66  		Topics []TopicGet `json:"topics"`
    67  	}
    68  	err := lr.Result.ExtractInto(&a)
    69  	return a.Topics, err
    70  }