Skip to content

Commit b36a4e7

Browse files
authored
chore: upgrade some storage samples (GoogleCloudPlatform#1384)
1 parent c4e3584 commit b36a4e7

25 files changed

+163
-319
lines changed

storage/README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,10 @@ This simple command-line application demonstrates how to invoke
3232
4. **Install dependencies** via [Composer](http://getcomposer.org/doc/00-intro.md).
3333
Run `php composer.phar install` (if composer is installed locally) or `composer install`
3434
(if composer is installed globally).
35-
5. Run `php storage.php`. The following commands are available:
35+
5. Run `php storage.php` to see a list of commands:
3636

3737
```sh
38-
bucket-acl Manage the ACL for Cloud Storage buckets.
39-
bucket-default-acl Manage the default ACL for Cloud Storage buckets.
40-
bucket-labels Manage Cloud Storage bucket labels
4138
bucket-lock Manage Cloud Storage retention policies and holds
42-
buckets Manage Cloud Storage buckets
43-
encryption Upload and download Cloud Storage objects with encryption
4439
object-acl Manage the ACL for Cloud Storage objects
4540
objects Manage Cloud Storage objects
4641
requester-pays Manage Cloud Storage requester pays buckets and objects

storage/composer.json

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,11 @@
66
},
77
"autoload": {
88
"files": [
9-
"src/add_bucket_acl.php",
109
"src/add_bucket_conditional_iam_binding.php",
11-
"src/add_bucket_default_acl.php",
1210
"src/add_bucket_iam_member.php",
13-
"src/add_bucket_label.php",
1411
"src/add_object_acl.php",
1512
"src/copy_object.php",
16-
"src/create_bucket.php",
1713
"src/create_hmac_key.php",
18-
"src/delete_bucket.php",
19-
"src/delete_bucket_acl.php",
20-
"src/delete_bucket_default_acl.php",
2114
"src/delete_object.php",
2215
"src/delete_object_acl.php",
2316
"src/delete_hmac_key.php",
@@ -26,23 +19,14 @@
2619
"src/disable_default_event_based_hold.php",
2720
"src/disable_requester_pays.php",
2821
"src/deactivate_hmac_key.php",
29-
"src/download_encrypted_object.php",
3022
"src/download_file_requester_pays.php",
3123
"src/download_object.php",
3224
"src/enable_bucket_lifecycle_management.php",
3325
"src/enable_uniform_bucket_level_access.php",
3426
"src/enable_default_event_based_hold.php",
35-
"src/enable_default_kms_key.php",
3627
"src/enable_requester_pays.php",
3728
"src/activate_hmac_key.php",
38-
"src/generate_encryption_key.php",
3929
"src/generate_v4_post_policy.php",
40-
"src/bucket_metadata.php",
41-
"src/get_bucket_acl.php",
42-
"src/get_bucket_acl_for_entity.php",
43-
"src/get_bucket_default_acl.php",
44-
"src/get_bucket_default_acl_for_entity.php",
45-
"src/get_bucket_labels.php",
4630
"src/get_uniform_bucket_level_access.php",
4731
"src/get_object_acl.php",
4832
"src/get_object_acl_for_entity.php",
@@ -53,7 +37,6 @@
5337
"src/get_retention_policy.php",
5438
"src/get_default_event_based_hold.php",
5539
"src/get_hmac_key.php",
56-
"src/list_buckets.php",
5740
"src/list_objects.php",
5841
"src/list_objects_with_prefix.php",
5942
"src/list_hmac_keys.php",
@@ -65,15 +48,11 @@
6548
"src/release_temporary_hold.php",
6649
"src/remove_bucket_iam_member.php",
6750
"src/remove_bucket_conditional_iam_binding.php",
68-
"src/remove_bucket_label.php",
6951
"src/remove_retention_policy.php",
70-
"src/rotate_encryption_key.php",
7152
"src/set_event_based_hold.php",
7253
"src/set_retention_policy.php",
7354
"src/set_temporary_hold.php",
74-
"src/upload_encrypted_object.php",
7555
"src/upload_object.php",
76-
"src/upload_with_kms_key.php",
7756
"src/view_bucket_iam_members.php"
7857
]
7958
},

storage/src/add_bucket_acl.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ function add_bucket_acl($bucketName, $entity, $role, $options = [])
4646
printf('Added %s (%s) to gs://%s ACL' . PHP_EOL, $entity, $role, $bucketName);
4747
}
4848
# [END storage_add_bucket_owner]
49+
50+
require_once __DIR__ . '/../../testing/sample_helpers.php';
51+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/add_bucket_default_acl.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ function add_bucket_default_acl($bucketName, $entity, $role, $options = [])
4646
printf('Added %s (%s) to gs://%s default ACL' . PHP_EOL, $entity, $role, $bucketName);
4747
}
4848
# [END storage_add_bucket_default_owner]
49+
50+
require_once __DIR__ . '/../../testing/sample_helpers.php';
51+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/add_bucket_label.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ function add_bucket_label($bucketName, $labelName, $labelValue)
4242
printf('Added label %s (%s) to %s' . PHP_EOL, $labelName, $labelValue, $bucketName);
4343
}
4444
# [END storage_add_bucket_label]
45+
46+
require_once __DIR__ . '/../../testing/sample_helpers.php';
47+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/create_bucket.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ function create_bucket($bucketName, $options = [])
4040
printf('Bucket created: %s' . PHP_EOL, $bucket->name());
4141
}
4242
# [END storage_create_bucket]
43+
44+
require_once __DIR__ . '/../../testing/sample_helpers.php';
45+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/delete_bucket.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ function delete_bucket($bucketName)
4141
printf('Bucket deleted: %s' . PHP_EOL, $bucket->name());
4242
}
4343
# [END storage_delete_bucket]
44+
45+
require_once __DIR__ . '/../../testing/sample_helpers.php';
46+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/delete_bucket_acl.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ function delete_bucket_acl($bucketName, $entity, $options = [])
4444
printf('Deleted %s from gs://%s ACL' . PHP_EOL, $entity, $bucketName);
4545
}
4646
# [END storage_remove_bucket_owner]
47+
48+
require_once __DIR__ . '/../../testing/sample_helpers.php';
49+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/delete_bucket_default_acl.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ function delete_bucket_default_acl($bucketName, $entity, $options = [])
4444
printf('Deleted %s from gs://%s default ACL' . PHP_EOL, $entity, $bucketName);
4545
}
4646
# [END storage_remove_bucket_default_owner]
47+
48+
require_once __DIR__ . '/../../testing/sample_helpers.php';
49+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/download_encrypted_object.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@ function download_encrypted_object($bucketName, $objectName, $destination, $base
4848
$bucketName, $objectName, basename($destination));
4949
}
5050
# [END storage_download_encrypted_file]
51+
52+
require_once __DIR__ . '/../../testing/sample_helpers.php';
53+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/enable_default_kms_key.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ function enable_default_kms_key($projectId, $bucketName, $kmsKeyName)
5151
$bucket->info()['encryption']['defaultKmsKeyName']);
5252
}
5353
# [END storage_set_bucket_default_kms_key]
54+
55+
require_once __DIR__ . '/../../testing/sample_helpers.php';
56+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/generate_encryption_key.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ function generate_encryption_key()
3737
printf('Your encryption key: %s' . PHP_EOL, $encodedKey);
3838
}
3939
# [END storage_generate_encryption_key]
40+
41+
require_once __DIR__ . '/../../testing/sample_helpers.php';
42+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/get_bucket_acl.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ function get_bucket_acl($bucketName)
4343
}
4444
}
4545
# [END storage_print_bucket_acl]
46+
47+
require_once __DIR__ . '/../../testing/sample_helpers.php';
48+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/get_bucket_acl_for_entity.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ function get_bucket_acl_for_entity($bucketName, $entity)
4343
printf('%s: %s' . PHP_EOL, $item['entity'], $item['role']);
4444
}
4545
# [END get_bucket_acl_for_entity]
46+
47+
require_once __DIR__ . '/../../testing/sample_helpers.php';
48+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/get_bucket_default_acl.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ function get_bucket_default_acl($bucketName)
4343
}
4444
}
4545
# [END get_bucket_default_acl]
46+
47+
require_once __DIR__ . '/../../testing/sample_helpers.php';
48+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/get_bucket_default_acl_for_entity.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ function get_bucket_default_acl_for_entity($bucketName, $entity)
4343
printf('%s: %s' . PHP_EOL, $item['entity'], $item['role']);
4444
}
4545
# [END get_bucket_default_acl_for_entity]
46+
47+
require_once __DIR__ . '/../../testing/sample_helpers.php';
48+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/get_bucket_labels.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ function get_bucket_labels($bucketName)
4343
}
4444
}
4545
# [END storage_get_bucket_labels]
46+
47+
require_once __DIR__ . '/../../testing/sample_helpers.php';
48+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/bucket_metadata.php renamed to storage/src/get_bucket_metadata.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ function get_bucket_metadata($bucketName)
4242
printf("Bucket Metadata: %s" . PHP_EOL, print_r($info));
4343
}
4444
# [END storage_get_bucket_metadata]
45+
46+
require_once __DIR__ . '/../../testing/sample_helpers.php';
47+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/list_buckets.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ function list_buckets()
3939
}
4040
}
4141
# [END storage_list_buckets]
42+
43+
require_once __DIR__ . '/../../testing/sample_helpers.php';
44+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/remove_bucket_label.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ function remove_bucket_label($bucketName, $labelName)
4141
printf('Removed label %s from %s' . PHP_EOL, $labelName, $bucketName);
4242
}
4343
# [END storage_remove_bucket_label]
44+
45+
require_once __DIR__ . '/../../testing/sample_helpers.php';
46+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/rotate_encryption_key.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ function rotate_encryption_key(
5454
$bucketName, $objectName);
5555
}
5656
# [END storage_rotate_encryption_key]
57+
58+
require_once __DIR__ . '/../../testing/sample_helpers.php';
59+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/upload_encrypted_object.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ function upload_encrypted_object($bucketName, $objectName, $source, $base64Encry
4949
basename($source), $bucketName, $objectName);
5050
}
5151
# [END storage_upload_encrypted_file]
52+
53+
require_once __DIR__ . '/../../testing/sample_helpers.php';
54+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

storage/src/upload_with_kms_key.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ function upload_with_kms_key($projectId, $bucketName, $objectName, $source, $kms
5555
$kmsKeyName);
5656
}
5757
# [END storage_upload_with_kms_key]
58+
59+
require_once __DIR__ . '/../../testing/sample_helpers.php';
60+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

0 commit comments

Comments
 (0)