mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[PR #7754/4a1006ac backport][stable-8] Fixed payload format (#7763)
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>
(cherry picked from commit 4a1006ac34
)
Co-authored-by: Ed Ferguson <5855090+eeferg@users.noreply.github.com>
This commit is contained in:
parent
2f47748154
commit
5dc20d9028
2 changed files with 8 additions and 7 deletions
2
changelogs/fragments/7754-fixed-payload-format.yml
Normal file
2
changelogs/fragments/7754-fixed-payload-format.yml
Normal 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).
|
|
@ -286,25 +286,24 @@ def create_maintenance(auth_headers, url, statuspage, host_ids,
|
||||||
returned_date, maintenance_notify_now,
|
returned_date, maintenance_notify_now,
|
||||||
maintenance_notify_72_hr, maintenance_notify_24_hr,
|
maintenance_notify_72_hr, maintenance_notify_24_hr,
|
||||||
maintenance_notify_1_hr):
|
maintenance_notify_1_hr):
|
||||||
returned_dates = [[x] for x in returned_date]
|
|
||||||
component_id = []
|
component_id = []
|
||||||
container_id = []
|
container_id = []
|
||||||
for val in host_ids:
|
for val in host_ids:
|
||||||
component_id.append(val['component_id'])
|
component_id.append(val['component_id'])
|
||||||
container_id.append(val['container_id'])
|
container_id.append(val['container_id'])
|
||||||
|
infrastructure_id = [i + '-' + j for i, j in zip(component_id, container_id)]
|
||||||
try:
|
try:
|
||||||
values = json.dumps({
|
values = json.dumps({
|
||||||
"statuspage_id": statuspage,
|
"statuspage_id": statuspage,
|
||||||
"components": component_id,
|
|
||||||
"containers": container_id,
|
|
||||||
"all_infrastructure_affected": str(int(all_infrastructure_affected)),
|
"all_infrastructure_affected": str(int(all_infrastructure_affected)),
|
||||||
|
"infrastructure_affected": infrastructure_id,
|
||||||
"automation": str(int(automation)),
|
"automation": str(int(automation)),
|
||||||
"maintenance_name": title,
|
"maintenance_name": title,
|
||||||
"maintenance_details": desc,
|
"maintenance_details": desc,
|
||||||
"date_planned_start": returned_dates[0],
|
"date_planned_start": returned_date[0],
|
||||||
"time_planned_start": returned_dates[1],
|
"time_planned_start": returned_date[1],
|
||||||
"date_planned_end": returned_dates[2],
|
"date_planned_end": returned_date[2],
|
||||||
"time_planned_end": returned_dates[3],
|
"time_planned_end": returned_date[3],
|
||||||
"maintenance_notify_now": str(int(maintenance_notify_now)),
|
"maintenance_notify_now": str(int(maintenance_notify_now)),
|
||||||
"maintenance_notify_72_hr": str(int(maintenance_notify_72_hr)),
|
"maintenance_notify_72_hr": str(int(maintenance_notify_72_hr)),
|
||||||
"maintenance_notify_24_hr": str(int(maintenance_notify_24_hr)),
|
"maintenance_notify_24_hr": str(int(maintenance_notify_24_hr)),
|
||||||
|
|
Loading…
Reference in a new issue