def from_response(response, body):
 cls = _code_map.get(response.status_code, ClientException)
 if response.headers:
  request_id = response.headers.get('x-compute-request-id')
 else:
  request_id = None
 if body:
  message = 'n/a'
  details = 'n/a'
  if hasattr(body, 'keys'):
   error = body[body.keys()[0]]
   message = error.get('message', None)
   details = error.get('details', None)
  return cls(code=response.status_code, message=message, details=details, request_id=request_id)
 else:
  return cls(code=response.status_code, request_id=request_id)

def from_response ( response , body ) : cls = _code_map . get ( response . status_code , ClientException ) if response . headers : request_id = response . headers . get ( 'x-compute-request-id' ) else : request_id = None if body : message = 'n/a' details = 'n/a' if hasattr ( body , 'keys' ) : error = body [ body . keys ( ) [ 0 ] ] message = error . get ( 'message' , None ) details = error . get ( 'details' , None ) return cls ( code = response . status_code , message = message , details = details , request_id = request_id ) else : return cls ( code = response . status_code , request_id = request_id )
return an instance of an clientexception or subclass based on an requests response .