From d5a29318b5c68678ea63eb40a4dfede562f8963e Mon Sep 17 00:00:00 2001 From: Dan Lee <71398022+dandhlee@users.noreply.github.com> Date: Wed, 1 Feb 2023 14:44:11 -0600 Subject: [PATCH] docs: fix c.g.c structure (#982) * docs: fix c.g.c structure * docs: make docs job happy --- docs/acl_guide.rst | 82 ++++++++++++++++++ .../generation_metageneration.rst | 0 docs/index.rst | 21 ++++- docs/{storage => }/retry_timeout.rst | 0 docs/{storage => }/snippets.py | 0 docs/storage/acl.rst | 85 +------------------ docs/storage/{blobs.rst => blob.rst} | 0 docs/storage/{buckets.rst => bucket.rst} | 2 +- docs/storage/modules.rst | 17 ---- 9 files changed, 104 insertions(+), 103 deletions(-) create mode 100644 docs/acl_guide.rst rename docs/{storage => }/generation_metageneration.rst (100%) rename docs/{storage => }/retry_timeout.rst (100%) rename docs/{storage => }/snippets.py (100%) rename docs/storage/{blobs.rst => blob.rst} (100%) rename docs/storage/{buckets.rst => bucket.rst} (93%) delete mode 100644 docs/storage/modules.rst diff --git a/docs/acl_guide.rst b/docs/acl_guide.rst new file mode 100644 index 000000000..3f0790965 --- /dev/null +++ b/docs/acl_guide.rst @@ -0,0 +1,82 @@ +ACL +=== + +Cloud Storage uses access control lists (ACLs) to manage object and bucket access. +ACLs are the mechanism you use to share files with other users and allow +other users to access your buckets and files. + +ACLs are suitable for fine-grained control, but you may prefer using IAM to +control access at the project level. See also: +`Cloud Storage Control Access to Data `_ + + +:class:`google.cloud.storage.bucket.Bucket` has a getting method that creates +an ACL object under the hood, and you can interact with that using +:func:`google.cloud.storage.bucket.Bucket.acl`: + +.. code-block:: python + + client = storage.Client() + bucket = client.get_bucket(bucket_name) + acl = bucket.acl + +Adding and removing permissions can be done with the following methods +(in increasing order of granularity): + +- :func:`ACL.all` + corresponds to access for all users. +- :func:`ACL.all_authenticated` corresponds + to access for all users that are signed into a Google account. +- :func:`ACL.domain` corresponds to access on a + per Google Apps domain (ie, ``example.com``). +- :func:`ACL.group` corresponds to access on a + per group basis (either by ID or e-mail address). +- :func:`ACL.user` corresponds to access on a + per user basis (either by ID or e-mail address). + +And you are able to ``grant`` and ``revoke`` the following roles: + +- **Reading**: + :func:`_ACLEntity.grant_read` and :func:`_ACLEntity.revoke_read` +- **Writing**: + :func:`_ACLEntity.grant_write` and :func:`_ACLEntity.revoke_write` +- **Owning**: + :func:`_ACLEntity.grant_owner` and :func:`_ACLEntity.revoke_owner` + +You can use any of these like any other factory method (these happen to +be :class:`_ACLEntity` factories): + +.. code-block:: python + + acl.user("me@example.org").grant_read() + acl.all_authenticated().grant_write() + +After that, you can save any changes you make with the +:func:`google.cloud.storage.acl.ACL.save` method: + +.. code-block:: python + + acl.save() + + +You can alternatively save any existing :class:`google.cloud.storage.acl.ACL` +object (whether it was created by a factory method or not) from a +:class:`google.cloud.storage.bucket.Bucket`: + +.. code-block:: python + + bucket.acl.save(acl=acl) + + +To get the list of ``entity`` and ``role`` for each unique pair, the +:class:`ACL` class is iterable: + +.. code-block:: python + + print(list(acl)) + # [{'role': 'OWNER', 'entity': 'allUsers'}, ...] + + +This list of tuples can be used as the ``entity`` and ``role`` fields +when sending metadata for ACLs to the API. + diff --git a/docs/storage/generation_metageneration.rst b/docs/generation_metageneration.rst similarity index 100% rename from docs/storage/generation_metageneration.rst rename to docs/generation_metageneration.rst diff --git a/docs/index.rst b/docs/index.rst index 5a9109944..07d236e25 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -8,12 +8,31 @@ :class:`multiprocessing.Pool` or :class:`multiprocessing.Process` invokes :func:`os.fork`. +Guides +------ +.. toctree:: + :maxdepth: 2 + + acl_guide + generation_metageneration + retry_timeout + API Reference ------------- .. toctree:: :maxdepth: 2 - storage/modules + storage/acl + storage/batch + storage/blob + storage/bucket + storage/client + storage/constants + storage/fileio + storage/hmac_key + storage/notification + storage/retry + More Examples ------------- diff --git a/docs/storage/retry_timeout.rst b/docs/retry_timeout.rst similarity index 100% rename from docs/storage/retry_timeout.rst rename to docs/retry_timeout.rst diff --git a/docs/storage/snippets.py b/docs/snippets.py similarity index 100% rename from docs/storage/snippets.py rename to docs/snippets.py diff --git a/docs/storage/acl.rst b/docs/storage/acl.rst index f96cd6597..4c8562626 100644 --- a/docs/storage/acl.rst +++ b/docs/storage/acl.rst @@ -1,88 +1,5 @@ -ACL -=== - -Cloud Storage uses access control lists (ACLs) to manage object and bucket access. -ACLs are the mechanism you use to share files with other users and allow -other users to access your buckets and files. - -ACLs are suitable for fine-grained control, but you may prefer using IAM to -control access at the project level. See also: -`Cloud Storage Control Access to Data `_ - - -:class:`google.cloud.storage.bucket.Bucket` has a getting method that creates -an ACL object under the hood, and you can interact with that using -:func:`google.cloud.storage.bucket.Bucket.acl`: - -.. code-block:: python - - client = storage.Client() - bucket = client.get_bucket(bucket_name) - acl = bucket.acl - -Adding and removing permissions can be done with the following methods -(in increasing order of granularity): - -- :func:`ACL.all` - corresponds to access for all users. -- :func:`ACL.all_authenticated` corresponds - to access for all users that are signed into a Google account. -- :func:`ACL.domain` corresponds to access on a - per Google Apps domain (ie, ``example.com``). -- :func:`ACL.group` corresponds to access on a - per group basis (either by ID or e-mail address). -- :func:`ACL.user` corresponds to access on a - per user basis (either by ID or e-mail address). - -And you are able to ``grant`` and ``revoke`` the following roles: - -- **Reading**: - :func:`_ACLEntity.grant_read` and :func:`_ACLEntity.revoke_read` -- **Writing**: - :func:`_ACLEntity.grant_write` and :func:`_ACLEntity.revoke_write` -- **Owning**: - :func:`_ACLEntity.grant_owner` and :func:`_ACLEntity.revoke_owner` - -You can use any of these like any other factory method (these happen to -be :class:`_ACLEntity` factories): - -.. code-block:: python - - acl.user("me@example.org").grant_read() - acl.all_authenticated().grant_write() - -After that, you can save any changes you make with the -:func:`google.cloud.storage.acl.ACL.save` method: - -.. code-block:: python - - acl.save() - - -You can alternatively save any existing :class:`google.cloud.storage.acl.ACL` -object (whether it was created by a factory method or not) from a -:class:`google.cloud.storage.bucket.Bucket`: - -.. code-block:: python - - bucket.acl.save(acl=acl) - - -To get the list of ``entity`` and ``role`` for each unique pair, the -:class:`ACL` class is iterable: - -.. code-block:: python - - print(list(acl)) - # [{'role': 'OWNER', 'entity': 'allUsers'}, ...] - - -This list of tuples can be used as the ``entity`` and ``role`` fields -when sending metadata for ACLs to the API. - - ACL Module ----------- +----------- .. automodule:: google.cloud.storage.acl :members: diff --git a/docs/storage/blobs.rst b/docs/storage/blob.rst similarity index 100% rename from docs/storage/blobs.rst rename to docs/storage/blob.rst diff --git a/docs/storage/buckets.rst b/docs/storage/bucket.rst similarity index 93% rename from docs/storage/buckets.rst rename to docs/storage/bucket.rst index c42d7e303..e63fe2115 100644 --- a/docs/storage/buckets.rst +++ b/docs/storage/bucket.rst @@ -1,4 +1,4 @@ -Buckets +Bucket ~~~~~~~ .. automodule:: google.cloud.storage.bucket diff --git a/docs/storage/modules.rst b/docs/storage/modules.rst deleted file mode 100644 index 9148a4385..000000000 --- a/docs/storage/modules.rst +++ /dev/null @@ -1,17 +0,0 @@ -Modules for Python Storage --------------------------- -.. toctree:: - :maxdepth: 2 - - client - blobs - buckets - acl - batch - fileio - constants - hmac_key - notification - retry - retry_timeout - generation_metageneration \ No newline at end of file