Updated on 2024-05-27 GMT+08:00

Testing Connections in Batches (Cluster Mode)

Function

  • This API is used to test connections in cluster mode.
  • This API is used to test connections for primary and standby tasks.

Debugging

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

Constraints

  • After the task is created, you can test the connection only when the task status is CONFIGURATION.
  • You can call a maximum of 10 APIs in batches.

URI

POST /v3/{project_id}/jobs/cluster/batch-connection

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

Requests for testing cluster connections in batches.

For details, see Table 4.

Table 4 Data structure description of field jobs

Parameter

Mandatory

Type

Description

action

Yes

String

Specific operation to be performed.

job_id

Yes

String

Task ID. (In cluster mode, the value is the ID of the parent task.).

property

Yes

String

The parameter that corresponds to the operation.

NOTE:

Combine the parameters in Table 5 into a JSON file and escape the JSON file.

Table 5 property field description

Name

Mandatory

Type

Description

dbtype

Yes

String

Database type.

dbport

Yes

Integer

Database port. The value is 0 for the MongoDB engine.

ssllink

Yes

boolean

Whether the connection is an SSL connection. Valid values:

  • true
  • false

nettype

Yes

String

Network type. Valid values:

  • vpn
  • vpc
  • eip

endpointtype

Yes

String

Endpoint type. Valid values:

  • so: indicates the source database.
  • ta: indicates the destination database.
  • ls: indicates the sharded database. If the source database is a cluster database, the endpointtype value corresponding to the database IP address is so, and the endpointtype value corresponding to the sharded database is ls.

ip

Yes

String

Database IP address.

dbName

Yes

String

Database name.

instid

No

String

DB instance ID. This parameter is mandatory for cloud DB instances.

dbuser

Yes

String

Database username.

dbpassword

Yes

String

Database password.

sslcertkey

No

String

Content of the SSL certificate. This parameter is required for SSL connection.

sslcertname

No

String

Name of the SSL certificate. This parameter is required for SSL connection.

sslcertchecksum

No

String

Checksum value of the SSL certificate content, which is required for SSL connections.

kafkaSecurityConfig

No

Object

This parameter is mandatory when the Kafka authentication mode is set to a security authentication mode.

For details, see Table 6.

Table 6 Data structure description of field kafkaSecurityConfig

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 the security protocol is set to SSL or SASL_SSL.

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 two-way SSL authentication is enabled. 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.

Response Parameters

Status code: 200

Table 7 Response body parameters

Parameter

Type

Description

results

Array of objects

Response body set for the batch test connection.

For details, see Table 8.

count

Integer

Total number of records.

Table 8 Data structure description of field results

Parameter

Type

Description

id

String

Task ID.

status

String

Test result. Value:

  • true: indicates that the connection test is successful.
  • false: indicates that the connection test fails.

error_code

String

Error code.

error_msg

String

Error message.

success

Boolean

Whether the request is successful.

Example Request

  • Testing connections for a MySQL primary/standby task
    https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/cluster/batch-connection
    
    {
    	"jobs": [{
    		"action": "testConnection",
    		"job_id": "0ac45233-8de7-4f02-9de1-d71cab7jb201",
    		"property": "[{\"ip\":\"192.168.2.232:3306\",\"dbtype\":\"mysql\",\"dbuser\":\"root\",\"dbpassword\":\"******\",\"ssllink\":false,\"projectId\":\"054ba152d480d55b2f5dc0069e7ddef0\",\"region\":\"cn-xianhz-1\",\"nettype\":\"eip\",\"endpointtype\":\"so\"}]"
    	}]
    }
  • Testing connections for a task in which the source database is DDS cluster
    https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/cluster/batch-connection
    
    {
      "jobs" : [ {
        "action" : "testConnection",
        "job_id" : "35d0d60b-4605-4686-b35d-3a3d059fjb15",
        "property" : "[{\"dbtype\":\"mongodb\",\"dbport\":0,\"ssllink\":false,\"nettype\":\"eip\",\"endpointtype\":\"so\",\"encrypt\":{\"elementId\":\"encrypt_switch\",\"offLabel\":\"OFF\",\"onLabel\":\"ON\",\"disable\":false,\"ip\":\"192.168.7.217:8635\",\"dbName\":\"admin\",\"dbuser\":\"rwuser\",\"dbpassword\":\"******\"},{\"dbtype\":\"mongodb\",\"dbport\":0,\"ssllink\":false,\"nettype\":\"eip\",\"endpointtype\":\"so\",\"encrypt\":{\"elementId\":\"encrypt_switch\",\"offLabel\":\"OFF\",\"onLabel\":\"ON\",\"disable\":false,\"ip\":\"192.168.7.72:8635\",\"dbName\":\"admin\",\"dbuser\":\"rwuser\",\"dbpassword\":\"******\"},{\"ip\":\"192.168.7.37:8635\",\"nettype\":\"eip\",\"dbtype\":\"mongodb\",\"dbport\":0,\"dbuser\":\"rwuser\",\"dbpassword\":\"******\",\"ssllink\":false,\"sslcertkey\":\"\",\"sslcertname\":\"\",\"sslcertchecksum\":\"\",\"endpointtype\":\"ls\",\"dbName\":\"admin\"}]"
      } ]
    }
  • Creating a real-time primary/standby synchronization task from MySQL to Kafka and setting the Kafka authentication mode to SASL_PLAINTEXT
    https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/cluster/batch-connection
    
    {
      "jobs": [
        {
          "action": "testConnection",
          "job_id": "f85c660b-c4d0-4571-ac53-629d906jb20i",
          "property": "[{\"ip\":\"xxxxxx:xxxx\",\"dbtype\":\"kafka\",\"dbuser\":\"xxxxxx\",\"dbpassword\":\"xxxxxx\",\"ssllink\":false,\"projectId\":\"5237e10fe9aa4ad5b16b6a5245248314\",\"region\":\"region-1\",\"vpcid\":\"f7ea6af9-dee8-456f-b3d7-0cc34b4c9cbf\",\"subnetid\":\"b04c1704-5bd9-4195-9bda-ea2a14e0537e\",\"kafkaSecurityConfig\":{\"type\":\"SASL_PLAINTEXT\",\"sasl_mechanism\":\"PLAIN\"},\"nettype\":\"vpc\",\"dbUseType\":\"sync\",\"endpointtype\":\"ta\"}]"
        }
      ]
    }

Example Response

Status code: 200

OK

{
  "results" : [ {
    "id" : "0eb704d0-5a1c-4cbd-b675-91152f06jb11",
    "status" : "true"
  } ],
  "count" : 1
}

Status Code

Status Code

Description

200

OK

400

Bad Request

Error Code

For details, see Error Code.