Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(storage transfer): Added samples for storage transfer #2059

Merged
merged 24 commits into from
Dec 13, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
43ed44d
quickstart and latest transfer check
thiyaguk09 Oct 11, 2024
3a999b6
added samples for nearline and combine test cases
thiyaguk09 Oct 15, 2024
a24fbc8
Merge pull request #1 from thiyaguk09/missing_transfer_service_samples
thiyaguk09 Oct 16, 2024
09bef5e
added samples for manifest and test cases
thiyaguk09 Oct 16, 2024
0756ae1
added samples and test cases for posix to GCS
thiyaguk09 Oct 16, 2024
5a9b2e8
fixes
thiyaguk09 Oct 17, 2024
21b22ce
variables fixes
thiyaguk09 Oct 17, 2024
83cd2ef
added samples and test cases for posix to posix
thiyaguk09 Oct 17, 2024
2c22adf
added samples and test cases for GCS to posix
thiyaguk09 Oct 17, 2024
285330d
Merge pull request #2 from thiyaguk09/sample_manifest
thiyaguk09 Oct 21, 2024
646298b
Merge branch 'GoogleCloudPlatform:main' into main
thiyaguk09 Oct 21, 2024
a32f6ad
Merge pull request #3 from thiyaguk09/sample_posix
thiyaguk09 Oct 21, 2024
f8a30e0
Merge branch 'GoogleCloudPlatform:main' into sample_transfer_between_…
thiyaguk09 Oct 21, 2024
9ece009
Merge pull request #4 from thiyaguk09/sample_transfer_between_posix
thiyaguk09 Oct 29, 2024
fc988fd
resolve conflict
thiyaguk09 Oct 31, 2024
067a654
Merge branch 'main' into sample_download_to_posix
thiyaguk09 Oct 31, 2024
d10c311
Merge pull request #5 from thiyaguk09/sample_download_to_posix
thiyaguk09 Oct 31, 2024
55ba8e3
added typehints
thiyaguk09 Nov 4, 2024
57d3b6e
added samples and test cases for event driven GCS transfer
thiyaguk09 Nov 6, 2024
b58b9fb
Merge pull request #6 from thiyaguk09/sample_event_driven_gcs
thiyaguk09 Nov 8, 2024
61f4ac5
lint fix
thiyaguk09 Nov 18, 2024
232bfa3
Merge branch 'main' into main
danielduhh Nov 18, 2024
4db5442
Merge branch 'main' into main
bshaffer Dec 13, 2024
2248b46
use latest library version
bshaffer Dec 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixes
thiyaguk09 committed Oct 17, 2024
commit 5a9b2e801241c914261fe32f85973939180649f3
8 changes: 4 additions & 4 deletions storagetransfer/src/manifest_request.php
Original file line number Diff line number Diff line change
@@ -57,13 +57,13 @@ function manifest_request($projectId, $sourceAgentPoolName, $rootDirectory, $sin
]);

$client = new StorageTransferServiceClient();
$request = (new CreateTransferJobRequest())
$createRequest = (new CreateTransferJobRequest())
->setTransferJob($transferJob);
$response = $client->createTransferJob($request);
$request2 = (new RunTransferJobRequest())
$response = $client->createTransferJob($createRequest);
$runRequest = (new RunTransferJobRequest())
->setJobName($response->getName())
->setProjectId($projectId);
$client->runTransferJob($request2);
$client->runTransferJob($runRequest);

printf('Created and ran transfer job from %s to %s using manifest %s with name %s ' . PHP_EOL, $rootDirectory, $sinkGcsBucketName, $manifestLocation, $response->getName());
}
8 changes: 4 additions & 4 deletions storagetransfer/src/nearline_request.php
Original file line number Diff line number Diff line change
@@ -85,13 +85,13 @@ function nearline_request($projectId, $description, $sourceGcsBucketName, $sinkG
]);

$client = new StorageTransferServiceClient();
$request = (new CreateTransferJobRequest())
$createRequest = (new CreateTransferJobRequest())
->setTransferJob($transferJob);
$response = $client->createTransferJob($request);
$request2 = (new RunTransferJobRequest())
$response = $client->createTransferJob($createRequest);
$runRequest = (new RunTransferJobRequest())
->setJobName($response->getName())
->setProjectId($projectId);
$client->runTransferJob($request2);
$client->runTransferJob($runRequest);

printf('Created and ran transfer job : %s' . PHP_EOL, $response->getName());
}
9 changes: 4 additions & 5 deletions storagetransfer/src/posix_request.php
Original file line number Diff line number Diff line change
@@ -35,7 +35,6 @@
* @param string $sourceAgentPoolName The agent pool associated with the POSIX data source.
* @param string $rootDirectory The root directory path on the source filesystem.
* @param string $sinkGcsBucketName The name of the GCS bucket to transfer objects to.
* @param string $manifestLocation Transfer manifest location. Must be a `gs:` URL.
*/
function posix_request($projectId, $sourceAgentPoolName, $rootDirectory, $sinkGcsBucketName)
{
@@ -54,13 +53,13 @@ function posix_request($projectId, $sourceAgentPoolName, $rootDirectory, $sinkGc
]);

$client = new StorageTransferServiceClient();
$request = (new CreateTransferJobRequest())
$createRequest = (new CreateTransferJobRequest())
->setTransferJob($transferJob);
$response = $client->createTransferJob($request);
$request2 = (new RunTransferJobRequest())
$response = $client->createTransferJob($createRequest);
$runRequest = (new RunTransferJobRequest())
->setJobName($response->getName())
->setProjectId($projectId);
$client->runTransferJob($request2);
$client->runTransferJob($runRequest);

printf('Created and ran transfer job from %s to %s with name %s ' . PHP_EOL, $rootDirectory, $sinkGcsBucketName, $response->getName());
}
8 changes: 4 additions & 4 deletions storagetransfer/src/quickstart.php
Original file line number Diff line number Diff line change
@@ -48,13 +48,13 @@ function quickstart($projectId, $sourceGcsBucketName, $sinkGcsBucketName)
]);

$client = new StorageTransferServiceClient();
$request = (new CreateTransferJobRequest())
$createRequest = (new CreateTransferJobRequest())
->setTransferJob($transferJob);
$response = $client->createTransferJob($request);
$request2 = (new RunTransferJobRequest())
$response = $client->createTransferJob($createRequest);
$runRequest = (new RunTransferJobRequest())
->setJobName($response->getName())
->setProjectId($projectId);
$client->runTransferJob($request2);
$client->runTransferJob($runRequest);

printf('Created and ran transfer job from %s to %s with name %s ' . PHP_EOL, $sourceGcsBucketName, $sinkGcsBucketName, $response->getName());
}
6 changes: 4 additions & 2 deletions storagetransfer/test/StorageTransferTest.php
Original file line number Diff line number Diff line change
@@ -32,13 +32,15 @@ class StorageTransferTest extends TestCase
use TestTrait;

private static $sts;
private static $root;
private static $storage;
private static $sourceBucket;
private static $sinkBucket;
private static $sourceAgentPoolName;

public static function setUpBeforeClass(): void
{
self::$root = sys_get_temp_dir();
self::checkProjectEnvVars();
self::$storage = new StorageClient();
self::$sts = new StorageTransferServiceClient();
@@ -110,7 +112,7 @@ public function testManifestRequest()
{
try {
$manifestName = 'manifest.csv';
$rootDirectory = sys_get_temp_dir() . '/sts-manifest-request-test';
$rootDirectory = self::$root . '/sts-manifest-request-test';
if (!is_dir($rootDirectory)) {
mkdir($rootDirectory, 0700, true);
}
@@ -153,7 +155,7 @@ public function testManifestRequest()
public function testPosixRequest()
{
try {
$rootDirectory = sys_get_temp_dir() . '/sts-manifest-request-test';
$rootDirectory = self::$root . '/sts-manifest-request-test';
if (!is_dir($rootDirectory)) {
mkdir($rootDirectory, 0700, true);
}