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:
parent
6e48c5fc4e
commit
171feb5a2c
2 changed files with 14 additions and 3 deletions
4
changelogs/fragments/12019-datadog-downtime-uuid.yml
Normal file
4
changelogs/fragments/12019-datadog-downtime-uuid.yml
Normal 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)."
|
||||
|
|
@ -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}")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue