Updated on 2023-08-03 GMT+08:00

Creating a Data Connection

Function

This API is used to create a data connection.

Debugging

You can debug this API in API Explorer. Automatic authentication is supported. API Explorer can automatically generate sample SDK code and provide the sample SDK code debugging.

URI

POST /v2/{project_id}/data-connectors

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

data_connector

Yes

object

Data connection. For details, see Table 3.

Table 3 DataConnector

Parameter

Mandatory

Type

Description

connector_name

Yes

String

Data connection name

source_type

Yes

String

The data connection type. The options are as follows:

  • RDS_POSTGRES: RDS PostgreSQL database
  • RDS_MYSQL: RDS MySQL database
  • gaussdb-mysql: GaussDB(for MySQL)

source_info

Yes

String

Data source information, in JSON format. The content varies from one data connection to another. For details about the source_info content for each data source, see the example request.

Response Parameters

Status code: 201

Table 4 Response body parameter

Parameter

Type

Description

connector_id

String

Data connection ID returned after a data connection is created.

Example Request

Create a data connection.

/v2/ac66f1a5-e8f4-4399-8ec6-2c8cb1aefda7/data-connector

{
  "data_connector" : {
    "connector_name" : "mrs-mysql-connector",
    "source_type" : "RDS_MYSQL",
    "source_info" : "{\"db_name\":\"default\",\"user_name\":\"mrs\",\"password\":\"*****\",\"rds_instance_id\":\"3aa55f1cb4c3491686936130f21e9f16in01\"}"
  }
}

Example Response

Status code: 201

Data connection created successfully.

{
  "connector_id" : "0822239c1e80d4502f82c008937da9b5"
}

Status Codes

See Status Codes.

Error Codes

See Error Codes.