From 70d769bbb48f01aeeaf8e8debf5df1c1c8e5e203 Mon Sep 17 00:00:00 2001 From: prahastakumar <55778953+prahastakumar@users.noreply.github.com> Date: Fri, 30 Aug 2024 10:28:50 +0530 Subject: [PATCH] Update grafana_silence.py --- plugins/modules/grafana_silence.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/plugins/modules/grafana_silence.py b/plugins/modules/grafana_silence.py index 5b9a6af9..d995d5cd 100644 --- a/plugins/modules/grafana_silence.py +++ b/plugins/modules/grafana_silence.py @@ -269,20 +269,20 @@ def organization_by_name(self, org_name): ) def get_version(self): - url = "/api/health" - response = self._send_request( - url, data=None, headers=self.headers, method="GET" - ) - version = response.get("version") - if version is not None: - try: - # Split the version by '-' to handle the build number - version_main, build_number = version.split("-") - major, minor, rev = version_main.split(".") - return {"major": int(major), "minor": int(minor), "rev": int(rev), "build": build_number} - except ValueError: - raise GrafanaError(f"Unexpected version format: '{version}'") - raise GrafanaError("Failed to retrieve version from '%s'" % url) + url = "/api/health" + response = self._send_request( + url, data=None, headers=self.headers, method="GET" + ) + version = response.get("version") + if version is not None: + try: + # Split the version by '-' to handle the build number + version_main, build_number = version.split("-") + major, minor, rev = version_main.split(".") + return {"major": int(major), "minor": int(minor), "rev": int(rev), "build": build_number} + except ValueError: + raise GrafanaError(f"Unexpected version format: '{version}'") + raise GrafanaError("Failed to retrieve version from '%s'" % url) def create_silence(self, comment, created_by, starts_at, ends_at, matchers): url = "/api/alertmanager/grafana/api/v2/silences"