mneethiraj commented on code in PR #158:
URL: https://github.com/apache/atlas/pull/158#discussion_r1215633135
##########
intg/src/main/python/apache_atlas/client/base_client.py:
##########
@@ -68,51 +68,36 @@ def call_api(self, api, response_type=None,
query_params=None, request_obj=None)
if request_obj is not None:
params['data'] = json.dumps(request_obj)
- if log.isEnabledFor(logging.DEBUG):
- log.debug("------------------------------------------------------")
- log.debug("Call : %s %s", api.method, path)
- log.debug("Content-type : %s", api.consumes)
- log.debug("Accept : %s", api.produces)
-
- response = None
-
- if api.method == HTTPMethod.GET:
- response = self.session.get(path, **params)
- elif api.method == HTTPMethod.POST:
- response = self.session.post(path, **params)
- elif api.method == HTTPMethod.PUT:
- response = self.session.put(path, **params)
- elif api.method == HTTPMethod.DELETE:
- response = self.session.delete(path, **params)
-
- if response is not None:
- log.debug("HTTP Status: %s", response.status_code)
-
- if response is None:
- return None
- elif response.status_code == api.expected_status:
+ log.debug("------------------------------------------------------")
+ log.debug("Call : %s %s", api.method, path)
+ log.debug("Content-type : %s", api.consumes)
+ log.debug("Accept : %s", api.produces)
+
+ method = HTTPMethod(api.method)
+ response = self.session.request(method.value, path, **params)
+ log.debug("HTTP Status: %s", response.status_code)
+
+ if response.status_code == api.expected_status:
if response_type is None:
return None
+
+ if response.content is None:
+ return None
+ log.debug("<== __call_api(%s,%s,%s), result = %s", vars(api),
params, request_obj, response)
try:
- if response.content is not None:
- if log.isEnabledFor(logging.DEBUG):
- log.debug("<== __call_api(%s,%s,%s), result = %s",
vars(api), params, request_obj, response)
+ log.debug(response.json())
- log.debug(response.json())
- if response_type == str:
- return json.dumps(response.json())
+ if response_type == str:
+ return json.dumps(response.json())
- return type_coerce(response.json(), response_type)
- else:
- return None
+ return type_coerce(response.json(), response_type)
except Exception as e:
- log.exception("Exception occurred while parsing response with
msg: %s", e)
+ log.exception("Exception occurred while parsing response")
Review Comment:
For easier troubleshooting, I suggest to retain including of exception
details in the log:
` log.exception("Exception occurred while parsing response with msg: %s", e)
`
##########
intg/src/main/python/apache_atlas/client/base_client.py:
##########
@@ -68,51 +68,36 @@ def call_api(self, api, response_type=None,
query_params=None, request_obj=None)
if request_obj is not None:
params['data'] = json.dumps(request_obj)
- if log.isEnabledFor(logging.DEBUG):
- log.debug("------------------------------------------------------")
- log.debug("Call : %s %s", api.method, path)
- log.debug("Content-type : %s", api.consumes)
- log.debug("Accept : %s", api.produces)
-
- response = None
-
- if api.method == HTTPMethod.GET:
- response = self.session.get(path, **params)
- elif api.method == HTTPMethod.POST:
- response = self.session.post(path, **params)
- elif api.method == HTTPMethod.PUT:
- response = self.session.put(path, **params)
- elif api.method == HTTPMethod.DELETE:
- response = self.session.delete(path, **params)
-
- if response is not None:
- log.debug("HTTP Status: %s", response.status_code)
-
- if response is None:
- return None
- elif response.status_code == api.expected_status:
+ log.debug("------------------------------------------------------")
+ log.debug("Call : %s %s", api.method, path)
+ log.debug("Content-type : %s", api.consumes)
+ log.debug("Accept : %s", api.produces)
+
+ method = HTTPMethod(api.method)
Review Comment:
Is `method` necessary? Why not use `api.method.value` in the following line?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]