Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
delete "more than one set "checks
  • Loading branch information
IlyaFaer committed May 5, 2020
commit 6f9f910ecfccc2f06022563b0396f91d5d83c9ba
40 changes: 0 additions & 40 deletions google/cloud/storage/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,7 @@ def reload(
:type if_metageneration_not_match: long
:param if_metageneration_not_match: (Optional) Make the operation conditional on whether the
blob's current metageneration does not match the given value.

:raises: :class:`ValueError` if ``if_metageneration_match`` and
``if_metageneration_not_match`` are both set.
"""
_raise_for_more_than_one_none(
if_generation_match=if_generation_match,
if_generation_not_match=if_generation_not_match,
)
_raise_for_more_than_one_none(
if_metageneration_match=if_metageneration_match,
if_metageneration_not_match=if_metageneration_not_match,
)
client = self._require_client(client)
query_params = self._query_params
# Pass only '?projection=noAcl' here because 'acl' and related
Expand Down Expand Up @@ -283,20 +272,7 @@ def patch(
:type if_metageneration_not_match: long
:param if_metageneration_not_match: (Optional) Make the operation conditional on whether the
blob's current metageneration does not match the given value.

:raises: :class:`ValueError` if ``if_metageneration_match`` and
``if_metageneration_not_match``, or
``if_generation_match`` and ``if_generation_not_match``
are both set.
"""
_raise_for_more_than_one_none(
if_generation_match=if_generation_match,
if_generation_not_match=if_generation_not_match,
)
_raise_for_more_than_one_none(
if_metageneration_match=if_metageneration_match,
if_metageneration_not_match=if_metageneration_not_match,
)
client = self._require_client(client)
query_params = self._query_params
# Pass '?projection=full' here because 'PATCH' documented not
Expand Down Expand Up @@ -365,23 +341,7 @@ def update(
:type if_metageneration_match: long
:param if_metageneration_match: (Optional) Make the operation conditional on whether the
blob's current metageneration matches the given value.

:raises: :class:`ValueError` if ``if_metageneration_match`` and
``if_metageneration_not_match``, or
``if_generation_match`` and ``if_generation_not_match``
are both set.

:raises: :class:`ValueError` if ``if_metageneration_match`` and
``if_metageneration_not_match`` are both set.
"""
_raise_for_more_than_one_none(
if_generation_match=if_generation_match,
if_generation_not_match=if_generation_not_match,
)
_raise_for_more_than_one_none(
if_metageneration_match=if_metageneration_match,
if_metageneration_not_match=if_metageneration_not_match,
)
client = self._require_client(client)

query_params = self._query_params
Expand Down
18 changes: 0 additions & 18 deletions google/cloud/storage/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,22 +613,9 @@ def exists(
:param if_metageneration_not_match: (Optional) Make the operation conditional on whether the
blob's current metageneration does not match the given value.

:raises: :class:`ValueError` if ``if_metageneration_match`` and
``if_metageneration_not_match``, or
``if_generation_match`` and ``if_generation_not_match``
are both set.

:rtype: bool
:returns: True if the blob exists in Cloud Storage.
"""
_raise_for_more_than_one_none(
if_generation_match=if_generation_match,
if_generation_not_match=if_generation_not_match,
)
_raise_for_more_than_one_none(
if_metageneration_match=if_metageneration_match,
if_metageneration_not_match=if_metageneration_not_match,
)
client = self._require_client(client)
# We only need the status code (200 or not) so we seek to
# minimize the returned payload.
Expand Down Expand Up @@ -709,11 +696,6 @@ def delete(
:raises: :class:`google.cloud.exceptions.NotFound`
(propagated from
:meth:`google.cloud.storage.bucket.Bucket.delete_blob`).

:raises: :class:`ValueError` if ``if_metageneration_match`` and
``if_metageneration_not_match``, or
``if_generation_match`` and ``if_generation_not_match``
are both set.
"""
self.bucket.delete_blob(
self.name,
Expand Down
39 changes: 0 additions & 39 deletions google/cloud/storage/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,14 +681,7 @@ def exists(

:rtype: bool
:returns: True if the bucket exists in Cloud Storage.

:raises: :class:`ValueError` if ``if_metageneration_match`` and
``if_metageneration_not_match`` are both set.
"""
_raise_for_more_than_one_none(
if_metageneration_match=if_metageneration_match,
if_metageneration_not_match=if_metageneration_not_match,
)
client = self._require_client(client)
# We only need the status code (200 or not) so we seek to
# minimize the returned payload.
Expand Down Expand Up @@ -823,14 +816,7 @@ def patch(
:type if_metageneration_not_match: long
:param if_metageneration_not_match: (Optional) Make the operation conditional on whether the
blob's current metageneration does not match the given value.

:raises: :class:`ValueError` if ``if_metageneration_match`` and
``if_metageneration_not_match`` are both set.
"""
_raise_for_more_than_one_none(
if_metageneration_match=if_metageneration_match,
if_metageneration_not_match=if_metageneration_not_match,
)
# Special case: For buckets, it is possible that labels are being
# removed; this requires special handling.
if self._label_removals:
Expand Down Expand Up @@ -951,11 +937,6 @@ def get_blob(

:rtype: :class:`google.cloud.storage.blob.Blob` or None
:returns: The blob object if it exists, otherwise None.

:raises: :class:`ValueError` if ``if_metageneration_match`` and
``if_metageneration_not_match``, or
``if_generation_match`` and ``if_generation_not_match``
are both set.
"""
blob = Blob(
bucket=self,
Expand Down Expand Up @@ -1208,14 +1189,7 @@ def delete(

:raises: :class:`ValueError` if ``force`` is ``True`` and the bucket
contains more than 256 objects / blobs.

:raises: :class:`ValueError` if ``if_metageneration_match`` and
``if_metageneration_not_match`` are both set.
"""
_raise_for_more_than_one_none(
if_metageneration_match=if_metageneration_match,
if_metageneration_not_match=if_metageneration_not_match,
)
client = self._require_client(client)
query_params = {}

Expand Down Expand Up @@ -1328,24 +1302,11 @@ def delete_blob(
the exception, call ``delete_blobs``, passing a no-op
``on_error`` callback, e.g.:

:raises: :class:`ValueError` if ``if_metageneration_match`` and
``if_metageneration_not_match``, or
``if_generation_match`` and ``if_generation_not_match``
are both set.

.. literalinclude:: snippets.py
:start-after: [START delete_blobs]
:end-before: [END delete_blobs]

"""
_raise_for_more_than_one_none(
if_generation_match=if_generation_match,
if_generation_not_match=if_generation_not_match,
)
_raise_for_more_than_one_none(
if_metageneration_match=if_metageneration_match,
if_metageneration_not_match=if_metageneration_not_match,
)
client = self._require_client(client)
blob = Blob(blob_name, bucket=self, generation=generation)

Expand Down
7 changes: 0 additions & 7 deletions google/cloud/storage/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,6 @@ def get_bucket(
google.cloud.exceptions.NotFound
If the bucket is not found.

ValueError
If `if_metageneration_match` and
`if_metageneration_not_match` are both set.

Examples:
Retrieve a bucket using a string.

Expand Down Expand Up @@ -391,9 +387,6 @@ def lookup_bucket(

:rtype: :class:`google.cloud.storage.bucket.Bucket`
:returns: The bucket matching the name provided or None if not found.

:raises: :class:`ValueError` if ``if_metageneration_match`` and
``if_metageneration_not_match`` are both set.
"""
try:
return self.get_bucket(
Expand Down