Move ResponseBody/List classes to service_client
ResponseBody/List classes are used as the return values of each
service client, so they are interfaces of service clients.
In addition, service_client depends on rest_client but now each
service client imports both rest_client and service_client.
This patch moves ResponseBody/List classes to service_client for
clean dependency and interfaces.
Change-Id: I080cedd0f0282d0abb5aa7a45edae8e178f36910
diff --git a/tempest/common/service_client.py b/tempest/common/service_client.py
index 0572a1f..c32a7d0 100644
--- a/tempest/common/service_client.py
+++ b/tempest/common/service_client.py
@@ -36,3 +36,37 @@
params.update({'build_timeout': build_timeout})
super(ServiceClient, self).__init__(auth_provider, service, region,
**params)
+
+
+class ResponseBody(dict):
+ """Class that wraps an http response and dict body into a single value.
+
+ Callers that receive this object will normally use it as a dict but
+ can extract the response if needed.
+ """
+
+ def __init__(self, response, body=None):
+ body_data = body or {}
+ self.update(body_data)
+ self.response = response
+
+ def __str__(self):
+ body = super.__str__(self)
+ return "response: %s\nBody: %s" % (self.response, body)
+
+
+class ResponseBodyList(list):
+ """Class that wraps an http response and list body into a single value.
+
+ Callers that receive this object will normally use it as a list but
+ can extract the response if needed.
+ """
+
+ def __init__(self, response, body=None):
+ body_data = body or []
+ self.extend(body_data)
+ self.response = response
+
+ def __str__(self):
+ body = super.__str__(self)
+ return "response: %s\nBody: %s" % (self.response, body)