Updated on 2025-02-25 GMT+08:00

Updating a Data Source

Function

This API is used to update data sources.

URI

PUT /v1/{project_id}/connections/{connection_id}

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For how to obtain the project ID, see Obtaining a Project ID.

connection_id

Yes

String

Data source ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Workspace-Id

Yes

String

Workspace ID. For how to obtain it, see Obtaining a Workspace ID.

X-Auth-Token

Yes

String

User token. Obtain a user token by calling IAM's "Obtaining a User Token" API. X-Subject-Token in the response header is the desired user token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Data source name.

description

No

String

Data source description.

type

Yes

String

Explanation

Data source type.

For example, MySQL indicates that the type of the connected data source is MySQL. The MySQL driver package is used for query.

Constraints

N/A

Value range

The enumerated values are:

  • MySQL.
  • DWS: data source type corresponding to GaussDB(DWS).
  • PostgreSQL.
  • OpenGauss: data source type corresponding to GaussDB.
  • Doris.
  • HIVE.
  • ClickHouse.
  • API: data source type corresponding to API data.

Default value

N/A

source

Yes

String

Data source. Enumerated values:

  • rds: RDS data source.
  • dws: GaussDB(DWS) data source.
  • mrs: MRS data source.
  • gaussdb: GaussDB data source.
  • public: public network data source.
  • restapi: API data source.
  • endpoint-service: VPCEP data source.

server_list

No

String

List of servers. Mandatory if the data source is in cluster mode (containing multiple instances), for example, DWS or ClickHouse.

database_name

Yes

String

Database name.

host

No

String

Domain name. Mandatory for non-cluster data sources, for example, mysql.

port

No

Integer

Port.

user_name

No

String

Username.

password

No

String

Password.

cluster

No

ClusterInfoDTO object

Mandatory when any cloud instance is connected.

region_id

No

String

Current region ID.

config

Yes

DcConfigDTO object

Configuration parameter.

Table 4 ClusterInfoDTO

Parameter

Mandatory

Type

Description

id

No

String

ID of the associated cloud instance.

Table 5 DcConfigDTO

Parameter

Mandatory

Type

Description

ssl

No

Boolean

SSL parameter configuration.

region_id

No

String

ID of the region where DLI is. Currently, cross-region deployment is not supported. The value must be the ID of the current region.

catalog_name

No

String

Data directory name. The default value is dli. The value of DLI catalogs is dli.

catalog_type

No

String

Data directory type. The default value is dil. The options include:

  • dli: DLI catalogs.
  • lakeformation: LakeFormation data directories.

ds_project_id

No

String

ID of the project the DLI queue belongs to.

queue_name

No

String

SQL queue.

auth_type

No

String

Authentication mode. The value is AKSK.

Enumerated values:

  • AKSK

ds_ak

No

String

User AK. Mandatory when the authentication mode is AKSK.

ds_sk

No

String

User SK. Mandatory when the authentication mode is AKSK.

time_out

No

Integer

Request timeout interval when an API is used as the data source.

protocol

No

String

Protocol. The value is REST.

token_key

No

String

Token key.

token_value

No

String

Token value.

request_url

No

String

Request URL when an API is used as the data source.

request_method

No

String

Request method. The value can be GET or POST.

Enumerated values:

  • GET
  • POST

request_params

No

Array of RequestParamDto objects

List of request parameters.

resp_param

No

Array of ResponseParamDto objects

Response parameters.

Table 6 RequestParamDto

Parameter

Mandatory

Type

Description

location

Yes

String

Location.

value

Yes

Array of strings

Parameter value.

tag_id

No

String

Tag ID. Mandatory when param_source is set to user.

param_name

Yes

String

Parameter name.

alias_name

No

String

Parameter alias.

field_type

Yes

String

Parameter type. The options include String, Long, Decimal, List<String>, List<Long>, List<Decimal>, DateTime, Bool, PageIndex, and PageNum.

param_source

Yes

String

Parameter source. The options include custom, user, and userGroup.

type

Yes

Boolean

Whether to encrypt data.

Table 7 ResponseParamDto

Parameter

Mandatory

Type

Description

alias_name

Yes

String

Parameter alias.

field_type

Yes

String

Parameter type. The options include String, Long, Decimal, DateTime, and Bool.

param_name

Yes

String

Parameter name.

Response Parameters

Status code: 200

Table 8 Response body parameter

Parameter

Type

Description

message

String

Description.

Example Request

Update data sources.

PUT /v1/{project_id}/connections/{connection_id}
Change the data source to a public network connection.
{
  "name": "dws02",
  "server_list": "xx.xx.x.xx:xxxx",
  "database_name": "gaussdb",
  "user_name": "xxxxx",
  "password": "xxxxxxx",
  "config": {
    "ssl": true
  },
  "source": "public",
  "type": "DWS"
}
Change the data source to GaussDB(DWS).
{
    "name": "dws04_instance",
    "description": "Added for Test",
    "source": "dws",
    "type": "DWS",
    "database_name": "xxxxx",
    "user_name": "xxxx",
    "password": "xxxx",
    "region_id": "xxxx",
    "cluster": {
        "id": "xxxxxxxxxxxx"
    },
    "config": {
        "ssl": false
    }
}
Change the data source to RDS.
{
    "name": "mysql_instance",
    "description": "Added for Test",
    "source": "rds",
    "type": "MySQL",
    "database_name": "xxxxx",
    "user_name": "xxxxx",
    "password": "xxxxx",
    "region_id": "xxxx",
    "cluster": {
        "id": "xxxxxxxxxxxx"
    },
    "config": {
        "ssl": false
    }
}
Change the data source to GaussDB.
{
    "name": "gaussdb_mysql_instance",
    "description": "Added for Test",
    "source": "gaussdb",
    "type": "MySQL",
    "database_name": "xxxxx",
    "user_name": "xxxxx",
    "password": "xxxxx",
    "region_id": "xxxx",
    "cluster": {
        "id": "xxxxxxxx"
    },
    "config": {
        "ssl": false
    }
}
Change the data source to openGauss.
{
    "name": "gaussdb_instance",
    "description": "Added for Test",
    "source": "gaussdb",
    "type": "OpenGauss",
    "database_name": "xxxxx",
    "user_name": "xxxxx",
    "password": "xxxxx",
    "region_id": "xxxx",
    "cluster": {
        "id": "xxxxxxxx"
    },
    "config": {
        "ssl": false
    }
}
Change the data source to PostgreSQL.
{
    "name": "postgre_instance",
    "description": "Added for Test",
    "source": "rds",
    "type": "PostgreSQL",
    "database_name": "xxxxx",
    "user_name": "xxxxx",
    "password": "xxxxx",
    "region_id": "xxxxx",
    "cluster": {
        "id": "xxxxxxxx"
    },
    "config": {
        "ssl": false
    }
}

Example Response

Status code: 200

The data sources are successfully updated.

{
  "message" : "Update Data Connection Success!"
}

Status Codes

Status Code

Description

200

The data sources are successfully updated.

Error Codes

See Error Codes.