github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/bss/v2/orders/requests.go (about)

     1  package orders
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  )
     6  
     7  type UnsubscribeOpts struct {
     8  	ResourceIds     []string `json:"resource_ids" required:"true"`
     9  	UnsubscribeType int      `json:"unsubscribe_type" required:"true"`
    10  }
    11  
    12  type UnsubscribeOptsBuilder interface {
    13  	ToOrderUnsubscribeMap() (map[string]interface{}, error)
    14  }
    15  
    16  func (opts UnsubscribeOpts) ToOrderUnsubscribeMap() (map[string]interface{}, error) {
    17  	return golangsdk.BuildRequestBody(opts, "")
    18  }
    19  
    20  func Unsubscribe(client *golangsdk.ServiceClient, opts UnsubscribeOptsBuilder) (r UnsubscribeResult) {
    21  	reqBody, err := opts.ToOrderUnsubscribeMap()
    22  	if err != nil {
    23  		r.Err = err
    24  		return
    25  	}
    26  	_, r.Err = client.Post(unsubscribeURL(client), reqBody, &r.Body, &golangsdk.RequestOpts{OkCodes: []int{200}})
    27  	return
    28  }
    29  
    30  func Get(client *golangsdk.ServiceClient, id string) (r GetResult) {
    31  	_, r.Err = client.Get(getURL(client, id), &r.Body, nil)
    32  	return
    33  }