diff --git a/README.md b/README.md index f9c9699..1d1e967 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: - API version: 2.0.0 -- Package version: 2.1.2 +- Package version: 2.1.3 - Build package: com.atlassian.opsgenie.codegen.geniepy.GeniepyGenerator For more information, please visit [https://www.opsgenie.com/contact-us](https://www.opsgenie.com/contact-us) diff --git a/opsgenie_sdk/__init__.py b/opsgenie_sdk/__init__.py index 8bf26b5..b30ba61 100644 --- a/opsgenie_sdk/__init__.py +++ b/opsgenie_sdk/__init__.py @@ -168,7 +168,7 @@ from opsgenie_sdk.models.weekday_time_restriction_interval import WeekdayTimeRestrictionInterval from opsgenie_sdk.models.weekday_time_restriction_interval_all_of import WeekdayTimeRestrictionIntervalAllOf -__version__ = "2.1.2" +__version__ = "2.1.3" # import apis into sdk package diff --git a/opsgenie_sdk/api_client.py b/opsgenie_sdk/api_client.py index caf7fbc..245cebe 100644 --- a/opsgenie_sdk/api_client.py +++ b/opsgenie_sdk/api_client.py @@ -88,7 +88,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None, self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = 'opsgenie-sdk-python-2.1.2' + self.user_agent = 'opsgenie-sdk-python-2.1.3' # init metric publishers self.http_metric_publisher = self.rest_client.http_metric diff --git a/opsgenie_sdk/configuration.py b/opsgenie_sdk/configuration.py index 135529f..32466d5 100644 --- a/opsgenie_sdk/configuration.py +++ b/opsgenie_sdk/configuration.py @@ -252,7 +252,7 @@ def to_debug_report(self): "OS: {env}\n"\ "Python Version: {pyversion}\n"\ "Version of the API: 2.0.0\n"\ - "SDK Package Version: 2.1.2".\ + "SDK Package Version: 2.1.3".\ format(env=sys.platform, pyversion=sys.version) def get_host_settings(self): diff --git a/opsgenie_sdk/rest.py b/opsgenie_sdk/rest.py index 75fa272..d7c5b16 100644 --- a/opsgenie_sdk/rest.py +++ b/opsgenie_sdk/rest.py @@ -236,27 +236,28 @@ def request(self, method, url, query_params=None, headers=None, # log response body logger.debug("response body: %s", r.data) - data = self.decodeResponse(r.data) http_metrics_request = [('method', method), ('url', url), ('query_params', query_params), ('headers', headers), ('body', body), ('post_params', post_params)] - if "message" not in data: - self.http_metric.build_metric(transaction_id=self.configuration.metrics_transaction_id, - duration=data.get("took"), - resource_path=url, - retry_statistics=copy.deepcopy(self.retrying.statistics), - error=False, - status=r.status, - status_code=r.status, - request=http_metrics_request) - else: - self.http_metric.build_metric(transaction_id=self.configuration.metrics_transaction_id, - duration=data.get("took"), - resource_path=url, - retry_statistics=copy.deepcopy(self.retrying.statistics), - error=True, - status=r.status, - status_code=r.status, - request=http_metrics_request) + + try: + data = self.decodeResponse(r.data) + duration = data.get("took") + if "message" not in data: + error = False + else: + error = True + except: + duration = None + error = True + + self.http_metric.build_metric(transaction_id=self.configuration.metrics_transaction_id, + duration=duration, + resource_path=url, + retry_statistics=copy.deepcopy(self.retrying.statistics), + error=error, + status=r.status, + status_code=r.status, + request=http_metrics_request) should_retry = self.__checkHttpCode__(r.status) if should_retry: diff --git a/scripts/sdk/config.json b/scripts/sdk/config.json index f3baa11..f77bee7 100644 --- a/scripts/sdk/config.json +++ b/scripts/sdk/config.json @@ -1,7 +1,7 @@ { "packageName": "opsgenie_sdk", "projectName": "opsgenie-sdk", - "packageVersion": "2.1.2", + "packageVersion": "2.1.3", "packageUrl": "https://github.com/opsgenie/opsgenie-python-sdk", "sortParamsByRequiredFlag": "true", "hideGenerationTimestamp": "true", diff --git a/setup.py b/setup.py index 18dcda7..1405640 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ from setuptools import setup, find_packages # noqa: H301 NAME = "opsgenie-sdk" -VERSION = "2.1.2" +VERSION = "2.1.3" # To install the library, run the following # # python setup.py install diff --git a/templates/api_client.mustache b/templates/api_client.mustache index 5cbc7cc..779e8af 100755 --- a/templates/api_client.mustache +++ b/templates/api_client.mustache @@ -190,13 +190,13 @@ class ApiClient(object): # perform request and return response try: - response_data = {{#asyncio}}await {{/asyncio}}{{#tornado}}yield {{/tornado}}self.retrying.call(fn=self.request, method=method, url=url, - query_params=query_params, - headers=header_params, - post_params=post_params, - body=body, - _preload_content=_preload_content, - _request_timeout=_request_timeout) + response_data = {{#asyncio}}await {{/asyncio}}{{#tornado}}yield {{/tornado}}self.retrying(fn=self.request, method=method, url=url, + query_params=query_params, + headers=header_params, + post_params=post_params, + body=body, + _preload_content=_preload_content, + _request_timeout=_request_timeout) except Exception as exception: self._sdk_request_details = { "query_params": query_params, diff --git a/templates/rest.mustache b/templates/rest.mustache index 2181f9a..46fe97a 100755 --- a/templates/rest.mustache +++ b/templates/rest.mustache @@ -227,27 +227,28 @@ class RESTClientObject(object): # log response body logger.debug("response body: %s", r.data) - data = self.decodeResponse(r.data) http_metrics_request = [('method', method), ('url', url), ('query_params', query_params), ('headers', headers), ('body', body), ('post_params', post_params)] - if "message" not in data: - self.http_metric.build_metric(transaction_id=self.configuration.metrics_transaction_id, - duration=data.get("took"), - resource_path=url, - retry_statistics=copy.deepcopy(self.retrying.statistics), - error=False, - status=r.status, - status_code=r.status, - request=http_metrics_request) - else: - self.http_metric.build_metric(transaction_id=self.configuration.metrics_transaction_id, - duration=data.get("took"), - resource_path=url, - retry_statistics=copy.deepcopy(self.retrying.statistics), - error=True, - status=r.status, - status_code=r.status, - request=http_metrics_request) + + try: + data = self.decodeResponse(r.data) + duration = data.get("took") + if "message" not in data: + error = False + else: + error = True + except: + duration = None + error = True + + self.http_metric.build_metric(transaction_id=self.configuration.metrics_transaction_id, + duration=duration, + resource_path=url, + retry_statistics=copy.deepcopy(self.retrying.statistics), + error=error, + status=r.status, + status_code=r.status, + request=http_metrics_request) should_retry = self.__checkHttpCode__(r.status) if should_retry: