Add 'Blob.update_storage_class' API method.#3051
Add 'Blob.update_storage_class' API method.#3051tseaver merged 3 commits intogoogleapis:masterfrom tseaver:2991-storage-per_object_storage_class
Conversation
| # 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.
| # 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
| """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.
|
|
||
| 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
| 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.