"ValueError: Protocol message DeidentifyTemplate has no 'deidentifyTemplate' field."



我正在尝试使用 GCP DLP API 客户端库(Python 3(创建 DE-identification 模板。我已经使用POST方法成功创建了去标识模板。DE 识别模板剂量是使用谷歌 KMS 包装的密钥加密一些 PII 字段。

client.create_deidentify_template(
parent=parent,
deidentify_template=deidentify_template,
template_id=templateId,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_co
re.gapic_v1.method.DEFAULT,
metadata=None)

错误:

ValueError: 协议消息 DeidentifyTemplate 没有 'deidentifyTemplate' 字段。

我相信你的参数deidentify_template=deidentify_template是问题所在。 来自Google DLP API Python Client文档:

deidentify_template(Union[dict, DeidentifyTemplate]( – 要创建的 DeidentifyTemplate。

如果提供了字典,它必须与 protobuf 消息 DeidentifyTemplate 的形式相同

对于如何定义DeidentiftTemplate,您缺少一些参数:

display_name显示名称(最多 256 个字符(。

描述简短描述(最多 256 个字符(。

create_time检查模板的创建时间戳,仅输出字段。

update_time检查模板的上次更新时间戳,仅输出字段。

deidentify_config//

create_time现场google.privacy.dlp.v2.DeidentifyTemplate.create_time

deidentify_config现场google.privacy.dlp.v2.DeidentifyTemplate.deidentify_config

描述字段google.privacy.dlp.v2.DeidentifyTemplate.description

display_name现场google.privacy.dlp.v2.DeidentifyTemplate.display_name

名称字段 google.privacy.dlp.v2.DeidentifyTemplate.name

update_time现场google.privacy.dlp.v2.DeidentifyTemplate.update_time

deidentify_template:DLP API 采用字段名称而不是字段类型。 例如:

{
"display_name" : "de_identification_template",
"description" : "masking sensitive data",
"deidentify_config" : {
"info_type_transformations" : {
#your specification here.
}
}

您必须将"deidentifyConfig"更改为"deidentify_config"才能调用python DLP api。

https://cloud.google.com/dlp/docs/creating-templates-deid 是相当误导的。 它仅适用于 WEB DLP API POST,不适用于 python 客户端库。

最新更新