Coder
Coder

Reputation: 23

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

Problem you have encountered:

  1. Following steps at link below for transferJobs.patch API
    https://cloud.google.com/storage-transfer/docs/reference/rest/v1/transferJobs/patch
  2. Patch API works as expected if want to update description. Sample Below Request:
    {
  "projectId": "<MY_PROJECT>",
  "transferJob": {
    "transferSpec": {
      "objectConditions": {
        "lastModifiedSince": "2022-01-24T18:30:00Z"
      }
    },
    "description": "updated description"
  },
  "updateTransferJobFieldMask": "description"
}

Response: Success 200

  1. Patch API do not work if want to update nested object field. Sample Below
    {
  "projectId": "<MY_PROJECT>",
  "transferJob": {
    "transferSpec": {
      "objectConditions": {
        "lastModifiedSince": "2022-01-22T18:30:00Z"
      }
    },
    "description": "updated description"
  },
  "updateTransferJobFieldMask": "transferSpec.objectConditions.lastModifiedSince"
}

Response: 400

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

Tried other combinations following documentation/sample code reference but none of them work. Tried options as

What I expected to happen:

Patch API to work successfully for nested object as per documentation I.e. "updateTransferJobFieldMask": "transferSpec.objectConditions.lastModifiedSince"

Upvotes: 0

Views: 147

Answers (2)

Coder
Coder

Reputation: 23

Providing complete object having required child field worked. Sample example for future reference to other dev.

Below job transfer dat from Azure to GCP bucket and during patch updating last modified time. Both transfer_spec and transferSpec works as 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>"
        }
      }
    }
  }
}

Upvotes: 1

Anup Talwalkar
Anup Talwalkar

Reputation: 26

updateTransferJobFieldMask works on the top level object, in this case transferSpec.

Changing that line to updateTransferJobFieldMask: transferSpec should work.

From 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.

Upvotes: 1

Related Questions