You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on the rewrite API docs, it seems like this should be a method on Bucket, parallel to Bucket.copy_blob. Something like:
defrewrite_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)
ifnew_nameisNone:
new_name=blob.namenew_blob=Blob(bucket=destination_bucket, name=new_name)
api_path=blob.path+'/rewriteTo'+new_blob.pathresource=dict(blob._properties)
result=client.connection.api_request(
method='POST', path=api_path, data=resource,
_target_object=new_blob)
token=result.get('rewriteToken')
whiletokennotin (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'])
returnnew_blob
That would be fine, alternatively blob.rewrite_to(destination_name, source_encryption_key=..., encryption_key=...) would be acceptable as well.
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 rewrite request are the keys passed? I see fields in the Object resource which are metadata about the encryption, but not the key itself.
@tseaver I have no idea - this API predates me joining and I'm not part of the API review team. My hunch is that it was a way to get around releasing a new API version. Maybe @Capstan can provide some background.
@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.
@dhermes I'm not quite sure how you've made sub-project releases after the umbrella-0.20.0 tag. I just ran $ git log umbrella-0.20.0..HEAD -- storage/ and got the following:
@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):
Activity
daspecster commentedon Jul 6, 2016
I don't believe we do at this time.
hohaichi commentedon Jul 6, 2016
Do you have any plan to add rewrite? It is hard for the user to rotate their encryption key without rewrite.
daspecster commentedon Jul 6, 2016
That's a great use case!
@tseaver & @dhermes WDYT? I can start this today or tomorrow if there are not blockers.
theacodes commentedon Jul 14, 2016
@tseaver @dhermes @jgeewax this is also a blocking issue for us to be able to re-write storage usage samples using this library.
tseaver commentedon Jul 14, 2016
Based on the
rewriteAPI docs, it seems like this should be a method onBucket, parallel toBucket.copy_blob. Something like:theacodes commentedon Jul 14, 2016
That would be fine, alternatively
blob.rewrite_to(destination_name, source_encryption_key=..., encryption_key=...)would be acceptable as well.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.
tseaver commentedon Jul 15, 2016
@jonparrott Where in the
rewriterequest are the keys passed? I see fields in theObjectresource which are metadata about the encryption, but not the key itself.theacodes commentedon Jul 15, 2016
In the headers, hilariously enough.
See the current sample here.
tseaver commentedon Jul 15, 2016
@jonparrott Why are those values not part of the payload? Worse, why is that not documented?
theacodes commentedon Jul 15, 2016
@tseaver I have no idea - this API predates me joining and I'm not part of the API review team. My hunch is that it was a way to get around releasing a new API version. Maybe @Capstan can provide some background.
tseaver commentedon Jul 15, 2016
/me grumbles This is exactly the kind of thing that is supposed to make you release a new API version.
theacodes commentedon Jul 15, 2016
@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.
9 remaining items
theacodes commentedon Oct 28, 2016
@tseaver @dhermes can I get a release of the storage client so I can update the sample?
tseaver commentedon Oct 28, 2016
@dhermes I'm not quite sure how you've made sub-project releases after the
umbrella-0.20.0tag. I just ran$ git log umbrella-0.20.0..HEAD -- storage/and got the following:dhermes commentedon Oct 28, 2016
@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):
https://github.com/GoogleCloudPlatform/google-cloud-python/commits/master/storage?since=2016-09-27
tseaver commentedon Oct 28, 2016
@dhermes FWIW, I wasn't grepping for "Merged" commits: I looked at the whole history for
/storagesince that tag.dhermes commentedon Oct 28, 2016
Haha DERP. I should've read closely.
theacodes commentedon Oct 31, 2016
Bump - I can has release?
dhermes commentedon Oct 31, 2016
@jonparrott It's not as easy as it seems. It requires a core release as well, which has implications on all packages.
theacodes commentedon Oct 31, 2016
The core change being the iterator work? If so, I can wait.
dhermes commentedon Oct 31, 2016
Yes
Make 'encryption_key' an attribute of the Blob.
Add 'Blob.rewrite' API wrapper method.
chore: replace aion-sdk and platform teams with updated names (#1960)
Make 'encryption_key' an attribute of the Blob.
Add 'Blob.rewrite' API wrapper method.