Skip to content

Commit

Permalink
chore: handle provisioning
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemental committed Mar 4, 2024
1 parent 5f6531c commit 6979e85
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions plugins/modules/grafana_contact_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,32 +78,19 @@ class GrafanaAPIException(Exception):
pass


def grafana_contact_point_payload(data):
payload = {
"uid": data["uid"],
"name": data["name"],
"type": data["type"],
"isDefault": data["is_default"],
"disableResolveMessage": data["disable_resolve_message"],
}

return payload


def grafana_contact_point_payload_email(data, payload):
payload["settings"]["addresses"] = ";".join(data["email_addresses"])
if data.get("email_single"):
payload["settings"]["singleEmail"] = data["email_single"]


def grafana_contact_point_payload(data):
payload = {
"uid": data["uid"],
"name": data["name"],
"type": data["type"],
"isDefault": data["is_default"],
"disableResolveMessage": data["disable_resolve_message"],
"settings": {"uploadImage": data["include_image"]},
"settings": {},
}

if data["type"] == "email":
Expand Down Expand Up @@ -134,6 +121,10 @@ def __init__(self, module):
self.grafana_switch_organisation(module.params, self.org_id)
# }}}

def grafana_api_provisioning(self, data):
if not data["provisioning"]:
self.headers["X-Disable-Provenance"] = "true"

def grafana_organization_by_name(self, data, org_name):
r, info = fetch_url(
self._module,
Expand Down Expand Up @@ -188,6 +179,7 @@ def grafana_handle_contact_point(self, data, before):
if before:
return self.grafana_update_contact_point(data, payload, before)
else:
self.grafana_api_provisioning(data)
return self.grafana_create_contact_point(data, payload)
else:
if before:
Expand Down Expand Up @@ -267,6 +259,7 @@ def main():
name=dict(type="str"),
org_id=dict(type="int", default=1),
org_name=dict(type="str"),
provisioning=dict(type="bool", default=True),
type=dict(
type="str",
choices=[
Expand Down

0 comments on commit 6979e85

Please sign in to comment.