custodia.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:commissaire-service 作者: projectatomic 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号