Skip to content

Commit 335981e

Browse files
author
Frank Natividad
committed
Fix sample use of projectId
1 parent b7fccb2 commit 335981e

File tree

7 files changed

+21
-17
lines changed

7 files changed

+21
-17
lines changed

storage/src/activate_hmac_key.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
* Activate HMAC key.
3131
*
3232
* @param string $accessId access ID for an inactive HMAC key.
33-
* @param string $options options for the new HMAC key.
3433
*
3534
*/
36-
function activate_hmac_key($accessId, $options = ['projectId' => 'your-project-id'])
35+
function activate_hmac_key($accessId)
3736
{
3837
$storage = new StorageClient();
39-
$hmacKey = $storage->hmacKey($accessId, $options);
38+
// By default hmacKey will use the projectId used by StorageClient().
39+
$hmacKey = $storage->hmacKey($accessId);
4040

4141
$hmacKey = $hmacKey->update('ACTIVE');
4242

storage/src/create_hmac_key.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@
3030
* Create a new HMAC key.
3131
*
3232
* @param string $serviceAccountEmail service account email to associate with new HMAC key.
33-
* @param string $options options for the new HMAC key.
33+
* @param string $options options for the new HMAC key such as projectId.
3434
*
3535
*/
3636
function create_hmac_key($serviceAccountEmail, $options = ['projectId' => 'your-project-id'])
3737
{
3838
$storage = new StorageClient();
39+
// By default createHmacKey will use the projectId used by StorageClient().
3940
$hmacKeyCreated = $storage->createHmacKey($serviceAccountEmail, $options);
41+
4042
printf("The base64 encoded secret is: %s", $hmacKeyCreated->secret());
4143
print("Do not miss that secret, there is no API to recover it.");
4244
printf("HMAC key Metadata: %s" . PHP_EOL, print_r($hmacKeyCreated->hmacKey()->info()));

storage/src/deactivate_hmac_key.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
* Deactivate HMAC key.
3131
*
3232
* @param string $accessId access ID for an inactive HMAC key.
33-
* @param string $options options for the new HMAC key.
3433
*
3534
*/
36-
function deactivate_hmac_key($accessId, $options = ['projectId' => 'your-project-id'])
35+
function deactivate_hmac_key($accessId)
3736
{
3837
$storage = new StorageClient();
39-
$hmacKey = $storage->hmacKey($accessId, $options);
38+
// By default hmacKey will use the projectId used by StorageClient().
39+
$hmacKey = $storage->hmacKey($accessId);
4040

4141
$hmacKey = $hmacKey->update('INACTIVE');
4242

storage/src/delete_hmac_key.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
* Delete HMAC key.
3131
*
3232
* @param string $accessId access ID for an inactive HMAC key.
33-
* @param string $options options for the new HMAC key.
3433
*
3534
*/
36-
function delete_hmac_key($accessId, $options = ['projectId' => 'your-project-id'])
35+
function delete_hmac_key($accessId)
3736
{
3837
$storage = new StorageClient();
39-
$hmacKey = $storage->hmacKey($accessId, $options);
38+
// By default hmacKey will use the projectId used by StorageClient().
39+
$hmacKey = $storage->hmacKey($accessId);
4040

4141
$hmacKey->delete();
4242
print("The key is deleted, though it may still appear in StorageClient.hmacKeys() results.");

storage/src/get_hmac_key.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
* Get HMAC key.
3131
*
3232
* @param string $accessId access ID for HMAC key.
33-
* @param string $options options for the new HMAC key.
33+
* @param string $projectId Google Cloud Project Id.
3434
*
3535
*/
36-
function get_hmac_key($accessId, $options = ['projectId' => 'your-project-id'])
36+
function get_hmac_key($accessId, $projectId)
3737
{
3838
$storage = new StorageClient();
39-
$hmacKey = $storage->hmacKey($accessId, $options);
39+
$hmacKey = $storage->hmacKey($accessId, $projectId);
4040

4141
printf("HMAC key Metadata: %s" . PHP_EOL, print_r($hmacKey->info()));
4242
}

storage/src/list_hmac_keys.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
function list_hmac_keys($options = ['projectId' => 'your-project-id'])
3636
{
3737
$storage = new StorageClient();
38+
// By default hmacKeys will use the projectId used by StorageClient() list HMAC Keys.
3839
$hmacKeys = $storage->hmacKeys($options);
40+
3941
foreach ($hmacKeys as $hmacKey) {
4042
printf("HMAC key Metadata: %s" . PHP_EOL, print_r($hmacKey->info()));
4143
}

storage/storage.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,13 +482,13 @@
482482
$projectId = $input->getArgument('projectId');
483483
$accessId = $input->getArgument('accessId');
484484
if ($input->getOption('activate')) {
485-
activate_hmac_key($accessId, ['projectId' => $projectId]);
485+
activate_hmac_key($accessId);
486486
} elseif ($input->getOption('deactivate')) {
487-
deactivate_hmac_key($accessId, ['projectId' => $projectId]);
487+
deactivate_hmac_key($accessId);
488488
} elseif ($input->getOption('get')) {
489-
get_hmac_key($accessId, ['projectId' => $projectId]);
489+
get_hmac_key($accessId, $projectId);
490490
} elseif ($input->getOption('delete')) {
491-
delete_hmac_key($accessId, ['projectId' => $projectId]);
491+
delete_hmac_key($accessId);
492492
} else {
493493
throw new \Exception('You must provide --activate, --deactivate, --get, or --delete with an HMAC key accessId.');
494494
}

0 commit comments

Comments
 (0)