调用ListDataSources接口,查询DataWorks数据源列表。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

请求参数

名称 类型 是否必选 示例值 描述
Action String ListDataSources

系统规定参数。取值:ListDataSources

ProjectId Long 1

数据源所在的DataWorks工作空间ID。您可以通过ListProjects接口获取工作空间ID。

Name String test

查询的数据源名称。

DataSourceType String rds

数据源的类型。常用的类型如下:

  • odps
  • mysql
  • rds
  • oss
  • sqlserver
  • polardb
  • oracle
  • mongodb
  • emr
  • postgresql
  • analyticdb_for_mysql
  • hybriddb_for_postgresql
  • holo
SubType String mysql

数据源的子类型。仅当DataSourceType参数配置为RDS时,该参数生效。

当DataSourceType参数配置为RDS时,该参数可以配置为mysql、sqlserver或postgresql。

Status String ENABLED

数据源的状态。取值如下:

  • ENABLED,正常。
  • DISABLED,禁用。
EnvType Integer 1

数据源所属的环境,包括0(开发环境)和1(生产环境)。

PageSize Integer 10

每页显示的条数,默认为10条,最大为100条。

PageNumber Integer 1

分页查询的页码。取值为大于等于1的正整数。

返回数据

名称 类型 示例值 描述
HttpStatusCode Integer 200

HTTP状态码。

RequestId String 0bc14115159376359****

请求ID。

Success Boolean true

请求是否成功。

Data Object

数据源的查询结果。

PageNumber Integer 1

页码。

PageSize Integer 20

每页显示的条数,默认为10条,最大为100条。

TotalCount Integer 233

数据源的总数。

DataSources Array of DataSources

数据源列表。

Status Integer 1

数据源的状态。取值如下:

  • 1,表示数据源正常使用。
  • 2,表示数据源已禁用。
ProjectId Integer 123

数据源关联的工作空间ID。

SubType String mysql

数据源的子类型。仅当DataSourceType参数配置为RDS时,该参数生效。

当DataSourceType参数配置为RDS时,该参数可以配置为mysql、sqlserver或postgresql。

GmtModified String Mar 17, 2021 4:09:32 PM

修改数据源的时间。时间格式示例为Mar 17, 2021 4:09:32 PM。

EnvType Integer 1

数据源所在的环境。取值如下:

  • 0,开发环境。
  • 1,生产环境。
ConnectStatus Integer 1

数据源的状态。取值如下:

  • 1,表示数据源正常使用。
  • 2,表示数据源已禁用。
Sequence Integer 300

排序字段。数据源按此字段从大到小排序。

Description String a connection

数据源的描述信息。

DataSourceType String rds

数据源的类型。常用类型如下:

  • odps
  • mysql
  • rds
  • oss
  • sqlserver
  • polardb
  • oracle
  • mongodb
  • emr
  • postgresql
  • analyticdb_for_mysql
  • hybriddb_for_postgresql
  • holo
GmtCreate String Mar 17, 2021 4:09:32 PM

创建数据源的时间。时间格式示例为Mar 17, 2021 4:09:32 PM。

DefaultEngine Boolean false

数据源关联的引擎是否为同类型数据源选用的默认引擎。

Shared Boolean false

是否为共享的数据源。

Operator String 193543050****

最近一次修改数据源的阿里云用户ID。

Name String abc

数据源的名称。

Content String {"pubEndpoint":"http://service.cn.maxcompute.aliyun.com/api","accessId":"TMP.3KecGjvzy3i8MYfn2BGHgF7EHGyBFZcHm7GgngrABVRyvvKQrfF5kskR36xP361C3dqwbGo7SGYptAeGyiTwHXqLaBUvYC","securityToken":null,"endpoint":"http://service.cn.maxcompute.aliyun-inc.com/api","accessKey":"***","name":"PRE_PROJECT_A_engine","project":"PRE_PROJECT_A","vpcEndpoint":"http://service.cn.maxcompute.aliyun-inc.com/api","region":"cn-shanghai","authType":"2"}

数据连接串的相关信息。格式为JSON格式。常用的数据源对应的连接串样例如下:

  • MaxCompute
json
{
  "pubEndpoint": "http://service.cn.maxcompute.aliyun.com/api",
  "accessId": "xxxxxxx",
  "securityToken": null,
  "endpoint": "http://service.cn.maxcompute.aliyun-inc.com/api",
  "accessKey": "***",
  "name": "PRE_PROJECT_A_engine",
  "project": "PRE_PROJECT_A",
  "vpcEndpoint": "http://service.cn.maxcompute.aliyun-inc.com/api",
  "region": "cn-shanghai",
  "authType": "2"
}
  • mysql
json
{
  "configType": "1",
  "database": "mysql_d111b",
  "instanceName": "rm-xxxxxx",
  "password": "***",
  "rdsOwnerId": "12133xxxxxx",
  "tag": "rds",
  "username": "mysql_db111"
}
  • sqlserver
json
{
  "configType": "1",
  "jdbcUrl": "jdbc:sqlserver://rm-xxxxx.sqlserver.rds.aliyuncs.com:1433;DatabaseName=sqlserver_db1",
  "password": "***",
  "tag": "public",
  "username": "sqlserver_db111"
}
  • oss
json
{
  "accessId": "LTAINbR9Uxxxx",
  "accessKey": "***",
  "bucket": "bigxxx1223",
  "configType": "1",
  "endpoint": "http://oss-cn-hangzhou.aliyuncs.com",
  "tag": "public"
}
  • postgresql
json
{
  "configType": "1",
  "database": "cdp_xxx",
  "instanceName": "rm-xxxx",
  "password": "***",
  "rdsOwnerId": "121xxxxx",
  "tag": "rds",
  "username": "cdp_xxx"
}
  • ads
json
{
  "configType": "1",
  "password": "***",
  "schema": "ads_demo",
  "tag": "public",
  "url": "ads-xxx-xxxx.cn-hangzhou-1.ads.aliyuncs.com:3029",
  "username": "lslslsls"
}
Id Long 1

数据源ID。

BindingCalcEngineId Long 123

数据源关联的计算引擎ID。

TenantId Long 1234567

租户ID。

示例

请求示例

http(s)://[Endpoint]/?Action=ListDataSources
&Name=test
&ProjectId=1
&RegionId=cn-shanghai
&<公共请求参数>

正常返回示例

XML格式

HTTP/1.1 200 OK
Content-Type:application/xml

<RequestId>0bc14115159376359****</RequestId>
<HttpStatusCode>200</HttpStatusCode>
<Data>
    <TotalCount>233</TotalCount>
    <PageSize>20</PageSize>
    <PageNumber>1</PageNumber>
    <DataSources>
        <Status>1</Status>
        <Operator>193543050****</Operator>
        <ConnectStatus>1</ConnectStatus>
        <SubType>mysql</SubType>
        <Description>a connection</Description>
        <BindingCalcEngineId>123</BindingCalcEngineId>
        <ProjectId>123</ProjectId>
        <GmtModified>Mar 17, 2021 4:09:32 PM</GmtModified>
        <Sequence>300</Sequence>
        <Shared>false</Shared>
        <EnvType>1</EnvType>
        <Name>abc</Name>
        <DefaultEngine>false</DefaultEngine>
        <TenantId>1234567</TenantId>
        <GmtCreate>Mar 17, 2021 4:09:32 PM</GmtCreate>
        <Content>{"pubEndpoint":"http://service.cn.maxcompute.aliyun.com/api","accessId":"TMP.3KecGjvzy3i8MYfn2BGHgF7EHGyBFZcHm7GgngrABVRyvvKQrfF5kskR36xP361C3dqwbGo7SGYptAeGyiTwHXqLaBUvYC","securityToken":null,"endpoint":"http://service.cn.maxcompute.aliyun-inc.com/api","accessKey":"***","name":"PRE_PROJECT_A_engine","project":"PRE_PROJECT_A","vpcEndpoint":"http://service.cn.maxcompute.aliyun-inc.com/api","region":"cn-shanghai","authType":"2"}</Content>
        <DataSourceType>rds</DataSourceType>
        <Id>1</Id>
    </DataSources>
</Data>
<Success>true</Success>

JSON格式

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "0bc14115159376359****",
  "HttpStatusCode" : 200,
  "Data" : {
    "TotalCount" : 233,
    "PageSize" : 20,
    "PageNumber" : 1,
    "DataSources" : {
      "Status" : 1,
      "Operator" : "193543050****",
      "ConnectStatus" : 1,
      "SubType" : "mysql",
      "Description" : "a connection",
      "BindingCalcEngineId" : 123,
      "ProjectId" : 123,
      "GmtModified" : "Mar 17, 2021 4:09:32 PM",
      "Sequence" : 300,
      "Shared" : false,
      "EnvType" : 1,
      "Name" : "abc",
      "DefaultEngine" : false,
      "TenantId" : 1234567,
      "GmtCreate" : "Mar 17, 2021 4:09:32 PM",
      "Content" : "{\"pubEndpoint\":\"http://service.cn.maxcompute.aliyun.com/api\",\"accessId\":\"TMP.3KecGjvzy3i8MYfn2BGHgF7EHGyBFZcHm7GgngrABVRyvvKQrfF5kskR36xP361C3dqwbGo7SGYptAeGyiTwHXqLaBUvYC\",\"securityToken\":null,\"endpoint\":\"http://service.cn.maxcompute.aliyun-inc.com/api\",\"accessKey\":\"***\",\"name\":\"PRE_PROJECT_A_engine\",\"project\":\"PRE_PROJECT_A\",\"vpcEndpoint\":\"http://service.cn.maxcompute.aliyun-inc.com/api\",\"region\":\"cn-shanghai\",\"authType\":\"2\"}",
      "DataSourceType" : "rds",
      "Id" : 1
    }
  },
  "Success" : true
}

错误码

HttpCode 错误码 错误信息 描述
400 Invalid.Tenant.ConnectionNotExists The connection does not exist. 数据源不存在。
400 Invalid.Tenant.ProjectNotExists The project does not exist. 项目不存在。
400 Invalid.Tenant.UserNotInProject The user is not in the project. 用户不在项目中。
403 Invalid.Tenant.UserIsNotProjectOwnerOrAdmin The user is not a project administrator or owner. 用户不是项目负责人或者项目管理员。
403 Invalid.Tenant.UserNotInTenant The user is not in tenant. 用户不在租户中。

访问错误中心查看更多错误码。