{
  "openapi": "3.1.0",
  "info": {
    "title": "PTV Flows KPI engine API",
    "description": "",
    "termsOfService": "https://ptvgroup.com/terms/",
    "license": {
      "name": "Apache 2.0",
      "url": "https://ptvgroup.com"
    },
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.ptvgroup.tech/kpieng/v1"
    }
  ],
  "paths": {
    "/location/by-id": {
      "get": {
        "tags": [
          "KPI Location API"
        ],
        "description": "Get a single KPI location associated to the location identifier",
        "operationId": "getLocation",
        "parameters": [
          {
            "name": "locationId",
            "in": "query",
            "description": "Location identifier. Only the KPI location with specified locationId is returned. It cannot be null.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiLocationWithEntitiesDto"
                }
              }
            }
          },
          "400": {
            "description": "Unable to authenticate the request with the provided API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Location not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "KPI Location API"
        ],
        "description": "Update a single KPI location associated to the location identifier. ",
        "operationId": "updateLocation",
        "parameters": [
          {
            "name": "locationId",
            "in": "query",
            "description": "location ID. Only the KPI location with specified locationId is updated. Cannot be NULL. ",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KpiLocationDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiLocationDto"
                }
              }
            }
          },
          "400": {
            "description": "Unable to authenticate the request with the provided API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Location not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/result/by-kpi-ids": {
      "post": {
        "tags": [
          "KPI Results API"
        ],
        "description": "Get results for multiple KPI instances and time span",
        "operationId": "getKpiResultsByMultipleKpiId",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KpiResultsByKpiRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/KpiResultDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Request not authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Results not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/instance": {
      "post": {
        "tags": [
          "KPI Instance API"
        ],
        "description": "Create a KPI instance by post request",
        "operationId": "createInstance",
        "parameters": [
          {
            "name": "template",
            "in": "query",
            "description": "The template name. The available templates list can be obtained from the getAllTemplates API call",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "EXPECTED_TRAVEL_TIME"
              ],
              "externalDocs": {
                "url": "www.ptvgroup.com"
              }
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KpiInstanceDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiInstanceDto"
                }
              }
            }
          },
          "400": {
            "description": "Can be caused by a validation of the request failed. Details can be found in causes, like exceeding corridor's limit of 1000 streets",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "KPI Instance API"
        ],
        "description": "Delete a single KPI instance based on the instance identifier.",
        "operationId": "deleteKpi",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "description": "The KPI instance identifier. Only a single KPI instance with a specified identifier is deleted.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
          }
        ],
        "responses": {
          "204": {
            "description": "Successful operation"
          },
          "400": {
            "description": "Unable to authenticate the request with the provided API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "KPI not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/template/all": {
      "get": {
        "tags": [
          "KPI Instance API"
        ],
        "description": "Get all the information associated to the KPI template",
        "operationId": "getAllTemplates",
        "responses": {
          "200": {
            "description": "Successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/KpiTemplateDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Unable to authenticate the request with the provided API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/status/by-kpi-id": {
      "get": {
        "tags": [
          "KPI Status API"
        ],
        "description": "Get the KPI status of a single KPI instance.",
        "operationId": "getKpiStatusByKpiId",
        "parameters": [
          {
            "name": "kpiId",
            "in": "query",
            "description": "KPI identifier. Only the status of the given KPI identifier is returned. It cannot be null.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/KpiStatusDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Request not authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Status not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/status/all": {
      "get": {
        "tags": [
          "KPI Status API"
        ],
        "description": "Get the status of all active KPI instances.",
        "operationId": "getKpiStatusAll",
        "responses": {
          "200": {
            "description": "Successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/KpiStatusDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Request not authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Status not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/result/by-kpi-id": {
      "get": {
        "tags": [
          "KPI Results API"
        ],
        "description": "Get all the results of a single KPI instance.",
        "operationId": "getKpiResultByKpiId",
        "parameters": [
          {
            "name": "kpiId",
            "in": "query",
            "description": "KPI identifier. Only the results for the given KPI identifier are returned. Cannot be null",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/KpiResultDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Request not authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Results not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/location/all": {
      "get": {
        "tags": [
          "KPI Location API"
        ],
        "description": "Get all KPI locations associated to active KPI instances ",
        "operationId": "getAllLocations",
        "responses": {
          "200": {
            "description": "Successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/KpiLocationDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Unable to authenticate the request with the provided API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No locations found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/instance/by-kpi-id": {
      "get": {
        "tags": [
          "KPI Instance API"
        ],
        "description": "Get a single KPI instance associated to the KPI identifier (KpiId)",
        "operationId": "getKpis",
        "parameters": [
          {
            "name": "kpiId",
            "in": "query",
            "description": "The KPI instance Identifier. Only a single KPI instance associated to the kpiId is returned.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiInstanceDto"
                }
              }
            }
          },
          "400": {
            "description": "Unable to authenticate the request with the provided API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "KPI instance not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/instance/all": {
      "get": {
        "tags": [
          "KPI Instance API"
        ],
        "description": "Get all KPI instances currently active and running",
        "operationId": "getAll",
        "responses": {
          "200": {
            "description": "Successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/KpiInstanceDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Unable to authenticate the request with the provided API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/count": {
      "get": {
        "tags": [
          "KPI Instance API"
        ],
        "description": "Get the total number of KPIs that are currently active.",
        "operationId": "kpiCount",
        "responses": {
          "204": {
            "description": "Successful operation"
          },
          "400": {
            "description": "Unable to authenticate the request with the provided API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No KPI instances found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "InstanceParameterMap": {
        "type": "object",
        "properties": {
          "forecastdistance": {
            "type": "integer",
            "format": "int32",
            "description": "Forecast distance parameter. Forecast horizon expressed in minutes"
          },
          "timetostart": {
            "type": "integer",
            "format": "int32",
            "description": "The amount of seconds in the future starting from which the travel time shall be calculated"
          }
        }
      },
      "AffectedEntityDto": {
        "type": "object",
        "properties": {
          "strt": {
            "type": "integer",
            "format": "int32",
            "description": "Street identifier",
            "example": 0
          },
          "fsnd": {
            "type": "integer",
            "format": "int32",
            "description": "Identifier of the node where a street begins. In our model a street is identified by two elements: Fromnode and Street.",
            "example": 0
          },
          "openLrCode": {
            "type": "string",
            "description": "Offset until the end of the segment (percentage).",
            "example": "Cwjloh3OozbUAv+U/7g2ZFJw",
            "readOnly": true
          },
          "order": {
            "type": "integer",
            "format": "int32",
            "default": 0,
            "description": "Segment progressive order",
            "minimum": 0
          },
          "startProgressive": {
            "type": "number",
            "format": "float",
            "default": 0,
            "description": "Offset from the start of the segment (percentage)",
            "maximum": 1
          },
          "endProgressive": {
            "type": "number",
            "format": "float",
            "default": 1,
            "description": "Offset to the end of the segment (percentage)",
            "maximum": 1
          }
        }
      },
      "KpiLocationDto": {
        "type": "object",
        "description": "Object description of the KPI location. Used for exchange data from KPI engine and API.Location is a spatial object related to the underlying network.\n\nA location aggregates several elements of the network in order to manage/export related data in a stable and efficient way.\nThe relation between network and locations must be able survive across network updates.\nIn order to be used, locations must be associated with a name. Names are provided by the user during the creation of the location so that the same location can be reused for multiple KPIs or in future other objects\n",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of the KPI location",
            "example": "location name"
          },
          "entities": {
            "type": "array",
            "description": "Entities involved in the KPI computation.",
            "items": {
              "$ref": "#/components/schemas/AffectedEntityDto"
            },
            "writeOnly": true
          },
          "shape": {
            "type": "string",
            "description": "Well-known text representation of location's geometry",
            "example": "LINESTRING(3 4,10 50,20 25)"
          },
          "locationId": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier of a KPI location",
            "example": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
          },
          "locationType": {
            "type": "string",
            "description": "Location type. Allowed location for the definition of a KPI are:\n\nArea\n\n    set of streets intersecting or included in the area;\n    in case further selection with link attributes\n    Shape of the area as given by the user\n\nPath\n\n    Ordered sequence on streets (a path can be a single link as well)\n    Shape is the ordered union of all street shapes\n\nTurn\n\n    Ordered sequence of 2 streets\n    Shape is the ordered union of the 2 street shapes\n\nOriented Point\n\n    Lat,Lon\n    Optionally map matched on a directed street\n    Bearing\n    Shape is a point\n",
            "enum": [
              "AREA",
              "PATH",
              "TURN",
              "ORIENTED_POINT"
            ]
          }
        }
      },
      "CausingError": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string"
          },
          "details": {
            "type": "object",
            "additionalProperties": {}
          },
          "errorCode": {
            "type": "string"
          },
          "parameter": {
            "type": "string"
          }
        },
        "required": [
          "description",
          "errorCode"
        ]
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "causes": {
            "type": "array",
            "description": "A list of affected parameters and/or properties that caused this error.",
            "items": {
              "$ref": "#/components/schemas/CausingError"
            }
          },
          "description": {
            "type": "string",
            "description": "A human readable message that describes the error"
          },
          "details": {
            "type": "object",
            "additionalProperties": {},
            "description": "Additional properties specific to this error class."
          },
          "errorCode": {
            "type": "string",
            "description": "        A constant string that can be used to identify this error class programmatically. An errorCode can have **details** to provide information in additional properties which are described with the code they apply to.\n        Note that additional errorCodes as well as the **details** of existing errorCodes may be added at any time.\n\n        HTTP status code: 400\n        * GENERAL_UNAUTHENTICATED: Invalid or missing authentication credentials\n        HTTP status code: 500\n        * GENERAL_VALIDATION_ERROR: The validation of the request failed. Details can be found in causes\n        HTTP status code: 503\n        * GENERAL_SERVICE_UNAVAILABLE: The request could not be processed due to an internal error\n        HTTP status code: 404\n        * GENERAL_RESOURCE_NOT_FOUND: A requested resource does not exist\n\n\n\n"
          },
          "errorId": {
            "type": "string",
            "description": "A unique identifier specific to this error instance. It can be used to trace errors by the support."
          },
          "traceId": {
            "type": "string",
            "description": "A unique identifier specific to this error instance. It can be used to trace errors by the support team."
          }
        },
        "required": [
          "description",
          "errorCode",
          "traceId"
        ]
      },
      "KpiResultDto": {
        "type": "object",
        "description": "Object description of KPI results. It is used to exchange data between the KPI engine and the API.",
        "properties": {
          "kpiId": {
            "type": "string",
            "format": "uuid",
            "description": "KPI identifier of the value"
          },
          "timeStamp": {
            "type": "string",
            "format": "date-time",
            "description": "Object description of KPI results. It is used to exchange data between the KPI engine and the API."
          },
          "results": {
            "type": "array",
            "description": "KPI exploded values. A list of results for each portion of the KPI location",
            "items": {
              "$ref": "#/components/schemas/KpiResultValueDto"
            },
            "minItems": 1
          },
          "overallResult": {
            "$ref": "#/components/schemas/KpiResultValueDto",
            "description": "KPI overall values. It contains the result of the KPI on its entire location length"
          }
        }
      },
      "KpiResultValueDto": {
        "type": "object",
        "description": "Description of a single KPI result, for a specific portion of its location as specified in the field 'progressive'. It is used for exchanging data between the KPI engine and the API.",
        "properties": {
          "value": {
            "type": "number",
            "format": "float",
            "description": "Numeric value, expressed in the same unit of measurement as the related KPI instance",
            "example": 12.3,
            "minimum": 0
          },
          "defaultValue": {
            "type": "number",
            "format": "float",
            "description": "Numeric value associated to the free flow state condition. Expressed in the same unit of measurement as the related KPI instance.",
            "example": 10.2,
            "minimum": 0
          },
          "unusualValue": {
            "type": "number",
            "format": "float",
            "description": "Numeric value associated to an unusual state condition. Expressed in the same unit of measurement as the related KPI instance",
            "example": 10.2,
            "minimum": 0
          },
          "averageValue": {
            "type": "number",
            "format": "float",
            "description": "Numeric value associated to an average state condition. Expressed in the same unit of measurement as the related KPI instance",
            "example": 10.2,
            "minimum": 0
          },
          "progressive": {
            "type": "number",
            "format": "float",
            "description": "Progressive index value of a sub-element of the KPI location. Expressed in kilometers.",
            "example": 0.5,
            "minimum": 0
          }
        }
      },
      "KpiResultsByKpiRequest": {
        "type": "object",
        "properties": {
          "kpiIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "fromTime": {
            "type": "string",
            "format": "date-time"
          },
          "toTime": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "KpiInstanceDto": {
        "type": "object",
        "description": "Object description of the KPI instance. Used to exchange data between the KPI engine and the API.",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of the KPI instance",
            "example": "<kpi_template> at <location-name>"
          },
          "notes": {
            "type": "string",
            "description": "Additional text notes for the KPI instance."
          },
          "kpiInstanceParameters": {
            "$ref": "#/components/schemas/KpiInstanceParametersDto",
            "description": "Instance parameters."
          },
          "location": {
            "$ref": "#/components/schemas/KpiLocationDto",
            "description": "KPI location"
          },
          "kpiId": {
            "type": "string",
            "format": "uuid",
            "description": "KPI instance identifier."
          },
          "thresholdsDefinition": {
            "$ref": "#/components/schemas/ThresholdsDefinitionDto",
            "description": "Thresholds values of the KPI instance: expressed as a tuple of numeric value, they represent the warning and the critical limit of the KPI value, according to which the KPI instance can be considered in a warning or critical condition."
          },
          "template": {
            "type": "string",
            "enum": [
              "EXPECTED_TRAVEL_TIME",
              "ACTUAL_OBSERVED_SPEED",
              "ACTUAL_ESTIMATED_SPEED"
            ],
            "readOnly": true
          },
          "direction": {
            "type": "string",
            "description": "KPI values can be considered in two different directions:\n\nINCREASING (higher KPI values corresponds to better quality)\n\nDECREASING (lower KPI values corresponder to better quality).\n\n",
            "enum": [
              "INCREASING",
              "DECREASING"
            ],
            "readOnly": true
          },
          "visualizationModes": {
            "type": "array",
            "description": "Available modalities of visualization.",
            "items": {
              "type": "string",
              "enum": [
                "MAP_REPRESENTATION",
                "GAUGE",
                "HISTORICAL_PROFILE",
                "MULTIPLE_HISTORICAL_PROFILE",
                "CARPET"
              ]
            },
            "minItems": 1,
            "readOnly": true
          },
          "unitOfMeasure": {
            "type": "string",
            "description": "unit of measure of KPI value",
            "enum": [
              "MINUTES",
              "ABSOLUTE",
              "PERCENTAGE",
              "MINUTES_STREET",
              "KILOMETERS_PER_HOUR",
              "KILOMETERS"
            ],
            "readOnly": true
          }
        }
      },
      "KpiInstanceParametersDto": {
        "type": "object",
        "properties": {
          "parameters": {
            "type": "object",
            "$ref": "#/components/schemas/InstanceParameterMap",
            "additionalProperties": {},
            "description": "KPI instance additional parameters"
          }
        }
      },
      "KpiThresholdsDto": {
        "type": "object",
        "properties": {
          "warningThreshold": {
            "type": "number",
            "format": "float",
            "description": "Warning threshold.",
            "example": 140
          },
          "criticalThreshold": {
            "type": "number",
            "format": "float",
            "description": "Critical threshold.",
            "example": 180
          }
        }
      },
      "ThresholdsDefinitionDto": {
        "type": "object",
        "properties": {
          "thresholdsValues": {
            "$ref": "#/components/schemas/KpiThresholdsDto",
            "description": "Thresholds values of the KPI instance: expressed as a tuple of numeric value, they represent the warning and the critical limit of the KPI value, according to which the KPI instance can be considered in a warning or critical condition."
          },
          "kpiThresholdsReference": {
            "type": "string",
            "description": "Threshold type definition",
            "enum": [
              "UNUSUAL",
              "FREE_FLOW"
            ]
          }
        }
      },
      "KpiLocationsUpdateRequest": {
        "type": "object",
        "properties": {
          "newLocationByOldId": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/KpiLocationDto"
            }
          },
          "mapVersion": {
            "type": "string"
          }
        }
      },
      "TstaKey": {
        "type": "object",
        "properties": {
          "customerId": {
            "type": "string"
          },
          "strt": {
            "type": "integer",
            "format": "int32"
          },
          "fsnd": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "EntityFields": {
        "type": "object",
        "properties": {
          "len": {
            "type": "number",
            "format": "float"
          },
          "hier": {
            "type": "integer",
            "format": "int32"
          },
          "speed": {
            "type": "number",
            "format": "float"
          },
          "capa": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "KpiTemplateDto": {
        "type": "object",
        "description": "Object description of KPI instance. Used for exchange data among KPI engine and API",
        "properties": {
          "locationType": {
            "type": "string",
            "description": "KPI location",
            "enum": [
              "AREA",
              "PATH",
              "TURN",
              "ORIENTED_POINT"
            ]
          },
          "thresholdsDefinitions": {
            "type": "array",
            "description": "V",
            "items": {
              "$ref": "#/components/schemas/ThresholdsDefinitionDto"
            }
          },
          "templateName": {
            "type": "string",
            "description": "Template name. Allowed templates for the definition of a KPI are:\n\nEXPECTED_TRAVEL_TIME: The expected travel time calculated in the future is an expected travel time in case the travel starts with a delay of T minutes from now.\n",
            "enum": [
              "EXPECTED_TRAVEL_TIME",
              "ACTUAL_OBSERVED_SPEED",
              "ACTUAL_ESTIMATED_SPEED"
            ],
            "readOnly": true
          },
          "templateDescription": {
            "type": "string",
            "readOnly": true
          },
          "source": {
            "type": "string",
            "enum": [
              "MEASURE",
              "HISTORICAL",
              "ESTIMATION"
            ],
            "readOnly": true
          },
          "direction": {
            "type": "string",
            "description": "KPI values can be considered in two different directions:\n\nINCREASING (higher KPI values correspond to better quality)\n\nDECREASING (lower KPI values correspond to better quality).\n",
            "enum": [
              "INCREASING",
              "DECREASING"
            ],
            "readOnly": true
          },
          "kpiInstanceParameters": {
            "$ref": "#/components/schemas/KpiInstanceParametersDto",
            "description": "required parameters"
          },
          "visualizationModes": {
            "type": "array",
            "description": "Available modalities of visualization.",
            "items": {
              "type": "string",
              "enum": [
                "MAP_REPRESENTATION",
                "GAUGE",
                "HISTORICAL_PROFILE",
                "MULTIPLE_HISTORICAL_PROFILE",
                "CARPET"
              ]
            },
            "minItems": 1,
            "readOnly": true
          },
          "unitOfMeasure": {
            "type": "string",
            "description": "Unit of measure associated to the KPI value",
            "enum": [
              "MINUTES",
              "ABSOLUTE",
              "PERCENTAGE",
              "MINUTES_STREET",
              "KILOMETERS_PER_HOUR",
              "KILOMETERS"
            ],
            "readOnly": true
          }
        },
        "readOnly": true
      },
      "KpiStatusDto": {
        "type": "object",
        "description": "Object description of KPI results. Used for exchange data from KPI engine and API.",
        "properties": {
          "kpiId": {
            "type": "string",
            "format": "uuid",
            "description": "KPI identifier associated to the related value"
          },
          "timeStamp": {
            "type": "string",
            "format": "date-time",
            "description": "Time stamp reference of the generated KPI value."
          },
          "statusCode": {
            "type": "string",
            "description": "KPI status can be considered in four different codes:\n\nUNDEFINED (the KPI higher values are associated to the better quality of the KPI)\n\nOK (the KPI value is ok)\n\nWARNING (the KPI value is in a warning state)\n\nCRITICAL (the KPI value is in a critical state)\n\n",
            "enum": [
              "UNDEFINED",
              "OK",
              "WARNING",
              "CRITICAL"
            ],
            "readOnly": true
          },
          "thresholds": {
            "$ref": "#/components/schemas/KpiThresholdsDto"
          },
          "value": {
            "type": "number",
            "format": "float"
          },
          "defaultValue": {
            "type": "number",
            "format": "float"
          },
          "unusualValue": {
            "type": "number",
            "format": "float"
          },
          "averageValue": {
            "type": "number",
            "format": "float"
          }
        }
      },
      "KpiLocationWithEntitiesDto": {
        "type": "object",
        "description": "Extension of KpiLocationDto schema with entities related to the location.\n",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of the KPI location",
            "example": "location name"
          },
          "entities": {
            "type": "array",
            "description": "Entities involved in the KPI computation.",
            "items": {
              "$ref": "#/components/schemas/AffectedEntityDto"
            }
          },
          "shape": {
            "type": "string",
            "description": "Well-known text representation of location's geometry",
            "example": "LINESTRING(3 4,10 50,20 25)"
          },
          "locationId": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier of a KPI location",
            "example": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
          },
          "locationType": {
            "type": "string",
            "description": "Location type. Allowed location for the definition of a KPI are:\n\nArea\n\n    set of streets intersecting or included in the area;\n    in case further selection with link attributes\n    Shape of the area as given by the user\n\nPath\n\n    Ordered sequence on streets (a path can be a single link as well)\n    Shape is the ordered union of all street shapes\n\nTurn\n\n    Ordered sequence of 2 streets\n    Shape is the ordered union of the 2 street shapes\n\nOriented Point\n\n    Lat,Lon\n    Optionally map matched on a directed street\n    Bearing\n    Shape is a point\n",
            "enum": [
              "AREA",
              "PATH",
              "TURN",
              "ORIENTED_POINT"
            ]
          }
        }
      }
    },
    "securitySchemes": {
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "apiKey"
      }
    }
  },
  "security": [
    {
      "apiKeyAuth": []
    }
  ]
}