CreateDataSource

Updated at:

Creates a DataWorks data source.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request parameters

Parameter

Type

Required

Description

Example

ProjectId

integer

Yes

The ID of the DataWorks workspace to which the data source belongs. You can obtain the workspace ID by calling the ListProjects operation.

1

Name

string

Yes

The name of the data source.

abc

Description

string

No

The description of the data source.

abc

DataSourceType

string

Yes

The type of the data source. Common types include:

  • odps

  • mysql

  • rds

  • oss

  • sqlserver

  • polardb

  • oracle

  • mongodb

  • emr

  • postgresql

  • analyticdb_for_mysql

  • hybriddb_for_postgresql

  • holo

rds

SubType

string

No

The subtype of the data source. Take note of the following items:

  • This parameter takes effect only when the DataSourceType parameter is set to RDS.

  • If the DataSourceType parameter is set to RDS, you can set this parameter to mysql, sqlserver, or postgresql.

mysql

EnvType

integer

Yes

The environment to which the data source belongs. Valid values:

  • 0: development environment.

  • 1: production environment.

1

Content

string

Yes

The details of the data source. Examples of common data sources are as follows:

  • odps

    {
      "accessId": "*****",
      "accessKey": "*****",
      "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": "*****",
      "accessKey": "*****",
      "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": "*****",
      "emrClusterId": "C-dsads",
      "emrResourceQueueName": "default",
      "emrEndpoint": "emr.aliyuncs.com",
      "accessKey": "*****",
      "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": "*****",
      "accessKey": "*****",
      "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 elements

Element

Type

Description

Example

object

The response.

HttpStatusCode

string

The HTTP status code.

200

Data

integer

The ID of the data source.

123

RequestId

string

The request ID.

0bc141151593763****

Success

boolean

Indicates whether the request is successful.

true

Examples

Success response

JSON format

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

Error codes

HTTP status code

Error code

Error message

Description

400 Invalid.Tenant.ConnectionNotExists The connection does not exist. The connection does not exist.
400 Invalid.Tenant.ProjectNotExists The project does not exist. The project does not exist.
400 Invalid.Tenant.UserNotInProject The user is not in the project. The user is not in the project.
400 ConnectionAlreadyExist The connection with envType %s and name %s already exists. ConnectionAlreadyExist
400 DataSource.CheckRamRoleFailure Failed to check the RAM role. AccountId %s. roleArn %s. Failed to verify data source permissions.
400 DataSource.ConnectionStrProperty.PatternNotMatch The pattern value %s is invalid. The correct pattern is %s. The data source connection string property does not match the rule.
400 Invalid.DataSource.DataSourceTypeNotSupport The dataSourceType %s and subType %s are not supported. DataSource type not support yet.
400 Invalid.Param.Odps.EngineIdOrConnectStrEmpty Either the compute engine ID or the connection string must be specified when data source type is ODPS.
400 MissingParam.ConnectionStr.Property You must specify property %s required by the data source connection string. The data source connection str required property missing.
400 Invalid.DataSource.DataSourceTypeNotExist The data source type %s does not exist. The dataSource type %s are not exist.
403 Invalid.Tenant.UserIsNotProjectOwnerOrAdmin The user is not a project administrator or owner. The user is not a project administrator or owner.
403 Invalid.Tenant.UserNotInTenant The user is not in tenant. The user is not in tenant.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.