All Products
Search
Document Center

DataWorks:CreateDataSource

Last Updated:Nov 21, 2024

Adds a data source to DataWorks.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
ProjectIdlongYes

The ID of the DataWorks workspace to which the data source belongs. You can call the ListProjects operation to query the ID.

1
NamestringYes

The name of the data source.

abc
DescriptionstringNo

The description of the data source.

abc
DataSourceTypestringYes

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
rds
SubTypestringNo

The subtype of the data source.

  • This parameter takes effect only if you set the DataSourceType parameter to rds.
  • If the DataSourceType parameter is set to rds, this parameter can be set to mysql, sqlserver, or postgresql.
mysql
EnvTypeintegerYes

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.

1
ContentstringYes

The details of the data source. Examples of details of some common data sources:

  • odps

    {
      "accessId": "xssssss",
      "accessKey": "xsaxsaxsa",
      "authType": 2,
      "endpoint": "http://service.odps.aliyun.com/api",
      "project": "xsaxsax",
      "tag": "public"
    }
    
  • mysql

    {
      "database": "xsaxsa",
      "instanceName": "rm-xsaxsa",
      "password": "xsaxsa",
      "rdsOwnerId": "xasxsa",
      "regionId": "cn-shanghai",
      "tag": "rds",
      "username": "xsaxsa"
    }
    
  • rds

    {
      "configType": 1,
      "tag": "rds",
      "database": "xsaxsa",
      "username": "xsaxsa",
      "password": "xssaxsa$32050",
      "instanceName": "rm-xsaxs",
      "rdsOwnerId": "11111111"
    }
    
  • oss

    {
      "accessId": "sssssxx",
      "accessKey": "xsaxaxsaxs",
      "bucket": "xsa-xs-xs",
      "endpoint": "http://oss-cn-shanghai.aliyuncs.com",
      "tag": "public"
    }
    
  • sqlserver

    {
      "jdbcUrl": "jdbc:sqlserver://xsaxsa-xsaxsa.database.xxx.cn:123;DatabaseName=xsxs-xsxs",
      "password": "sdasda$fs",
      "tag": "public",
      "username": "sxaxacdacdd"
    }
    
  • polardb

    {
      "clusterId": "pc-sdadsadsa",
      "database": "dsadsadsa",
      "ownerId": "121212122",
      "password": "sdasdafssa",
      "region": "cn-shanghai",
      "tag": "polardb",
      "username": "asdadsads"
    }
    
  • redis

    {    
    "password": "xxxxxx",   
     "address":"[{\"host\":\"xxxxxxx.redis.rds.aliyuncs.com\",\"port\":6379}]",    
    "tag": "public"
    }
    
  • oracle

    {
      "jdbcUrl": "jdbc:oracle:saaa:@xxxxx:1521:PROD",
      "password": "sxasaxsa",
      "tag": "public",
      "username": "sasfadfa"
    }
    
  • mongodb

    {
      "address": "[\"xsaxxsa.mongodb.rds.aliyuncs.com:3717\"]",
      "database": "admin",
      "password": "sadsda@",
      "tag": "public",
      "username": "dsadsadas"
    }
    
  • emr

    {
      "accessId": "xsaxsa",
      "emrClusterId": "C-dsads",
      "emrResourceQueueName": "default",
      "emrEndpoint": "emr.aliyuncs.com",
      "accessKey": "dsadsad",
      "emrUserId": "224833315798889783",
      "name": "sasdsadsa",
      "emrAccessMode": "simple",
      "region": "cn-shanghai",
      "authType": "2",
      "emrProjectId": "FP-sdadsad"
    }
    
  • postgresql

    {
      "jdbcUrl": "jdbc:postgresql://xxxx:1921/ssss",
      "password": "sdadsads",
      "tag": "public",
      "username": "sdsasda"
    }
    
  • analyticdb_for_mysql

    {
      "instanceId": "am-sadsada",
      "database": "xsxsx",
      "username": "xsxsa",
      "password": "asdadsa",
      "connectionString": "am-xssxsxs.ads.aliyuncs.com:3306"
    }
    
  • hybriddb_for_postgresql

    {
      "connectionString": "gp-xsaxsaxa-master.gpdbmaster.rds.aliyuncs.com",
      "database": "xsaxsaxas",
      "password": "xsaxsaxsa@11",
      "instanceId": "gp-xsaxsaxsa",
      "port": "541132",
      "ownerId": "xsaxsaxsas",
      "username": "sadsad"
    }
    
  • holo

    {
      "accessId": "xsaxsaxs",
      "accessKey": "xsaxsaxsa",
      "database": "xsaxsaxsa",
      "instanceId": "xsaxa",
      "tag": "aliyun"
    }
    
  • kafka

    {
      "instanceId": "xsax-cn-xsaxsa",
      "regionId": "cn-shanghai",
      "tag": "aliyun",
      "ownerId": "1212121212112"
    }
    
{"database":"dbname","instanceName":"instancename","password":"password","rdsOwnerId":"123","username":"username"}

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

HttpStatusCodestring

The HTTP status code.

200
Datalong

The data source ID.

123
RequestIdstring

The request ID.

0bc141151593763****
Successboolean

Indicates whether the request was successful.

true

Examples

Sample success responses

JSONformat

{
  "HttpStatusCode": "200",
  "Data": 123,
  "RequestId": "0bc141151593763****",
  "Success": true
}

Error codes

HTTP status codeError codeError messageDescription
400Invalid.Tenant.ConnectionNotExistsThe connection does not exist.The connection does not exist.
400Invalid.Tenant.ProjectNotExistsThe project does not exist.The project does not exist.
400Invalid.Tenant.UserNotInProjectThe user is not in the project.The user is not in the project.
400ConnectionAlreadyExistThe connection with envType %s and name %s already exists.ConnectionAlreadyExist
400DataSource.CheckRamRoleFailureFailed to check the RAM role. AccountId %s. roleArn %s.-
400DataSource.ConnectionStrProperty.PatternNotMatchThe pattern value %s is invalid. The correct pattern is %s.-
400Invalid.DataSource.DataSourceTypeNotSupportThe dataSourceType %s and subType %s are not supported.DataSource type not support yet.
400Invalid.Param.Odps.EngineIdOrConnectStrEmptyEither the compute engine ID or the connection string must be specified when data source type is ODPS.-
400MissingParam.ConnectionStr.PropertyYou must specify property %s required by the data source connection string.The data source connection str required property missing.
400Invalid.DataSource.DataSourceTypeNotExistThe data source type %s does not exist.The dataSource type %s are not exist.
403Invalid.Tenant.UserIsNotProjectOwnerOrAdminThe user is not a project administrator or owner.The user is not a project administrator or owner.
403Invalid.Tenant.UserNotInTenantThe user is not in tenant.The user is not in tenant.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2022-07-18API Description Update. The Error code has changedView Change Details