1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-05-12 12:44:15 +00:00

datadog_downtime: handle uuid.UUID type in API response (#12019)

* fix(datadog_downtime): convert uuid field to str for datadog-api-client>=2.28.0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* changelog: add fragment for PR 12019

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Alexei Znamensky 2026-05-12 20:59:14 +12:00 committed by GitHub
parent 6e48c5fc4e
commit 171feb5a2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 3 deletions

View file

@ -247,13 +247,20 @@ def build_downtime(module):
return downtime
def _resp_to_dict(resp):
d = resp.to_dict()
if "uuid" in d:
d["uuid"] = str(d["uuid"])
return d
def _post_downtime(module, api_client):
api = DowntimesApi(api_client)
downtime = build_downtime(module)
try:
resp = api.create_downtime(downtime)
module.params["id"] = resp.id
module.exit_json(changed=True, downtime=resp.to_dict())
module.exit_json(changed=True, downtime=_resp_to_dict(resp))
except ApiException as e:
module.fail_json(msg=f"Failed to create downtime: {e}")
@ -273,9 +280,9 @@ def _update_downtime(module, current_downtime, api_client):
else:
resp = api.update_downtime(module.params["id"], downtime)
if _equal_dicts(resp.to_dict(), current_downtime.to_dict(), ["active", "creator_id", "updater_id"]):
module.exit_json(changed=False, downtime=resp.to_dict())
module.exit_json(changed=False, downtime=_resp_to_dict(resp))
else:
module.exit_json(changed=True, downtime=resp.to_dict())
module.exit_json(changed=True, downtime=_resp_to_dict(resp))
except ApiException as e:
module.fail_json(msg=f"Failed to update downtime: {e}")