如何从存储桶(GCS)中读取实木复合地板文件并使用DLP api取消对特定列的标识?

问题描述 投票:0回答:1

以下是我的DLP API调用的JSON对象,用于屏蔽GCS上存储桶中的实木复合地板文件上的特定数据列。虽然我必须将calli dlp.deidentify_content()方法传递给它,但不确定如何传递镶木地板文件,但我已经提到过镶木地板文件路径。

inspect_config = {
    'info_types': info_types,
    'custom_info_types': custom_info_types,
    'min_likelihood': min_likelihood,
    'limits': {'max_findings_per_request': max_findings},
}

actions = [{
    'saveFindings': {
        'outputConfig': {
            'table': {
                'projectId': project,
                'datasetId': 1,
                'tableId': "result1"
            }
        }
    }
}]
# Construct a storage_config containing the file's URL.
url = 'gs://{}/{}'.format(bucket, filename)

storage_config = {
    'cloud_storage_options': {
        'file_set': {'url': url}
    }
}
# Construct deidentify configuration dictionary
deidentify_config = {
    "recordTransformations": {
        "fieldTransformations": [
            {
                "fields": [
                    {
                        "name": "IP-address"
                    }
                ],
                "primitiveTransformation": {
                    "cryptoHashConfig": {
                        "cryptoKey": {
                            "transient": {
                                "name": "[TRANSIENT-CRYPTO-KEY-1]"
                            }
                        }
                    }
                }
            },
            {
                "fields": [
                    {
                        "name": "comments"
                    }
                ],
                "infoTypeTransformations": {
                    "transformations": [
                        {
                            "infoTypes": [
                                {
                                    "name": "PHONE_NUMBER"
                                },
                                {
                                    "name": "EMAIL_ADDRESS"
                                },
                                {
                                    "name": "IP_ADDRESS"
                                }
                            ],
                            "primitiveTransformation": {
                                "cryptoHashConfig": {
                                    "cryptoKey": {
                                        "transient": {
                                            "name": "[TRANSIENT-CRYPTO-KEY-2]"
                                        }
                                    }
                                }
                            }
                        }
                    ]
                }
            }
        ]
    }
}
# Call the API
response = dlp.deidentify_content(
    parent, inspect_config=inspect_config,
    deidentify_config=deidentify_config, item=item)

我要完成的工作是屏蔽GCS存储桶上的实木复合地板文件并屏蔽几列,并将屏蔽的实木复合地板文件存储为BigQuery表上的表。

google-cloud-platform google-cloud-dlp
1个回答
0
投票

Parquet文件当前被扫描为二进制对象,因为系统尚未对其进行智能解析。在V2 API中,列出了受支持的文件类型here

您可以按照此guide中的说明,将存储区中的实木复合地板文件加载到bigquery中,然后解析bigquery with DLP API中的数据

© www.soinside.com 2019 - 2024. All rights reserved.