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

[PR #12019/171feb5a backport][stable-12] datadog_downtime: handle uuid.UUID type in API response (#12036)

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



* changelog: add fragment for PR 12019



---------


(cherry picked from commit 171feb5a2c)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
patchback[bot] 2026-05-13 08:07:37 +02:00 committed by GitHub
parent b94ac3fa21
commit 46f6a7a69a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 3 deletions

View file

@ -0,0 +1,4 @@
bugfixes:
- "datadog_downtime - fix ``TypeError`` when returning API response with ``datadog-api-client`` >= 2.28.0
(https://github.com/ansible-collections/community.general/issues/9079,
https://github.com/ansible-collections/community.general/pull/12019)."

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}")