{
  "openapi": "3.0.3",
  "info": {
    "title": "Waylay Alarms",
    "version": "1.13.1",
    "description": ""
  },
  "externalDocs": {
    "url": "https://docs.waylay.io/#/api/alarms/",
    "description": "Waylay Documentation"
  },
  "tags": [
    {
      "name": "Alarms"
    },
    {
      "name": "Alarm Events"
    },
    {
      "name": "Alarms Batch Operations"
    },
    {
      "name": "About"
    }
  ],
  "paths": {
    "/alarms/v1/alarms": {
      "post": {
        "operationId": "create",
        "summary": "Create Alarm",
        "description": "Create an alarm.\n\nIf an `ACTIVE` or `ACKNOWLEDGED` alarm with the same `source.id` and `type` exists, \nno new alarm is created. \n\nInstead, the existing alarm is updated by incrementing the `count` property \nand a new audit record of type `io.waylay.alarm.EventOccuredAgain` is added to the history. \n\nOnly the latest 1000 `io.waylay.alarm.EventOccuredAgain` audit records are kept in the history.",
        "tags": [
          "Alarms"
        ],
        "externalDocs": {
          "description": "Waylay Docs",
          "url": "https://docs.waylay.io/#/api/alarms/?id=create-an-alarm"
        },
        "requestBody": {
          "$ref": "#/components/requestBodies/AlarmsSpecification"
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/SuccessCreationResponse"
          },
          "400": {
            "$ref": "#/components/responses/ErrorResponseWithDetails"
          }
        },
        "security": [
          {
            "waylayApiKeySecret": []
          }
        ]
      },
      "get": {
        "operationId": "list",
        "summary": "Query Multiple Alarms",
        "description": "Query multiple alarms using a query language.\nThe response contains the total number of alarms that fulfill the criteria.\n\nBy default, returns the first 50 alarms.",
        "tags": [
          "Alarms"
        ],
        "externalDocs": {
          "description": "Waylay Docs",
          "url": "https://docs.waylay.io/#/api/alarms/?id=query-multiple-alarms"
        },
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/AlarmType"
              }
            },
            "explode": true,
            "description": "Filter on one or more alarm types."
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/AlarmStatus"
              }
            },
            "description": "Filter on one or more alarm statuses.",
            "explode": true
          },
          {
            "name": "severity",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/AlarmSeverity"
              }
            },
            "description": "Filter on one or more alarm severities.",
            "explode": true
          },
          {
            "name": "source",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "explode": true,
            "description": "Filter on one or more source ids.\n\nAt least one source id is mandatory in combination with `Accept: application/vnd.waylay.alarms.timeseries+json`"
          },
          {
            "name": "dateFrom",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/UnixEpochMillis"
            },
            "description": "Filter on alarm timestamp (equal or above)."
          },
          {
            "name": "dateTo",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/UnixEpochMillis"
            },
            "description": "Filter on alarm timestamp (equal or below)."
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/UnixEpochMillis"
            },
            "description": "Only applicable in combination with `Accept: application/vnd.waylay.alarms.timeseries+json`\n\nLimits the timestamp of the Alarm Audit Records to be >= `from`"
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/UnixEpochMillis"
            },
            "description": "Only applicable in combination with `Accept: application/vnd.waylay.alarms.timeseries+json`\n\nLimits the timestamp of the Alarm Audit Records to be <= `to`"
          },
          {
            "name": "creationTimeFrom",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/UnixEpochMillis"
            },
            "description": "Filter on alarm creationTime (equal or above)."
          },
          {
            "name": "creationTimeTo",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/UnixEpochMillis"
            },
            "description": "Filter on alarm creationTime (equal or below)."
          },
          {
            "name": "lastUpdatedFrom",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/UnixEpochMillis"
            },
            "description": "Filter on alarm lastUpdateTime (equal or above)."
          },
          {
            "name": "lastUpdatedTo",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/UnixEpochMillis"
            },
            "description": "Filter on alarm lastUpdateTime (equal or below)."
          },
          {
            "name": "lastTriggeredFrom",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/UnixEpochMillis"
            },
            "description": "Filter on alarm lastTriggeredTime (equal or above)."
          },
          {
            "name": "lastTriggeredTo",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/UnixEpochMillis"
            },
            "description": "Filter on alarm lastTriggeredTime (equal or below)."
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "timestamp",
                "lastUpdateTime",
                "lastTriggeredTime"
              ],
              "default": "timestamp"
            },
            "description": "(Pagination) field used to sort the alarms\n\nIgnored in combination with `Accept: application/vnd.waylay.alarms.timeseries+json`"
          },
          {
            "name": "order",
            "in": "query",
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "title": "Sort order",
                  "x-classname": "SortOrder",
                  "enum": [
                    "ascending",
                    "descending"
                  ],
                  "default": "descending"
                },
                {
                  "type": "string",
                  "title": "Deprecated Sort order",
                  "x-classname": "DeprecatedSortOrder",
                  "enum": [
                    "asc",
                    "desc"
                  ],
                  "default": "desc",
                  "deprecated": true
                }
              ]
            },
            "description": "(Pagination) sort order\n\nIgnored in combination with `Accept: application/vnd.waylay.alarms.timeseries+json`"
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 1
            },
            "description": "(Pagination) page Number \n\nIgnored in combination with `Accept: application/vnd.waylay.alarms.timeseries+json`"
          },
          {
            "name": "size",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50
            },
            "description": "(Pagination) size of a page\n\nIgnored in combination with `Accept: application/vnd.waylay.alarms.timeseries+json`"
          },
          {
            "name": "additionalQueryParams",
            "in": "query",
            "style": "form",
            "explode": true,
            "schema": {
              "type": "object",
              "x-classname": "AdditionalQueryParams",
              "additionalProperties": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "string"
                  },
                  {
                    "type": "boolean"
                  }
                ],
                "x-classname": "AdditionalQueryParamValue"
              }
            },
            "description": "To query the alarms based on the value of an additional property of the alarm, \nyou can add the key of the additional property as query parameter \nwith value the value you expect the alarm to have.",
            "example": {
              "task": 3425
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "headers": {
              "X-Count": {
                "description": "Total number of alarms that fulfill the criteria",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AlarmsQueryResult"
                }
              },
              "application/vnd.waylay.alarms.timeseries+json": {
                "schema": {
                  "title": "Query alarms as a timeline",
                  "externalDocs": {
                    "description": "Query alarms as a timeline",
                    "url": "https://docs.waylay.io/#/api/alarms/?id=query-alarms-as-a-timeline"
                  },
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AlarmsTimelineItem"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ErrorResponse"
          }
        },
        "security": [
          {
            "waylayApiKeySecret": []
          }
        ]
      }
    },
    "/alarms/v1/alarms/{alarmId}": {
      "get": {
        "operationId": "get_alarm",
        "summary": "Get Alarm",
        "description": "Get an alarm.",
        "tags": [
          "Alarms"
        ],
        "externalDocs": {
          "description": "Waylay Docs",
          "url": "https://docs.waylay.io/#/api/alarms/?id=get-an-alarm"
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/AlarmId"
          }
        ],
        "responses": {
          "200": {
            "description": "Alarm Fetched",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AlarmEntity"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/AlarmNotFoundResponse"
          }
        },
        "security": [
          {
            "waylayApiKeySecret": []
          }
        ]
      },
      "put": {
        "operationId": "update",
        "summary": "Update Alarm",
        "description": "Update an alarm.",
        "tags": [
          "Alarms"
        ],
        "externalDocs": {
          "description": "Waylay Docs",
          "url": "https://docs.waylay.io/#/api/alarms/?id=update-an-alarm"
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/AlarmId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AlarmUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Alarm Updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AlarmEntity"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ErrorResponseWithDetails"
          },
          "404": {
            "$ref": "#/components/responses/AlarmNotFoundResponse"
          },
          "412": {
            "description": "Precondition Failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "statusCode": 412,
                  "error": "Alarm is in final state"
                }
              }
            }
          }
        },
        "security": [
          {
            "waylayApiKeySecret": []
          }
        ]
      },
      "delete": {
        "operationId": "delete",
        "summary": "Delete Alarm",
        "description": "Delete an Alarm.",
        "tags": [
          "Alarms"
        ],
        "externalDocs": {
          "description": "Waylay Docs",
          "url": "https://docs.waylay.io/#/api/alarms/?id=deletion-of-an-alarm"
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/AlarmId"
          }
        ],
        "responses": {
          "204": {
            "description": "Alarm Deleted"
          },
          "404": {
            "$ref": "#/components/responses/AlarmNotFoundResponse"
          }
        },
        "security": [
          {
            "waylayApiKeySecret": []
          }
        ]
      }
    },
    "/alarms/v1/events": {
      "get": {
        "operationId": "get_eventstream",
        "summary": "Alarm Events",
        "description": "Opens a data stream for all Alarm Events for this tenant.",
        "tags": [
          "Alarm Events"
        ],
        "externalDocs": {
          "description": "Waylay Docs",
          "url": "https://docs.waylay.io/#/api/alarms/?id=alarm-events"
        },
        "parameters": [
          {
            "name": "eventFormat",
            "in": "query",
            "schema": {
              "type": "string",
              "x-classname": "EventStreamFormat",
              "enum": [
                "application/cloudevents+json"
              ]
            },
            "description": "The format of events in the stream. \n\nIf specified this must be `application/cloudevents+json` (make sure to correctly URL encode the `+` as `%2B`)"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/GetEventStreamResponse"
          }
        },
        "security": [
          {
            "waylayApiKeySecret": []
          }
        ]
      }
    },
    "/alarms/v1/batch": {
      "post": {
        "operationId": "start",
        "summary": "Start Alarms Batch Operation",
        "description": "Start Alarms Batch Operation.",
        "tags": [
          "Alarms Batch Operations"
        ],
        "externalDocs": {
          "description": "Waylay Docs",
          "url": "https://docs.waylay.io/#/api/alarms/?id=batch-alarm-operations"
        },
        "requestBody": {
          "$ref": "#/components/requestBodies/BatchAlarmsSpecification"
        },
        "responses": {
          "202": {
            "$ref": "#/components/responses/BatchStartResponse"
          },
          "400": {
            "$ref": "#/components/responses/ErrorResponseWithDetails"
          }
        },
        "security": [
          {
            "waylayApiKeySecret": []
          }
        ]
      }
    },
    "/alarms/v1/batch/{batchId}": {
      "get": {
        "operationId": "get_batchoperation",
        "summary": "Get Alarms Batch Operation Status",
        "description": "Get the results of the Alarms Batch Operation.",
        "externalDocs": {
          "description": "Waylay Docs",
          "url": "https://docs.waylay.io/#/api/alarms/?id=batch-alarm-operations"
        },
        "tags": [
          "Alarms Batch Operations"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/BatchId"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/GetBatchOperationResponse"
          },
          "404": {
            "$ref": "#/components/responses/BatchNotFoundResponse"
          }
        },
        "security": [
          {
            "waylayApiKeySecret": []
          }
        ]
      }
    },
    "/alarms/v1": {
      "get": {
        "tags": [
          "About"
        ],
        "operationId": "get_about",
        "summary": "Get Service Information",
        "description": "Get the name and version of the service.",
        "responses": {
          "200": {
            "$ref": "#/components/responses/VersionResponse"
          }
        },
        "security": [
          {
            "waylayApiKeySecret": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "AlarmId": {
        "title": "Alarm identifier",
        "description": "Unique alarm identifier.",
        "type": "string",
        "example": "2c49e3bf-547b-42bc-a5e9-9193155ec03d"
      },
      "VersionResponse": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "example": "2.7.0"
          },
          "name": {
            "type": "string",
            "example": "alarm-service"
          }
        },
        "required": [
          "name",
          "version"
        ]
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "integer",
            "title": "The error code",
            "example": 400
          },
          "error": {
            "type": "string",
            "title": "The error message",
            "example": "error in body"
          }
        },
        "required": [
          "statusCode",
          "error"
        ]
      },
      "ErrorResponseWithDetails": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ErrorResponse"
          },
          {
            "type": "object",
            "properties": {
              "details": {
                "type": "array",
                "minItems": 1,
                "items": {
                  "type": "string",
                  "description": "specific error message",
                  "example": "/severity <- Could not parse severity, valid values are: CRITICAL, MAJOR, MINOR, WARNING"
                }
              }
            }
          }
        ]
      },
      "AlarmType": {
        "type": "string",
        "description": "Type of the alarm.",
        "example": "io.waylay.alarm.test"
      },
      "AlarmText": {
        "type": "string",
        "description": "Description of the alarm.",
        "example": "Some alarm documentation"
      },
      "AlarmAssignee": {
        "type": "string",
        "description": "String field to indicate an assignee for the alarm.",
        "example": "operator13"
      },
      "CreateAlarm": {
        "title": "create an alarm",
        "type": "object",
        "description": "To create an alarm, you need to provide the following mandatory inputs.",
        "properties": {
          "type": {
            "$ref": "#/components/schemas/AlarmType"
          },
          "text": {
            "$ref": "#/components/schemas/AlarmText"
          },
          "severity": {
            "$ref": "#/components/schemas/AlarmSeverity"
          },
          "source": {
            "$ref": "#/components/schemas/IdObject"
          },
          "status": {
            "$ref": "#/components/schemas/AlarmStatus"
          },
          "timestamp": {
            "$ref": "#/components/schemas/ISO8601TimestampOrMillis"
          },
          "assignee": {
            "$ref": "#/components/schemas/AlarmAssignee"
          }
        },
        "additionalProperties": {
          "title": "Additional properties",
          "description": "Any additional properties provided upon creation will be stored in the `additionalProperties` field\nof the created alarm."
        },
        "required": [
          "type",
          "text",
          "severity",
          "source"
        ],
        "example": {
          "type": "io.waylay.alarm.test",
          "text": "Valve test failed",
          "severity": "CRITICAL",
          "source": {
            "id": "733c06ed-7919-416a-9d19-8996821be70d"
          },
          "task": "1e294c8b-8a7d-4770-997e-2d57fc5ad6ea",
          "myRef": "902d4191-d1ab-47ae-8405-c33bb237f1d5"
        }
      },
      "AlarmUpdate": {
        "title": "Alarm update",
        "type": "object",
        "description": "At least one field must be specified.",
        "properties": {
          "severity": {
            "$ref": "#/components/schemas/AlarmSeverity"
          },
          "status": {
            "$ref": "#/components/schemas/AlarmStatus"
          },
          "assignee": {
            "allOf": [
              {
                "$ref": "#/components/schemas/AlarmAssignee"
              },
              {
                "nullable": true
              }
            ]
          }
        }
      },
      "BatchAlarmEntity": {
        "type": "string",
        "enum": [
          "alarm"
        ]
      },
      "BatchAlarm": {
        "type": "object",
        "properties": {
          "entity": {
            "$ref": "#/components/schemas/BatchAlarmEntity"
          },
          "action": {
            "type": "string"
          },
          "query": {
            "type": "object"
          }
        }
      },
      "BatchDeleteAlarm": {
        "title": "Delete alarms by query or Id's",
        "type": "object",
        "allOf": [
          {
            "$ref": "#/components/schemas/BatchAlarm"
          },
          {
            "type": "object",
            "properties": {
              "action": {
                "enum": [
                  "delete"
                ],
                "x-classname": "BatchDeleteAction"
              },
              "query": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/BulkQueryIds"
                  },
                  {
                    "$ref": "#/components/schemas/BulkQueryFilter"
                  }
                ],
                "x-classname": "BatchDeleteQuery"
              }
            }
          }
        ],
        "required": [
          "entity",
          "action",
          "query"
        ]
      },
      "BatchUpdateAlarm": {
        "title": "Update alarm",
        "type": "object",
        "allOf": [
          {
            "$ref": "#/components/schemas/BatchAlarm"
          },
          {
            "properties": {
              "actionParameters": {
                "$ref": "#/components/schemas/AlarmUpdate"
              },
              "action": {
                "enum": [
                  "update"
                ],
                "x-classname": "BatchUpdateAction"
              },
              "query": {
                "$ref": "#/components/schemas/BulkQueryIds"
              }
            }
          }
        ],
        "required": [
          "entity",
          "action",
          "query",
          "actionParameters"
        ]
      },
      "BatchAlarmsSpecification": {
        "title": "a batch alarms specification",
        "type": "object",
        "oneOf": [
          {
            "$ref": "#/components/schemas/BatchUpdateAlarm"
          },
          {
            "$ref": "#/components/schemas/BatchDeleteAlarm"
          }
        ],
        "example": {
          "entity": "alarm",
          "action": "delete",
          "query": {
            "ids": [
              "2c49e3bf-547b-42bc-a5e9-9193155ec03d"
            ]
          }
        }
      },
      "BulkQueryIds": {
        "title": "Bulk Query Ids Filter",
        "type": "object",
        "properties": {
          "ids": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/AlarmId"
            }
          }
        },
        "required": [
          "ids"
        ]
      },
      "BulkQueryFilter": {
        "title": "Bulk Query Filter",
        "type": "object",
        "description": "Object specifying filters on the alarm to which the operation will be applied.\nAt least one of the filters must be set.",
        "properties": {
          "type": {
            "title": "Alarm Type Filter",
            "oneOf": [
              {
                "$ref": "#/components/schemas/AlarmType"
              },
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/AlarmType"
                }
              }
            ]
          },
          "status": {
            "title": "Alarm Status Filter",
            "oneOf": [
              {
                "$ref": "#/components/schemas/AlarmStatus"
              },
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/AlarmStatus"
                }
              }
            ]
          },
          "severity": {
            "title": "Alarm Severity Filter",
            "oneOf": [
              {
                "$ref": "#/components/schemas/AlarmSeverity"
              },
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/AlarmSeverity"
                }
              }
            ]
          },
          "source": {
            "title": "Alarm Source Filter",
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ]
          },
          "dateFrom": {
            "allOf": [
              {
                "$ref": "#/components/schemas/UnixEpochMillis"
              },
              {
                "title": "Alarm timestamp filter (>=)"
              }
            ]
          },
          "dateTo": {
            "allOf": [
              {
                "$ref": "#/components/schemas/UnixEpochMillis"
              },
              {
                "title": "Alarm timestamp filter (<=)"
              }
            ]
          },
          "assignee": {
            "$ref": "#/components/schemas/AlarmAssignee"
          },
          "creationTimeFrom": {
            "allOf": [
              {
                "$ref": "#/components/schemas/UnixEpochMillis"
              },
              {
                "title": "Alarm creationTime filter (>=)"
              }
            ]
          },
          "creationTimeTo": {
            "allOf": [
              {
                "$ref": "#/components/schemas/UnixEpochMillis"
              },
              {
                "title": "Alarm creationTime filter (<=)"
              }
            ]
          },
          "lastUpdatedFrom": {
            "allOf": [
              {
                "$ref": "#/components/schemas/UnixEpochMillis"
              },
              {
                "title": "Alarm lastUpdateTime filter (>=)"
              }
            ]
          },
          "lastUpdatedTo": {
            "allOf": [
              {
                "$ref": "#/components/schemas/UnixEpochMillis"
              },
              {
                "title": "Alarm lastUpdateTime filter (<=)"
              }
            ]
          },
          "lastTriggeredFrom": {
            "allOf": [
              {
                "$ref": "#/components/schemas/UnixEpochMillis"
              },
              {
                "title": "Alarm lastTriggeredTime filter (>=)"
              }
            ]
          },
          "lastTriggeredTo": {
            "allOf": [
              {
                "$ref": "#/components/schemas/UnixEpochMillis"
              },
              {
                "title": "Alarm lastTriggeredTime filter (<=)"
              }
            ]
          }
        }
      },
      "ISO8601Timestamp": {
        "title": "ISO8601 timestamp",
        "type": "string",
        "format": "date-time",
        "example": "2011-09-06T12:03:27.845Z"
      },
      "ISO8601TimestampOrMillis": {
        "title": "timestamp",
        "description": "ISO8601 timestamp or unix epoch milliseconds.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/UnixEpochMillis"
          },
          {
            "$ref": "#/components/schemas/ISO8601Timestamp"
          }
        ]
      },
      "UnixEpochMillis": {
        "type": "integer",
        "title": "Unix Epoch Milliseconds",
        "description": "Timestamp expressed as milliseconds since 00:00:00 UTC on 1 January 1970, \nnot counting leap seconds.",
        "example": 1663269720694
      },
      "AlarmSelfLink": {
        "type": "string",
        "format": "uri",
        "title": "Link to alarm",
        "example": "/alarms/v1/alarms/ea381b65-eb57-4dca-b510-44a9efba3cf3"
      },
      "IdObject": {
        "type": "object",
        "description": "A JSON object with an id field indicating the resource.",
        "properties": {
          "id": {
            "type": "string",
            "title": "Resource Id"
          }
        },
        "required": [
          "id"
        ],
        "example": {
          "id": "12345"
        }
      },
      "AlarmStatus": {
        "title": "Alarm Status",
        "type": "string",
        "enum": [
          "ACTIVE",
          "ACKNOWLEDGED",
          "CLEARED"
        ],
        "default": "ACTIVE"
      },
      "AlarmSeverity": {
        "title": "Alarm Severity",
        "type": "string",
        "enum": [
          "CRITICAL",
          "MAJOR",
          "MINOR",
          "WARNING"
        ]
      },
      "AlarmEntity": {
        "type": "object",
        "title": "Alarm Representation",
        "properties": {
          "id": {
            "$ref": "#/components/schemas/AlarmId"
          },
          "creationTime": {
            "$ref": "#/components/schemas/ISO8601Timestamp"
          },
          "lastUpdateTime": {
            "$ref": "#/components/schemas/ISO8601Timestamp"
          },
          "lastTriggeredTime": {
            "$ref": "#/components/schemas/ISO8601Timestamp"
          },
          "type": {
            "$ref": "#/components/schemas/AlarmType"
          },
          "text": {
            "$ref": "#/components/schemas/AlarmText"
          },
          "timestamp": {
            "$ref": "#/components/schemas/ISO8601Timestamp"
          },
          "source": {
            "$ref": "#/components/schemas/IdObject"
          },
          "severity": {
            "$ref": "#/components/schemas/AlarmSeverity"
          },
          "status": {
            "$ref": "#/components/schemas/AlarmStatus"
          },
          "count": {
            "title": "Event count",
            "description": "The number of times this alarm has been sent",
            "type": "integer",
            "minimum": 1
          },
          "assignee": {
            "$ref": "#/components/schemas/AlarmAssignee"
          },
          "history": {
            "title": "History of modifications",
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/AlarmAuditRecord"
            }
          },
          "self": {
            "$ref": "#/components/schemas/AlarmSelfLink"
          },
          "additionalProperties": {
            "description": "Additional properties that were present in the creation payload",
            "type": "object",
            "example": {
              "task": "1e294c8b-8a7d-4770-997e-2d57fc5ad6ea",
              "myRef": "902d4191-d1ab-47ae-8405-c33bb237f1d5"
            }
          }
        },
        "required": [
          "id",
          "creationTime",
          "lastUpdateTime",
          "lastTriggeredTime",
          "type",
          "text",
          "timestamp",
          "source",
          "severity",
          "status",
          "count"
        ]
      },
      "AlarmAuditRecord": {
        "title": "Audit Record",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "ca0c5181-11dc-47dd-aeb3-a7a508ea1599\""
          },
          "type": {
            "$ref": "#/components/schemas/AlarmEventType"
          },
          "text": {
            "type": "string",
            "description": "Text describing the change",
            "example": "Alarm raised"
          },
          "timestamp": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ISO8601Timestamp"
              },
              {
                "description": "timestamp when the change happened"
              }
            ]
          }
        },
        "required": [
          "id",
          "type",
          "text",
          "timestamp"
        ]
      },
      "AlarmsQueryResult": {
        "type": "object",
        "title": "Alarm Query Response",
        "properties": {
          "self": {
            "type": "string",
            "format": "uri",
            "description": "Link to alarm query",
            "example": "/alarms/v1/alarms?page=3"
          },
          "alarms": {
            "type": "array",
            "title": "List of alarms",
            "items": {
              "$ref": "#/components/schemas/AlarmEntity"
            }
          },
          "total": {
            "type": "integer",
            "description": "Total number of alarms that fulfill the criteria",
            "example": 248
          },
          "next": {
            "type": "string",
            "format": "uri",
            "description": "Link to the next page of results (if more results are available)",
            "example": "/alarms/v1/alarms?page=4"
          },
          "prev": {
            "type": "string",
            "format": "uri",
            "description": "Link to the previous page of result (if previous page is available)",
            "example": "/alarms/v1/alarms?page=2"
          }
        },
        "required": [
          "self",
          "alarms",
          "total"
        ]
      },
      "AlarmTimelineInfo": {
        "type": "object",
        "description": "The alarm as it is after the event",
        "properties": {
          "id": {
            "$ref": "#/components/schemas/AlarmId"
          },
          "creationTime": {
            "$ref": "#/components/schemas/ISO8601Timestamp"
          },
          "timestamp": {
            "$ref": "#/components/schemas/ISO8601Timestamp"
          },
          "source": {
            "$ref": "#/components/schemas/IdObject"
          },
          "type": {
            "$ref": "#/components/schemas/AlarmType"
          },
          "text": {
            "$ref": "#/components/schemas/AlarmText"
          },
          "severity": {
            "$ref": "#/components/schemas/AlarmSeverity"
          },
          "status": {
            "$ref": "#/components/schemas/AlarmStatus"
          },
          "assignee": {
            "$ref": "#/components/schemas/AlarmAssignee"
          }
        },
        "required": [
          "id",
          "creationTime",
          "timestamp",
          "source",
          "type",
          "text",
          "severity",
          "status"
        ]
      },
      "AlarmTimelineTimestamp": {
        "description": "Timestamp of the event",
        "type": "integer",
        "title": "Unix Epoch Milliseconds",
        "example": 1663269720694
      },
      "AlarmsTimelineItem": {
        "type": "object",
        "title": "Alarm Timeline Item.",
        "properties": {
          "timestamp": {
            "$ref": "#/components/schemas/AlarmTimelineTimestamp"
          },
          "type": {
            "$ref": "#/components/schemas/AlarmEventType"
          },
          "alarm": {
            "$ref": "#/components/schemas/AlarmTimelineInfo"
          }
        },
        "required": [
          "timestamp",
          "type",
          "alarm"
        ]
      },
      "AlarmEventType": {
        "title": "Alarm Event Type",
        "type": "string",
        "oneOf": [
          {
            "enum": [
              "io.waylay.alarm.AlarmRaised"
            ],
            "x-classname": "AlarmRaisedEventType",
            "description": "A new alarm was created.",
            "title": "Alarm Creation Event Type"
          },
          {
            "enum": [
              "io.waylay.alarm.EventOccuredAgain"
            ],
            "x-classname": "EventOccurredAgainEventType",
            "description": "An alarm happened again.",
            "title": "Alarm Event Happened Again Event type"
          },
          {
            "enum": [
              "io.waylay.alarm.AlarmUpdated"
            ],
            "x-classname": "AlarmUpdatedEventType",
            "description": "An alarm was updated.",
            "title": "Alarm Update Event Type"
          }
        ]
      },
      "AlarmEvent": {
        "type": "object",
        "title": "Alarm Event",
        "properties": {
          "eventtype": {
            "$ref": "#/components/schemas/AlarmEventType"
          },
          "eventtime": {
            "$ref": "#/components/schemas/ISO8601Timestamp"
          },
          "alarm": {
            "$ref": "#/components/schemas/AlarmEventAlarm"
          },
          "changes": {
            "type": "array",
            "description": "Describes the changes that where done\n\nWill only be there if `eventtype` is `io.waylay.alarm.AlarmUpdated`",
            "items": {
              "type": "object",
              "x-classname": "AlarmChangeRecord",
              "properties": {
                "attribute": {
                  "type": "string",
                  "example": "severity"
                },
                "type": {
                  "type": "string",
                  "x-classname": "AlarmChangeType",
                  "description": "Indication of what has changed",
                  "enum": [
                    "io.waylay.alarm.change.severity",
                    "io.waylay.alarm.change.status",
                    "io.waylay.alarm.change.attribute"
                  ]
                },
                "oldValue": {
                  "type": "string",
                  "nullable": true,
                  "example": "MAJOR"
                },
                "newValue": {
                  "type": "string",
                  "nullable": true,
                  "example": "CRITICAL"
                }
              }
            }
          }
        },
        "required": [
          "eventtype",
          "eventtime",
          "alarm"
        ]
      },
      "AlarmEventAlarm": {
        "title": "Alarm",
        "description": "Summary representation of an alarm.",
        "type": "object",
        "properties": {
          "id": {
            "$ref": "#/components/schemas/AlarmId"
          },
          "tenantId": {
            "type": "string"
          },
          "creationTime": {
            "$ref": "#/components/schemas/ISO8601Timestamp"
          },
          "type": {
            "$ref": "#/components/schemas/AlarmType"
          },
          "text": {
            "$ref": "#/components/schemas/AlarmText"
          },
          "timestamp": {
            "$ref": "#/components/schemas/ISO8601Timestamp"
          },
          "source": {
            "$ref": "#/components/schemas/IdObject"
          },
          "severity": {
            "$ref": "#/components/schemas/AlarmSeverity"
          },
          "status": {
            "$ref": "#/components/schemas/AlarmStatus"
          },
          "count": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "id",
          "tenantId",
          "creationTime",
          "type",
          "text",
          "timestamp",
          "source",
          "severity",
          "status",
          "count"
        ]
      },
      "CloudAlarmEventData": {
        "type": "object",
        "properties": {
          "id": {
            "example": "dd59d2d9-9657-4d36-b045-ef97315f2d20"
          },
          "source": {
            "example": "/alarms/v1/alarms"
          },
          "subject": {
            "type": "string",
            "example": "289dd1a3-35a7-44fa-8596-9aee3ad0b36f/2c49e3bf-547b-42bc-a5e9-9193155ec03d"
          },
          "type": {
            "enum": [
              "io.waylay.alarms.v1.AlarmRaised",
              "io.waylay.alarms.v1.EventOccurredAgain",
              "io.waylay.alarms.v1.AlarmUpdated"
            ],
            "x-classname": "CloudAlarmEventType"
          },
          "data": {
            "$ref": "#/components/schemas/AlarmEvent"
          },
          "time": {
            "$ref": "#/components/schemas/ISO8601Timestamp"
          }
        }
      },
      "CloudAlarmEvent": {
        "allOf": [
          {
            "$ref": "./cloudevents.schema.json#/definitions/cloudevent_json"
          },
          {
            "$ref": "#/components/schemas/CloudAlarmEventData"
          },
          {
            "required": [
              "subject",
              "time"
            ]
          }
        ],
        "example": {
          "time": "2011-09-06T12:03:27.845Z",
          "type": "io.waylay.alarms.v1.AlarmUpdated",
          "subject": "289dd1a3-35a7-44fa-8596-9aee3ad0b36f/2c49e3bf-547b-42bc-a5e9-9193155ec03d"
        }
      },
      "BatchId": {
        "title": "Batch Operation id",
        "type": "string",
        "example": "afcea5a1-81df-44f6-bd34-e0b602a2cf3d"
      },
      "BatchOperation": {
        "title": "Batch Operation",
        "type": "object",
        "properties": {
          "id": {
            "$ref": "#/components/schemas/BatchId"
          },
          "user": {
            "type": "string",
            "description": "User id of the user who started the operation",
            "example": "user/22f6dfdf-a50c-4eab-953e-8d2e56891dbe"
          },
          "operation": {
            "type": "object",
            "x-classname": "BatchOperationSummary",
            "description": "Summary of the batch operation",
            "properties": {
              "entity": {
                "$ref": "#/components/schemas/BatchAlarmEntity"
              },
              "action": {
                "type": "string",
                "enum": [
                  "delete",
                  "update"
                ]
              },
              "description": {
                "type": "string",
                "description": "Description of the operation",
                "example": "deleting 3 alarms"
              }
            },
            "required": [
              "entity",
              "action",
              "description"
            ]
          },
          "queueTime": {
            "$ref": "#/components/schemas/ISO8601Timestamp"
          }
        },
        "required": [
          "id",
          "user",
          "operation",
          "queueTime"
        ]
      },
      "SuccessOperationResult": {
        "type": "object",
        "description": "Object containing the successful operation results.\nThe keys will be alarm ids.",
        "additionalProperties": {
          "type": "object",
          "x-classname": "SuccessOperationResultValue",
          "description": "The keys will be alarm ids.",
          "properties": {
            "statusCode": {
              "type": "integer",
              "description": "The statusCode of the operation"
            }
          },
          "required": [
            "statusCode"
          ]
        }
      },
      "FailureOperationResult": {
        "type": "object",
        "description": "Object containing the unsuccessful operation results.\nThe keys will be alarm ids.",
        "additionalProperties": {
          "type": "object",
          "x-classname": "FailureOperationResultValue",
          "description": "The keys will be alarm ids.",
          "properties": {
            "statusCode": {
              "type": "integer",
              "description": "The statusCode of the operation"
            },
            "error": {
              "type": "string",
              "description": "Error description of what went wrong."
            }
          },
          "required": [
            "statusCode",
            "error"
          ]
        }
      },
      "OperationResultObject": {
        "description": "Finished Batch Operation results",
        "type": "object",
        "properties": {
          "finishedTime": {
            "$ref": "#/components/schemas/ISO8601Timestamp"
          },
          "results": {
            "type": "object",
            "x-classname": "BatchOperationResults",
            "properties": {
              "success": {
                "$ref": "#/components/schemas/SuccessOperationResult"
              },
              "failure": {
                "$ref": "#/components/schemas/FailureOperationResult"
              }
            },
            "required": [
              "success",
              "failure"
            ]
          }
        },
        "required": [
          "finishedTime",
          "results"
        ]
      },
      "BatchOperationResult": {
        "title": "Result of a finished Batch Operation",
        "allOf": [
          {
            "$ref": "#/components/schemas/BatchOperation"
          },
          {
            "$ref": "#/components/schemas/OperationResultObject"
          }
        ],
        "example": {
          "id": "afcea5a1-81df-44f6-bd34-e0b602a2cf3d",
          "user": "user/22f6dfdf-a50c-4eab-953e-8d2e56891dbe",
          "operation": {
            "entity": "alarm",
            "action": "delete",
            "description": "deleting 3 alarms"
          },
          "queueTime": "2020-04-27T09:54:44.051Z",
          "finishedTime": "2020-04-27T09:54:44.129Z",
          "results": {
            "success": {
              "df036bf8-4b32-4bd8-8ee7-42800ab26bf5": {
                "statusCode": 204
              }
            },
            "failure": {
              "586ac2f2-fbec-426a-b696-d63d6cb153ac": {
                "statusCode": "404,",
                "error": "alarm with id '586ac2f2-fbec-426a-b696-d63d6cb153ac' not found"
              },
              "e64de65c-e3ef-482d-9eb7-32ca17d1e147": {
                "statusCode": "404,",
                "error": "alarm with id 'e64de65c-e3ef-482d-9eb7-32ca17d1e147' not found"
              }
            }
          }
        }
      }
    },
    "parameters": {
      "AlarmId": {
        "name": "alarmId",
        "in": "path",
        "description": "Unique Alarm Identifier",
        "required": true,
        "schema": {
          "$ref": "#/components/schemas/AlarmId"
        }
      },
      "BatchId": {
        "name": "batchId",
        "in": "path",
        "description": "Unique Batch Operation identifier",
        "required": true,
        "schema": {
          "$ref": "#/components/schemas/BatchId"
        }
      }
    },
    "requestBodies": {
      "AlarmsSpecification": {
        "description": "Alarm Operations",
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/CreateAlarm"
            }
          }
        }
      },
      "BatchAlarmsSpecification": {
        "description": "Batch Alarm Operation",
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/BatchAlarmsSpecification"
            }
          }
        }
      }
    },
    "responses": {
      "DefaultSuccessResponse": {
        "description": "Successful Response",
        "content": {
          "application/json": {
            "schema": {
              "type": "object"
            }
          }
        }
      },
      "ErrorResponse": {
        "description": "Error Response",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "ErrorResponseWithDetails": {
        "description": "Error Response",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponseWithDetails"
            }
          }
        }
      },
      "VersionResponse": {
        "description": "Successful Response",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/VersionResponse"
            }
          }
        }
      },
      "SuccessCreationResponse": {
        "description": "Successful Response",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AlarmEntity"
            }
          }
        }
      },
      "AlarmNotFoundResponse": {
        "description": "Alarm Not Found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "statusCode": 404,
              "error": "alarm with id '2c49e3bf-547b-42bc-a5e9-9193155ec03d' not found"
            }
          }
        }
      },
      "GetEventStreamResponse": {
        "description": "Alarm Events Stream",
        "content": {
          "application/x-ndjson": {
            "schema": {
              "title": "NdJsonResponseStream",
              "oneOf": [
                {
                  "$ref": "#/components/schemas/AlarmEvent"
                },
                {
                  "$ref": "#/components/schemas/CloudAlarmEvent"
                }
              ],
              "example": {
                "time": "2011-09-06T12:03:27.845Z",
                "type": "io.waylay.alarms.v1.AlarmUpdated",
                "subject": "289dd1a3-35a7-44fa-8596-9aee3ad0b36f/2c49e3bf-547b-42bc-a5e9-9193155ec03d"
              }
            }
          },
          "text/event-stream": {
            "schema": {
              "title": "SSEventStream",
              "oneOf": [
                {
                  "$ref": "#/components/schemas/AlarmEvent"
                },
                {
                  "$ref": "#/components/schemas/CloudAlarmEvent"
                }
              ]
            }
          }
        }
      },
      "BatchStartResponse": {
        "description": "Batch Operation Started",
        "content": {
          "application/json": {
            "schema": {
              "title": "Batch operation enqueued",
              "type": "object",
              "x-classname": "BatchOperationEnqueued",
              "properties": {
                "statusCode": {
                  "type": "integer",
                  "example": 202
                },
                "uri": {
                  "type": "string",
                  "description": "URI where the batch operation status can be followed",
                  "format": "uri",
                  "example": "/alarms/v1/batch/afcea5a1-81df-44f6-bd34-e0b602a2cf3d"
                },
                "entity": {
                  "type": "object",
                  "x-classname": "BatchOperationEnqueuedEntity",
                  "properties": {
                    "id": {
                      "$ref": "#/components/schemas/BatchId"
                    },
                    "queueTime": {
                      "$ref": "#/components/schemas/ISO8601Timestamp"
                    },
                    "operation": {
                      "title": "Queued operation summary",
                      "type": "object",
                      "x-classname": "QueuedOperationSummary",
                      "properties": {
                        "entity": {
                          "$ref": "#/components/schemas/BatchAlarmEntity"
                        },
                        "action": {
                          "type": "string",
                          "enum": [
                            "update",
                            "delete"
                          ]
                        }
                      },
                      "required": [
                        "entity",
                        "action"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "queueTime",
                    "operation"
                  ]
                }
              },
              "required": [
                "statusCode",
                "uri",
                "entity"
              ]
            }
          }
        },
        "headers": {
          "Location": {
            "description": "URI where the batch operation status can be followed",
            "example": "/alarms/v1/batch/afcea5a1-81df-44f6-bd34-e0b602a2cf3d",
            "schema": {
              "type": "string",
              "format": "uri"
            }
          }
        }
      },
      "GetBatchOperationResponse": {
        "description": "Get Batch Operation",
        "content": {
          "application/json": {
            "schema": {
              "title": "BatchOperationResults",
              "x-classname": "GetBatchOperationResponse",
              "anyOf": [
                {
                  "$ref": "#/components/schemas/BatchOperationResult"
                },
                {
                  "$ref": "#/components/schemas/BatchOperation"
                }
              ]
            }
          }
        }
      },
      "BatchNotFoundResponse": {
        "description": "Batch Operation Not Found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "statusCode": 404,
              "error": "Operation with id 'afcea5a1-81df-44f6-bd34-e0b602a2cf3d' not found"
            }
          }
        }
      }
    },
    "securitySchemes": {
      "waylayApiKeySecret": {
        "type": "http",
        "description": "Waylay apiKey/apiSecret basic authentication. All endpoints support also Waylay JWT Bearer authentication.",
        "scheme": "basic"
      }
    }
  },
  "servers": [
    {
      "url": "https://api.waylay.io",
      "description": "Waylay enterprise gateway"
    }
  ]
}