github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/drs/v3/public/BatchCheckResults.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 BatchQueryPrecheckResultReq struct {
    10  	// Request for querying pre-check results in batches. The value cannot be empty.
    11  	// The values must comply with the UUID rule. The task ID must be unique.
    12  	Jobs []string `json:"jobs"`
    13  }
    14  
    15  // POST /v3/{project_id}/jobs/batch-precheck-result
    16  
    17  type BatchCheckResultsResponse struct {
    18  	Results []QueryPreCheckResp `json:"results,omitempty"`
    19  	Count   int                 `json:"count,omitempty"`
    20  }
    21  
    22  type QueryPreCheckResp struct {
    23  	// Pre-check ID.
    24  	PrecheckId string `json:"precheck_id,omitempty"`
    25  	// Whether the pre-check items are passed. true: indicates that the pre-check is passed.
    26  	// The task can be started only after the pre-check is passed.
    27  	Result bool `json:"result,omitempty"`
    28  	// Pre-check progress, in percentage.
    29  	Process string `json:"process,omitempty"`
    30  	// Percentage of passed pre-checks.
    31  	TotalPassedRate string `json:"total_passed_rate,omitempty"`
    32  	// RDS DB instance ID.
    33  	RdsInstanceId string `json:"rds_instance_id,omitempty"`
    34  	// Migration direction. Values:
    35  	// up: The current cloud is the standby cloud in the cloud DR and backup scenario.
    36  	// down: The current cloud is the active cloud in the cloud DR scenario.
    37  	// non-dbs: self-built databases.
    38  	JobDirection string `json:"job_direction,omitempty"`
    39  	// Pre-check results.
    40  	PrecheckResult []PrecheckResult `json:"precheck_result,omitempty"`
    41  	// Error message, which is optional and indicates the returned information about the failure status.
    42  	ErrorMsg string `json:"error_msg,omitempty"`
    43  	// Error code, which is optional and indicates the returned information about the failure status.
    44  	ErrorCode string `json:"error_code,omitempty"`
    45  }
    46  
    47  func BatchCheckResults(client *golangsdk.ServiceClient, opts BatchQueryPrecheckResultReq) (*BatchCheckResultsResponse, error) {
    48  	b, err := build.RequestBody(opts, "")
    49  	if err != nil {
    50  		return nil, err
    51  	}
    52  
    53  	// POST /v3/{project_id}/jobs/batch-precheck-result
    54  	raw, err := client.Post(client.ServiceURL("jobs", "batch-precheck-result"), b, nil, &golangsdk.RequestOpts{
    55  		OkCodes: []int{200},
    56  	})
    57  	if err != nil {
    58  		return nil, err
    59  	}
    60  
    61  	var res BatchCheckResultsResponse
    62  	err = extract.Into(raw.Body, &res)
    63  	return &res, err
    64  }
    65  
    66  type PrecheckResult struct {
    67  	// Check item.
    68  	Item string `json:"item,omitempty"`
    69  	// Check results. Values:
    70  	// PASSED ALARM FAILED
    71  	Result string `json:"result,omitempty"`
    72  	// Failure cause.
    73  	FailedReason string `json:"failed_reason,omitempty"`
    74  	// Encrypted data.
    75  	Data string `json:"data,omitempty"`
    76  	// Row error message.
    77  	RawErrorMsg string `json:"raw_error_msg,omitempty"`
    78  	// Check item group.
    79  	Group string `json:"group,omitempty"`
    80  	// Information about failed subtasks.
    81  	FailedSubJobs []PrecheckFailSubJobVo `json:"failed_sub_jobs,omitempty"`
    82  }
    83  
    84  type PrecheckFailSubJobVo struct {
    85  	// ID of the subtask that fails to pass the pre-check.
    86  	Id string `json:"id,omitempty"`
    87  	// The name of the subtask that fails to pass the pre-check.
    88  	Name string `json:"name,omitempty"`
    89  	// Check results.
    90  	CheckResult string `json:"check_result,omitempty"`
    91  }