github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/geminidb/v3/configurations/requests.go (about)

     1  package configurations
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  )
     6  
     7  type ApplyOpts struct {
     8  	InstanceIds []string `json:"instance_ids" required:"true"`
     9  }
    10  
    11  type ApplyBuilder interface {
    12  	ToConfigApplyMap() (map[string]interface{}, error)
    13  }
    14  
    15  func (opts ApplyOpts) ToConfigApplyMap() (map[string]interface{}, error) {
    16  	b, err := golangsdk.BuildRequestBody(opts, "")
    17  	if err != nil {
    18  		return nil, err
    19  	}
    20  	return b, nil
    21  }
    22  
    23  func Apply(client *golangsdk.ServiceClient, id string, opts ApplyBuilder) (r ApplyResult) {
    24  	b, err := opts.ToConfigApplyMap()
    25  	if err != nil {
    26  		r.Err = err
    27  		return
    28  	}
    29  
    30  	_, r.Err = client.Put(applyURL(client, id), b, &r.Body, &golangsdk.RequestOpts{
    31  		OkCodes:     []int{200},
    32  		MoreHeaders: map[string]string{"Content-Type": "application/json"},
    33  	})
    34  	return
    35  }
    36  
    37  func Get(client *golangsdk.ServiceClient, id string) (r GetResult) {
    38  	_, r.Err = client.Get(getURL(client, id), &r.Body, &golangsdk.RequestOpts{
    39  		OkCodes:     []int{200},
    40  		MoreHeaders: map[string]string{"Content-Type": "application/json"},
    41  	})
    42  	return
    43  }
    44  
    45  func GetInstanceConfig(client *golangsdk.ServiceClient, id string) (r GetResult) {
    46  	_, r.Err = client.Get(instanceConfigURL(client, id), &r.Body, &golangsdk.RequestOpts{
    47  		OkCodes:     []int{200},
    48  		MoreHeaders: map[string]string{"Content-Type": "application/json"},
    49  	})
    50  	return
    51  }