Adding a recurring maintenance window to a monitor

When you add recurring maintenance windows to a monitor through the API, all pre-existing recurring maintenance windows are overwritten. For this reason, it is important to include in your addition all pre-existing recurring maintenance window definitions. Therefore, before performing the addition, issue a query such as the following:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:prov="http://www.gomeznetworks.com/schemas/provisioning">
   <soapenv:Header/>
   <soapenv:Body>
      <prov:GetMaintenanceWindowsRequest>
         <prov:Credentials>
            <prov:UserName>testuser</prov:UserName>
            <prov:Password>testpassword</prov:Password>
         </prov:Credentials>
         <!--Optional:-->
         <prov:MaintenanceWindowFilter>
            <prov:MonitorIds>
               <!--Zero or more repetitions:-->
               <prov:MonitorId>327989</prov:MonitorId>
            </prov:MonitorIds>
	              <prov:MaintenanceWindowType>RECURRING</prov:MaintenanceWindowType>
         </prov:MaintenanceWindowFilter>
      </prov:GetMaintenanceWindowsRequest>
   </soapenv:Body>
</soapenv:Envelope>

The query returns the pre-existing recurring maintenance windows for the target monitor:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <GetMaintenanceWindowsResponse
           xmlns="http://www.gomeznetworks.com/schemas/provisioning">
         <ResponseStatus>SUCCESS</ResponseStatus>
         <MaintenanceWindowMonitor monitorId="327989"
                                   createDate="2012-11-06T19:32:12.83"
                                   modifyDate="2012-11-07T00:05:00.64"
                                   monitorStatus="Inactive">
            <RecurringMaintenanceWindows>
               <RecurringMaintenanceWindow dayOfWeek="SAT"
                                           startTime="21:50:00.0000000-05:00"
                                           endTime="22:50:00.0000000-05:00"/>
            </RecurringMaintenanceWindows>
         </MaintenanceWindowMonitor>
      </GetMaintenanceWindowsResponse>
   </soap:Body>
</soap:Envelope>

In this example, the recurring maintenance window returned is a window created through the setting of an Account-Level preference. Based on this return data, you can create an AddOrUpdateMaintenanceWindows() request that includes the pre-existing maintenance window and the window that you want to add:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:prov="http://www.gomeznetworks.com/schemas/provisioning">
   <soapenv:Header/>
   <soapenv:Body>
      <prov:AddOrUpdateMaintenanceWindowsRequest>
         <prov:Credentials>
            <prov:UserName>erics</prov:UserName>
            <prov:Password>erics</prov:Password>
         </prov:Credentials>
         <MaintenanceWindowMonitor monitorId="326334"
              xmlns="http://www.gomeznetworks.com/schemas/provisioning">
            <RecurringMaintenanceWindows>
               <RecurringMaintenanceWindow dayOfWeek="SAT"
                                           startTime="01:00:00.0000000-04:00"
                                           endTime="02:20:00.0000000-04:00"
                                           deletionFlag="On"/>
               <RecurringMaintenanceWindow dayOfWeek="SUN"
                                           startTime="21:50:00.0000000-05:00"
                                           endTime="22:50:00.0000000-05:00"/>
            </RecurringMaintenanceWindows>
         </MaintenanceWindowMonitor>
      </prov:AddOrUpdateMaintenanceWindowsRequest>
   </soapenv:Body>
</soapenv:Envelope>

This message will create the new maintenance window for Sunday while preserving the pre-existing maintenance window for Saturday. You don’t need to worry about modifying pre-existing one-time maintenance windows if you are only updating recurring maintenance windows.

The following is the response to this request:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <AddOrUpdateMaintenanceWindowsResponse
           xmlns="http://www.gomeznetworks.com/schemas/provisioning">
         <ResponseStatus>SUCCESS</ResponseStatus>
      </AddOrUpdateMaintenanceWindowsResponse>
   </soap:Body>
</soap:Envelope>