Example of creating a maintenance schedule and add a device via UIMAPI Swagger
search cancel

Example of creating a maintenance schedule and add a device via UIMAPI Swagger

book

Article ID: 258579

calendar_today

Updated On:

Products

DX Unified Infrastructure Management (Nimsoft / UIM)

Issue/Introduction

I would like to create a maintenance schedule with the UIMAPI Swagger interface.

Environment

Release : 20.3+

Component: maintenance_mode

Resolution

Create a schedule

XML payload:

<?xml version="1.0" encoding="UTF-8"?>
<MaintenanceSchedule>
 <account_id>-1</account_id>
 <description>test</description>
 <end_time>
  <duration>
   <hours>20</hours>
   <minutes>00</minutes>
   <seconds>00</seconds>
  </duration>
  <type>duration</type>
 </end_time>
 <name>My_Schedule</name>
 <start_date_time>
  <day>27</day>
  <month>02</month>
  <timestamp>
   <hours>08</hours>
   <minutes>45</minutes>
   <seconds>00</seconds>
  </timestamp>
  <year>2023</year>
 </start_date_time>
 <timezone>PST</timezone>
</MaintenanceSchedule>

Curl command from my XML above:

curl -X POST "http://<uimapi system>:80/uimapi/maintenance_mode/<my_system>_domain/<my_system>_hub/<my_system>/add_schedule" -H "accept: application/xml" -H "Content-Type: application/xml" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><MaintenanceSchedule> <account_id>-1</account_id> <description>test</description> <end_time> <duration> <hours>20</hours> <minutes>00</minutes> <seconds>00</seconds> </duration> <type>duration</type> </end_time> <name>My_Schedule</name> <start_date_time> <day>27</day> <month>02</month> <timestamp> <hours>08</hours> <minutes>45</minutes> <seconds>00</seconds> </timestamp> <year>2023</year> </start_date_time> <timezone>PST</timezone></MaintenanceSchedule>"

 

Get a list of schedules

You will need the schedule ID to be used in the curl command.

Curl command:

curl -X GET "http://<uimapi system>:80/uimapi/maintenance_mode/<my_system>_domain/<my_system>_hub/<my_system>/get_all_maintenance_schedules" -H "accept: application/xml"

 

Get a list of devices with IDs

http://<uimapi system>:80/uimapi/devices

 

Add a computer to schedule

The number 1 in the curl command below represents the schedule ID.

JSON payload (where the number represents the cs_id of the system to be added to the schedule):

{
  "cs": [
    9
  ]
}


Curl command for JSON payload above:

curl -X POST "http://<uimapi system>:80/uimapi/maintenance_mode/<my_system>_domain/<my_system>_hub/<my_system>/add_computer_systems_to_schedule/1" -H "accept: application/xml" -H "Content-Type: application/json" -d "{\"cs\":[9]}"


XML payload (where the number represents the cs_id of the system to be added to the schedule):

<?xml version="1.0" encoding="UTF-8"?>
<MaintenanceSchedule>
<cs>8</cs>
</MaintenanceSchedule>


Curl command for XML payload above:

curl -X POST "http://<uimapi system>:80/uimapi/maintenance_mode/<my_system>_domain/<my_system>_hub/<my_system>/add_computer_systems_to_schedule/1" -H "accept: application/xml" -H "Content-Type: application/xml" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><MaintenanceSchedule><cs>8</cs></MaintenanceSchedule>"

Additional Information

When issuing the command it will have a response code of 204 which is normal.  Development has confirmed that this normal response indicates that the operation has completed successfully.