Updated on 2023-11-22 GMT+08:00

Stopping or Deleting Tasks in Batches

Function

This API is used to stop tasks in batches or delete real-time migration, real-time synchronization, and real-time DR tasks.

After a yearly/monthly task is started, unsubscribe from the order and then call this API to delete the task. For details, see Unsubscribing from a Yearly/Monthly Task.

Debugging

You can debug the API in API Explorer to support automatic authentication. API Explorer can automatically generate and debug example SDK code.

Constraints

  • Only tasks in the CREATE_FAILED, RELEASE_RESOURCE_COMPLETE, or RELEASE_CHILD_TRANSFER_COMPLETE state can be deleted. To delete a task in other states, stop the task first.
  • The parent task can call the API only in the dual-active DR scenario.

URI

DELETE /v3/{project_id}/jobs/batch-jobs

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID of a tenant in a region

For details about how to obtain the project ID, see Obtaining a Project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

The content type.

The default value is application/json.

X-Auth-Token

Yes

String

User token obtained from IAM.

X-Language

No

String

Request language type

Default value: en-us

Values:

  • en-us
  • zh-cn
Table 3 Request body parameters

Parameter

Mandatory

Type

Description

jobs

Yes

Array of objects

List of requests for stopping or deleting tasks in batches.

For details, see Table 4.

Table 4 Data structure description of field jobs

Parameter

Mandatory

Type

Description

delete_type

Yes

String

The value can be terminate, force_terminate, or delete. terminate indicates that the migration task is stopped, force_terminate indicates that the migration task is forcibly stopped, and delete indicates that the migration task is deleted.

Values:

  • terminate
  • force_terminate
  • delete
    NOTE:

    You need to manually unsubscribe from a yearly/monthly task, and then set delete_type to delete to delete the task.

job_id

Yes

String

Task ID.

is_show_breakpoint_position

No

Boolean

Specifies whether to display breakpoint information when a real-time migration, synchronization, or DR task with MySQL serving as the source is complete. The default value is null, indicating that the breakpoint information is not displayed.

Response Parameters

Status code: 202

Table 5 Response body parameters

Parameter

Type

Description

results

Array of objects

Response body set for stopping or deleting tasks in batches.

For details, see Table 6.

count

Integer

Total number.

Table 6 Data structure description of field results

Parameter

Type

Description

id

String

Task ID.

status

String

Status Values:

  • success
  • failed

error_code

String

Error code.

error_msg

String

Error message.

Example Request

  • Stopping two specified tasks
    https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/batch-jobs
    
    {
      "jobs" : [ {
        "delete_type" : "terminate",
        "job_id" : "4c6ac8c0-2f51-426a-97b2-cb2c668jb201"
      }, {
        "delete_type" : "terminate",
        "job_id" : "6211d20d-0006-41da-836e-db3301ajb20b"
      } ]
    }
  • Deleting a specified task
    https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/batch-jobs
    
    {
      "jobs" : [ {
        "delete_type" : "delete",
        "job_id" : "140b5236-88ad-43c8-811c-1268453jb101"
      } ]
    }
  • Displaying breakpoint information when a task is complete
    https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/batch-jobs 
      
     { 
       "jobs" : [{ 
         "delete_type" : "terminate", 
         "job_id" : "6211d20d-0006-41da-836e-db3301ajb20b", 
         "is_show_breakpoint_position" : true 
       } ] 
     }

Example Response

Status code: 202

Accepted

  • Example response for stopping a task
    {
      "count" : 2,
      "results" : [ {
        "id" : "4c6ac8c0-2f51-426a-97b2-cb2c668jb201",
        "status" : "success"
      }, {
        "id" : "6211d20d-0006-41da-836e-db3301ajb20b",
        "status" : "failed",
        "error_code" : "DRS.M01504",
        "error_msg" : "Another operation is being performed on the migration task or the migration task is abnormal. Try again later."
      } ]
    }
  • Example response for deleting a task
    {
      "count" : 1,
      "results" : [ {
        "id" : "140b5236-88ad-43c8-811c-1268453jb101",
        "status" : "success"
      } ]
    }

Status Code

Status Code

Description

202

Accepted

400

Bad Request

Error Code

For details, see Error Code.