According to the documentation here:
https://cloud.google.com/storage/docs/json_api#patch
setting:
"metadata": null
will clear the metadata, whereas setting:
{
"metadata": {"NEW_KEY" : "NEW_VALUE"}
}
will actually add to the metadata, like so:
"metadata": {
"EXISTING_KEY" : "EXISTING_VALUE",
"NEW_KEY" : "NEW_VALUE"
}
Lets say I didn’t want to clear the metadata, nor add key/value pairs, but instead replace the metadata field with a new set of key/value pairs. For example, lets say my current metadata was:
"metadata": {
"EXISTING_KEY" : "EXISTING_VALUE"
}
and I sent a PATCH request like so:
PATCH ...
"metadata": {
"KEY1" : "VALUE1",
"KEY2" : "VALUE2",
"NO_OTHER_KEYS" : "NO_OTHER_VALUES"
},
that should result in the metadata being:
"metadata": {
"KEY1" : "VALUE1",
"KEY2" : "VALUE2",
"NO_OTHER_KEYS" : "NO_OTHER_VALUES"
},
not:
"metadata": {
"KEY1" : "VALUE1",
"KEY2" : "VALUE2",
"NO_OTHER_KEYS" : "NO_OTHER_VALUES",
"EXISTING_KEY" : "EXISTING_VALUE"
},
i.e. the old keys are gone.
Now I could achieve this in two PATCH requests, first sending:
"metadata": null
and then:
"metadata": {
"KEY1" : "VALUE1",
"KEY2" : "VALUE2",
"NO_OTHER_KEYS" : "NO_OTHER_VALUES"
},
would presumably result in all the old keys being removed, but could I achieve this in one patch request?