Skip to content

Commit 62b4a50

Browse files
cojencodandhleegcf-owl-bot[bot]
authored
docs: update c.g.c docs and guides (#994)
* docs: streamline acl/iam docs * update docs and guides * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * exclude README from owlbot * revert owlbot readme reverts --------- Co-authored-by: Dan Lee <[email protected]> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 1eb1f4c commit 62b4a50

File tree

4 files changed

+132
-28
lines changed

4 files changed

+132
-28
lines changed

README.rst

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,73 @@
1-
Python Client for Google Cloud Storage API
2-
==========================================
1+
Python Client for Google Cloud Storage
2+
======================================
33

44
|stable| |pypi| |versions|
55

6-
`Google Cloud Storage API`_: is a durable and highly available object storage service. Google Cloud Storage is almost infinitely scalable and guarantees consistency: when a write succeeds, the latest copy of the object will be returned to any GET, globally.
6+
`Google Cloud Storage`_ is a managed service for storing unstructured data. Cloud Storage
7+
allows world-wide storage and retrieval of any amount of data at any time. You can use
8+
Cloud Storage for a range of scenarios including serving website content, storing data
9+
for archival and disaster recovery, or distributing large data objects to users via direct download.
10+
11+
A comprehensive list of changes in each version may be found in the `CHANGELOG`_.
712

8-
- `Client Library Documentation`_
913
- `Product Documentation`_
14+
- `Client Library Documentation`_
15+
- `github.com/googleapis/python-storage`_
16+
17+
Read more about the client libraries for Cloud APIs, including the older
18+
Google APIs Client Libraries, in `Client Libraries Explained`_.
1019

1120
.. |stable| image:: https://img.shields.io/badge/support-stable-gold.svg
1221
:target: https://github.com/googleapis/google-cloud-python/blob/main/README.rst#stability-levels
1322
.. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-storage.svg
1423
:target: https://pypi.org/project/google-cloud-storage/
1524
.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-storage.svg
1625
:target: https://pypi.org/project/google-cloud-storage/
17-
.. _Google Cloud Storage API: https://cloud.google.com/storage
26+
.. _Google Cloud Storage: https://cloud.google.com/storage
1827
.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/storage/latest
1928
.. _Product Documentation: https://cloud.google.com/storage
29+
.. _CHANGELOG: https://github.com/googleapis/python-storage/blob/main/CHANGELOG.md
30+
.. _github.com/googleapis/python-storage: https://github.com/googleapis/python-storage
31+
.. _Client Libraries Explained: https://cloud.google.com/apis/docs/client-libraries-explained
2032

2133
Quick Start
2234
-----------
2335

24-
In order to use this library, you first need to go through the following steps:
36+
In order to use this library, you first need to go through the following steps.
37+
A step-by-step guide may also be found in `Get Started with Client Libraries`_.
2538

2639
1. `Select or create a Cloud Platform project.`_
2740
2. `Enable billing for your project.`_
2841
3. `Enable the Google Cloud Storage API.`_
2942
4. `Setup Authentication.`_
3043

44+
.. _Get Started with Client Libraries: https://cloud.google.com/storage/docs/reference/libraries#client-libraries-install-python
3145
.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
3246
.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
33-
.. _Enable the Google Cloud Storage API.: https://cloud.google.com/storage
34-
.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
47+
.. _Enable the Google Cloud Storage API.: https://console.cloud.google.com/flows/enableapi?apiid=storage-api.googleapis.com
48+
.. _Setup Authentication.: https://cloud.google.com/docs/authentication/client-libraries
3549

3650
Installation
3751
~~~~~~~~~~~~
3852

39-
Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to
40-
create isolated Python environments. The basic problem it addresses is one of
41-
dependencies and versions, and indirectly permissions.
53+
Install this library in a virtual environment using `venv`_. `venv`_ is a tool that
54+
creates isolated Python environments. These isolated environments can have separate
55+
versions of Python packages, which allows you to isolate one project's dependencies
56+
from the dependencies of other projects.
4257

43-
With `virtualenv`_, it's possible to install this library without needing system
58+
With `venv`_, it's possible to install this library without needing system
4459
install permissions, and without clashing with the installed system
4560
dependencies.
4661

47-
.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/
62+
.. _`venv`: https://docs.python.org/3/library/venv.html
4863

4964

5065
Code samples and snippets
5166
~~~~~~~~~~~~~~~~~~~~~~~~~
5267

53-
Code samples and snippets live in the `samples/` folder.
68+
Code samples and snippets live in the `samples/`_ folder.
69+
70+
.. _`samples/`: https://github.com/googleapis/python-storage/tree/main/samples
5471

5572

5673
Supported Python Versions
@@ -77,31 +94,29 @@ Mac/Linux
7794

7895
.. code-block:: console
7996
80-
pip install virtualenv
81-
virtualenv <your-env>
97+
python3 -m venv <your-env>
8298
source <your-env>/bin/activate
83-
<your-env>/bin/pip install google-cloud-storage
99+
pip install google-cloud-storage
84100
85101
86102
Windows
87103
^^^^^^^
88104

89105
.. code-block:: console
90106
91-
pip install virtualenv
92-
virtualenv <your-env>
93-
<your-env>\Scripts\activate
94-
<your-env>\Scripts\pip.exe install google-cloud-storage
107+
py -m venv <your-env>
108+
.\<your-env>\Scripts\activate
109+
pip install google-cloud-storage
95110
96111
Next Steps
97112
~~~~~~~~~~
98113

114+
- Read the `Google Cloud Storage Product documentation`_ to learn
115+
more about the product and see How-to Guides.
99116
- Read the `Client Library Documentation`_ for Google Cloud Storage API
100117
to see other available methods on the client.
101-
- Read the `Google Cloud Storage API Product documentation`_ to learn
102-
more about the product and see How-to Guides.
103118
- View this `README`_ to see the full list of Cloud
104119
APIs that we cover.
105120

106-
.. _Google Cloud Storage API Product documentation: https://cloud.google.com/storage
121+
.. _Google Cloud Storage Product documentation: https://cloud.google.com/storage
107122
.. _README: https://github.com/googleapis/google-cloud-python/blob/main/README.rst

docs/acl_guide.rst

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1+
Managing Access to Data
2+
=======================
3+
4+
Cloud Storage offers two systems for granting users access your buckets and objects:
5+
IAM and Access Control Lists (ACLs). These systems act in parallel - in order for a user to
6+
access a Cloud Storage resource, only one of the systems needs to grant that user permission.
7+
For additional access control options, see also:
8+
`Cloud Storage Control Access to Data <https://cloud.google.com/storage/docs/access-control>`_
9+
10+
111
ACL
2-
===
12+
---
313

414
Cloud Storage uses access control lists (ACLs) to manage object and bucket access.
515
ACLs are the mechanism you use to share files with other users and allow
616
other users to access your buckets and files.
717

818
ACLs are suitable for fine-grained control, but you may prefer using IAM to
9-
control access at the project level. See also:
10-
`Cloud Storage Control Access to Data <https://cloud.google.com/storage/docs/access-control>`_
19+
control access at the project level.
1120

1221

1322
:class:`google.cloud.storage.bucket.Bucket` has a getting method that creates
@@ -80,3 +89,77 @@ To get the list of ``entity`` and ``role`` for each unique pair, the
8089
This list of tuples can be used as the ``entity`` and ``role`` fields
8190
when sending metadata for ACLs to the API.
8291

92+
93+
IAM
94+
---
95+
96+
Identity and Access Management (IAM) controls permissioning throughout Google Cloud and allows you
97+
to grant permissions at the bucket and project levels. You should use IAM for any permissions that
98+
apply to multiple objects in a bucket to reduce the risks of unintended exposure. To use IAM
99+
exclusively, enable uniform bucket-level access to disallow ACLs for all Cloud Storage resources.
100+
See also:
101+
`Additional access control options <https://cloud.google.com/storage/docs/access-control#additional_access_control_options>`_
102+
103+
Constants used across IAM roles:
104+
::::::::::::::::::::::::::::::::
105+
106+
- ``STORAGE_OBJECT_CREATOR_ROLE = "roles/storage.objectCreator"``
107+
corresponds to role implying rights to create objects, but not delete or overwrite them.
108+
- ``STORAGE_OBJECT_VIEWER_ROLE = "roles/storage.objectViewer"``
109+
corresponds to role implying rights to view object properties, excluding ACLs.
110+
- ``STORAGE_OBJECT_ADMIN_ROLE = "roles/storage.objectAdmin"``
111+
corresponds to role implying full control of objects.
112+
- ``STORAGE_ADMIN_ROLE = "roles/storage.admin"``
113+
corresponds to role implying full control of objects and buckets.
114+
- ``STORAGE_VIEWER_ROLE = "Viewer"``
115+
corresponds to role that can list buckets.
116+
- ``STORAGE_EDITOR_ROLE = "Editor"``
117+
corresponds to role that can create, list, and delete buckets.
118+
- ``STORAGE_OWNER_ROLE = "Owners"``
119+
corresponds to role that can Can create, list, and delete buckets;
120+
and list tag bindings; and control HMAC keys in the project.
121+
122+
Constants used across IAM permissions:
123+
::::::::::::::::::::::::::::::::::::::
124+
125+
- ``STORAGE_BUCKETS_CREATE = "storage.buckets.create"``
126+
corresponds to permission that can create buckets.
127+
128+
- ``STORAGE_BUCKETS_DELETE = "storage.buckets.delete"``
129+
corresponds to permission that can delete buckets.
130+
131+
- ``STORAGE_BUCKETS_GET = "storage.buckets.get"``
132+
corresponds to permission that can read bucket metadata, excluding ACLs.
133+
134+
- ``STORAGE_BUCKETS_LIST = "storage.buckets.list"``
135+
corresponds to permission that can list buckets.
136+
137+
- ``STORAGE_BUCKETS_GET_IAM_POLICY = "storage.buckets.getIamPolicy"``
138+
corresponds to permission that can read bucket ACLs.
139+
140+
- ``STORAGE_BUCKETS_SET_IAM_POLICY = "storage.buckets.setIamPolicy"``
141+
corresponds to permission that can update bucket ACLs.
142+
143+
- ``STORAGE_BUCKETS_UPDATE = "storage.buckets.update"``
144+
corresponds to permission that can update buckets, excluding ACLS.
145+
146+
- ``STORAGE_OBJECTS_CREATE = "storage.objects.create"``
147+
corresponds to permission that can add new objects to a bucket.
148+
149+
- ``STORAGE_OBJECTS_DELETE = "storage.objects.delete"``
150+
corresponds to permission that can delete objects.
151+
152+
- ``STORAGE_OBJECTS_GET = "storage.objects.get"``
153+
corresponds to permission that can read object data / metadata, excluding ACLs.
154+
155+
- ``STORAGE_OBJECTS_LIST = "storage.objects.list"``
156+
corresponds to permission that can list objects in a bucket.
157+
158+
- ``STORAGE_OBJECTS_GET_IAM_POLICY = "storage.objects.getIamPolicy"``
159+
corresponds to permission that can read object ACLs.
160+
161+
- ``STORAGE_OBJECTS_SET_IAM_POLICY = "storage.objects.setIamPolicy"``
162+
corresponds to permission that can update object ACLs.
163+
164+
- ``STORAGE_OBJECTS_UPDATE = "storage.objects.update"``
165+
corresponds to permission that can update object metadata, excluding ACLs.

google/cloud/storage/constants.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""Constants used across google.cloud.storage modules."""
15+
"""Constants used across google.cloud.storage modules.
16+
17+
See [Python Storage Client Constants Page](https://github.com/googleapis/python-storage/blob/main/google/cloud/storage/constants.py)
18+
for constants used across storage classes, location types, public access prevention, etc.
19+
20+
"""
1621

1722
# Storage classes
1823

owlbot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"docs/multiprocessing.rst",
4646
"noxfile.py",
4747
"CONTRIBUTING.rst",
48+
"README.rst",
4849
".kokoro/samples/python3.6", # remove python 3.6 support
4950
".github/workflows", # exclude gh actions as credentials are needed for tests
5051
".github/release-please.yml", # special support for a python2 branch in this repo

0 commit comments

Comments
 (0)