DsgDesensPlanAddOrUpdate

Updated at:

Creates or updates a data masking rule.

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

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

dataworks:DsgDesensPlanAddOrUpdate

list

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

DesensRules

array<object>

Yes

The collection of data masking rules to create or update.

array<object>

No

The data masking rule information.

Id

integer

No

The ID of the data masking rule. You can call the DsgDesensPlanQueryList operation to query the ID.

123

DataType

string

No

The sensitive field type. Call the DsgQueryDefaultTemplates operation to query the available types for the current tenant, obtain the value from Data[].DataType, and select a supported masking method in DesensPlanTemplate of the same record.

If the required type is not returned, verify the classification and grading template and sensitive fields of the current tenant. To configure or import a template, go to Data Security Guard > Rule Configuration > Data Classification and Grading in the DataWorks console. To add a sensitive field to an existing template, call the QueryDefaultTemplate operation to view the default template, and then call the AddRecognizeRule operation. After the configuration is complete, query the available masking types again.

phone

RuleName

string

Yes

The name of the data masking rule.

phone_hash

Status

integer

No

The effective status of the data masking rule. Valid values:

  • 0: Inactive.

  • 1: Active.

1

SceneIds

array

Yes

The secondary data masking scenarios.

integer

No

The ID of the secondary data masking scenario. The secondary data masking scenario specified here must not have a data masking rule configured for the sensitive field type specified by the DataType parameter. You can call the DsgSceneQuerySceneListByName operation to query the ID of the data masking scenario.

123

Owner

string

Yes

The owner of the data masking rule.

test_user

CheckWatermark

boolean

No

Specifies whether to add a watermark. Valid values:

  • true: Yes.

  • false: No.

true

DesensPlan

object

Yes

The data masking plan.

DesensPlanType

string

Yes

The masking method configured in the data masking rule. Valid values:

  • hash: Hashing.

  • mapping: Pseudonymization.

  • mask: Masking.

  • charreplacement: Character replacement.

  • intervalselect: Interval transformation.

  • decimalpoint: Rounding.

  • emptydesens: Nullification.

hash

ExtParam

object

No

The parameters of the data masking rule.

any

No

The parameter settings of the data masking rule. Add different parameters based on the data masking rule you want to configure. For more information, see the following examples.

{ "algo": "MD5", "salt":6 }

emptyNotDesens

boolean

No

Specifies whether to keep null values unmasked. A value of true indicates that null values are not masked. A value of false indicates that null values are processed according to the rule.

columns

array<object>

No

The list of columns associated with the data masking rule.

object

No

dbType

string

Yes

The type of the data source.

ODPS.ODPS

project

string

Yes

The name of the workspace.

test_dev

table

string

Yes

The name of the table.

test_table_dev

column

string

Yes

The name of the column.

test_col_dev

ExtParam is a dynamic parameter and varies based on the data masking rule. The following examples are for reference:

Hashing:
{
    "algo": "MD5",
    "salt": 6
}
Pseudonymization:
{
    "charset": "Aa",
    "salt": 6
}
Masking:
{
    "before": 3,
    "after": 4
}
Custom masking:
{
    "separatorList": [
        {
            "desens": true,
            "left": 3
        },
        {
            "desens": false,
            "left": 6
        },
        {
            "desens": true,
            "left": -99
        }
    ]
}
Sample value character replacement:
{
    "library": "test_library",
    "position": 3
}
Fixed value character replacement:
{
    "replace": "repData",
    "position": 3
}
Random character replacement:
{
    "replace": "repData"
}
Custom character replacement:
{
    "separatorList": [
        {
            "desensParam": {
                "replace": "repData"
            },
            "left": 3
        },
        {
            "desensParam": {
                "library": "test_library"
            },
            "left": 6
        },
        {
            "desensParam": {
            },
            "left": 99
        }
    ]
}
Interval transformation:
{
    "intervalselects": [
        {
            "desens": "1",
            "interval": [
                "1",
                "100"
            ]
        }
    ]
}
Rounding:
{
"point":3
}
Nullification:
{}

For more information about the supported masking methods and related rules, call the DsgQueryDefaultTemplates operation.

Response elements

Element

Type

Description

Example

object

OpenApiResultModel

Success

boolean

Indicates whether the call was successful. Valid values:

  • true: The call was successful.

  • false: The call failed.

true

ErrorCode

string

The error code.

1029030003

ErrorMessage

string

The error message.

param error

HttpStatusCode

integer

The HTTP status code.

400

Data

boolean

The execution result of the creation or update operation.

true

RequestId

string

The ID of the request. You can use the ID to locate logs and troubleshoot issues.

102400001

Examples

Success response

JSON format

{
  "Success": true,
  "ErrorCode": "1029030003",
  "ErrorMessage": "param error",
  "HttpStatusCode": 400,
  "Data": true,
  "RequestId": "102400001"
}

Error codes

HTTP status code

Error code

Error message

Description

400 PARAMS.ERROR param error. The parameter is invalid.
400 DESENSPLAN.DATATYPE.ERROR Sensitive type already has a desensitization rule. Desensitization rules have been configured for sensitive types.
400 DESENSPLAN.DATATYPENOTEXIST.ERROR Sensitive type not exist. The sensitive type does not exist.
400 DESENSPLAN.ID.ERROR Desensitization rule ID does not exist. The desensitization rule ID does not exist.
400 DESENSPLAN.PAGESIZE.ERROR Page size is too large, maximum of 100. Page size limit, up to 100
400 DESENSPLAN.PARAM.ERROR Desensitization rule parameter error. The desensitization rule parameter is incorrect.
400 DESENSPLAN.SCENECODE.ERROR Scene code does not exist. Scene code does not exist
400 DESENSPLAN.SCENEID.ERROR Scene ID does not exist. Scene ID does not exist.
400 DESENSPLAN.SCENEIDLEVEL.ERROR The scene is not a secondary scene. The scene is not a secondary scene.
400 DESENSPLAN.SIZE.ERROR The number of desens plan exceeds the limit. The number of desensitization rules exceeded the limit.
500 UNKNOWN.ERROR unknown error. Unknown error.
403 PERMISSION.DENIED.ERROR Permission denied Insufficient permissions.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.