1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fixed payload format (#7754)

* Fixed payload format

* added changelog fragment

* Update changelogs/fragments/7754-fixed-payload-format.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Ed Ferguson <eferguson@nrtc.coop>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Ed Ferguson 2023-12-26 15:46:25 -05:00 committed by GitHub
parent 825bec7053
commit 4a1006ac34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- statusio_maintenance - fix error caused by incorrectly formed API data payload. Was raising "Failed to create maintenance HTTP Error 400 Bad Request" caused by bad data type for date/time and deprecated dict keys (https://github.com/ansible-collections/community.general/pull/7754).

View file

@ -286,25 +286,24 @@ def create_maintenance(auth_headers, url, statuspage, host_ids,
returned_date, maintenance_notify_now,
maintenance_notify_72_hr, maintenance_notify_24_hr,
maintenance_notify_1_hr):
returned_dates = [[x] for x in returned_date]
component_id = []
container_id = []
for val in host_ids:
component_id.append(val['component_id'])
container_id.append(val['container_id'])
infrastructure_id = [i + '-' + j for i, j in zip(component_id, container_id)]
try:
values = json.dumps({
"statuspage_id": statuspage,
"components": component_id,
"containers": container_id,
"all_infrastructure_affected": str(int(all_infrastructure_affected)),
"infrastructure_affected": infrastructure_id,
"automation": str(int(automation)),
"maintenance_name": title,
"maintenance_details": desc,
"date_planned_start": returned_dates[0],
"time_planned_start": returned_dates[1],
"date_planned_end": returned_dates[2],
"time_planned_end": returned_dates[3],
"date_planned_start": returned_date[0],
"time_planned_start": returned_date[1],
"date_planned_end": returned_date[2],
"time_planned_end": returned_date[3],
"maintenance_notify_now": str(int(maintenance_notify_now)),
"maintenance_notify_72_hr": str(int(maintenance_notify_72_hr)),
"maintenance_notify_24_hr": str(int(maintenance_notify_24_hr)),