def _raise_from_response(self, response):
     if response.status_code == requests.codes.not_found:
         raise exc.K8sResourceNotFound(response.text)
     if response.status_code == requests.codes.conflict:
         raise exc.K8sConflict(response.text)
     if response.status_code == requests.codes.forbidden:
         if 'because it is being terminated' in response.json()['message']:
             raise exc.K8sNamespaceTerminating(response.text)
         raise exc.K8sForbidden(response.text)
     if not response.ok:
         raise exc.K8sClientException(response.text)
Beispiel #2
0
 def _raise_from_response(self, response):
     if response.status_code == requests.codes.not_found:
         raise exc.K8sResourceNotFound(response.text)
     if response.status_code == requests.codes.conflict:
         raise exc.K8sConflict(response.text)
     if response.status_code == requests.codes.forbidden:
         if 'because it is being terminated' in response.json()['message']:
             raise exc.K8sNamespaceTerminating(response.text)
         raise exc.K8sForbidden(response.text)
     if response.status_code == requests.codes.unprocessable_entity:
         # NOTE(gryf): on k8s API code 422 is also Forbidden, but specified
         # to FieldValueForbidden. Perhaps there are other usages for
         # throwing unprocessable entity errors in different cases.
         if ('FieldValueForbidden' in response.text
                 and 'Forbidden' in response.json()['message']):
             raise exc.K8sFieldValueForbidden(response.text)
         raise exc.K8sUnprocessableEntity(response.text)
     if not response.ok:
         raise exc.K8sClientException(response.text)