API 提供的多项操作在 GCP 的 DLP 中不起作用

Multiple actions provided from the API for in GCP's DLP does not work

目标:从 Cloud Storage 存储桶读取 CSV 文件并将结果发布到 Pub/Sub 并将结果写入 BigQuery

问题:我可以使用控制台执行此操作,但是当我尝试使用 API 执行此操作时,只有操作有效。以下是我的代码示例:

'actions': [{
          'pub_sub': {
              'topic':
                  'projects/{project_id}/topics/{topic_id}'.format(
                      project_id=PROJECT_ID, topic_id=PUB_SUB_TOPIC)
          },
          
        'save_findings': {
            "output_config": {
                "table": {
                    "project_id": PROJECT_ID,
                    "dataset_id": DATASET_ID,
                    "table_id": TABLE_ID
               
                }
            }
        }
      }]

在上面的代码中,只有发布到 BigQuery 的选项会起作用,因为它是稍后编写的。我看到了 link 中给出的文档,上面写着 'Union field action can be only one of the following'

问题: 我的理解是否正确,使用 API 只能执行其中一项操作(写入数据库或发布到 pub/sub 等)?

如果是,是否会支持使用类似于控制台的 API 进行多项操作?

附录:使用具有多个操作的控制台配置 DLP 作业的 PFA 屏幕截图

您的对象嵌套不正确。

"actions": [
  {
    "pubSub": {
      "topic": "mytopic"
    }
  },
  {
    "saveFindings": {
      "outputConfig": {
        "outputSchema": "BIG_QUERY_COLUMNS",
        "table": {
          "datasetId": "",
          "tableId": "",
          "projectId": ""
        }
      }
    }
  }
]

根据documentation, it is a documented limitation for the REST API. It mentions. In addition, this limitation is also found at in the RPC side of the Rest API, here。两个州:

action can be only one of the following

但是,我建议您更改脚本以使 two calls 变为 create_dlp_job() 方法,每个方法在带有 REST 的变量中一次包含一个动作。

最后,您还可以在以下 link 中提出功能请求。