調用DsgDesensPlanAddOrUpdate介面建立或編輯資料脫敏規則。
調試
您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。
請求參數
|
名稱 |
類型 |
是否必選 |
樣本值 |
描述 |
| Action | String | 是 | DsgDesensPlanAddOrUpdate | 系統規定參數。取值:DsgDesensPlanAddOrUpdate。 |
| DesensRules | Array | 是 | 需要新增或編輯的脫敏規則集合。 |
|
| Id | Integer | 否 | 123 | 脫敏規則ID。您可調用DsgDesensPlanQueryList介面查詢。 |
| DataType | String | 是 | phone | 敏感欄位類型。 |
| RuleName | String | 是 | phone_hash | 脫敏規則名稱。 |
| Status | Integer | 否 | 1 | 脫敏規則的生效狀態。取值如下:
|
| SceneIds | Array of Integer | 是 | 123 | 二級脫敏情境ID。此處輸入的二級脫敏情境需要未配置DataType參數指定的敏感欄位類型脫敏規則。您可調用DsgSceneQuerySceneListByName查詢脫敏情境ID。 |
| Owner | String | 是 | test_user | 脫敏規則的負責人。 |
| CheckWatermark | Boolean | 否 | true | 是否添加浮水印。取值如下:
|
| DesensPlan | Object | 是 | 脫敏規則。 |
|
| DesensPlanType | String | 是 | hash | 脫敏規則中配置的脫敏方式。取值如下:
|
| ExtParam | Map | 否 | { "algo": "MD5", "salt":6 } | 脫敏規則參數。 |
| Any | 否 | { "algo": "MD5", "salt":6 } | 脫敏規則參數配置,根據您要配置的脫敏規則添加不同參數,具體內容請參見下文樣本。 |
ExtParam為動態參數,對於不同脫敏規則配置不同,參考樣本如下:
雜湊:
{
"algo": "MD5",
"salt": 6
}
假名:
{
"charset": "Aa",
"salt": 6
}
掩蓋:
{
"before": 3,
"after": 4
}
自訂掩蓋:
{
"separatorList": [
{
"desens": true,
"left": 3
},
{
"desens": false,
"left": 6
},
{
"desens": true,
"left": -99
}
]
}
樣本值字元替換:
{
"library": "test_library",
"position": 3
}
固定值字元替換:
{
"replace": "repData",
"position": 3
}
隨機字元替換:
{
"replace": "repData"
}
自訂字元替換:
{
"separatorList": [
{
"desensParam": {
"replace": "repData"
},
"left": 3
},
{
"desensParam": {
"library": "test_library"
},
"left": 6
},
{
"desensParam": {
},
"left": 99
}
]
}
區間變換:
{
"intervalselects": [
{
"desens": "1",
"interval": [
"1",
"100"
]
}
]
}
取整:
{
"point":3
}
置空:
{}
具體支援的脫敏方式及相關規則,可參考DsgQueryDefaultTemplates介面查詢。
返回資料
名稱 |
類型 |
樣本值 |
描述 |
| Success | Boolean | true | 調用是否成功。取值如下: true:調用成功。 false:調用失敗。 |
| ErrorCode | String | 1029030003 | 錯誤碼。 |
| ErrorMessage | String | param error | 錯誤資訊。 |
| HttpStatusCode | Integer | 400 | HTTP狀態代碼。 |
| Data | Boolean | true | 新增或編輯的執行結果。 |
| RequestId | String | 102400001 | 請求的ID。用於定位日誌,排查問題。 |
樣本
請求樣本
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 }"}}}]
&公用請求參數
正常返回樣本
XML格式
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格式
HTTP/1.1 200 OK
Content-Type:application/json
{
"Success" : true,
"ErrorCode" : "1029030003",
"ErrorMessage" : "param error",
"HttpStatusCode" : 400,
"Data" : true,
"RequestId" : "102400001"
}
錯誤碼
|
HttpCode |
錯誤碼 |
錯誤資訊 |
描述 |
| 400 | PARAMS.ERROR | param error. | 參數錯誤。 |
| 400 | DESENSPLAN.DATATYPE.ERROR | Sensitive type already has a desensitization rule. | 敏感類型已經配置脫敏規則。 |
| 400 | DESENSPLAN.DATATYPENOTEXIST.ERROR | Sensitive type not exist. | 敏感類型不存在。 |
| 400 | DESENSPLAN.ID.ERROR | Desensitization rule ID does not exist. | 脫敏規則ID不存在。 |
| 400 | DESENSPLAN.PAGESIZE.ERROR | Page size is too large, maximum of 100. | 頁大小超限,最大為100。 |
| 400 | DESENSPLAN.PARAM.ERROR | Desensitization rule parameter error. | 歐敏規則參數錯誤。 |
| 400 | DESENSPLAN.SCENECODE.ERROR | Scene code does not exist. | 情境碼不存在。 |
| 400 | DESENSPLAN.SCENEID.ERROR | Scene ID does not exist. | 情境ID不存在。 |
| 400 | DESENSPLAN.SCENEIDLEVEL.ERROR | The scene is not a secondary scene. | 情境不是二級情境。 |
| 400 | DESENSPLAN.SIZE.ERROR | The number of desens plan exceeds the limit. | 脫敏規則數量超限。 |
| 403 | PERMISSION.DENIED.ERROR | Permission denied | 許可權不足。 |
| 500 | UNKNOWN.ERROR | unknown error. | 未知錯誤。 |
訪問錯誤中心查看更多錯誤碼。