更新动态数据脱敏策略
功能介绍
更新动态数据脱敏策略。
调用方法
请参见如何调用API。
URI
PUT /v1/{project_id}/security/masking/dynamic/policies/{id}
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
项目ID,获取方法请参见项目ID和账号ID。 |
id |
是 |
String |
脱敏策略id |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
workspace |
是 |
String |
工作空间ID,获取方法请参见实例ID和工作空间ID。 |
X-Auth-Token |
是 |
String |
IAM Token,通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)使用Token认证时必选。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
name |
是 |
String |
策略名称。英文和汉字开头, 支持英文、汉字、数字、下划线, 2-64字符。 |
datasource_type |
是 |
String |
数据源类型
|
cluster_id |
是 |
String |
集群id。请于集群管理页面查看集群ID信息。当数据源类型为DLI时,该参数需要填写为DLI。 |
cluster_name |
是 |
String |
集群名称。请于集群管理页面查看集群名称信息。当数据源类型为DLI时,该参数需要填写为DLI。 |
database_name |
是 |
String |
数据库名称。获取方法请参见获取数据源中的表。 |
table_id |
否 |
String |
数据表id,获取方法请参见获取数据源中的表。 |
table_name |
是 |
String |
数据表名称, 获取方法请参见获取数据源中的表。 |
user_groups |
否 |
String |
用户组列表,用户组名称逗号分隔(非必填项,但用户、用户组必须二选其一进行配置)。例如:"userGroup1,userGroup2"。 |
users |
否 |
String |
用户列表,用户名称逗号分隔(非必填项,但用户、用户组必须二选其一进行配置),例如:"user1,user2"。 |
conn_name |
是 |
String |
数据连接名称,获取方法请参见查询数据连接列表。 |
conn_id |
是 |
String |
数据连接id,获取方法请参见查询数据连接列表。 |
schema_name |
否 |
String |
DWS数据源的模式名称。 |
policy_list |
是 |
Array of DynamicMaskingPolicyUpdate objects |
动态数据脱敏策略列表。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
column_name |
是 |
String |
数据表中的字段名称。 |
column_type |
是 |
String |
数据表中字段的数据类型。 |
algorithm_type |
否 |
String |
动态脱敏规则参数介绍,具体请参考用户指南手册中的“动态脱敏规则介绍”章节。 HIVE数据源动态脱敏算法
DWS数据源动态脱敏算法
DLI数据源动态脱敏算法
|
algorithm_detail |
否 |
String |
动态脱敏策略算法详情。 |
algorithm_detail_dto |
否 |
AlgorithmDetailDTO object |
动态脱敏策略算法详情 |
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
id |
String |
策略id。 |
name |
String |
策略名称。英文和汉字开头, 支持英文、汉字、数字、下划线, 2-64字符。 |
datasource_type |
String |
数据源类型
|
cluster_id |
String |
集群id。请于集群管理页面查看集群ID信息。当数据源类型为DLI时,该参数需要填写为DLI。 |
cluster_name |
String |
集群名称。请于集群管理页面查看集群名称信息。当数据源类型为DLI时,该参数需要填写为DLI。 |
database_name |
String |
数据库名称。获取方法请参见获取数据源中的表。 |
table_id |
String |
数据表id,获取方法请参见获取数据源中的表。 |
table_name |
String |
数据表名称, 获取方法请参见获取数据源中的表。 |
user_groups |
String |
用户组列表,用户组名称逗号分隔(非必填项,但用户、用户组必须二选其一进行配置)。例如:"userGroup1,userGroup2"。 |
users |
String |
用户列表,用户名称逗号分隔(非必填项,但用户、用户组必须二选其一进行配置),例如:"user1,user2"。 |
conn_name |
String |
数据连接名称,获取方法请参见查询数据连接列表。 |
conn_id |
String |
数据连接id,获取方法请参见查询数据连接列表。 |
sync_status |
String |
同步状态:
|
sync_msg |
String |
策略同步信息。 |
sync_log |
String |
同步运行日志, 格式为 字段同步信息+换行符。 |
create_time |
Long |
策略创建时间。 |
create_user |
String |
策略创建者。 |
update_time |
Long |
策略更新时间。 |
update_user |
String |
策略更新者。 |
schema_name |
String |
DWS数据源的模式名称。 |
policy_list |
Array of DynamicMaskingPolicy objects |
动态数据脱敏策略列表。 |
参数 |
参数类型 |
描述 |
---|---|---|
id |
String |
字段脱敏策略id。 |
policy_set_id |
String |
动态脱敏策略id。 |
column_name |
String |
数据表中的字段名称。 |
column_type |
String |
数据表中字段的数据类型。 |
algorithm_type |
String |
动态脱敏规则参数介绍,具体请参考用户指南手册中的“动态脱敏规则介绍”章节。 HIVE数据源动态脱敏算法
DWS数据源动态脱敏算法
DLI数据源动态脱敏算法
|
sync_status |
String |
同步状态:
|
algorithm_detail |
String |
动态脱敏策略算法详情。 |
algorithm_detail_dto |
AlgorithmDetailDTO object |
动态脱敏策略算法详情 |
参数 |
参数类型 |
描述 |
---|---|---|
start |
Integer |
开始位数,该值需要大于0且小于end值。 |
end |
Integer |
结束位数,该值需要大于或等于start值。 |
int_target |
Integer |
数值类型。 |
string_target |
String |
字符串类型。可输入参数为"*"或者"#"。 |
状态码: 400
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误码。 |
error_msg |
String |
错误描述。 |
请求示例
- 更新HIVE数据源动态脱敏策略
/v1/0833a5737480d53b2f25c010dc1a7b88/security/masking/dynamic/policies/f52f0f7fe2074421e473b88cdb7752ab { "name" : "OpenAPI_HIVE_test", "datasource_type" : "HIVE", "cluster_id" : "dc425074-26b3-479c-9e2f-b103c0cdd90f", "cluster_name" : "mrs_3x_autotest_do_not_del", "database_name" : "bigdatatest", "table_name" : "chuan", "table_id" : "NativeTable-ae55cb5c44be4119b8958a3ba5d9a71f-bigdatatest-chuan", "user_groups" : "DataArts User", "users" : "", "conn_name" : "hive_xxxx_0520", "conn_id" : "ae55cb5c44be4119b8958a3ba5d9a71f", "policy_list" : [ { "column_name" : "rr", "column_type" : "string", "algorithm_type" : "MASK_SHOW_FIRST_4" } ] }
- 更新DWS数据源动态脱敏策略
/v1/0833a5737480d53b2f25c010dc1a7b88/security/masking/dynamic/policies/6c21c00bbabf1941eebbc2d5a586b2fa { "name" : "OpenAPI_DWS_test", "datasource_type" : "DWS", "cluster_id" : "c94a9133-ef65-47ad-9483-bfa8c5eaa101", "cluster_name" : "dws_ssl_xxxx_nomodify", "database_name" : "gaussdb", "table_name" : "all_column", "table_id" : "NativeTable-e2f6c44100654778aee017f8ad9e3ac9-gaussdb-public-all_column", "user_groups" : "DataArts_PDP5_NoPrivilleage", "users" : "autotest_tics", "conn_name" : "dws_0430", "conn_id" : "e2f6c44100654778aee017f8ad9e3ac9", "policy_list" : [ { "column_name" : "avarchar", "column_type" : "varchar", "algorithm_type" : "DWS_FRONT_KEEP", "algorithm_detail_dto" : null } ], "schema_name" : "public" }
- 更新DLI数据源动态脱敏策略
/v1/0833a5737480d53b2f25c010dc1a7b88/security/masking/dynamic/policies/62355f975ff8a2943e6ac8992d0951e7 { "name" : "OpenAPI_DLI_xxxx", "datasource_type" : "DLI", "cluster_id" : "DLI", "cluster_name" : "DLI", "database_name" : "bi", "table_name" : "ab", "table_id" : "NativeTable-619d52a0e6954aa68844f5f010e06ef8-bi-ab", "user_groups" : "", "users" : "", "conn_name" : "xxxx_dli_link", "conn_id" : "619d52a0e6954aa68844f5f010e06ef8", "policy_list" : [ { "column_name" : "name1", "column_type" : "string", "algorithm_type" : "MASK_HASH" } ] }
响应示例
状态码: 200
OK
{ "name" : "OpenAPI_HIVE_test", "datasource_type" : "HIVE", "cluster_id" : "dc425074-26b3-479c-9e2f-b103c0cdd90f", "cluster_name" : "mrs_3x_xxxx_do_not_del", "database_name" : "bigdatatest", "table_name" : "chuan", "table_id" : "NativeTable-ae55cb5c44be4119b8958a3ba5d9a71f-bigdatatest-chuan", "user_groups" : "DataArts User", "users" : "", "conn_name" : "hive_xxxx_0520", "conn_id" : "ae55cb5c44be4119b8958a3ba5d9a71f", "policy_list" : [ { "column_name" : "rr", "column_type" : "string", "algorithm_type" : "MASK_NULL" } ] }
SDK代码示例
SDK代码示例如下。
- 更新HIVE数据源动态脱敏策略
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.dataartsstudio.v1.region.DataArtsStudioRegion; import com.huaweicloud.sdk.dataartsstudio.v1.*; import com.huaweicloud.sdk.dataartsstudio.v1.model.*; import java.util.List; import java.util.ArrayList; public class UpdateSecurityDynamicMaskingPolicySolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); DataArtsStudioClient client = DataArtsStudioClient.newBuilder() .withCredential(auth) .withRegion(DataArtsStudioRegion.valueOf("<YOUR REGION>")) .build(); UpdateSecurityDynamicMaskingPolicyRequest request = new UpdateSecurityDynamicMaskingPolicyRequest(); request.withId("{id}"); DynamicMaskingPolicyUpdateDTO body = new DynamicMaskingPolicyUpdateDTO(); List<DynamicMaskingPolicyUpdate> listbodyPolicyList = new ArrayList<>(); listbodyPolicyList.add( new DynamicMaskingPolicyUpdate() .withColumnName("rr") .withColumnType("string") .withAlgorithmType("MASK_SHOW_FIRST_4") ); body.withPolicyList(listbodyPolicyList); body.withConnId("ae55cb5c44be4119b8958a3ba5d9a71f"); body.withConnName("hive_xxxx_0520"); body.withUsers(""); body.withUserGroups("DataArts User"); body.withTableName("chuan"); body.withTableId("NativeTable-ae55cb5c44be4119b8958a3ba5d9a71f-bigdatatest-chuan"); body.withDatabaseName("bigdatatest"); body.withClusterName("mrs_3x_autotest_do_not_del"); body.withClusterId("dc425074-26b3-479c-9e2f-b103c0cdd90f"); body.withDatasourceType(DynamicMaskingPolicyUpdateDTO.DatasourceTypeEnum.fromValue("HIVE")); body.withName("OpenAPI_HIVE_test"); request.withBody(body); try { UpdateSecurityDynamicMaskingPolicyResponse response = client.updateSecurityDynamicMaskingPolicy(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } }
- 更新DWS数据源动态脱敏策略
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.dataartsstudio.v1.region.DataArtsStudioRegion; import com.huaweicloud.sdk.dataartsstudio.v1.*; import com.huaweicloud.sdk.dataartsstudio.v1.model.*; import java.util.List; import java.util.ArrayList; public class UpdateSecurityDynamicMaskingPolicySolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); DataArtsStudioClient client = DataArtsStudioClient.newBuilder() .withCredential(auth) .withRegion(DataArtsStudioRegion.valueOf("<YOUR REGION>")) .build(); UpdateSecurityDynamicMaskingPolicyRequest request = new UpdateSecurityDynamicMaskingPolicyRequest(); request.withId("{id}"); DynamicMaskingPolicyUpdateDTO body = new DynamicMaskingPolicyUpdateDTO(); List<DynamicMaskingPolicyUpdate> listbodyPolicyList = new ArrayList<>(); listbodyPolicyList.add( new DynamicMaskingPolicyUpdate() .withColumnName("avarchar") .withColumnType("varchar") .withAlgorithmType("DWS_FRONT_KEEP") ); body.withPolicyList(listbodyPolicyList); body.withSchemaName("public"); body.withConnId("e2f6c44100654778aee017f8ad9e3ac9"); body.withConnName("dws_0430"); body.withUsers("autotest_tics"); body.withUserGroups("DataArts_PDP5_NoPrivilleage"); body.withTableName("all_column"); body.withTableId("NativeTable-e2f6c44100654778aee017f8ad9e3ac9-gaussdb-public-all_column"); body.withDatabaseName("gaussdb"); body.withClusterName("dws_ssl_xxxx_nomodify"); body.withClusterId("c94a9133-ef65-47ad-9483-bfa8c5eaa101"); body.withDatasourceType(DynamicMaskingPolicyUpdateDTO.DatasourceTypeEnum.fromValue("DWS")); body.withName("OpenAPI_DWS_test"); request.withBody(body); try { UpdateSecurityDynamicMaskingPolicyResponse response = client.updateSecurityDynamicMaskingPolicy(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } }
- 更新DLI数据源动态脱敏策略
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.dataartsstudio.v1.region.DataArtsStudioRegion; import com.huaweicloud.sdk.dataartsstudio.v1.*; import com.huaweicloud.sdk.dataartsstudio.v1.model.*; import java.util.List; import java.util.ArrayList; public class UpdateSecurityDynamicMaskingPolicySolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); DataArtsStudioClient client = DataArtsStudioClient.newBuilder() .withCredential(auth) .withRegion(DataArtsStudioRegion.valueOf("<YOUR REGION>")) .build(); UpdateSecurityDynamicMaskingPolicyRequest request = new UpdateSecurityDynamicMaskingPolicyRequest(); request.withId("{id}"); DynamicMaskingPolicyUpdateDTO body = new DynamicMaskingPolicyUpdateDTO(); List<DynamicMaskingPolicyUpdate> listbodyPolicyList = new ArrayList<>(); listbodyPolicyList.add( new DynamicMaskingPolicyUpdate() .withColumnName("name1") .withColumnType("string") .withAlgorithmType("MASK_HASH") ); body.withPolicyList(listbodyPolicyList); body.withConnId("619d52a0e6954aa68844f5f010e06ef8"); body.withConnName("xxxx_dli_link"); body.withUsers(""); body.withUserGroups(""); body.withTableName("ab"); body.withTableId("NativeTable-619d52a0e6954aa68844f5f010e06ef8-bi-ab"); body.withDatabaseName("bi"); body.withClusterName("DLI"); body.withClusterId("DLI"); body.withDatasourceType(DynamicMaskingPolicyUpdateDTO.DatasourceTypeEnum.fromValue("DLI")); body.withName("OpenAPI_DLI_xxxx"); request.withBody(body); try { UpdateSecurityDynamicMaskingPolicyResponse response = client.updateSecurityDynamicMaskingPolicy(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } }
- 更新HIVE数据源动态脱敏策略
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkdataartsstudio.v1.region.dataartsstudio_region import DataArtsStudioRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkdataartsstudio.v1 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = DataArtsStudioClient.new_builder() \ .with_credentials(credentials) \ .with_region(DataArtsStudioRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateSecurityDynamicMaskingPolicyRequest() request.id = "{id}" listPolicyListbody = [ DynamicMaskingPolicyUpdate( column_name="rr", column_type="string", algorithm_type="MASK_SHOW_FIRST_4" ) ] request.body = DynamicMaskingPolicyUpdateDTO( policy_list=listPolicyListbody, conn_id="ae55cb5c44be4119b8958a3ba5d9a71f", conn_name="hive_xxxx_0520", users="", user_groups="DataArts User", table_name="chuan", table_id="NativeTable-ae55cb5c44be4119b8958a3ba5d9a71f-bigdatatest-chuan", database_name="bigdatatest", cluster_name="mrs_3x_autotest_do_not_del", cluster_id="dc425074-26b3-479c-9e2f-b103c0cdd90f", datasource_type="HIVE", name="OpenAPI_HIVE_test" ) response = client.update_security_dynamic_masking_policy(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
- 更新DWS数据源动态脱敏策略
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkdataartsstudio.v1.region.dataartsstudio_region import DataArtsStudioRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkdataartsstudio.v1 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = DataArtsStudioClient.new_builder() \ .with_credentials(credentials) \ .with_region(DataArtsStudioRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateSecurityDynamicMaskingPolicyRequest() request.id = "{id}" listPolicyListbody = [ DynamicMaskingPolicyUpdate( column_name="avarchar", column_type="varchar", algorithm_type="DWS_FRONT_KEEP" ) ] request.body = DynamicMaskingPolicyUpdateDTO( policy_list=listPolicyListbody, schema_name="public", conn_id="e2f6c44100654778aee017f8ad9e3ac9", conn_name="dws_0430", users="autotest_tics", user_groups="DataArts_PDP5_NoPrivilleage", table_name="all_column", table_id="NativeTable-e2f6c44100654778aee017f8ad9e3ac9-gaussdb-public-all_column", database_name="gaussdb", cluster_name="dws_ssl_xxxx_nomodify", cluster_id="c94a9133-ef65-47ad-9483-bfa8c5eaa101", datasource_type="DWS", name="OpenAPI_DWS_test" ) response = client.update_security_dynamic_masking_policy(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
- 更新DLI数据源动态脱敏策略
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkdataartsstudio.v1.region.dataartsstudio_region import DataArtsStudioRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkdataartsstudio.v1 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = DataArtsStudioClient.new_builder() \ .with_credentials(credentials) \ .with_region(DataArtsStudioRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateSecurityDynamicMaskingPolicyRequest() request.id = "{id}" listPolicyListbody = [ DynamicMaskingPolicyUpdate( column_name="name1", column_type="string", algorithm_type="MASK_HASH" ) ] request.body = DynamicMaskingPolicyUpdateDTO( policy_list=listPolicyListbody, conn_id="619d52a0e6954aa68844f5f010e06ef8", conn_name="xxxx_dli_link", users="", user_groups="", table_name="ab", table_id="NativeTable-619d52a0e6954aa68844f5f010e06ef8-bi-ab", database_name="bi", cluster_name="DLI", cluster_id="DLI", datasource_type="DLI", name="OpenAPI_DLI_xxxx" ) response = client.update_security_dynamic_masking_policy(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
- 更新HIVE数据源动态脱敏策略
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" dataartsstudio "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := dataartsstudio.NewDataArtsStudioClient( dataartsstudio.DataArtsStudioClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateSecurityDynamicMaskingPolicyRequest{} request.Id = "{id}" algorithmTypePolicyList:= "MASK_SHOW_FIRST_4" var listPolicyListbody = []model.DynamicMaskingPolicyUpdate{ { ColumnName: "rr", ColumnType: "string", AlgorithmType: &algorithmTypePolicyList, }, } usersDynamicMaskingPolicyUpdateDto:= "" userGroupsDynamicMaskingPolicyUpdateDto:= "DataArts User" tableIdDynamicMaskingPolicyUpdateDto:= "NativeTable-ae55cb5c44be4119b8958a3ba5d9a71f-bigdatatest-chuan" request.Body = &model.DynamicMaskingPolicyUpdateDto{ PolicyList: listPolicyListbody, ConnId: "ae55cb5c44be4119b8958a3ba5d9a71f", ConnName: "hive_xxxx_0520", Users: &usersDynamicMaskingPolicyUpdateDto, UserGroups: &userGroupsDynamicMaskingPolicyUpdateDto, TableName: "chuan", TableId: &tableIdDynamicMaskingPolicyUpdateDto, DatabaseName: "bigdatatest", ClusterName: "mrs_3x_autotest_do_not_del", ClusterId: "dc425074-26b3-479c-9e2f-b103c0cdd90f", DatasourceType: model.GetDynamicMaskingPolicyUpdateDtoDatasourceTypeEnum().HIVE, Name: "OpenAPI_HIVE_test", } response, err := client.UpdateSecurityDynamicMaskingPolicy(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
- 更新DWS数据源动态脱敏策略
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" dataartsstudio "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := dataartsstudio.NewDataArtsStudioClient( dataartsstudio.DataArtsStudioClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateSecurityDynamicMaskingPolicyRequest{} request.Id = "{id}" algorithmTypePolicyList:= "DWS_FRONT_KEEP" var listPolicyListbody = []model.DynamicMaskingPolicyUpdate{ { ColumnName: "avarchar", ColumnType: "varchar", AlgorithmType: &algorithmTypePolicyList, }, } schemaNameDynamicMaskingPolicyUpdateDto:= "public" usersDynamicMaskingPolicyUpdateDto:= "autotest_tics" userGroupsDynamicMaskingPolicyUpdateDto:= "DataArts_PDP5_NoPrivilleage" tableIdDynamicMaskingPolicyUpdateDto:= "NativeTable-e2f6c44100654778aee017f8ad9e3ac9-gaussdb-public-all_column" request.Body = &model.DynamicMaskingPolicyUpdateDto{ PolicyList: listPolicyListbody, SchemaName: &schemaNameDynamicMaskingPolicyUpdateDto, ConnId: "e2f6c44100654778aee017f8ad9e3ac9", ConnName: "dws_0430", Users: &usersDynamicMaskingPolicyUpdateDto, UserGroups: &userGroupsDynamicMaskingPolicyUpdateDto, TableName: "all_column", TableId: &tableIdDynamicMaskingPolicyUpdateDto, DatabaseName: "gaussdb", ClusterName: "dws_ssl_xxxx_nomodify", ClusterId: "c94a9133-ef65-47ad-9483-bfa8c5eaa101", DatasourceType: model.GetDynamicMaskingPolicyUpdateDtoDatasourceTypeEnum().DWS, Name: "OpenAPI_DWS_test", } response, err := client.UpdateSecurityDynamicMaskingPolicy(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
- 更新DLI数据源动态脱敏策略
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" dataartsstudio "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := dataartsstudio.NewDataArtsStudioClient( dataartsstudio.DataArtsStudioClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateSecurityDynamicMaskingPolicyRequest{} request.Id = "{id}" algorithmTypePolicyList:= "MASK_HASH" var listPolicyListbody = []model.DynamicMaskingPolicyUpdate{ { ColumnName: "name1", ColumnType: "string", AlgorithmType: &algorithmTypePolicyList, }, } usersDynamicMaskingPolicyUpdateDto:= "" userGroupsDynamicMaskingPolicyUpdateDto:= "" tableIdDynamicMaskingPolicyUpdateDto:= "NativeTable-619d52a0e6954aa68844f5f010e06ef8-bi-ab" request.Body = &model.DynamicMaskingPolicyUpdateDto{ PolicyList: listPolicyListbody, ConnId: "619d52a0e6954aa68844f5f010e06ef8", ConnName: "xxxx_dli_link", Users: &usersDynamicMaskingPolicyUpdateDto, UserGroups: &userGroupsDynamicMaskingPolicyUpdateDto, TableName: "ab", TableId: &tableIdDynamicMaskingPolicyUpdateDto, DatabaseName: "bi", ClusterName: "DLI", ClusterId: "DLI", DatasourceType: model.GetDynamicMaskingPolicyUpdateDtoDatasourceTypeEnum().DLI, Name: "OpenAPI_DLI_xxxx", } response, err := client.UpdateSecurityDynamicMaskingPolicy(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
OK |
400 |
Bad Request |