Queries the data sources added to a DataWorks workspace.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes ListDataSources

The operation that you want to perform. Set the value to ListDataSources.

ProjectId Long Yes 1

The ID of the DataWorks workspace to which the data sources belong. You can call the ListProjects operation to obtain the ID.

Name String No test

The name of the data source that you want to query.

DataSourceType String No rds

The type of the data source. Valid values:

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

The subtype of the data source. This parameter takes effect only if the DataSourceType parameter is set to rds.

If the DataSourceType parameter is set to rds, this parameter can be set to mysql, sqlserver, or postgresql.

Status String No ENABLED

The status of the data source. Valid values:

  • ENABLED
  • DISABLED
EnvType Integer No 1

The environment in which the data source is used. Valid values: 0 and 1. The value 0 indicates the development environment. The value 1 indicates the production environment.

PageSize Integer No 10

The number of entries per page. Maximum value: 100. Default value: 10.

PageNumber Integer No 1

The page number. The value of this parameter must be an integer greater than or equal to 1.

Response parameters

Parameter Type Example Description
HttpStatusCode Integer 200

The HTTP status code returned.

RequestId String 0bc14115159376359****

The request ID.

Success Boolean true

Indicates whether the request was successful.

Data Object

The query result returned.

PageNumber Integer 1

The page number.

PageSize Integer 20

The number of entries per page. Maximum value: 100. Default value: 10.

TotalCount Integer 233

The total number of data sources.

DataSources Array of DataSources

The data sources.

Status Integer 1

The status of the data source. Valid values:

  • 1: The data source is accessible.
  • 2: The data source is inaccessible.
ProjectId Integer 123

The ID of the workspace to which the data source belongs.

SubType String mysql

The subtype of the data source. This parameter takes effect only if the value of DataSourceType is rds.

If the value of DataSourceType is rds, the value of this parameter can be mysql, sqlserver, or postgresql.

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

The time when the data source was last modified. Example: Mar 17, 2021 4:09:32 PM.

EnvType Integer 1

The environment in which the data source is used. Valid values:

  • 0: development environment
  • 1: production environment
ConnectStatus Integer 1

The status of the data source. Valid values:

  • 1: The data source is accessible.
  • 2: The data source is inaccessible.
Sequence Integer 300

The sequence number of the data source. Data sources are sorted in descending order based on the value of this parameter.

Description String a connection

The description of the data source.

DataSourceType String rds

The type of the data source. Valid values:

  • 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

The time when the data source was created. Example: Mar 17, 2021 4:09:32 PM.

DefaultEngine Boolean false

Indicates whether the compute engine instance that is associated with the data source is the default compute engine used by data sources of the same type.

Shared Boolean false

Indicates whether the data source is a shared data source.

Operator String 193543050****

The ID of the Alibaba Cloud account that is used to last modify the data source.

Name String abc

The name of the data source.

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"}

The data connection string. The value of this parameter is in the JSON format. Examples of connection strings of common data sources:

  • 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

The data source ID.

BindingCalcEngineId Long 123

The ID of the compute engine instance with which the data source is associated.

TenantId Long 1234567

The tenant ID.

Examples

Sample requests

http(s)://[Endpoint]/?Action=ListDataSources
&Name=test
&ProjectId=1
&RegionId=cn-shanghai
&<Common request parameters>

Sample success responses

XML format

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 format

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
}

Error codes

HTTP status code Error code Error message Description
400 Invalid.Tenant.ConnectionNotExists The connection does not exist. The error message returned because the specified data source does not exist.
400 Invalid.Tenant.ProjectNotExists The project does not exist. The error message returned because the specified workspace does not exist.
400 Invalid.Tenant.UserNotInProject The user is not in the project. The error message returned because the user is not added to the workspace.
403 Invalid.Tenant.UserIsNotProjectOwnerOrAdmin The user is not a project administrator or owner. The error message returned because the user is not the workspace owner or workspace administrator.
403 Invalid.Tenant.UserNotInTenant The user is not in tenant. The error message returned because the user does not belong to the tenant.

For a list of error codes, see Service error codes.