Updated on 2024-08-23 GMT+08:00

Creating Tasks in Batches

Function

This API is used to create real-time migration, real-time synchronization, and real-time DR tasks in batches based on different request parameters.

Constraints

You can call a maximum of 10 APIs in batches.

URI

POST /v3/{project_id}/jobs/batch-creation

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. The default value is en-us.

Values:

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

Parameter

Mandatory

Type

Description

jobs

Yes

Array of objects

Request body for creating tasks.

For details, see Table 4.

Table 4 Data structure description of field jobs

Parameter

Mandatory

Type

Description

name

Yes

String

The task name. The task name can be 4 to 50 characters in length. It is case-insensitive and can contain only letters, digits, hyphens (-), and underscores (_).

  • Minimum length: 4 characters
  • Maximum length: 50 characters

db_use_type

Yes

String

Migration scenario.

Values:

  • migration: real-time migration.
  • sync: real-time synchronization.
  • cloudDataGuard: real-time disaster recovery.

engine_type

Yes

String

Engine type of a DRS task.

Values:

  • mysql: used for migration and synchronization from MySQL to MySQL
  • mongodb: used for migration from MongoDB to DDS
  • cloudDataGuard-mysql: used for DR from MySQL to MySQL
  • gaussdbv5: used for GaussDB synchronization
  • mysql-to-kafka: used for synchronization from MySQL to Kafka
  • taurus-to-kafka: used for synchronization from GaussDB(for MySQL) to Kafka
  • gaussdbv5ha-to-kafka: used for synchronization from GaussDB primary/standby to Kafka
  • postgresql: used for synchronization from PostgreSQL to PostgreSQL

job_direction

Yes

String

Task direction.

Values:

  • up: to-the-cloud scenarios and the current cloud is the standby cloud in the DR.
  • down: out-of-cloud scenarios and the current cloud is the active cloud in the DR.
  • non-dbs: self-built databases.

bind_eip

No

Boolean

Whether to bind an EIP. This parameter is mandatory and set to true when the network type is EIP.

customize_sutnet_id

Yes

String

The ID of the subnet where the DRS instance resides, which corresponds to the network ID of the subnet created in the VPC of the destination database. The value is in UUID format.

product_id

No

String

Product ID.

is_target_readonly

No

Boolean

Whether the destination DB instance can be read-only. This parameter is valid only when the destination DB instance is a MySQL DB instance and the job_direction value is up. In the DR scenario, this parameter is mandatory and set to true if the current cloud is a standby cloud. If this parameter is not specified, the default value is true.

net_type

Yes

String

Network type. Value:

  • vpn
  • vpc
  • eip

The VPC network cannot be selected in the DR scenario.

node_type

Yes

String

Specifications. Values:

  • micro: minimum specifications.
  • small: small specifications.
  • medium: medium specifications.
  • high: large specifications.
  • xlarge: ultra-large specifications.
  • 2xlarge: maximum specifications.

The values supported in a specific scenario can be obtained through the API for Querying Available Node Specifications.

node_num

No

Integer

The number of nodes.

For a MongoDB database, this parameter indicates the number of source shards. This parameter is mandatory when the source database is a cluster. The value ranges from 1 to 32. The default value is 2 for MySQL dual-active DR.

For a MongoDB database, this parameter indicates the number of source shards. This parameter is mandatory when the source database is a cluster. The value ranges from 1 to 32.

source_endpoint

Yes

Object

The source database information.

For details, see Table 5.

target_endpoint

Yes

Object

The destination database information.

For details, see Table 5.

task_type

Yes

String

Task mode. The default value is FULL_INCR_TRANS.

Values:

  • FULL_TRANS: full migration
  • FULL_INCR_TRANS: full+incremental migration
  • INCR_TRANS: incremental migration

In the single-active DR scenario, only FULL_INCR_TRANS is available.

tags

No

Array of object

Tag information. Up to 20 tags can be added.

For details, see Table 7.

description

No

String

Task description. The task description can contain a maximum of 256 characters and cannot contain the following special characters: !<>'&"\

multi_write

No

Boolean

  • This parameter is mandatory when db_use_type is set to cloudDataGuard. If the DR type is dual-active, the value of multi_write is true. Otherwise, the value is false.
  • If db_use_type is set to other values, multi_write is optional.

Default value: false

sys_tags

No

Array of object

Enterprise project. If this parameter is not specified, the value is default. The key must be _sys_enterprise_project_id, and the value is the enterprise project ID. Only one enterprise project can be selected.

For details, see Table 7.

expired_days

No

String

After a task is in the abnormal status for a period of time, the task is automatically stopped. The unit is day. The value ranges from 14 to 100. If this parameter is not transferred, the default value is 14.

master_az

No

String

AZ where the primary task is located. You can obtain the value by calling the API for querying AZs where flavors are not sold out.

  • This parameter takes effect when both master_az and slave_az are specified.
  • MySQL and gaussdbv5ha-to-kafka scenarios are supported.

slave_az

No

String

AZ where the standby task is located. You can obtain the value by calling the API for querying AZs where flavors are not sold out.

  • This parameter takes effect when both master_az and slave_az are specified.
  • MySQL and gaussdbv5ha-to-kafka scenarios are supported.

charging_mode

No

String

Billing Mode: Pay-per-use is used by default.

Values:

  • period: indicates the monthly/yearly billing.
  • on_demand: indicates the pay-per-use billing.
    NOTE:
    • If db_use_type is set to migration, the yearly/monthly billing is not supported.
    • The engine_type can be set to mysql, cloudDataGuard-mysql, postgresql, or gaussdbv5ha-to-kafka.

period_order

No

Object

Yearly/Monthly information.

For details, see Table 8.

NOTE:

This parameter is mandatory when charging_mode is set to period.

public_ip_list

No

Array of objects

Information about a specified EIP.

For details, see Table 9.

is_open_fast_clean

No

Boolean

Specifies whether to enable binlog clearing for RDS for MySQL or RDS for MariaDB. If this parameter is not transferred, the default value false is used, indicating that quick binlog clearing is disabled.

Table 5 Data structure description of fields source_endpoint and target_endpoint

Parameter

Mandatory

Type

Description

db_type

No

String

Database type. Values:

  • mysql: MySQL
  • mongodb: MongoDB
  • gaussdbv5: GaussDB Distributed
  • gaussdbv5ha: GaussDB Primary/Standby
  • kafka: Kafka
  • postgresql: PostgreSQL

az_code

No

String

azCode of the AZ where the database is located.

region

No

String

Region where the DB instance is located. This parameter is mandatory when the database is a cloud instance, for example, an RDS instance. In DR scenarios, if job_direction is set to down, this parameter is mandatory in source_endpoint. If job_direction is set to up, this parameter is mandatory in target_endpoint.

inst_id

No

String

DB instance ID. This parameter is mandatory when the database is a cloud instance, for example, an RDS instance. In DR scenarios, if job_direction is set to down, this parameter is mandatory in source_endpoint. If job_direction is set to up, this parameter is mandatory in target_endpoint.

vpc_id

No

String

ID of the VPC where the database is located.

subnet_id

No

String

ID of the subnet where the database is located.

security_group_id

No

String

ID of the security group to which the database belongs.

project_id

No

String

If the database is a cloud DB instance, set this parameter to the project ID in the region where the DB instance is located. Otherwise, set this parameter to the project ID in the region where the current task is located.

For details, see Obtaining a Project ID.

db_name

No

String

The service name. This parameter is mandatory when the source database is an Oracle database. The database name can be a maximum of 128 characters in length and cannot contain the following special characters: !<>&'\"

db_password

No

String

Database password.

db_port

No

Integer

Database port. The value is an integer ranging from 1 to 65535.

db_user

No

String

Database user.

inst_name

No

String

RDS instance name.

ip

No

String

Database IP address.

mongo_ha_mode

No

String

Mongo HA mode.

safe_mode

No

Integer

Running mode of an MRS cluster. Values:

  • 0: Normal cluster
  • 1: Security cluster

ssl_cert_password

No

String

SSL certificate password. The certificate file name extension is .p12.

ssl_cert_check_sum

No

String

The checksum value of the SSL certificate, which is used for backend verification. This parameter is mandatory for secure connection to the source database.

ssl_cert_key

No

String

SSL certificate content, which is encrypted using Base64.

ssl_cert_name

No

String

SSL certificate name.

ssl_link

No

Boolean

Whether SSL is enabled.

topic

No

String

Kafka topic name.

cluster_mode

No

String

For MongoDB 4.0 or later, if the cluster instance cannot obtain the IP address of the sharded node, set source_endpoint to Sharding4.0+.

Default value: Sharding4.0+

Value: Sharding4.0+

kafka_security_config

No

Object

This parameter is only for Kafka security authentication.

For details, see Table 6.

Table 6 Data structure description of field kafka_security_config

Parameter

Mandatory

Type

Description

type

No

String

Security protocol. This parameter is mandatory for security authentication. The corresponding field for Kafka is security.protocol.

  • PLAINTEXT: No security authentication mode is available. You only need to enter an IP address and a port number.
  • SASL_PLAINTEXT: The SASL mechanism is used to connect to Kafka, and you need to configure SASL parameters.
  • SSL: The SSL encryption is used to connect to Kafka, and you need to configure SSL parameters.
  • SASL_SSL: The SASL and SSL encryption authentication modes are used. You need to configure SSL and SASL parameters.

Enumerated values:

  • PLAINTEXT
  • SASL_PLAINTEXT
  • SASL_SSL
  • SSL

trust_store_key_name

No

String

Certificate name. This parameter is mandatory when the security protocol is set to SSL or SASL_SSL.

trust_store_key

No

String

Value of the security certificate after Base64 transcoding. This parameter is mandatory when the security protocol is set to SSL or SASL_SSL.

trust_store_password

No

String

Certificate password. This parameter is mandatory when a password is set for the certificate.

endpoint_algorithm

No

String

Host name endpoint identification algorithm, which specifies the endpoint identification algorithm for verifying the server host name using the server certificate. If this parameter is left blank, host name verification is disabled. The corresponding field for Kafka is ssl.endpoint.identification.algorithm.

sasl_mechanism

No

String

SASL mechanism used for client connection. The corresponding field for Kafka is sasl.mechanism. The values are as follows:

  • GSSAPI
  • PLAIN
  • SCRAM-SHA-256
  • SCRAM-SHA-512

delegation_tokens

No

Boolean

Whether to use token authentication. This parameter is valid only when the security protocol is set to SASL_SSL or SASL_PLAINTEXT and the SASL mechanism is set to SCRAM-SHA-256 or SCRAM-SHA-512.

enable_key_store

No

Boolean

Whether to enable two-way SSL authentication.

key_store_key

No

String

Keystore certificate. This parameter is mandatory when two-way SSL authentication is enabled.

key_store_key_name

No

String

Keystore certificate name. This parameter is mandatory when two-way SSL authentication is enabled.

key_store_password

No

String

Keystore certificate password. This parameter is mandatory when a password is set for the certificate. The corresponding field for Kafka is ssl.keystore.password.

set_private_key_password

No

Boolean

Whether to set the keystore private key password. The default value is false.

key_password

No

String

Keystore private key password. This parameter is mandatory when two-way SSL authentication is enabled and set_private_key_password is set to true. The corresponding field for Kafka is ssl.key.password.

Table 7 Data structure description of fields tags and sys_tags

Parameter

Mandatory

Type

Description

key

No

String

Tag key. The value can contain a maximum of 36 characters, including letters, digits, underscores (_), and hyphens (-).

value

No

String

Tag value. The value can contain a maximum of 43 characters, including letters, digits, underscores (_), and hyphens (-).

Table 8 Data structure description of field period_order

Parameter

Mandatory

Type

Description

period_type

No

Integer

Subscription period type.

Values:

  • 2: indicates that the service is subscribed by month.
  • 3: indicates that the service is subscribed by year.
    NOTE:

    This parameter is available and mandatory only when charging_mode is set to period.

period_num

No

Integer

Number of subscription periods.

Values:

  • If period_type is set to 2 (month), the value ranges from 1 to 9.
  • If period_type is set to 3 (year), the value ranges from 1 to 3.
    NOTE:
    • This parameter is available and mandatory only when charging_mode is set to period.
    • The value of period_num must be a positive integer.

is_auto_renew

No

Integer

Whether auto renewal is enabled.

Values:

  • 0: The subscription is not automatically renewed.
  • true: The subscription is automatically renewed.
    NOTE:

    This parameter is available only when charging_mode is set to period. If this parameter is not specified, automatic renewal is disabled by default.

Table 9 Data structure description of field public_ip_list

Parameter

Mandatory

Type

Description

id

Yes

String

ID of a specified EIP.

public_ip

Yes

String

EIP.

type

Yes

String

Type of a task with an EIP bound.

  • In a primary/standby task, master indicates the primary task, and slave indicates the standby task.
  • In other cases, the value is fixed to master.

Enumerated values:

  • master
  • slave

Response Parameters

Status code: 202

Table 10 Response body parameters

Parameter

Type

Description

results

Array of objects

The response body for creating tasks in batches.

For details, see Table 11.

count

Integer

Total number of records.

Table 11 Data structure description of field results

Parameter

Type

Description

id

String

Task ID.

child_ids

Array of strings

Subtask ID set. This parameter is returned when there are subtasks.

name

String

Task name.

status

String

Task status.

create_time

String

Creation time (timestamp).

error_code

String

Error code.

error_msg

String

Error message.

Example Request

  • Creating to-the-cloud MySQL migration tasks in batches, in which task_type is set to FULL_INCR_TRANS, and net_type is set to eip
    https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/batch-creation
    
    {
      "jobs" : [ {
        "name" : "DRS-9228",
        "node_type" : "high",
        "engine_type" : "mysql",
        "net_type" : "eip",
        "job_direction" : "up",
        "db_use_type" : "migration",
        "task_type" : "FULL_INCR_TRANS",
        "customize_sutnet_id" : "352ad828-3467-4f03-987a-c55a5a9dd417",
        "source_endpoint" : {
          "db_type" : "mysql"
        },
        "target_endpoint" : {
          "region" : "eu-west-101",
          "db_type" : "mysql",
          "inst_id" : "e05a3679efe241d8b5dee80b17c1a863in01"
        },
        "is_target_readonly" : false,
        "bind_eip" : true
      } ]
    }
  • Creating real-time MySQL DR tasks in batches (current cloud as standby), in which net_type is set to eip
    https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/batch-creation
    
    {
      "jobs" : [ {
        "name" : "DRS-api-test",
        "engine_type" : "cloudDataGuard-mysql",
        "net_type" : "eip",
        "node_type" : "high",
        "job_direction" : "up",
        "source_endpoint" : {
          "db_type" : "mysql"
        },
        "target_endpoint" : {
          "region" : "eu-west-101",
          "db_type" : "mysql",
          "inst_id" : "e05a3679efe241d8b5dee80b17c1a863in01",
          "project_id" : "054ba152d480d55b2f5dc0069e7ddef0"
        },
        "is_target_readonly" : true,
        "bind_eip" : true,
        "db_use_type" : "cloudDataGuard",
        "task_type" : "FULL_INCR_TRANS",
        "customize_sutnet_id" : "352ad828-3467-4f03-987a-c55a5a9dd417",
        "multi_write" : false
      } ]
    }
  • Creating to-the-cloud DDS replica set migration tasks in batches, in which task_type is set to FULL_INCR_TRANS, and net_type is set to eip
    https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/batch-creation
    
    {
      "jobs" : [ {
        "name" : "DRS-3371-linxiaolu",
        "node_type" : "high",
        "engine_type" : "mongodb",
        "net_type" : "eip",
        "job_direction" : "up",
        "db_use_type" : "migration",
        "task_type" : "FULL_INCR_TRANS",
        "customize_sutnet_id" : "faf513f3-7a88-4a5c-bec7-238699c29c17",
        "source_endpoint" : {
          "db_type" : "mongodb"
        },
        "target_endpoint" : {
          "region" : "eu-west-101",
          "db_type" : "mongodb",
          "inst_id" : "3cadd5a0ef724f55ac7fa5bcb5f4fc5fin02"
        },
        "bind_eip" : true
      } ]
    }
  • Creating a MySQL primary/standby synchronization task, in which task_type is set to FULL_INCR_TRANS, and net_type is set to eip
    https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/batch-creation
    
    {
      "jobs" : [ {
        "name" : "DRS-linxiaolu-test3",
        "engine_type" : "mysql",
        "net_type" : "eip",
        "node_type" : "high",
        "job_direction" : "up",
        "source_endpoint" : {
          "db_type" : "mysql"
        },
        "target_endpoint" : {
          "region" : "eu-west-101",
          "db_type" : "mysql",
          "inst_id" : "64e8d7a31afa476ca85609a17af83765in01",
          "project_id" : "054ba152d480d55b2f5dc0069e7ddef0"
        },
        "bind_eip" : true,
        "db_use_type" : "sync",
        "task_type" : "FULL_INCR_TRANS",
        "customize_sutnet_id" : "0cf77cfb-3785-4065-a9c4-74b7bb2df071",
        "master_az" : "az2xahz",
        "slave_az" : "az3xahz"
      } ]
    }

Example Response

Status code: 202

Accepted

{
  "results" : [ {
    "id" : "e11eaf8f-71ef-4fad-8890-aed7572ajb11",
    "name" : "DRS-9228",
    "status" : "CREATING",
    "create_time" : "1599188556112"
  } ],
  "count" : 1
}

Status Code

Status Code

Description

202

Accepted

400

Bad Request

Error Code

For details, see Error Code.