def _delete(self, model_instance):
"""
Deletes a serialized SecretModel string from Custodia.
:param model_instance: SecretModel instance to delete.
:type model_instance: commissaire.model.SecretModel
:raises StorageLookupError: if data lookup fails (404 Not Found)
:raises requests.HTTPError: if the request fails (other than 404)
"""
url = self._build_key_url(model_instance)
try:
response = self.session.request(
'DELETE', url, timeout=self.CUSTODIA_TIMEOUT)
response.raise_for_status()
except requests.HTTPError as error:
# XXX bool(response) defers to response.ok, which is a misfeature.
# Have to explicitly test "if response is None" to know if the
# object is there.
have_response = response is not None
if have_response and error.response.status_code == 404:
raise StorageLookupError(str(error), model_instance)
else:
raise error
评论列表
文章目录