Creates a data source in DataWorks.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | CreateDataSource |
The operation that you want to perform. Set the value to CreateDataSource. |
RegionId | String | Yes | cn-shanghai |
The region ID of the data source. For example, the ID of the China (Shanghai) region is cn-shanghai, and the ID of the China (Zhangjiakou) region is cn-zhangjiakou. The system determines the value of this parameter based on the endpoint that is used to call the operation. |
ProjectId | Long | Yes | 1 |
The ID of the DataWorks workspace to which the data source belongs. You can call the ListProjects operation to obtain the ID. |
Name | String | Yes | abc |
The name of the data source. |
Description | String | No | abc |
The description of the data source. |
DataSourceType | String | Yes | rds |
The type of the data source. Valid values:
|
SubType | String | No | mysql |
The subtype of the data source. This parameter takes effect only when the DataSourceType parameter is set to mysql. If the DataSourceType parameter is set to mysql, this parameter can be set to rds sqlserver, or postgresql. |
EnvType | Integer | Yes | 1 |
The environment in which the data source is used. Valid values: 0 and 1. 0 indicates the development environment. 1 indicates the production environment. |
Content | String | Yes | null |
The details of the data source. Examples of details of some common data sources:
|
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
HttpStatusCode | String | 200 |
The HTTP status code returned. |
Data | Long | 123 |
The ID of the data source. |
RequestId | String | 0bc141151593763**** |
The ID of the request. |
Success | Boolean | true |
Indicates whether the request is successful. |
Examples
Sample requests
http(s)://[Endpoint]/?Action=CreateDataSource
&Content={"database":"dbname","instanceName":"instancename","password":"password","rdsOwnerId":"123","username":"username"}
&DataSourceType=rds
&EnvType=1
&Name=abc
&ProjectId=1
&RegionId=cn-shanghai
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<RequestId>0bc141151593763****</RequestId>
<HttpStatusCode>200</HttpStatusCode>
<Data>123</Data>
<Success>true</Success>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "0bc141151593763****",
"HttpStatusCode" : 200,
"Data" : 123,
"Success" : true
}
Error codes
HttpCode | 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. |
400 | ConnectionAlreadyExist | The connection with envType %s and name %s already exists. | The error message returned because the connection string already exists. |
400 | DataSource.CheckRamRoleFailure | Failed to check the RAM role. AccountId %s. roleArn %s. | The error message returned because the permissions on the data source failed to be verified. |
400 | DataSource.ConnectionStrProperty.PatternNotMatch | The pattern value %s is invalid. The correct pattern is %s. | The error message returned because the connection string property of the data source does not match the specified rules. |
400 | Invalid.DataSource.DataSourceTypeNotSupport | The dataSourceType %s and subType %s are not supported. | The error message returned because the data source type is not supported. |
400 | MissingParam.ConnectionStr.Property | You must specify property %s required by the data source connection string. | The error message returned because the required properties of the connection string of the data source are not specified. |
400 | Invalid.DataSource.DataSourceTypeNotExist | The data source type %s does not exist. | The error message returned because the specified data source type does not exist. |
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 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, visit the API Error Center.