Watchers API Documentation¶
This document provides detailed information about the watchers-related endpoints in the API.
Endpoints¶
1. Create Watchers Table¶
- Endpoint:
POST /watcher/createTable - Description: Creates the watchers table in the database.
- Request Body: None
- Response:
- 200 OK: Returns an integer indicating success.
- 500 Internal Server Error: Error occurred while creating the table.
2. Get All Watchers¶
- Endpoint:
GET /watcher/all - Description: Retrieves all watchers from the database.
- Request Parameters: None
- Response:
- 200 OK: Returns all watchers as an array of objects.
- 500 Internal Server Error: Error occurred while fetching watchers.
3. Get Watcher by ID¶
- Endpoint:
GET /watcher/:watcherid - Description: Retrieves a specific watcher by its ID.
- Path Parameter:
watcherid(string): The ID of the watcher to retrieve.- Response:
- 200 OK: Returns the watcher object.
- 404 Not Found: Watcher with the specified ID not found.
- 500 Internal Server Error: Error occurred while fetching the watcher.
4. Create a New Watcher¶
- Endpoint:
POST /watcher - Description: Creates a new watcher.
- Request Body (JSON):
{ "user": "admin", "dashboard": "controlHub", "service": "status", "type": "webex", "devicesId": ["device1", "device2"], "allDevices": false, "severity": 1, "operations": { "type": "group", "operatorType": "AND", "conditions": [ { "operator": "!=", "value": "connected", "element": "connectionStatus" } ] }, "description": "Alarma si está desconectado", "sendEmail": true, "emails": ["example@example.com"] } - Response:
- 200 OK: Returns the ID of the created watcher.
- 400 Bad Request: Invalid input data.
- 500 Internal Server Error: Error occurred while creating the watcher.
5. Update a Watcher¶
- Endpoint:
PUT /watcher/:watcherid - Description: Updates an existing watcher.
- Path Parameter:
watcherid(string): The ID of the watcher to update.- Request Body (JSON):
{ "user": "admin", "dashboard": "controlHub", "service": "status", "type": "webex", "devicesId": ["device1", "device2"], "allDevices": false, "severity": 1, "operations": { "type": "group", "operatorType": "AND", "conditions": [ { "operator": "!=", "value": "connected", "element": "connectionStatus" } ] }, "description": "Alarma si está desconectado", "sendEmail": true, "emails": ["example@example.com"] } - Response:
- 200 OK: Watcher updated successfully.
- 400 Bad Request: Invalid input data.
- 404 Not Found: Watcher with the specified ID not found.
- 500 Internal Server Error: Error occurred while updating the watcher.
6. Delete a Watcher¶
- Endpoint:
DELETE /watcher/:watcherid - Description: Deletes a specific watcher by its ID.
- Path Parameter:
watcherid(string): The ID of the watcher to delete.- Response:
- 200 OK: Watcher deleted successfully.
- 404 Not Found: Watcher with the specified ID not found.
- 500 Internal Server Error: Error occurred while deleting the watcher.
7. Update Watcher Active Status¶
- Endpoint:
PUT /watcher/:watcherid/status - Description: Updates the active status of a watcher.
- Path Parameter:
watcherid(string): The ID of the watcher to update.- Request Body (JSON):
{ "active": true } - Response:
- 200 OK: Watcher status updated successfully.
- 400 Bad Request: Invalid input data.
- 404 Not Found: Watcher with the specified ID not found.
- 500 Internal Server Error: Error occurred while updating the watcher status.
Notes¶
- Ensure the
x-api-keyheader is included in all requests for authentication. - Refer to the User Guide for additional context on using the API.