Adds a data source to 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. |
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.
|
EnvType | Integer | Yes | 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. |
Content | String | Yes | {"database":"dbname","instanceName":"instancename","password":"password","rdsOwnerId":"123","username":"username"} | 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. |
Data | Long | 123 | The data source ID. |
RequestId | String | 0bc141151593763**** | The request ID. |
Success | Boolean | true | Indicates whether the request was successful. |
Examples
Sample requests
http(s)://[Endpoint]/?Action=CreateDataSource
&ProjectId=1
&Name=abc
&Description=abc
&DataSourceType=rds
&SubType=mysql
&EnvType=1
&Content={"database":"dbname","instanceName":"instancename","password":"password","rdsOwnerId":"123","username":"username"}
&Common request parameters
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateDataSourceResponse>
<HttpStatusCode>200</HttpStatusCode>
<Data>123</Data>
<RequestId>0bc141151593763****</RequestId>
<Success>true</Success>
</CreateDataSourceResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"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 specified data source does not exist. |
400 | Invalid.Tenant.ProjectNotExists | The project does not exist. | The specified workspace does not exist. |
400 | Invalid.Tenant.UserNotInProject | The user is not in the project. | The user is not added to the workspace. |
400 | ConnectionAlreadyExist | The connection with envType %s and name %s already exists. | The connection string already exists. |
400 | DataSource.CheckRamRoleFailure | Failed to check the RAM role. AccountId %s. roleArn %s. | 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 connection string properties of the data source do not match the specified rules. |
400 | Invalid.DataSource.DataSourceTypeNotSupport | The dataSourceType %s and subType %s are not supported. | The data source type is not supported. |
400 | MissingParam.ConnectionStr.Property | You must specify property %s required by the data source connection string. | 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 specified data source type does not exist. |
403 | Invalid.Tenant.UserIsNotProjectOwnerOrAdmin | The user is not a project administrator or owner. | The user is not the workspace owner or administrator. |
403 | Invalid.Tenant.UserNotInTenant | The user is not in tenant. | The user does not belong to the tenant. |
For a list of error codes, see Service error codes.