存储传输服务 transferJobs.patch API 不适用于嵌套对象

Storage Transfer Service transferJobs.patch API does not work for nested object

您遇到的问题:

  1. 按照下面 link 中的步骤 transferJobs.patch API
    https://cloud.google.com/storage-transfer/docs/reference/rest/v1/transferJobs/patch
  2. 如果要更新描述,补丁 API 将按预期工作。下面的示例 要求:
    {
  "projectId": "<MY_PROJECT>",
  "transferJob": {
    "transferSpec": {
      "objectConditions": {
        "lastModifiedSince": "2022-01-24T18:30:00Z"
      }
    },
    "description": "updated description"
  },
  "updateTransferJobFieldMask": "description"
}

响应:成功 200

  1. 如果要更新嵌套对象字段,补丁 API 不起作用。下面的示例
    {
  "projectId": "<MY_PROJECT>",
  "transferJob": {
    "transferSpec": {
      "objectConditions": {
        "lastModifiedSince": "2022-01-22T18:30:00Z"
      }
    },
    "description": "updated description"
  },
  "updateTransferJobFieldMask": "transferSpec.objectConditions.lastModifiedSince"
}

响应:400

{"error": {
"code": 400,
"message": "Invalid path in the field mask.",
"status": "INVALID_ARGUMENT"}}

按照 documentation/sample 代码参考尝试了其他组合,但其中 none 行得通。尝试过的选项为

我预期会发生什么:

补丁 API 以根据文档成功处理嵌套对象,即“updateTransferJobFieldMask”:“transferSpec.objectConditions.lastModifiedSince”

updateTransferJobFieldMask 适用于顶级对象,在本例中为 transferSpec.

将该行更改为 updateTransferJobFieldMask: transferSpec 应该可以。

来自the documentation

The field mask of the fields in transferJob that are to be updated in this request. Fields in transferJob that can be updated are: description, transfer_spec, notification_config, and status. To update the transfer_spec of the job, a complete transfer specification must be provided. An incomplete specification missing any required fields will be rejected with the error INVALID_ARGUMENT.

提供具有所需子字段的完整对象。供将来其他开发者参考的示例。

以下是从 Azure 到 GCP 存储桶的作业传输数据以及补丁更新期间的上次修改时间。 transfer_spec 和 transferSpec 都用作 updateTransferJobFieldMask。

{
  "projectId": "<MY_PROJECT>",
  "updateTransferJobFieldMask": "transfer_spec",
  "transferJob": {
    "transferSpec": {
      "gcsDataSink": {
        "bucketName": "<BUCKET_NAME>"
      },
      "objectConditions": {
        "lastModifiedSince": "2021-12-30T18:30:00Z"
      },
      "transferOptions": {},
      "azureBlobStorageDataSource": {
        "storageAccount": "<ACCOUNT_NAME>",
        "container": "<CONTAINER>",
        "azureCredentials": {
          "sasToken": "<SAS TOKEN>"
        }
      }
    }
  }
}