github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/drs/v3/public/PreCheckTask.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 BatchPreCheckReq struct { 10 Jobs []PreCheckInfo `json:"jobs" required:"true"` 11 } 12 13 type PreCheckInfo struct { 14 JobId string `json:"job_id" required:"true"` 15 PreCheckMode string `json:"precheck_mode" required:"true"` 16 } 17 18 type QueryPreCheckResultReq struct { 19 Jobs []string `json:"jobs" required:"true"` 20 } 21 22 func BatchCheckTasks(client *golangsdk.ServiceClient, opts BatchPreCheckReq) (*BatchCheckTasksResponse, error) { 23 b, err := build.RequestBody(opts, "") 24 if err != nil { 25 return nil, err 26 } 27 28 // POST /v3/{project_id}/jobs/batch-precheck 29 raw, err := client.Post(client.ServiceURL("jobs", "batch-precheck"), b, nil, &golangsdk.RequestOpts{ 30 OkCodes: []int{200}, 31 MoreHeaders: map[string]string{"Content-Type": "application/json"}, 32 }) 33 if err != nil { 34 return nil, err 35 } 36 37 var res BatchCheckTasksResponse 38 err = extract.Into(raw.Body, &res) 39 return &res, err 40 } 41 42 type BatchCheckTasksResponse struct { 43 Results []PreCheckDetail `json:"results"` 44 Count int `json:"count"` 45 } 46 47 type PreCheckDetail struct { 48 Id string `json:"id"` 49 PreCheckId string `json:"precheck_id"` 50 Status string `json:"status"` 51 ErrorCode string `json:"error_code"` 52 ErrorMsg string `json:"error_msg"` 53 }