From 94a11d0394b907362ba40cf2c4938bde02f8e87a Mon Sep 17 00:00:00 2001 From: Frank Natividad Date: Fri, 26 Jul 2019 16:06:46 -0700 Subject: [PATCH 1/2] Update BPO -> UBLA --- storage/cloud-client/README.rst | 26 ++--- storage/cloud-client/README.rst.in | 6 +- storage/cloud-client/bucket_policy_only.py | 96 ------------------- .../uniform_bucket_level_access.py | 96 +++++++++++++++++++ ...py => uniform_bucket_level_access_test.py} | 22 ++--- 5 files changed, 123 insertions(+), 123 deletions(-) delete mode 100644 storage/cloud-client/bucket_policy_only.py create mode 100644 storage/cloud-client/uniform_bucket_level_access.py rename storage/cloud-client/{bucket_policy_only_test.py => uniform_bucket_level_access_test.py} (59%) diff --git a/storage/cloud-client/README.rst b/storage/cloud-client/README.rst index ef32d53de96..64ecd88276b 100644 --- a/storage/cloud-client/README.rst +++ b/storage/cloud-client/README.rst @@ -311,11 +311,11 @@ To run this sample: -Bucket Policy Only +Uniform Bucket Level Access +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=storage/cloud-client/bucket_policy_only.py,storage/cloud-client/README.rst + :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=storage/cloud-client/uniform_bucket_level_access.py,storage/cloud-client/README.rst @@ -324,20 +324,20 @@ To run this sample: .. code-block:: bash - $ python bucket_policy_only.py + $ python uniform_bucket_level_access.py - usage: bucket_policy_only.py [-h] - {enable-bucket-policy-only,disable-bucket-policy-only,get-bucket-policy-only} + usage: uniform_bucket_level_access.py [-h] + {enable-uniform-bucket-level-access,disable-uniform-bucket-level-access,get-uniform-bucket-level-access} ... positional arguments: - {enable-bucket-policy-only,disable-bucket-policy-only,get-bucket-policy-only} - enable-bucket-policy-only - Enable Bucket Policy Only for a bucket - disable-bucket-policy-only - Disable Bucket Policy Only for a bucket - get-bucket-policy-only - Get Bucket Policy Only for a bucket + {enable-uniform-bucket-level-access,disable-uniform-bucket-level-access,get-uniform-bucket-level-access} + enable-uniform-bucket-level-access + Enable uniform bucket-level access for a bucket + disable-uniform-bucket-level-access + Disable uniform bucket-level access for a bucket + get-uniform-bucket-level-access + Get uniform bucket-level access for a bucket optional arguments: -h, --help show this help message and exit @@ -420,4 +420,4 @@ to `browse the source`_ and `report issues`_. https://github.com/GoogleCloudPlatform/google-cloud-python/issues -.. _Google Cloud SDK: https://cloud.google.com/sdk/ \ No newline at end of file +.. _Google Cloud SDK: https://cloud.google.com/sdk/ diff --git a/storage/cloud-client/README.rst.in b/storage/cloud-client/README.rst.in index 3b8f33af7f5..87481e83f84 100644 --- a/storage/cloud-client/README.rst.in +++ b/storage/cloud-client/README.rst.in @@ -27,8 +27,8 @@ samples: - name: Bucket Lock file: bucket_lock.py show_help: true -- name: Bucket Policy Only - file: bucket_policy_only.py +- name: Uniform bucket-level access + file: uniform_bucket_level_access.py show_help: true - name: Notification Polling file: notification_polling.py @@ -36,4 +36,4 @@ samples: cloud_client_library: true -folder: storage/cloud-client \ No newline at end of file +folder: storage/cloud-client diff --git a/storage/cloud-client/bucket_policy_only.py b/storage/cloud-client/bucket_policy_only.py deleted file mode 100644 index 53057454471..00000000000 --- a/storage/cloud-client/bucket_policy_only.py +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2019 Google Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the 'License'); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import argparse - -from google.cloud import storage - - -def enable_bucket_policy_only(bucket_name): - """Enable Bucket Policy Only for a bucket""" - # [START storage_enable_bucket_policy_only] - # bucket_name = "my-bucket" - - storage_client = storage.Client() - bucket = storage_client.bucket(bucket_name) - - bucket.iam_configuration.bucket_policy_only_enabled = True - bucket.patch() - - print('Bucket Policy Only was enabled for {}.'.format(bucket.name)) - # [END storage_enable_bucket_policy_only] - - -def disable_bucket_policy_only(bucket_name): - """Disable Bucket Policy Only for a bucket""" - # [START storage_disable_bucket_policy_only] - # bucket_name = "my-bucket" - - storage_client = storage.Client() - bucket = storage_client.bucket(bucket_name) - - bucket.iam_configuration.bucket_policy_only_enabled = False - bucket.patch() - - print('Bucket Policy Only was disabled for {}.'.format(bucket.name)) - # [END storage_disable_bucket_policy_only] - - -def get_bucket_policy_only(bucket_name): - """Get Bucket Policy Only for a bucket""" - # [START storage_get_bucket_policy_only] - # bucket_name = "my-bucket" - - storage_client = storage.Client() - bucket = storage_client.get_bucket(bucket_name) - iam_configuration = bucket.iam_configuration - - if iam_configuration.bucket_policy_only_enabled: - print('Bucket Policy Only is enabled for {}.'.format(bucket.name)) - print('Bucket will be locked on {}.'.format( - iam_configuration.bucket_policy_only_locked_time)) - else: - print('Bucket Policy Only is disabled for {}.'.format(bucket.name)) - # [END storage_get_bucket_policy_only] - - -if __name__ == '__main__': - - parser = argparse.ArgumentParser( - description=__doc__, - formatter_class=argparse.RawDescriptionHelpFormatter) - subparsers = parser.add_subparsers(dest='command') - - enable_bucket_policy_only_parser = subparsers.add_parser( - 'enable-bucket-policy-only', help=enable_bucket_policy_only.__doc__) - enable_bucket_policy_only_parser.add_argument('bucket_name') - - disable_bucket_policy_only_parser = subparsers.add_parser( - 'disable-bucket-policy-only', help=disable_bucket_policy_only.__doc__) - disable_bucket_policy_only_parser.add_argument('bucket_name') - - get_bucket_policy_only_parser = subparsers.add_parser( - 'get-bucket-policy-only', help=get_bucket_policy_only.__doc__) - get_bucket_policy_only_parser.add_argument('bucket_name') - - args = parser.parse_args() - - if args.command == 'enable-bucket-policy-only': - enable_bucket_policy_only(args.bucket_name) - elif args.command == 'disable-bucket-policy-only': - disable_bucket_policy_only(args.bucket_name) - elif args.command == 'get-bucket-policy-only': - get_bucket_policy_only(args.bucket_name) diff --git a/storage/cloud-client/uniform_bucket_level_access.py b/storage/cloud-client/uniform_bucket_level_access.py new file mode 100644 index 00000000000..d33685fae01 --- /dev/null +++ b/storage/cloud-client/uniform_bucket_level_access.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python + +# Copyright 2019 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse + +from google.cloud import storage + + +def enable_uniform_bucket_level_access(bucket_name): + """Enable uniform bucket-level access for a bucket""" + # [START storage_enable_uniform_bucket_level_access] + # bucket_name = "my-bucket" + + storage_client = storage.Client() + bucket = storage_client.bucket(bucket_name) + + bucket.iam_configuration.uniform_bucket_level_access_enabled = True + bucket.patch() + + print('Uniform bucket-level access was enabled for {}.'.format(bucket.name)) + # [END storage_enable_uniform_bucket_level_access] + + +def disable_uniform_bucket_level_access(bucket_name): + """Disable uniform bucket-level access for a bucket""" + # [START storage_uniform_bucket_level_access] + # bucket_name = "my-bucket" + + storage_client = storage.Client() + bucket = storage_client.bucket(bucket_name) + + bucket.iam_configuration.uniform_bucket_level_access_enabled = False + bucket.patch() + + print('Uniform bucket-level access was disabled for {}.'.format(bucket.name)) + # [END storage_disable_uniform_bucket_level_access] + + +def get_uniform_bucket_level_access(bucket_name): + """Get uniform bucket-level access for a bucket""" + # [START storage_get_uniform_bucket_level_access] + # bucket_name = "my-bucket" + + storage_client = storage.Client() + bucket = storage_client.get_bucket(bucket_name) + iam_configuration = bucket.iam_configuration + + if iam_configuration.uniform_bucket_level_access_enabled: + print('Uniform bucket-level access is enabled for {}.'.format(bucket.name)) + print('Bucket will be locked on {}.'.format( + iam_configuration.uniform_bucket_level_locked_time)) + else: + print('Uniform bucket-level access is disabled for {}.'.format(bucket.name)) + # [END storage_get_uniform_bucket_level_access] + + +if __name__ == '__main__': + + parser = argparse.ArgumentParser( + description=__doc__, + formatter_class=argparse.RawDescriptionHelpFormatter) + subparsers = parser.add_subparsers(dest='command') + + enable_uniform_bucket_level_access_parser = subparsers.add_parser( + 'enable-uniform-bucket-level-access', help=enable_uniform_bucket_level_access.__doc__) + enable_uniform_bucket_level_access_parser.add_argument('bucket_name') + + disable_uniform_bucket_level_access_parser = subparsers.add_parser( + 'disable-uniform-bucket-level-access', help=disable_uniform_bucket_level_access.__doc__) + disable_uniform_bucket_level_access_parser.add_argument('bucket_name') + + get_uniform_bucket_level_access_parser = subparsers.add_parser( + 'get-uniform-bucket-level-access', help=get_uniform_bucket_level_access.__doc__) + get_uniform_bucket_level_access_parser.add_argument('bucket_name') + + args = parser.parse_args() + + if args.command == 'enable-uniform-bucket-level-access': + enable_uniform_bucket_level_access(args.bucket_name) + elif args.command == 'disable-uniform-bucket-level-access': + disable_uniform_bucket_level_access(args.bucket_name) + elif args.command == 'get-uniform-bucket-level-access': + get_uniform_bucket_level_access(args.bucket_name) diff --git a/storage/cloud-client/bucket_policy_only_test.py b/storage/cloud-client/uniform_bucket_level_access_test.py similarity index 59% rename from storage/cloud-client/bucket_policy_only_test.py rename to storage/cloud-client/uniform_bucket_level_access_test.py index 5ae433fa47f..6c6bacc8aca 100644 --- a/storage/cloud-client/bucket_policy_only_test.py +++ b/storage/cloud-client/uniform_bucket_level_access_test.py @@ -18,36 +18,36 @@ import pytest -import bucket_policy_only +import uniform_bucket_level_access @pytest.fixture() def bucket(): """Creates a test bucket and deletes it upon completion.""" client = storage.Client() - bucket_name = 'bucket-policy-only-' + str(int(time.time())) + bucket_name = 'uniform-bucket-level-access-' + str(int(time.time())) bucket = client.create_bucket(bucket_name) yield bucket time.sleep(3) bucket.delete(force=True) -def test_get_bucket_policy_only(bucket, capsys): - bucket_policy_only.get_bucket_policy_only(bucket.name) +def test_get_uniform_bucket_level_access(bucket, capsys): + uniform_bucket_level_access.get_uniform_bucket_level_access(bucket.name) out, _ = capsys.readouterr() - assert 'Bucket Policy Only is disabled for {}.'.format( + assert 'Uniform bucket-level access is disabled for {}.'.format( bucket.name) in out -def test_enable_bucket_policy_only(bucket, capsys): - bucket_policy_only.enable_bucket_policy_only(bucket.name) +def test_enable_uniform_bucket_level_access(bucket, capsys): + uniform_bucket_level_access.enable_uniform_bucket_level_access(bucket.name) out, _ = capsys.readouterr() - assert 'Bucket Policy Only was enabled for {}.'.format( + assert 'Uniform bucket-level access was enabled for {}.'.format( bucket.name) in out -def test_disable_bucket_policy_only(bucket, capsys): - bucket_policy_only.disable_bucket_policy_only(bucket.name) +def test_disable_uniform_bucket_level_access(bucket, capsys): + uniform_bucket_level_access.disable_uniform_bucket_level_access(bucket.name) out, _ = capsys.readouterr() - assert 'Bucket Policy Only was disabled for {}.'.format( + assert 'Uniform bucket-level access was disabled for {}.'.format( bucket.name) in out From 7c2e57f293149a51f30cf8f1538fcf5ed4cd05a9 Mon Sep 17 00:00:00 2001 From: Frank Natividad Date: Fri, 26 Jul 2019 16:06:46 -0700 Subject: [PATCH 2/2] Update BPO -> UBLA --- storage/cloud-client/README.rst | 26 ++--- storage/cloud-client/README.rst.in | 6 +- storage/cloud-client/bucket_policy_only.py | 96 ---------------- .../uniform_bucket_level_access.py | 103 ++++++++++++++++++ ...py => uniform_bucket_level_access_test.py} | 23 ++-- 5 files changed, 131 insertions(+), 123 deletions(-) delete mode 100644 storage/cloud-client/bucket_policy_only.py create mode 100644 storage/cloud-client/uniform_bucket_level_access.py rename storage/cloud-client/{bucket_policy_only_test.py => uniform_bucket_level_access_test.py} (59%) diff --git a/storage/cloud-client/README.rst b/storage/cloud-client/README.rst index ef32d53de96..64ecd88276b 100644 --- a/storage/cloud-client/README.rst +++ b/storage/cloud-client/README.rst @@ -311,11 +311,11 @@ To run this sample: -Bucket Policy Only +Uniform Bucket Level Access +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=storage/cloud-client/bucket_policy_only.py,storage/cloud-client/README.rst + :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=storage/cloud-client/uniform_bucket_level_access.py,storage/cloud-client/README.rst @@ -324,20 +324,20 @@ To run this sample: .. code-block:: bash - $ python bucket_policy_only.py + $ python uniform_bucket_level_access.py - usage: bucket_policy_only.py [-h] - {enable-bucket-policy-only,disable-bucket-policy-only,get-bucket-policy-only} + usage: uniform_bucket_level_access.py [-h] + {enable-uniform-bucket-level-access,disable-uniform-bucket-level-access,get-uniform-bucket-level-access} ... positional arguments: - {enable-bucket-policy-only,disable-bucket-policy-only,get-bucket-policy-only} - enable-bucket-policy-only - Enable Bucket Policy Only for a bucket - disable-bucket-policy-only - Disable Bucket Policy Only for a bucket - get-bucket-policy-only - Get Bucket Policy Only for a bucket + {enable-uniform-bucket-level-access,disable-uniform-bucket-level-access,get-uniform-bucket-level-access} + enable-uniform-bucket-level-access + Enable uniform bucket-level access for a bucket + disable-uniform-bucket-level-access + Disable uniform bucket-level access for a bucket + get-uniform-bucket-level-access + Get uniform bucket-level access for a bucket optional arguments: -h, --help show this help message and exit @@ -420,4 +420,4 @@ to `browse the source`_ and `report issues`_. https://github.com/GoogleCloudPlatform/google-cloud-python/issues -.. _Google Cloud SDK: https://cloud.google.com/sdk/ \ No newline at end of file +.. _Google Cloud SDK: https://cloud.google.com/sdk/ diff --git a/storage/cloud-client/README.rst.in b/storage/cloud-client/README.rst.in index 3b8f33af7f5..87481e83f84 100644 --- a/storage/cloud-client/README.rst.in +++ b/storage/cloud-client/README.rst.in @@ -27,8 +27,8 @@ samples: - name: Bucket Lock file: bucket_lock.py show_help: true -- name: Bucket Policy Only - file: bucket_policy_only.py +- name: Uniform bucket-level access + file: uniform_bucket_level_access.py show_help: true - name: Notification Polling file: notification_polling.py @@ -36,4 +36,4 @@ samples: cloud_client_library: true -folder: storage/cloud-client \ No newline at end of file +folder: storage/cloud-client diff --git a/storage/cloud-client/bucket_policy_only.py b/storage/cloud-client/bucket_policy_only.py deleted file mode 100644 index 53057454471..00000000000 --- a/storage/cloud-client/bucket_policy_only.py +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2019 Google Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the 'License'); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import argparse - -from google.cloud import storage - - -def enable_bucket_policy_only(bucket_name): - """Enable Bucket Policy Only for a bucket""" - # [START storage_enable_bucket_policy_only] - # bucket_name = "my-bucket" - - storage_client = storage.Client() - bucket = storage_client.bucket(bucket_name) - - bucket.iam_configuration.bucket_policy_only_enabled = True - bucket.patch() - - print('Bucket Policy Only was enabled for {}.'.format(bucket.name)) - # [END storage_enable_bucket_policy_only] - - -def disable_bucket_policy_only(bucket_name): - """Disable Bucket Policy Only for a bucket""" - # [START storage_disable_bucket_policy_only] - # bucket_name = "my-bucket" - - storage_client = storage.Client() - bucket = storage_client.bucket(bucket_name) - - bucket.iam_configuration.bucket_policy_only_enabled = False - bucket.patch() - - print('Bucket Policy Only was disabled for {}.'.format(bucket.name)) - # [END storage_disable_bucket_policy_only] - - -def get_bucket_policy_only(bucket_name): - """Get Bucket Policy Only for a bucket""" - # [START storage_get_bucket_policy_only] - # bucket_name = "my-bucket" - - storage_client = storage.Client() - bucket = storage_client.get_bucket(bucket_name) - iam_configuration = bucket.iam_configuration - - if iam_configuration.bucket_policy_only_enabled: - print('Bucket Policy Only is enabled for {}.'.format(bucket.name)) - print('Bucket will be locked on {}.'.format( - iam_configuration.bucket_policy_only_locked_time)) - else: - print('Bucket Policy Only is disabled for {}.'.format(bucket.name)) - # [END storage_get_bucket_policy_only] - - -if __name__ == '__main__': - - parser = argparse.ArgumentParser( - description=__doc__, - formatter_class=argparse.RawDescriptionHelpFormatter) - subparsers = parser.add_subparsers(dest='command') - - enable_bucket_policy_only_parser = subparsers.add_parser( - 'enable-bucket-policy-only', help=enable_bucket_policy_only.__doc__) - enable_bucket_policy_only_parser.add_argument('bucket_name') - - disable_bucket_policy_only_parser = subparsers.add_parser( - 'disable-bucket-policy-only', help=disable_bucket_policy_only.__doc__) - disable_bucket_policy_only_parser.add_argument('bucket_name') - - get_bucket_policy_only_parser = subparsers.add_parser( - 'get-bucket-policy-only', help=get_bucket_policy_only.__doc__) - get_bucket_policy_only_parser.add_argument('bucket_name') - - args = parser.parse_args() - - if args.command == 'enable-bucket-policy-only': - enable_bucket_policy_only(args.bucket_name) - elif args.command == 'disable-bucket-policy-only': - disable_bucket_policy_only(args.bucket_name) - elif args.command == 'get-bucket-policy-only': - get_bucket_policy_only(args.bucket_name) diff --git a/storage/cloud-client/uniform_bucket_level_access.py b/storage/cloud-client/uniform_bucket_level_access.py new file mode 100644 index 00000000000..32cb46dc8d8 --- /dev/null +++ b/storage/cloud-client/uniform_bucket_level_access.py @@ -0,0 +1,103 @@ +#!/usr/bin/env python + +# Copyright 2019 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse + +from google.cloud import storage + + +def enable_uniform_bucket_level_access(bucket_name): + """Enable uniform bucket-level access for a bucket""" + # [START storage_enable_uniform_bucket_level_access] + # bucket_name = "my-bucket" + + storage_client = storage.Client() + bucket = storage_client.bucket(bucket_name) + + bucket.iam_configuration.uniform_bucket_level_access_enabled = True + bucket.patch() + + print('Uniform bucket-level access was enabled for {}.'.format( + bucket.name)) + # [END storage_enable_uniform_bucket_level_access] + + +def disable_uniform_bucket_level_access(bucket_name): + """Disable uniform bucket-level access for a bucket""" + # [START storage_uniform_bucket_level_access] + # bucket_name = "my-bucket" + + storage_client = storage.Client() + bucket = storage_client.bucket(bucket_name) + + bucket.iam_configuration.uniform_bucket_level_access_enabled = False + bucket.patch() + + print('Uniform bucket-level access was disabled for {}.'.format( + bucket.name)) + # [END storage_disable_uniform_bucket_level_access] + + +def get_uniform_bucket_level_access(bucket_name): + """Get uniform bucket-level access for a bucket""" + # [START storage_get_uniform_bucket_level_access] + # bucket_name = "my-bucket" + + storage_client = storage.Client() + bucket = storage_client.get_bucket(bucket_name) + iam_configuration = bucket.iam_configuration + + if iam_configuration.uniform_bucket_level_access_enabled: + print('Uniform bucket-level access is enabled for {}.'.format( + bucket.name)) + print('Bucket will be locked on {}.'.format( + iam_configuration.uniform_bucket_level_locked_time)) + else: + print('Uniform bucket-level access is disabled for {}.'.format( + bucket.name)) + # [END storage_get_uniform_bucket_level_access] + + +if __name__ == '__main__': + + parser = argparse.ArgumentParser( + description=__doc__, + formatter_class=argparse.RawDescriptionHelpFormatter) + subparsers = parser.add_subparsers(dest='command') + + enable_uniform_bucket_level_access_parser = subparsers.add_parser( + 'enable-uniform-bucket-level-access', + help=enable_uniform_bucket_level_access.__doc__) + enable_uniform_bucket_level_access_parser.add_argument('bucket_name') + + disable_uniform_bucket_level_access_parser = subparsers.add_parser( + 'disable-uniform-bucket-level-access', + help=disable_uniform_bucket_level_access.__doc__) + disable_uniform_bucket_level_access_parser.add_argument('bucket_name') + + get_uniform_bucket_level_access_parser = subparsers.add_parser( + 'get-uniform-bucket-level-access', + help=get_uniform_bucket_level_access.__doc__) + get_uniform_bucket_level_access_parser.add_argument('bucket_name') + + args = parser.parse_args() + + if args.command == 'enable-uniform-bucket-level-access': + enable_uniform_bucket_level_access(args.bucket_name) + elif args.command == 'disable-uniform-bucket-level-access': + disable_uniform_bucket_level_access(args.bucket_name) + elif args.command == 'get-uniform-bucket-level-access': + get_uniform_bucket_level_access(args.bucket_name) diff --git a/storage/cloud-client/bucket_policy_only_test.py b/storage/cloud-client/uniform_bucket_level_access_test.py similarity index 59% rename from storage/cloud-client/bucket_policy_only_test.py rename to storage/cloud-client/uniform_bucket_level_access_test.py index 5ae433fa47f..e18a0d79bb8 100644 --- a/storage/cloud-client/bucket_policy_only_test.py +++ b/storage/cloud-client/uniform_bucket_level_access_test.py @@ -18,36 +18,37 @@ import pytest -import bucket_policy_only +import uniform_bucket_level_access @pytest.fixture() def bucket(): """Creates a test bucket and deletes it upon completion.""" client = storage.Client() - bucket_name = 'bucket-policy-only-' + str(int(time.time())) + bucket_name = 'uniform-bucket-level-access-' + str(int(time.time())) bucket = client.create_bucket(bucket_name) yield bucket time.sleep(3) bucket.delete(force=True) -def test_get_bucket_policy_only(bucket, capsys): - bucket_policy_only.get_bucket_policy_only(bucket.name) +def test_get_uniform_bucket_level_access(bucket, capsys): + uniform_bucket_level_access.get_uniform_bucket_level_access(bucket.name) out, _ = capsys.readouterr() - assert 'Bucket Policy Only is disabled for {}.'.format( + assert 'Uniform bucket-level access is disabled for {}.'.format( bucket.name) in out -def test_enable_bucket_policy_only(bucket, capsys): - bucket_policy_only.enable_bucket_policy_only(bucket.name) +def test_enable_uniform_bucket_level_access(bucket, capsys): + uniform_bucket_level_access.enable_uniform_bucket_level_access(bucket.name) out, _ = capsys.readouterr() - assert 'Bucket Policy Only was enabled for {}.'.format( + assert 'Uniform bucket-level access was enabled for {}.'.format( bucket.name) in out -def test_disable_bucket_policy_only(bucket, capsys): - bucket_policy_only.disable_bucket_policy_only(bucket.name) +def test_disable_uniform_bucket_level_access(bucket, capsys): + uniform_bucket_level_access.disable_uniform_bucket_level_access( + bucket.name) out, _ = capsys.readouterr() - assert 'Bucket Policy Only was disabled for {}.'.format( + assert 'Uniform bucket-level access was disabled for {}.'.format( bucket.name) in out