View Source

WAS THIS PAGE HELPFUL? {html}<a href="mailto:training@gwos.com?subject=Notification APIs">Leave Feedback</a>{html}

h4. 15.0 Notification APIs

h5. 15.1 Create Host Notifications

Send a batch (1..n) of host NOMA notifications to GroundWork server.

If one or more notification messages fails, others may still succeed. This is not an all-or-none transactional operation. The results of each individual notification message is returned back in the resultset described below with a status of success or failure.

h6. 15.1.1 Method: POST

{color:#4a86e8}POST /api/notifications/hosts{color}

h6. 15.1.2 HTTP Headers

|| Header || Valid Values || Required ||
| Content-Type | application/xml or application/json | True |
| GWOS-API-TOKEN | a valid token returned from login | True |
| GWOS-APP-NAME | your application name | True |

h6. 15.1.3 Post Data Attributes and Elements

|| Field || Description || Required ||
| hostState | A valid Host Monitor Status such as UP, UNREACHABLE, WARNING, PENDING, UNSCHEDULED DOWN, SCHEDULED DOWN, DOWN | Yes |
| hostName | the name of the host | Yes |
| hostGroupNames | a comma-separated list of one or more valid host group names | No |
| notificationType | A valid Notification type such as RECOVERY or PROBLEM | Yes |
| hostAddress | the IP address of the host | No |
| hostOutput | the textual output to be sent to the notification server | Yes |
| checkDateTime | a time stamp in YYYY-MM-DD hh:mm:ss format | No |
| hostNotificationId | | No |
| notificationAuthOrAlias | &nbsp; | No |
| notificationComment | Additional comments | No |
| notificationRecipients | | No |

h6. 15.1.4 XML POST Data Example
{code}<notifications>
<notification
hostName='server-12'
hostAddress='10.0.0.11'
hostGroupNames='group-21,group-22'
hostNotificationId=''
hostOutput='Hypervisor cannot be reached to determine the status'
hostState='PENDING'
notificationComment='Cloud Hub Host Notification'
notificationRecipients=''
notificationType='RECOVERY'
checkDateTime='2014-04-14 07:21:'
notificationAuthOrAlias=''
/>
</notifications>{code}

See [Appendix A|1.0 Appendix A Curl Examples] for examples of usage with Curl
More Post Data Examples: [XML|2.0 Appendix B XML Example Data#Consolidation Post Data Data XML] \- [JSON|3.0 Appendix C JSON Example Data#Consolidation Post Data Data JSON]

h6. 15.1.5 HTTP Status Codes

200 - Zero or more notifications were created without any internal server errors
500 - An internal server error occurred

h6. 15.1.6 Example Response

In this example, we use the POST data above. Two host notifications were successfully created.
{code}<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<results successful="2" failed="0" entityType="HostNotification"
operation="Update" warning="0" count="2">
<result>
<entity>server-12</entity>
<message></message>
<status>success</status>
</result>
<result>
<entity>server-13</entity>
<message></message>
<status>success</status>
</result>
</results>{code}

h5. 15.2 Create Service Notifications

Send a batch (1..n) of service NOMA notifications to GroundWork server.

If one or more notification messages fails, others may still succeed. This is not an all-or-none transactional operation. The results of each individual notification message is returned back in the resultset described below with a status of success or failure.

h6. 15.2.1 Method: POST

{color:#4a86e8}POST /api/notifications/services{color}

h6. 15.2.2 HTTP Headers

|| Header || Valid Values || Required ||
| Content-Type | application/xml or application/json | True |
| GWOS-API-TOKEN | a valid token returned from login | True |
| GWOS-APP-NAME | your application name | True |

h6. 15.2.3 Post Data Attributes and Elements

|| Field || Description || Required ||
| serviceState | A valid Service Status such as WARNING, OK, UNKNOWN, UNSCHEDULED CRITICAL, PENDING_SERVICE, SCHEDULED CRITICAL | Yes |
| hostName | The name of the host | Yes |
| hostGroupNames | a comma-separated list of one or more valid Host Group names | No |
| serviceGroupNames | a comma-separated list of one or more valid Service Group names | No |
| serviceDescription | the name (description) of the service | Yes |
| serviceOutput | the textual output to be sent to the notification server | Yes |
| notificationType | A valid Notification type such as RECOVERY or PROBLEM | Yes |
| hostAlias | | No |
| hostAddress | the IP address of the host | No |
| checkDateTime | a time stamp in YYYY-MM-DD hh:mm:ss format | No |
| serviceNotificationId | | No |
| notificationAuthOrAlias | &nbsp; | No |
| notificationComment | Additional comments | No |
| notificationRecipients | | No |

h6. 15.2.4 XML POST Data Example
{code}<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<notifications>
<notification
hostName='server-12'
serviceDescription='local_cpu_nagios'
hostAddress='10.0.0.11'
hostGroupNames='group-21,group-22'
hostAlias='host1'
serviceGroupNames='sg1,sg2'
serviceOutput='Service cannot be reached to determine the status'
serviceState='UNKNOWN'
serviceNotificationId='433'
notificationComment='Cloud Hub Host Notification'
notificationRecipients='admin@gwos.com'
notificationType='RECOVERY'
checkDateTime='2014-04-14 07:21:33'
notificationAuthOrAlias='alias'
/>
/notifications>{code}

See [Appendix A|1.0 Appendix A Curl Examples] for examples of usage with Curl
More Post Data Examples: [XML|2.0 Appendix B XML Example Data#Service Notification POST Data XML] \- [JSON|3.0 Appendix C JSON Example Data#Service Notification POST Data JSON]


h6. 15.2.5 HTTP Status Codes

200 - Zero or more notifications were created without any internal server errors
500 - An internal server error occurred

h6. 15.2.6 Example Response

In this example, we use the POST data above. Two service notifications were successfully created.
{code}<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<results successful="2" failed="0" entityType="ServiceNotification"
operation="Update" warning="0" count="2">
<result>
<entity>server-12:local_cpu_nagios</entity>
<message></message>
<status>success</status>
</result>
<result>
<entity>service-13:vm.cpu_util</entity>
<message></message>
<status>success</status>
</result>
</results>{code}