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

     1  package subscriptions
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  )
     6  
     7  type Subscription struct {
     8  	RequestId       string `json:"request_id"`
     9  	SubscriptionUrn string `json:"subscription_urn"`
    10  }
    11  
    12  type SubscriptionGet struct {
    13  	TopicUrn        string `json:"topic_urn"`
    14  	Protocol        string `json:"protocol"`
    15  	SubscriptionUrn string `json:"subscription_urn"`
    16  	Owner           string `json:"owner"`
    17  	Endpoint        string `json:"endpoint"`
    18  	Remark          string `json:"remark"`
    19  	Status          int    `json:"status"`
    20  }
    21  
    22  // Extract will get the subscription object out of the commonResult object.
    23  func (r commonResult) Extract() (*Subscription, error) {
    24  	var s Subscription
    25  	err := r.ExtractInto(&s)
    26  	return &s, err
    27  }
    28  
    29  func (r commonResult) ExtractInto(v interface{}) error {
    30  	return r.Result.ExtractIntoStructPtr(v, "")
    31  }
    32  
    33  type commonResult struct {
    34  	golangsdk.Result
    35  }
    36  
    37  // CreateResult contains the response body and error from a Create request.
    38  type CreateResult struct {
    39  	commonResult
    40  }
    41  
    42  type DeleteResult struct {
    43  	golangsdk.ErrResult
    44  }
    45  
    46  type GetResult struct {
    47  	commonResult
    48  }
    49  
    50  type ListResult struct {
    51  	golangsdk.Result
    52  }
    53  
    54  func (lr ListResult) Extract() ([]SubscriptionGet, error) {
    55  	var a struct {
    56  		Subscriptions []SubscriptionGet `json:"subscriptions"`
    57  	}
    58  	err := lr.Result.ExtractInto(&a)
    59  	return a.Subscriptions, err
    60  }