-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 'Blob.update_storage_class' API method. #3051
Add 'Blob.update_storage_class' API method. #3051
Conversation
@@ -12,6 +12,8 @@ | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
|
|||
# pylint: disable=too-many-lines |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -12,6 +12,8 @@ | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
|
|||
# pylint: disable=too-many-lines |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
storage/google/cloud/storage/blob.py
Outdated
@@ -73,6 +75,9 @@ class Blob(_PropertyMixin): | |||
_CHUNK_SIZE_MULTIPLE = 256 * 1024 | |||
"""Number (256 KB, in bytes) that must divide the chunk size.""" | |||
|
|||
_STORAGE_CLASSES = ( | |||
'STANDARD', 'NEARLINE', 'MULTI_REGIONAL', 'REGIONAL', 'COLDLINE') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -852,6 +857,31 @@ def rewrite(self, source, token=None, client=None): | |||
|
|||
return api_response['rewriteToken'], rewritten, size | |||
|
|||
def update_storage_class(self, new_class, client=None): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
storage/google/cloud/storage/blob.py
Outdated
@@ -852,6 +857,31 @@ def rewrite(self, source, token=None, client=None): | |||
|
|||
return api_response['rewriteToken'], rewritten, size | |||
|
|||
def update_storage_class(self, new_class, client=None): | |||
"""Rewrite source blob into this one. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
storage/google/cloud/storage/blob.py
Outdated
:param new_class: new storage class for the object | ||
|
||
:type client: :class:`~google.cloud.storage.client.Client` or | ||
``NoneType`` |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
self._encryption_key, source=True)) | ||
|
||
api_response = client._connection.api_request( | ||
method='POST', path=self.path + '/rewriteTo' + self.path, |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
api_response = client._connection.api_request( | ||
method='POST', path=self.path + '/rewriteTo' + self.path, | ||
data={'storageClass': new_class}, headers=headers, |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
self.assertNotIn('X-Goog-Copy-Source-Encryption-Key-Sha256', headers) | ||
self.assertNotIn('X-Goog-Encryption-Algorithm', headers) | ||
self.assertNotIn('X-Goog-Encryption-Key', headers) | ||
self.assertNotIn('X-Goog-Encryption-Key-Sha256', headers) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Two remaining sticking points:
|
The two sets aren't identical: in particular, the DRA class is only documented for Buckets, although it is deprecated, while the 'STANDARD' class isn't documented for POSC at all (although it happens to work). |
Is one a strict superset of the other? If so, the module with the larger set could import the smaller one and If neither set is a strict superset of the other, I agree with @tseaver that they should just be separate (rather than, say, having a base set that is the intersection). |
@lukesneeringer By inspection of the documented values at point-of-last-reading, yes: however, the docs don't specify that: they just describe the two sets which happen to overlap:
We could perhaps coalesce the two lists if we dropped support for setting the DRA type on buckets, or if we could get the storage back-end folks to document the possible values definitively for both buckets and objects. |
Okay, got it. Based on that, I think I am going to say that we stick with @tseaver's approach as implemented for now (while acknowledging that it is a close call). |
@lukesneeringer @tseaver We should
|
Re-order to match canonical order in docs. Add docstrings with links to relevant docs. Explain why the two lists differ.
@dhermes, @lukesneeringer Any further issues? |
…ct_storage_class Add 'Blob.update_storage_class' API method.
Closes #2991.