diff --git a/storagetransfer/composer.json b/storagetransfer/composer.json index ddb8648454..c4c7b78edb 100644 --- a/storagetransfer/composer.json +++ b/storagetransfer/composer.json @@ -1,6 +1,6 @@ { "require": { - "google/cloud-storage-transfer": "^1.0", + "google/cloud-storage-transfer": "^1.4", "paragonie/random_compat": "^9.0.0" }, "require-dev": { diff --git a/storagetransfer/src/quickstart.php b/storagetransfer/src/quickstart.php index 2fcee93d38..85383317cd 100644 --- a/storagetransfer/src/quickstart.php +++ b/storagetransfer/src/quickstart.php @@ -18,11 +18,13 @@ namespace Google\Cloud\Samples\StorageTransfer; # [START storagetransfer_quickstart] -use Google\Cloud\StorageTransfer\V1\StorageTransferServiceClient; +use Google\Cloud\StorageTransfer\V1\Client\StorageTransferServiceClient; +use Google\Cloud\StorageTransfer\V1\CreateTransferJobRequest; +use Google\Cloud\StorageTransfer\V1\GcsData; +use Google\Cloud\StorageTransfer\V1\RunTransferJobRequest; use Google\Cloud\StorageTransfer\V1\TransferJob; use Google\Cloud\StorageTransfer\V1\TransferJob\Status; use Google\Cloud\StorageTransfer\V1\TransferSpec; -use Google\Cloud\StorageTransfer\V1\GcsData; /** * Creates and runs a transfer job between two GCS buckets @@ -46,8 +48,13 @@ function quickstart($projectId, $sourceGcsBucketName, $sinkGcsBucketName) ]); $client = new StorageTransferServiceClient(); - $response = $client->createTransferJob($transferJob); - $client->runTransferJob($response->getName(), $projectId); + $request = (new CreateTransferJobRequest()) + ->setTransferJob($transferJob); + $response = $client->createTransferJob($request); + $request2 = (new RunTransferJobRequest()) + ->setJobName($response->getName()) + ->setProjectId($projectId); + $client->runTransferJob($request2); printf('Created and ran transfer job from %s to %s with name %s ' . PHP_EOL, $sourceGcsBucketName, $sinkGcsBucketName, $response->getName()); } diff --git a/storagetransfer/test/StorageTransferTest.php b/storagetransfer/test/StorageTransferTest.php index e31a206b2d..c23060f6e0 100644 --- a/storagetransfer/test/StorageTransferTest.php +++ b/storagetransfer/test/StorageTransferTest.php @@ -18,10 +18,12 @@ namespace Google\Cloud\Samples\StorageTransfer; use Google\Cloud\Storage\StorageClient; -use Google\Cloud\StorageTransfer\V1\StorageTransferServiceClient; +use Google\Cloud\StorageTransfer\V1\Client\StorageTransferServiceClient; +use Google\Cloud\StorageTransfer\V1\GetGoogleServiceAccountRequest; +use Google\Cloud\StorageTransfer\V1\TransferJob; use Google\Cloud\StorageTransfer\V1\TransferJob\Status; +use Google\Cloud\StorageTransfer\V1\UpdateTransferJobRequest; use Google\Cloud\TestUtils\TestTrait; -use Google\Cloud\StorageTransfer\V1\TransferJob; use PHPUnit\Framework\TestCase; class StorageTransferTest extends TestCase @@ -70,13 +72,19 @@ public function testQuickstart() 'name' => $jobName, 'status' => Status::DELETED ]); + $request = (new UpdateTransferJobRequest()) + ->setJobName($jobName) + ->setProjectId(self::$projectId) + ->setTransferJob($transferJob); - self::$sts->updateTransferJob($jobName, self::$projectId, $transferJob); + self::$sts->updateTransferJob($request); } private static function grantStsPermissions($bucket) { - $googleServiceAccount = self::$sts->getGoogleServiceAccount(self::$projectId); + $request2 = (new GetGoogleServiceAccountRequest()) + ->setProjectId(self::$projectId); + $googleServiceAccount = self::$sts->getGoogleServiceAccount($request2); $email = $googleServiceAccount->getAccountEmail(); $members = ['serviceAccount:' . $email];