Shares a data source to a specified DataWorks workspace or a specified user. After you call this operation, all members of the specified DataWorks workspace or the specified user can view and use the data source.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes SetDataSourceShare

The operation that you want to perform.

DatasourceName String Yes mysql_name

The name of the data source to be shared.

EnvType String Yes 1

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

  • 0: development environment
  • 1: production environment
ProjectId Long Yes 10000

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

RegionId String Yes cn-shanghai

The ID of the region in which the data source resides. For example, the ID of the China (Shanghai) region is cn-shanghai, and that of the China (Zhangjiakou) region is cn-zhangjiakou. The system automatically determines the value of this parameter based on the endpoint used to call the operation.

ProjectPermissions String No [{"projectId":1000,"permission":"WRITE","sharedName":"PX_DATAHUB1.shared_name"}]

The DataWorks workspace to which the data source is to be shared. If you set this parameter, all members of the specified DataWorks workspace can view and use the data source. The value must be a JSON array. Example: {"projectId":1000,"permission":"WRITE","sharedName":"PX_DATAHUB1.shared_name"}.

Field description:

  • projectId: the ID of the DataWorks workspace to which the data source is to be shared.
  • permission: the mode in which the data source is shared. Valid values: READ and WRITE. The value READ indicates that all members of the specified workspace can read data from the data source, but cannot modify the data. The value WRITE indicates that all members of the specified workspace can modify the data in the data source.
  • sharedName: the name of the data source to be shared.
UserPermissions String No [{"projectId":10000,"users":[{"userId":"276184575345452131","permission":"WRITE"}],"sharedName":"PX_DATAHUB1.shared_name"}]

The user to whom the data source is to be shared. If you set this parameter, the specified user can view or use the data source. The value must be a JSON array. Example: {"projectId":10000,"users":[{"userId":"276184575345452131","permission":"WRITE"},"sharedName":"PX_DATAHUB1.shared_name"}].

Field description:

  • projectId: the ID of the DataWorks workspace. If you set the UserPermissions parameter, the specified user can view or use the data source only in this specified DataWorks workspace.
  • userId: the ID of the user to whom the data source is to be shared.
  • permission: the mode in which the data source is shared. Valid values: READ and WRITE. The value READ indicates that the specified user can read data from the data source, but cannot modify the data. The value WRITE indicates that the specified user can modify the data in the data source.
  • sharedName: the name of the data source to be shared.

If the ProjectPermissions and UserPermissions parameters are both left empty, the specified data source is not shared to any DataWorks workspace or user. If neither of the parameters is left empty, both parameters take effect.

Response parameters

Parameter Type Example Description
Data Struct

The information about the sharing operation.

Message String datasource is wrong

The reason why the data source failed to be shared. If the data source was shared, this parameter is left empty.

Status String success

Indicates whether the data source was shared. Valid values:

  • success: The data source was shared.
  • fail: The data source failed to be shared. You can troubleshoot issues based on the Message parameter.
RequestId String 0000-ABCD-EFG

The ID of the request. You can locate logs and troubleshoot issues based on the ID.

Success Boolean true

Indicates whether the request was successful. Valid values:

  • true: The request was successful.
  • false: The request failed.

Examples

Sample requests

http(s)://[Endpoint]/?Action=SetDataSourceShare
&DatasourceName=mysql_name
&EnvType=1
&ProjectId=10000
&RegionId=cn-shanghai
&<Common request parameters>

Sample success responses

XML format

<RequestId>0000-ABCD-EFG    </RequestId>
<Data>
    <Status>success</Status>
    <Message>datasource is wrong</Message>
</Data>
<Success>true</Success>

JSON format

{
    "RequestId": "0000-ABCD-EFG",
    "Data": {
        "Status": "success",
        "Message": "datasource is wrong"
    },
    "Success": true
}

Error codes

Http status code Error code Error message Description
403 Forbidden.DI.NoPrivilege No access. The error message returned because you do not have the required permissions.
500 InternalError.DI.Parameter A DI internal error occurred. The error message returned because an internal error in Data Integration occurred.
400 Invalid.DI.Parameter The parameter is invalid. The error code returned because one or more parameters are invalid.

For a list of error codes, visit the API Error Center.