Updated on 2024-04-17 GMT+08:00

Task Creation Example

This section describes how to create a real-time migration task by calling an API.

Involved APIs

  • API for obtaining tokens from IAM

    Obtain a token and add X-Auth-Token to the request header of API calls.

  • API used to create a real-time migration task.

Procedure

  1. Obtain the token by referring to Authentication.
  2. Obtain the DRS endpoints.

    • Before calling this API, obtain the required region and endpoint from the enterprise administrator.
    • Before calling this API, obtain the required region and endpoint.

  3. Obtain the project ID of a user in a region. For details, see Obtaining a Project ID.
  4. Send POST https://{DRS endpoint}/v3/{projectId}/jobs.
  5. Add X-Auth-Token to the request header. The value is user token.
  6. Add the Content-Type key to the request header. The value of Content-Type is application/json.
  7. Specify the following parameters in the request body:

    For details about the API used for creating DB instances, see Creating Tasks in Batches.

    {
        "bind_eip": true,//Check whether an EIP has been bound to the replication instance in the public network scenario.
        "db_use_type": "migration",//The usage type. The value can be migration (real-time migration), sync (real-time synchronization), or cloudDataGuard (real-time DR). This parameter is mandatory.
        ""description": "",//Task description
        "engine_type": "mysql",//The engine type. The value can be mysql, mongodb, gaussdbv5, or cloudDataGuard-mysql.
        "is_target_readonly": true,//Specifies whether the destination instance is readable only.
        "job_direction": "up",//Task direction. The value can be up or down.
        "name": "DRS-2057",//Task name. This parameter is mandatory.
        "net_type": "eip",// Network type. This parameter is mandatory and the value can be vpn, vpc, or eip.
        "node_type": "high",//Specification type. This parameter is mandatory.
        "source_Endpoint": {//Information body of the source database. This parameter is mandatory.
            "db_type": "mysql",//The database type. The value can be mysql, mongodb, gaussdbv5, or gaussdbv5. This parameter is mandatory.
        },
        "target_Endpoint": {//Information body of the destination database
            "db_type": "mysql",//Database type. This parameter is mandatory.
        "inst_id": "63e0699063494a8a93798f38abf3247ein01",// RDS instance ID. This parameter is mandatory when the database is an RDS DB instance.
            "region": "cn-xianhz-1" // The region where the RDS DB instance is located. This parameter is mandatory when the database is an RDS DB instance.
        },
        "task_type": "FULL_INCR_TRANS" //Task mode. The value can be FULL_TRANS or FULL_INCR_TRANS.
    }

    If the request fails, an error code and error message are returned. For details, see section Error Code.