github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/drs/v3/public/BatchStartTasks.go (about)

     1  package public
     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 BatchStartJobOpts struct {
    10  	// Request list for starting tasks in batches.
    11  	Jobs []StartInfo `json:"jobs"`
    12  }
    13  
    14  type StartInfo struct {
    15  	// Task ID.
    16  	JobId string `json:"job_id"`
    17  	// Task start time. The timestamp is accurate to milliseconds, for example, 1608188903063.
    18  	// If the value is empty, the task is started immediately.
    19  	StartTime string `json:"start_time,omitempty"`
    20  }
    21  
    22  func BatchStartTasks(client *golangsdk.ServiceClient, opts BatchStartJobOpts) (*BatchTasksResponse, error) {
    23  	b, err := build.RequestBody(opts, "")
    24  	if err != nil {
    25  		return nil, err
    26  	}
    27  
    28  	// POST /v3/{project_id}/jobs/batch-starting
    29  	raw, err := client.Post(client.ServiceURL("jobs", "batch-starting"), b, nil, &golangsdk.RequestOpts{
    30  		OkCodes: []int{202}})
    31  	if err != nil {
    32  		return nil, err
    33  	}
    34  
    35  	var res BatchTasksResponse
    36  	err = extract.Into(raw.Body, &res)
    37  	return &res, err
    38  }
    39  
    40  type BatchTasksResponse struct {
    41  	Results []IdJobResp `json:"results,omitempty"`
    42  	Count   int         `json:"count,omitempty"`
    43  }
    44  
    45  type IdJobResp struct {
    46  	// Task ID.
    47  	Id     string `json:"id"`
    48  	Status string `json:"status,omitempty"`
    49  	// Error code, which is optional and indicates the returned information about the failure status.
    50  	ErrorCode string `json:"error_code,omitempty"`
    51  	// Error message, which is optional and indicates the returned information about the failure status.
    52  	ErrorMsg string `json:"error_msg,omitempty"`
    53  }