Adds or modifies a data masking rule.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | DsgDesensPlanAddOrUpdate | The operation that you want to perform. Set the value to DsgDesensPlanAddOrUpdate. |
DesensRules | Array | Yes | A collection of data masking rules that you want to add or modify. | |
Id | Integer | No | 123 | The ID of the data masking rule. You can call the DsgDesensPlanQueryList operation to query the ID of the data masking rule. |
DataType | String | Yes | phone | The sensitive field type. |
RuleName | String | Yes | phone_hash | The name of the data masking rule. |
Status | Integer | No | 1 | The status of the data masking rule. Valid values:
|
SceneIds | Array of Integer | Yes | 123 | The ID of the level-2 data masking scenario. Make sure that the data masking rule in which the sensitive field type determined by the DataType parameter is specified is not configured for the level-2 data masking scenario that you use. You can call the DsgSceneQuerySceneListByName operation to query the ID of the data masking scenario. |
Owner | String | Yes | test_user | The owner of the data masking rule. |
CheckWatermark | Boolean | No | true | Specifies whether to add a watermark. Valid values:
|
DesensPlan | Object | Yes | The data masking rule. | |
DesensPlanType | String | Yes | hash | The masking method configured in the data masking rule. Valid values:
|
ExtParam | Map | No | { "algo": "MD5", "salt":6 } | The parameters for the data masking rule. |
Any | No | { "algo": "MD5", "salt":6 } | The parameter configurations of the data masking rule. You can add different parameters based on the data masking rule that you want to configure. For more information, see the following example. |
The ExtParam parameter is a dynamic parameter. The value of the ExtParam parameter varies based on the data masking rule. The following example shows how to configure the parameters:
Hash:
{
"algo": "MD5",
"salt": 6
}
Pseudonym:
{
"charset": "Aa",
"salt": 6
}
Mask:
{
"before": 3,
"after": 4
}
Custom mask:
{
"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
}
]
}
Range change:
{
"intervalselects": [
{
"desens": "1",
"interval": [
"1",
"100"
]
}
]
}
Rounding:
{
"point":3
}
Leave empty:
{}
You can call the DsgQueryDefaultTemplates operation to query the supported data masking methods and related rules.
Response parameters
Parameter | Type | Example | Description |
Success | Boolean | true | Indicates whether the request was successful. Valid values: true false |
ErrorCode | String | 1029030003 | The error code. |
ErrorMessage | String | param error | The error message. |
HttpStatusCode | Integer | 400 | The HTTP status code. |
Data | Boolean | true | The execution result of adding or modifying a data masking rule. |
RequestId | String | 102400001 | The request ID. You can use the ID to locate logs and troubleshoot issues. |
Examples
Sample requests
http(s)://[Endpoint]/?Action=DsgDesensPlanAddOrUpdate
&DesensRules=[{"id":123,"DataType":"phone","RuleName":"phone_hash","Status":1,"SceneIds":[123],"Owner":"test_user","CheckWatermark":true,"DesensPlan":{"DesensPlanType":"hash","ExtParam":{"key":"{ \"algo\": \"MD5\", \"salt\":6 }"}}}]
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<DsgDesensPlanAddOrUpdateResponse>
<Success>true</Success>
<ErrorCode>1029030003</ErrorCode>
<ErrorMessage>param error</ErrorMessage>
<HttpStatusCode>400</HttpStatusCode>
<Data>true</Data>
<RequestId>102400001</RequestId>
</DsgDesensPlanAddOrUpdateResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"Success" : true,
"ErrorCode" : "1029030003",
"ErrorMessage" : "param error",
"HttpStatusCode" : 400,
"Data" : true,
"RequestId" : "102400001"
}
Error codes
HttpCode | Error code | Error message | Description |
400 | PARAMS.ERROR | param error. | The values specified for one or more parameters are invalid. |
400 | DESENSPLAN.DATATYPE.ERROR | Sensitive type already has a desensitization rule. | The sensitive field type has been specified in the data masking rule. |
400 | DESENSPLAN.DATATYPENOTEXIST.ERROR | Sensitive type not exist. | The sensitive field type does not exist. |
400 | DESENSPLAN.ID.ERROR | Desensitization rule ID does not exist. | The ID of the data masking rule does not exist. |
400 | DESENSPLAN.PAGESIZE.ERROR | Page size is too large, maximum of 100. | The number of entries per page exceeds the upper limit. The maximum number of entries per page is 100. |
400 | DESENSPLAN.PARAM.ERROR | Desensitization rule parameter error. | The values specified for one or more data masking rule parameters are invalid. |
400 | DESENSPLAN.SCENECODE.ERROR | Scene code does not exist. | The scenario code does not exist. |
400 | DESENSPLAN.SCENEID.ERROR | Scene ID does not exist. | The scenario ID does not exist. |
400 | DESENSPLAN.SCENEIDLEVEL.ERROR | The scene is not a secondary scene. | The data masking scenario is not a level-2 data masking scenario. |
400 | DESENSPLAN.SIZE.ERROR | The number of desens plan exceeds the limit. | The number of data masking rules exceeds the upper limit. |
403 | PERMISSION.DENIED.ERROR | Permission denied | You are not authorized to perform this operation. |
500 | UNKNOWN.ERROR | unknown error. | An unknown error has occurred. |
For a list of error codes, see Service error codes.