{
  "swagger": "2.0",
  "info": {
    "description": "Microservice to process device events",
    "version": "0.0.1",
    "title": "Business Rules Microservice API",
    "contact": {}
  },
  "host": "dev-motion.cwbyminsait.com",
  "basePath": "/business-rules",
  "tags": [
    {
      "name": "business-rules-controller",
      "description": "Business Rules Controller"
    }
  ],
  "schemes": [
    "http",
    "https"
  ],
  "produces": [
    "application/json",
    "application/yaml",
    "text/plain"
  ],
  "paths": {
    "/v1/events": {
      "post": {
        "tags": [
          "business-rules-controller"
        ],
        "summary": "Process an event and trigger initiative if required",
        "description": "It uses the rule engine",
        "operationId": "processEventUsingPOST",
        "consumes": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "event",
            "description": "Event to process",
            "required": true,
            "schema": {
              "$ref": "#/definitions/EventDTO"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Request Successful, review the resulting object. If infoError is not null, then a functional error has occurred in the back-end ",
            "schema": {
              "$ref": "#/definitions/InitiativeDTO"
            }
          },
          "201": {
            "description": "Created"
          },
          "204": {
            "description": "Request Successful, no content returned"
          },
          "400": {
            "description": "Bad request, review the request param"
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Event processed but not initiative was triggered"
          },
          "500": {
            "description": "Unexpected exception (Internal Server Error)"
          }
        }
      }
    }
  },
  "definitions": {
    "Action model": {
      "type": "object",
      "properties": {
        "actionId": {
          "type": "string",
          "description": "Action id",
          "allowEmptyValue": false
        },
        "affectedAssetId": {
          "type": "string",
          "description": "Affected asset id by this action",
          "allowEmptyValue": false
        },
        "creationDate": {
          "type": "string",
          "description": "Action creation date",
          "allowEmptyValue": false
        },
        "extrainfo": {
          "description": "Action extra info (no default fields)",
          "allowEmptyValue": false,
          "$ref": "#/definitions/JsonNode"
        },
        "responsible": {
          "type": "string",
          "description": "Responsible for this action",
          "allowEmptyValue": false
        },
        "status": {
          "type": "string",
          "description": "Action status",
          "allowEmptyValue": false
        },
        "type": {
          "type": "string",
          "description": "Action type",
          "allowEmptyValue": false
        }
      },
      "title": "Action model"
    },
    "EventDTO": {
      "type": "object",
      "properties": {
        "deviceId": {
          "type": "string"
        },
        "eventId": {
          "type": "string"
        },
        "extrainfo": {
          "$ref": "#/definitions/JsonNode"
        },
        "geometry": {
          "$ref": "#/definitions/GeometryDTO"
        },
        "prority": {
          "type": "string"
        },
        "tsEvent": {
          "type": "integer",
          "format": "int64"
        },
        "type": {
          "type": "string"
        }
      },
      "title": "EventDTO"
    },
    "GeometryDTO": {
      "type": "object",
      "properties": {
        "coordinates": {
          "type": "array",
          "items": {
            "type": "number",
            "format": "double"
          }
        },
        "type": {
          "type": "string"
        }
      },
      "title": "GeometryDTO"
    },
    "InitiativeDTO": {
      "type": "object",
      "properties": {
        "actionList": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Action model"
          }
        },
        "initiativeId": {
          "type": "string"
        },
        "type": {
          "type": "string"
        }
      },
      "title": "InitiativeDTO"
    },
    "JsonNode": {
      "type": "object",
      "properties": {
        "array": {
          "type": "boolean"
        },
        "bigDecimal": {
          "type": "boolean"
        },
        "bigInteger": {
          "type": "boolean"
        },
        "binary": {
          "type": "boolean"
        },
        "boolean": {
          "type": "boolean"
        },
        "containerNode": {
          "type": "boolean"
        },
        "double": {
          "type": "boolean"
        },
        "float": {
          "type": "boolean"
        },
        "floatingPointNumber": {
          "type": "boolean"
        },
        "int": {
          "type": "boolean"
        },
        "integralNumber": {
          "type": "boolean"
        },
        "long": {
          "type": "boolean"
        },
        "missingNode": {
          "type": "boolean"
        },
        "nodeType": {
          "type": "string",
          "enum": [
            "ARRAY",
            "BINARY",
            "BOOLEAN",
            "MISSING",
            "NULL",
            "NUMBER",
            "OBJECT",
            "POJO",
            "STRING"
          ]
        },
        "null": {
          "type": "boolean"
        },
        "number": {
          "type": "boolean"
        },
        "object": {
          "type": "boolean"
        },
        "pojo": {
          "type": "boolean"
        },
        "short": {
          "type": "boolean"
        },
        "textual": {
          "type": "boolean"
        },
        "valueNode": {
          "type": "boolean"
        }
      },
      "title": "JsonNode"
    }
  }
}
