文档

CreateDataSource - 创建数据源

更新时间:

该接口用于创建DataWorks数据源。

调试

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

授权信息

下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:

  • 操作:是指具体的权限点。
  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。
  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:
    • 对于必选的资源类型,用背景高亮的方式表示。
    • 对于不支持资源级授权的操作,用全部资源表示。
  • 条件关键字:是指云产品自身定义的条件关键字。
  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。
操作访问级别资源类型条件关键字关联操作
dataworks:*Write
  • 全部资源
    *

请求参数

名称类型必填描述示例值
ProjectIdlong

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

1
Namestring

数据源的名称。

abc
Descriptionstring

数据源的描述信息。

abc
DataSourceTypestring

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

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

数据源的子类型。使用如下:

  • 当 DataSourceType 参数配置为 RDS 时,SubType 参数生效。
  • 如果 DataSourceType 参数配置为 RDS,SubType 参数支持配置为 mysql、sqlserver 或 postgresql。
mysql
EnvTypeinteger

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

1
Contentstring

数据源的详细信息。部分常用数据源样例如下:

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

返回参数

名称类型描述示例值
object

返回结果。

HttpStatusCodestring

请求返回码。

200
Datalong

数据源 ID。

123
RequestIdstring

请求 ID。

0bc141151593763****
Successboolean

请求是否成功。

true

示例

正常返回示例

JSON格式

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

错误码

HTTP status code错误码错误信息描述
400Invalid.Tenant.ConnectionNotExistsThe connection does not exist.数据源不存在。
400Invalid.Tenant.ProjectNotExistsThe project does not exist.项目不存在。
400Invalid.Tenant.UserNotInProjectThe user is not in the project.用户不在项目中。
400ConnectionAlreadyExistThe connection with envType %s and name %s already exists.连接串名称重复
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.数据源类型暂不支持
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.数据源连接串信息必填属性缺失
400Invalid.DataSource.DataSourceTypeNotExistThe data source type %s does not exist.数据源类型不存在。
403Invalid.Tenant.UserIsNotProjectOwnerOrAdminThe user is not a project administrator or owner.用户不是项目负责人或者项目管理员。
403Invalid.Tenant.UserNotInTenantThe user is not in tenant.用户不在租户中。

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

变更历史

变更时间变更内容概要操作
2022-07-18OpenAPI 描述信息更新、OpenAPI 错误码发生变更看变更集
变更项变更内容
API 描述OpenAPI 描述信息更新
错误码OpenAPI 错误码发生变更
    删除错误码:400
    删除错误码:403
  • 本页导读 (1)