更新时间:2025-03-10 GMT+08:00
分享

数据源更新

功能介绍

数据源更新。

URI

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

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID。获取方法请参见获取项目ID

connection_id

String

数据源ID。

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Workspace-Id

String

工作空间ID。获取方法请参见获取工作空间ID

X-Auth-Token

String

用户Token。 通过调用IAM服务获取IAM用户Token接口,接口返回的响应消息头中“X-Subject-Token”就是需要获取的用户Token。

表3 请求Body参数

参数

是否必选

参数类型

描述

name

String

数据源名称。

description

String

数据源描述信息。

type

String

参数解释:

数据源类型。

示例:MySQL,指定当前对接的数据源类型为MySQL,涉及查询时会使用MySQL驱动包。

约束限制:

不涉及

取值范围:

以下枚举值:

  • MySQL;
  • DWS:GaussDB(DWS)对应的数据源类型;
  • PostgreSQL;
  • OpenGauss:GaussDB对应的数据源类型;
  • Doris;
  • HIVE;
  • ClickHouse;
  • API:API数据对应数据源类型。

默认取值:

不涉及

source

String

数据源来源。枚举值:

  • rds:云服务RDS数据源;
  • dws:DWS集群数据源;
  • mrs:云服务MRS数据源;
  • gaussdb:云服务GaussDB数据源;
  • public:公网接入方式数据源;
  • restapi:API数据源;
  • endpoint-service:终端节点服务接入方式数据源。

server_list

String

集群模式(多实例)必填,如DWS,ClickHouse。

database_name

String

数据库名。

host

String

域名,非集群数据源必填,如mysql。

port

Integer

端口。

user_name

String

用户名。

password

String

密码。

cluster

ClusterInfoDTO object

云实例接入方式时必填。

region_id

String

当前region的ID。

config

DcConfigDTO object

配置参数。

表4 ClusterInfoDTO

参数

是否必选

参数类型

描述

id

String

关联云实例ID。

表5 DcConfigDTO

参数

是否必选

参数类型

描述

ssl

Boolean

ssl参数配置。

region_id

String

DLI归属regionId;当前不支持跨region,值只能是当前regionId。

catalog_name

String

数据目录名称,默认值:dli;DLI自有catalog值为dli。

catalog_type

String

数据目录类型,默认值:dil,枚举值:

  • dli:DLI自有catalog;
  • lakeformation:lakeformation的数据目录。

ds_project_id

String

DLI队列归属rpojectId。

queue_name

String

SQL队列。

auth_type

String

验证方式;AKSK

枚举值:

  • AKSK

ds_ak

String

用户ak(验证方式为AKSK时必填)。

ds_sk

String

用户sk(验证方式为AKSK时必填)。

time_out

Integer

API数据源时,请求超时时间。

protocol

String

协议:REST。

token_key

String

token key。

token_value

String

token value。

request_url

String

API数据源时,请求url。

request_method

String

请求方式:GET、POST。

枚举值:

  • GET
  • POST

request_params

Array of RequestParamDto objects

请求参数列表。

resp_param

Array of ResponseParamDto objects

返回参数。

表6 RequestParamDto

参数

是否必选

参数类型

描述

location

String

位置。

value

Array of strings

参数值。

tag_id

String

标签ID,当param_source为user时必填。

param_name

String

参数名称。

alias_name

String

参数别名。

field_type

String

参数类型:String、Long、Decimal、List<String>、List<Long>、List<Decimal>、DateTime、Bool、PageIndex、PageNum。

param_source

String

参数来源:custom、user、userGroup。

type

Boolean

是否加密。

表7 ResponseParamDto

参数

是否必选

参数类型

描述

alias_name

String

参数别名。

field_type

String

参数类型:String、Long、Decimal、DateTime、Bool。

param_name

String

参数名称。

响应参数

状态码: 200

表8 响应Body参数

参数

参数类型

描述

message

String

描述

请求示例

数据源更新。

PUT /v1/{project_id}/connections/{connection_id}
修改公网连接类型数据源
{
  "name": "dws02",
  "server_list": "xx.xx.x.xx:xxxx",
  "database_name": "gaussdb",
  "user_name": "xxxxx",
  "password": "xxxxxxx",
  "config": {
    "ssl": true
  },
  "source": "public",
  "type": "DWS"
}
修改DWS云数据源
{
    "name": "dws04_instance",
    "description": "测试新增",
    "source": "dws",
    "type": "DWS",
    "database_name": "xxxxx",
    "user_name": "xxxx",
    "password": "xxxx",
    "region_id": "xxxx",
    "cluster": {
        "id": "xxxxxxxxxxxx"
    },
    "config": {
        "ssl": false
    }
}
修改RDS的MySQL云数据源
{
    "name": "mysql_instance",
    "description": "测试新增",
    "source": "rds",
    "type": "MySQL",
    "database_name": "xxxxx",
    "user_name": "xxxxx",
    "password": "xxxxx",
    "region_id": "xxxx",
    "cluster": {
        "id": "xxxxxxxxxxxx"
    },
    "config": {
        "ssl": false
    }
}
修改GaussDBForMySQL云数据源
{
    "name": "gaussdb_mysql_instance",
    "description": "测试新增",
    "source": "gaussdb",
    "type": "MySQL",
    "database_name": "xxxxx",
    "user_name": "xxxxx",
    "password": "xxxxx",
    "region_id": "xxxx",
    "cluster": {
        "id": "xxxxxxxx"
    },
    "config": {
        "ssl": false
    }
}
修改OpenGauss云数据源
{
    "name": "gaussdb_instance",
    "description": "测试新增",
    "source": "gaussdb",
    "type": "OpenGauss",
    "database_name": "xxxxx",
    "user_name": "xxxxx",
    "password": "xxxxx",
    "region_id": "xxxx",
    "cluster": {
        "id": "xxxxxxxx"
    },
    "config": {
        "ssl": false
    }
}
修改PostgreSQL云数据源
{
    "name": "postgre_instance",
    "description": "测试新增",
    "source": "rds",
    "type": "PostgreSQL",
    "database_name": "xxxxx",
    "user_name": "xxxxx",
    "password": "xxxxx",
    "region_id": "xxxxx",
    "cluster": {
        "id": "xxxxxxxx"
    },
    "config": {
        "ssl": false
    }
}

响应示例

状态码: 200

更新成功。

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

状态码

状态码

描述

200

更新成功。

错误码

请参见错误码

相关文档

    OSZAR »