Skip to content

Commit

Permalink
Revert "add fragment and improve module code quality"
Browse files Browse the repository at this point in the history
This reverts commit fc91b567112565cfb2f97e5d35ddbeab7983ef5a.
  • Loading branch information
rndmh3ro committed Jan 4, 2024
1 parent 2ae6553 commit 8eb7404
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 0 additions & 2 deletions changelogs/fragments/add grafana_silence module.yml

This file was deleted.

16 changes: 9 additions & 7 deletions plugins/modules/grafana_silence.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright: (c) 2023, flkhndlr (@flkhndlr)
# Copyright: (c) 2023, Rémi REY (@rrey)

from __future__ import absolute_import, division, print_function

DOCUMENTATION = '''
---
module: grafana_silence
author:
- flkhndlr (@flkhndlr)
- Falk (@flkhndlr)
version_added: "1.5.5"
short_description: Manage Grafana Silences
description:
Expand Down Expand Up @@ -169,6 +169,7 @@
from ansible.module_utils.urls import fetch_url, basic_auth_header
from ansible.module_utils._text import to_text
from ansible_collections.community.grafana.plugins.module_utils import base
from ansible.module_utils.six.moves.urllib.parse import quote

__metaclass__ = type

Expand Down Expand Up @@ -230,20 +231,20 @@ def get_version(self):
return {"major": int(major), "minor": int(minor), "rev": int(rev)}
raise GrafanaError("Failed to retrieve version from '%s'" % url)

def create_silence(self, comment, created_by, starts_at, ends_at, matchers):
def create_silence(self, comment, createdBy, startsAt ,endsAt, matchers):
url = "/api/alertmanager/grafana/api/v2/silences"
silence = dict(comment=comment, createdBy=created_by, startsAt=starts_at, endsAt=ends_at, matchers=matchers)
silence = dict(comment=comment, createdBy=createdBy, startsAt=startsAt, endsAt=endsAt, matchers=matchers)
response = self._send_request(url, data=silence, headers=self.headers, method="POST")
return response

def get_silence(self, comment, created_by, starts_at, ends_at, matchers):
def get_silence(self, comment, createdBy, startsAt ,endsAt, matchers):
url = "/api/alertmanager/grafana/api/v2/silences"

responses = self._send_request(url, headers=self.headers, method="GET")

for response in responses:
if response["comment"] == comment and response["createdBy"] == created_by and \
response["startsAt"] == starts_at and response["endsAt"] == ends_at and \
if response["comment"] == comment and response["createdBy"] == createdBy and \
response["startsAt"] == startsAt and response["endsAt"] == endsAt and \
response["matchers"] == matchers:
return response
else:
Expand All @@ -266,6 +267,7 @@ def delete_silence(self, silence_id):
return response



def setup_module_object():
module = AnsibleModule(
argument_spec=argument_spec,
Expand Down

0 comments on commit 8eb7404

Please sign in to comment.