I ran into some issues trying to delete a custom metadata key from a storage object. I expected the following to work, but did not result in the key being deleted:
# blob has metadata with key 'foo'new_metadata= {}
forxinblob.metadata:
ifx!='foo':
new_metadata[x] =blob.metadata[x]
# new_metadata is now a copy of the metadata without key 'foo'blob.metadata=new_metadatablob.patch()
# The blob's metadata still has key 'foo'The Rest API indicated to send a value of JSON null associated with the key to perform a deletion, but that doesn't seem to happen when issuing a blob.patch with a metadata with a key removed.
As a work around, I created a copy of the desired metadata, deleted all of the blob's metadata (which does work), then updated the metadata to be the desired metadata.
new_metadata= {}
forxinblob.metadata:
ifx!='foo':
new_metadata[x] =blob.metadata[x]
blob.metadata=Noneblob.patch()
blob.metadata=new_metadatablob.patch()
I ran into some issues trying to delete a custom metadata key from a storage object. I expected the following to work, but did not result in the key being deleted:
The Rest API indicated to send a value of JSON null associated with the key to perform a deletion, but that doesn't seem to happen when issuing a blob.patch with a metadata with a key removed.
As a work around, I created a copy of the desired metadata, deleted all of the blob's metadata (which does work), then updated the metadata to be the desired metadata.