github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/smn/v2/subscriptions/results.go (about)

     1  package subscriptions
     2  
     3  import (
     4  	"github.com/opentelekomcloud/gophertelekomcloud"
     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 CreateResult) Extract() (*Subscription, error) {
    24  	s := new(Subscription)
    25  	err := r.ExtractIntoStructPtr(s, "")
    26  	if err != nil {
    27  		return nil, err
    28  	}
    29  	return s, nil
    30  }
    31  
    32  // CreateResult contains the response body and error from a Create request.
    33  type CreateResult struct {
    34  	golangsdk.Result
    35  }
    36  
    37  type DeleteResult struct {
    38  	golangsdk.ErrResult
    39  }
    40  
    41  type ListResult struct {
    42  	golangsdk.Result
    43  }
    44  
    45  func (r ListResult) Extract() ([]SubscriptionGet, error) {
    46  	var s []SubscriptionGet
    47  	err := r.ExtractIntoSlicePtr(&s, "subscriptions")
    48  	if err != nil {
    49  		return nil, err
    50  	}
    51  	return s, nil
    52  }