github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/dcs/v1/lifecycle/BatchDelete.go (about)

     1  package lifecycle
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     7  )
     8  
     9  type BatchDeleteOpts struct {
    10  	// An indicator of whether all DCS instances failed to be created will be deleted. Options:
    11  	// Options:
    12  	// true: all instances that fail to be created are deleted. In this case, the instances parameter in the request can be empty.
    13  	// false or other values: The DCS instances specified by the instances parameter in the API request will be deleted.
    14  	AllFailure *bool `q:"allFailure"`
    15  	Body       BatchDeleteBody
    16  }
    17  
    18  type BatchDeleteBody struct {
    19  	// IDs of DCS instances to be deleted.
    20  	// This parameter is set only when the allFailure parameter in the URI is set to false or another value.
    21  	// A maximum of 50 instances can be deleted at a time.
    22  	Instances []string `json:"instances,omitempty"`
    23  }
    24  
    25  func BatchDelete(client *golangsdk.ServiceClient, opts BatchDeleteOpts) ([]BatchOpsResult, error) {
    26  	url, err := golangsdk.NewURLBuilder().WithEndpoints("instances").WithQueryParams(&opts).Build()
    27  	if err != nil {
    28  		return nil, err
    29  	}
    30  
    31  	b, err := build.RequestBody(opts.Body, "")
    32  	if err != nil {
    33  		return nil, err
    34  	}
    35  
    36  	raw, err := client.DeleteWithBody(client.ServiceURL(url.String()), b, nil)
    37  	if err != nil {
    38  		return nil, err
    39  	}
    40  
    41  	var res []BatchOpsResult
    42  	err = extract.IntoSlicePtr(raw.Body, &res, "results")
    43  	return res, err
    44  }
    45  
    46  type BatchOpsResult struct {
    47  	// Instance deletion result. Options: success and failed
    48  	Result string `json:"result,omitempty"`
    49  	// DCS instance ID.
    50  	Instance string `json:"instance,omitempty"`
    51  }