SetDataSourceShare

更新时间:
复制 MD 格式

Shares a data source to a specific DataWorks workspace or a specific user.

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 call the ListProjects operation to query the ID.

10000

DatasourceName

string

Yes

The name of the data source that you want to share.

mysql_name

EnvType

string

No

The environment in which the data source is used. Valid values:

  • 0: development environment

  • 1: production environment

1

ProjectPermissions

string

No

The DataWorks workspace to which you want to share the data source. If you configure this parameter, all members of the specified DataWorks workspace can view and use the data source. The value of this parameter is a JSON array. Example: [{"projectId":1000,"permission":"WRITE","sharedName":"PX_DATAHUB1.shared_name"}], Parameter description:

  • projectId: the ID of the DataWorks workspace to which you want to share the data source.

  • 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 that you want to share.

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

UserPermissions

string

No

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

  • projectId: the ID of the DataWorks workspace. If you configure the UserPermissions parameter, the specified user can view or use the data source only in the specified DataWorks workspace.

  • userId: the ID of the user to whom you want to share the data source.

  • 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 that you want to share.

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.

[{"projectId":10000,"users":[{"userId":"276184575345452131","permission":"WRITE"}],"sharedName":"PX_DATAHUB1.shared_name"}]

Response elements

Element

Type

Description

Example

object

Success

boolean

Indicates whether the request was successful. Valid values:

  • true

  • false

true

RequestId

string

The request ID.

0000-ABCD-EFG

Data

object

The information about the sharing operation.

Status

string

Indicates whether the data source was shared. Valid values:

  • success.

  • fail. You can view the value of the Message parameter to identify the cause of the failure.

success

Message

string

The reason why the data source failed to be shared. If the data source is successfully shared, the value of this parameter is an empty string.

datasource is wrong

Examples

Success response

JSON format

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

Error codes

HTTP status code

Error code

Error message

Description

400 Invalid.DI.Parameter The parameter is invalid.
500 InternalError.DI.Parameter A DI internal error occurred.
403 Forbidden.DI.NoPrivilege No access.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.