From 7eb881d7e5f78d29376cfa4172b1a3a0516c1653 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 23 Sep 2016 16:44:02 -0400 Subject: [PATCH] Add API code values to confluent messages When a message is used that would raise an exception in a singleton case, make available the appropriate apicode in contexts that would be relevant (namely multi-node operations and all asynchttp). --- confluent_server/confluent/messages.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/confluent_server/confluent/messages.py b/confluent_server/confluent/messages.py index 6dac39aa..36371048 100644 --- a/confluent_server/confluent/messages.py +++ b/confluent_server/confluent/messages.py @@ -59,6 +59,7 @@ def _htmlify_structure(indict): class ConfluentMessage(object): + apicode = 200 readonly = False defaultvalue = '' defaulttype = 'text' @@ -174,6 +175,8 @@ class ConfluentMessage(object): class ConfluentNodeError(object): + apicode = 500 + def __init__(self, node, errorstr): self.node = node self.error = errorstr @@ -191,15 +194,20 @@ class ConfluentNodeError(object): class ConfluentTargetTimeout(ConfluentNodeError): + apicode = 504 + def __init__(self, node, errstr='timeout'): self.node = node self.error = errstr + def strip_node(self, node): raise exc.TargetEndpointUnreachable(self.error) class ConfluentTargetNotFound(ConfluentNodeError): + apicode = 404 + def __init__(self, node, errorstr='not found'): self.node = node self.error = errorstr @@ -209,6 +217,7 @@ class ConfluentTargetNotFound(ConfluentNodeError): class ConfluentTargetInvalidCredentials(ConfluentNodeError): + apicode = 502 def __init__(self, node): self.node = node self.error = 'bad credentials'