-
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
Cloud storage rewrite with GCloud? #1960
Comments
I don't believe we do at this time. |
Do you have any plan to add rewrite? It is hard for the user to rotate their encryption key without rewrite. |
Based on the def rewrite_blob(self, blob, destination_bucket, new_name, client=None):
"""Rewrite the given blob to the given bucket, with a new name.
:type blob: :class:`gcloud.storage.blob.Blob`
:param blob: The blob to be copied.
:type destination_bucket: :class:`gcloud.storage.bucket.Bucket`
:param destination_bucket: The bucket into which the blob should be
copied.
:type new_name: string
:param new_name: (optional) the new name for the copied file.
:type client: :class:`gcloud.storage.client.Client` or ``NoneType``
:param client: Optional. The client to use. If not passed, falls back
to the ``client`` stored on the current bucket.
:rtype: bytes
:returns: The new Blob.
"""
client = self._require_client(client)
if new_name is None:
new_name = blob.name
new_blob = Blob(bucket=destination_bucket, name=new_name)
api_path = blob.path + '/rewriteTo' + new_blob.path
resource = dict(blob._properties)
result = client.connection.api_request(
method='POST', path=api_path, data=resource,
_target_object=new_blob)
token = result.get('rewriteToken')
while token not in (None, ''):
query_params = {'rewriteToken': token}
result = client.connection.api_request(
method='POST', path=api_path, query_params=query_params,
_target_object=new_blob)
token = result.get('rewriteToken')
new_blob._set_properties(result['resource'])
return new_blob |
That would be fine, alternatively N.B. this method must take two encryption key parameters, one for the source and one for the destination. This a the primary use case of the rewrite method, other than just moving objects between buckets. |
@jonparrott Where in the |
In the headers, hilariously enough. See the current sample here. |
@jonparrott Why are those values not part of the payload? Worse, why is that not documented? |
/me grumbles This is exactly the kind of thing that is supposed to make you release a new API version. |
@tseaver don't shoot the messenger. I thought it was whack when I had to write the samples for it using google-api-python-client, because it's awkward to add headers using that library. |
@jonparrott I'm grumbling about that (hypothetical) motive, which predates you. New API release or not, the API docs should still be updated to define the (added?) behaviors: how did you learn about those headers in the first place? |
@tseaver I've filed an internal bug about Rewrite docs not saying enough about how to use it with customer-supplied encryption keys. I'm not entirely sure why it couldn't have been added to the post body, but I do know that ensuring that no key is ever persisted anywhere is of paramount importance and may have guided that decision. |
Bump, any update on this? |
It looks like it was last updated August 19th, |
Re: object resource having encryption key metadata but not key materials: It is a little bit confusing in the first glance, as object resources can appear in both requests and responses. But if you look more closely, the table denotes which fields are "writable". Only those fields can be updated. Key metadata cannot be updated, they are only helpful in responses. Re: why the keys are passed in as headers rather than the post body: Actually adding the keys to the request body is not as straightforward as it seems. In our current API, a request body either contains object data or object metadata. And key materials are neither. |
@dhermes I'm not quite sure how you've made sub-project releases after the
|
@tseaver I think it's more robust just to use the GitHub UI (since people can merge PRs however they like now, and we haven't disabled the other two options, though we can): |
@dhermes FWIW, I wasn't grepping for "Merged" commits: I looked at the whole history for |
Haha DERP. I should've read closely. |
Bump - I can has release? |
@jonparrott It's not as easy as it seems. It requires a core release as well, which has implications on all packages. |
The core change being the iterator work? If so, I can wait. |
Yes |
Avoids the need to plumb it through all the 'upload' and 'download' methods. Convert '_set_encryption_headers(key, headers)' into a pure function, '_get_encryption_headers(key)', returning a new dict. Preparing for use of encryption in to-be-added 'Blob.rewrite(source_blob)' method. See: googleapis#1960.
Does GCloud support Google Cloud Storage rewrite?
The text was updated successfully, but these errors were encountered: