Creating a Connection
Function
This API is used to create a connection. The supported connection types include DWS, DLI, SparkSQL, Hive, RDS, and CloudTable.
- Parameter description
Table 1 URI parameter description Parameter
Mandatory
Type
Description
project_id
Yes
String
Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.
Request Message
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| workspace | No | String | Workspace ID.
|
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | Yes | String | Name of the connection. The name consists of a maximum of 100 characters. Only letters, digits, hyphens (-), and underscores (_) are allowed. The connection name must be unique. |
| type | Yes | String | Connection type. The options are as follows:
|
| config | No | Map<String,String> | Connection configuration item. The configuration item varies with the connection type. You do not need to set the config parameter for the DLI connection. For other types of connections, see the description of connection configuration items. |
| description | No | String | The description contains a maximum of 255 characters. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| clusterName | No | String | DWS cluster name. Perform the following operations to obtain the DWS cluster name:
You can obtain the cluster name from the cluster management list. By default, this parameter is left blank. |
| ip | No | String | IP address for accessing the DWS cluster. Perform the following operations to obtain the DWS access address:
You can obtain the private network IP address on the Database Attribute tab. If there are multiple IP addresses, select the first IP address. By default, this parameter is left blank. |
| port | No | String | Port for accessing the DWS cluster. Perform the following operations to obtain the DWS access port:
You can obtain the port information on the Database Attribute tab. For example, 8000. By default, this parameter is left blank. |
| userName | Yes | String | Username of the database. The username is required for creating the DWS cluster. |
| password | Yes | String | Password for accessing the database. The password is required for creating the DWS cluster. |
| sslEnable | Yes | boolean | Specifies whether to enable the SSL connection. |
| kmsKey | Yes | String | Name of the KMS key. Perform the following operations to obtain the key:
You can obtain the key name from the key list. |
| agentName | Yes | String | Name of the CDM cluster. Perform the following operations to obtain the CDM cluster name:
You can obtain the cluster name from the cluster list. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| clusterName | Yes | String | MRS cluster name. Perform the following operations to obtain the MRS cluster name:
You can obtain the cluster name from the active clusters, such as mrsCluster1. |
| connectionMethod | Yes | String | Method to connect.
|
| userName | No | String | Username of the MRS cluster. This parameter is mandatory when connectionMethod is set to agent. |
| password | No | String | Password for accessing the MRS cluster. This parameter is mandatory when connectionMethod is set to agent. |
| agentName | No | String | Name of the CDM cluster. This parameter is mandatory when connectionMethod is set to agent. Perform the following operations to obtain the CDM cluster name:
You can obtain the cluster name from the cluster list. |
| kmsKey | No | String | Name of the KMS key. This parameter is mandatory when connectionMethod is set to agent. Perform the following operations to obtain the key:
You can obtain the key name from the key list. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| clusterName | Yes | String | Name of the MRS cluster. For example, mrsCluster1 |
| connectionMethod | Yes | String | Method to connect.
|
| userName | No | String | Username of the MRS cluster. This parameter is mandatory when connectionMethod is set to agent. |
| password | No | String | Password for accessing the MRS cluster. This parameter is mandatory when connectionMethod is set to agent. |
| agentName | No | String | Name of the CDM cluster. This parameter is mandatory when connectionMethod is set to agent. Perform the following operations to obtain the CDM cluster name:
You can obtain the cluster name from the cluster list. |
| kmsKey | No | String | Name of the KMS key. This parameter is mandatory when connectionMethod is set to agent. Perform the following operations to obtain the key:
You can obtain the key name from the key list. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| ip | Yes | String | Address for accessing RDS. Perform the following operations to obtain the RDS access address:
You can obtain the IP address on the Connection Information tab. |
| port | Yes | String | Port for accessing RDS. Perform the following operations to obtain the RDS access port:
You can obtain the database port number on the Connection Information tab. |
| userName | Yes | String | Username of the database. The username is required for creating the cluster. |
| password | Yes | String | Password for accessing the database. The password is required for creating the cluster. |
| kmsKey | Yes | String | Name of the KMS key. Perform the following operations to obtain the key:
You can obtain the key name from the key list. |
| agentName | Yes | String | Name of the CDM cluster. Perform the following operations to obtain the CDM cluster name:
You can obtain the cluster name from the cluster list. |
| driverName | Yes | String | Name of the driver.
|
| driverPath | Yes | String | Path of the driver on OBS. |
CloudTable connection parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| clusterName | Yes | String | Name of the CloudTable cluster. Perform the following operations to obtain the cluster name:
You can obtain the cluster name from the cluster list. |
Response Message
None.
Example
Create a connection.
- Request
POST /v1/b384b9e9ab9b4ee8994c8633aabc9505/connections
{ "name":"connection1", "type":"DWS", "config":{ "clusterName":"test", "userName":"dbadmin", "password":"test1234", "kmsKey":"cdm-dlf", "agentName":"cdm-donotdelete", "sslEnable":false } }
- Success response
- Failure response
{ "error_code":"DLF.6309", "error_msg":"The name already exists." }
Status Codes
For details about status codes, see Status Codes.
Last Article: Connection Management APIs
Next Article: Querying a Connection List
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.