Skip to content

Commit

Permalink
chore: add state to return
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemental committed May 28, 2024
1 parent 6f10807 commit ee9ff4d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions plugins/modules/grafana_contact_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ def grafana_handle_contact_point(self, data):
if self.contact_point:
return self.grafana_delete_contact_point(data)
else:
return {"changed": False}
return {"changed": False, "state": data["state"]}

def grafana_create_contact_point(self, data, payload):
r, info = fetch_url(
Expand All @@ -1031,6 +1031,7 @@ def grafana_create_contact_point(self, data, payload):
return {
"changed": True,
"contact_point": contact_point,
"state": data["state"],
}
else:
raise GrafanaAPIException("Unable to create contact point: %s" % info)
Expand All @@ -1051,12 +1052,13 @@ def grafana_update_contact_point(self, data, payload):
del contact_point["provenance"]

if self.contact_point == contact_point:
return {"changed": False, "contact_point": contact_point}
return {"changed": False, "contact_point": contact_point, "state": data["state"]}
else:
return {
"changed": True,
"diff": {"before": self.contact_point, "after": contact_point},
"contact_point": contact_point,
"state": data["state"],
}
else:
raise GrafanaAPIException(
Expand All @@ -1072,9 +1074,9 @@ def grafana_delete_contact_point(self, data):
)

if info["status"] == 202:
return {"changed": True, "contact_point": self.contact_point}
return {"changed": True, "contact_point": self.contact_point, "state": data["state"]}
elif info["status"] == 404:
return {"changed": False}
return {"changed": False, "state": data["state"]}
else:
raise GrafanaAPIException(
"Unable to delete contact point '%s': %s" % (data["uid"], info)
Expand Down

0 comments on commit ee9ff4d

Please sign in to comment.