{
  "openapi": "3.0.3",
  "info": {
    "title": "REST API documentation",
    "version": "v1",
    "description": ""
  },
  "servers": [
    {
      "url": "https://cloud.kaaiot.com/api/v1/rs",
      "description": "API Server"
    }
  ],
  "paths": {
    "/evaluate": {
      "post": {
        "description": "Executes a query to retrieve data for the report table.",
        "responses": {
          "202": {
            "description": "Data successfully retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": [
                  {
                    "Device ID": "568b5afe-2437-468b-b57b-1335b499f589",
                    "Vehicle name": "Toyota",
                    "Vehicle brand": "Corolla",
                    "Average speed": "45 km/h"
                  },
                  {
                    "Device ID": "fa489f9b-295d-41ae-a425-5a52dce0ed21",
                    "Vehicle name": "Honda",
                    "Vehicle brand": "Civic",
                    "Average speed": "60 km/h"
                  }
                ]
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "tenant:report:evaluate"
            ]
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Query"
              },
              "example": {
                "dimensions": [
                  {
                    "source": "ANALYTICS",
                    "name": "Device ID",
                    "path": "endpointId.keyword",
                    "type": "STRING"
                  },
                  {
                    "source": "METADATA",
                    "name": "Vehicle name",
                    "path": "name",
                    "type": "STRING",
                    "useDefaultValue": true,
                    "defaultValue": "unknown"
                  },
                  {
                    "source": "ASSET",
                    "name": "Vehicle brand",
                    "path": "dataSample.relations.IS_CONTAINED_BY.entityId.asset_tp_f8bc6ed6:brand",
                    "type": "STRING"
                  }
                ],
                "columns": [
                  {
                    "source": "ANALYTICS",
                    "name": "Average speed",
                    "path": "dataSample.speed",
                    "type": "NUMBER",
                    "function": "AVG",
                    "expression": "{{average speed}} km/h",
                    "useDefaultValue": true,
                    "defaultValue": 0
                  }
                ],
                "where": [
                  {
                    "source": "METADATA",
                    "path": "connected",
                    "type": "BOOL",
                    "function": "EQ",
                    "value": true
                  }
                ],
                "application": "cnc5h752908c73fp4pd0",
                "from": "now-10h",
                "to": "now"
              }
            }
          }
        }
      }
    },
    "/evaluate/schema": {
      "get": {
        "description": "Retrieves the schema necessary to build a query for generating a report.",
        "responses": {
          "200": {
            "description": "Schema successfully retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "tenant:report:evaluate"
            ]
          }
        ],
        "parameters": [
          {
            "name": "application",
            "in": "query",
            "description": "Application name.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/evaluate/schema/operations": {
      "get": {
        "description": "Retrieves allowed operations on the schema required to build a query for generating a report.",
        "responses": {
          "200": {
            "description": "Operations successfully retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "TIME_SERIES": [
                    {
                      "type": "STRING",
                      "allowedStages": [
                        "DIMENSION"
                      ]
                    }
                  ],
                  "ANALYTICS": [
                    {
                      "type": "STRING",
                      "allowedStages": [
                        "DIMENSION",
                        "WHEN_CONDITION",
                        "AGGREGATION"
                      ],
                      "aggregationFunctions": [
                        "COUNT",
                        "LAST"
                      ],
                      "filterFunctions": [
                        "EQ",
                        "IN"
                      ]
                    },
                    {
                      "type": "NUMBER",
                      "allowedStages": [
                        "AGGREGATION",
                        "DIMENSION",
                        "WHEN_CONDITION"
                      ],
                      "aggregationFunctions": [
                        "MIN",
                        "AVG",
                        "SUM",
                        "MAX",
                        "COUNT",
                        "LAST"
                      ],
                      "filterFunctions": [
                        "EQ",
                        "IN"
                      ]
                    },
                    {
                      "type": "DATE",
                      "allowedStages": [
                        "DIMENSION",
                        "TIME_DIMENSION",
                        "WHEN_CONDITION",
                        "AGGREGATION"
                      ],
                      "aggregationFunctions": [
                        "MAX",
                        "MIN",
                        "COUNT",
                        "LAST"
                      ],
                      "filterFunctions": [
                        "IN_RANGE"
                      ]
                    },
                    {
                      "type": "BOOL",
                      "allowedStages": [
                        "DIMENSION",
                        "WHEN_CONDITION",
                        "AGGREGATION"
                      ],
                      "aggregationFunctions": [
                        "COUNT",
                        "LAST"
                      ],
                      "filterFunctions": [
                        "EQ"
                      ]
                    }
                  ],
                  "METADATA": [
                    {
                      "type": "BOOL",
                      "allowedStages": [
                        "DIMENSION",
                        "WHEN_CONDITION"
                      ],
                      "filterFunctions": [
                        "EQ"
                      ]
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/templates": {
      "post": {
        "description": "Creates a new report template.",
        "responses": {
          "201": {
            "description": "Item is successfully created.",
            "headers": {
              "Location": {
                "description": "URI in format `{schema}://{host}/rs/api/v1/templates/{templateId}`",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "template:create"
            ]
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreationRequest"
              },
              "example": {
                "name": "Monthly Sensor Readings",
                "reportName": "sensor__readings__{{createdDate}}",
                "exportType": "PDF",
                "executionState": "ACTIVE",
                "triggers": [
                  "aa3f7b8d-3a22-46e8-8803-e89480ff73f1"
                ],
                "exportTemplate": {
                  "pdfTemplate": "<html><head><table><thead><tr><#list table.headers as header><th>${header}</th></#list></tr></thead></table></#list></body></html>",
                  "csvTemplate": "${table.headers?join(\",\")}"
                },
                "emailTemplate": {
                  "subject": "Sensor Readings Report",
                  "template": "<html><body><p>{{report_name}}</p></body></html>",
                  "recipients": [
                    "example@kaaiot.io"
                  ]
                },
                "poolIds": [
                  "aXJuOnJjNzNkYmg3cTA6aWFtY29yZTo0YXRjaWNuaXNnOjpwb29sL2Rldg=="
                ]
              }
            }
          }
        }
      },
      "get": {
        "description": "Retrieves templates.",
        "responses": {
          "200": {
            "description": "List is successfully retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponse"
                },
                "example": {
                  "totalElements": 1,
                  "content": [
                    {
                      "id": "3d37097f-3258-4b16-b2e7-2e6df97a303b",
                      "name": "Monthly Sensor Readings",
                      "executionState": "ACTIVE",
                      "triggers": [
                        {
                          "id": "aa3f7b8d-3a22-46e8-8803-e89480ff73f1",
                          "tenantId": "qs73c8ovqg",
                          "name": "Monthly Trigger",
                          "description": "On the last day of the month, every month",
                          "type": "CRON",
                          "cronLine": "0 0 0 L * ?",
                          "createdAt": "2024-03-26T15:00:00.000Z",
                          "updatedAt": "2024-04-26T15:00:00.000Z"
                        }
                      ],
                      "createdAt": "2024-04-26T15:00:00.000Z",
                      "updatedAt": "2024-04-26T15:00:00.000Z"
                    }
                  ]
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "template:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "templateId",
            "in": "query",
            "description": "Template IDs.",
            "required": false,
            "schema": {
              "type": "string[]"
            }
          },
          {
            "name": "name",
            "in": "query",
            "description": "Template name. Supports partial match.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "executionState",
            "in": "query",
            "description": "State of the template execution.",
            "required": false,
            "schema": {
              "type": "template.ExecutionState"
            }
          }
        ]
      }
    },
    "/templates/{templateId}": {
      "parameters": [
        {
          "name": "templateId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "Template ID."
        }
      ],
      "delete": {
        "description": "Deletes template.",
        "responses": {
          "204": {
            "description": "Template is successfully deleted."
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "template:delete"
            ]
          }
        ]
      },
      "get": {
        "description": "Retrieves template.",
        "responses": {
          "200": {
            "description": "Template is successfully retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ItemDetailsResponse"
                },
                "example": {
                  "id": "3d37097f-3258-4b16-b2e7-2e6df97a303b",
                  "name": "Monthly Sensor Readings",
                  "reportName": "sensor__readings__{{createdDate}}",
                  "executionState": "ACTIVE",
                  "tenantId": "qs73c8ovqg",
                  "exportType": "PDF",
                  "exportTemplate": {
                    "pdfTemplate": "<html><head><table><thead><tr><#list table.headers as header><th>${header}</th></#list></tr></thead></table></#list></body></html>",
                    "csvTemplate": "${table.headers?join(\",\")}"
                  },
                  "triggers": [
                    {
                      "id": "aa3f7b8d-3a22-46e8-8803-e89480ff73f1",
                      "tenantId": "qs73c8ovqg",
                      "name": "Monthly Trigger",
                      "description": "On the last day of the month, every month",
                      "type": "CRON",
                      "cronLine": "0 0 0 L * ?",
                      "createdAt": "2024-03-26T15:00:00.000Z",
                      "updatedAt": "2024-04-26T15:00:00.000Z"
                    }
                  ],
                  "emailTemplate": {
                    "subject": "Sensor Readings Report",
                    "template": "<html><body><p>{{report_name}}</p></body></html>",
                    "recipients": [
                      "example@kaaiot.io"
                    ]
                  },
                  "tables": [
                    {
                      "id": "768b5afe-2437-468b-b77b-1335b499f588",
                      "name": "Sensor humidity readings",
                      "description": "Sensor FMC-500",
                      "query": {
                        "dimensions": [
                          {
                            "source": "METADATA",
                            "path": "name",
                            "type": "STRING"
                          },
                          {
                            "source": "TIME_SERIES",
                            "path": "endpointId",
                            "type": "NUMBER"
                          },
                          {
                            "source": "TIME_SERIES",
                            "name": "humidity",
                            "path": "auto~humidity",
                            "type": "NUMBER"
                          }
                        ],
                        "application": "cnc5h752908c73fp4pd0",
                        "from": "now-1h",
                        "to": "now"
                      }
                    }
                  ],
                  "createdAt": "2024-04-26T15:00:00.000Z",
                  "updatedAt": "2024-04-26T15:00:00.000Z"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "template:read"
            ]
          }
        ]
      },
      "put": {
        "description": "Updates template.",
        "responses": {
          "204": {
            "description": "Template is successfully updated."
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "template:update"
            ]
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateRequest"
              },
              "example": {
                "name": "Monthly Sensor Readings",
                "reportName": "sensor__readings__{{createdDate}}",
                "exportType": "PDF",
                "exportTemplate": {
                  "pdfTemplate": "<html><head><table><thead><tr><#list table.headers as header><th>${header}</th></#list></tr></thead></table></#list></body></html>",
                  "csvTemplate": "${table.headers?join(\",\")}"
                },
                "emailTemplate": {
                  "subject": "Sensor Readings Report",
                  "template": "<html><body><p>{{report_name}}</p></body></html>",
                  "recipients": [
                    "example@kaaiot.io"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/templates/{templateId}/state": {
      "parameters": [
        {
          "name": "templateId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "Template ID."
        }
      ],
      "put": {
        "description": "Updates template execution state.\nWhen set to ACTIVE, all associated triggers will be enabled.\n",
        "responses": {
          "204": {
            "description": "Execution state successfully updated."
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "template:update"
            ]
          }
        ],
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "description": "The execution state to set.",
            "required": true,
            "schema": {
              "type": "template.ExecutionState"
            }
          }
        ]
      }
    },
    "/templates/{templateId}/triggers": {
      "parameters": [
        {
          "name": "templateId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "Template ID."
        }
      ],
      "put": {
        "description": "Updates triggers associated with this template.\nThese trigger IDs define when the report should be generated.\n",
        "responses": {
          "204": {
            "description": "Triggers successfully updated."
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "template:update"
            ]
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": [
                "aa3f7b8d-3a22-46e8-8803-e89480ff73f1"
              ]
            }
          }
        }
      }
    },
    "/templates/{templateId}/excel/upload": {
      "parameters": [
        {
          "name": "templateId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "Template ID."
        }
      ],
      "put": {
        "description": "Allows uploading of an Excel template file to customize the layout and content for exporting reports in Excel format.\n            \nIf not provided, default template will be used.\n\nPlaceholders for report data:\n- \"${reportName}\": The name of the report.\n- \"${reportCreatedDate}\": The creation date of the report.\n- \"${reportCreatedDateTime}\": The creation date and time of the report.\n\nPlaceholders for each table:\n- \"${table.name}\": Table name.\n- \"${table.description}\": Table description.\n- \"${table.application}\": Application name.\n- \"${table.fromDate}\": Start date of the table data.\n- \"${table.fromDateTime}\": Start date and time of the table data.\n- \"${table.toDate}\": End date of the table data.\n- \"${table.toDateTime}\": End date and time of the table data.\n- \"${table.headers}\": Table headers.\n- \"${table.data}\": Table data.\n\nFor a comprehensive guide on creating templates, visit the [Template Generation Guide](https://jxls.sourceforge.net/getting-started.html).\n",
        "responses": {
          "204": {
            "description": "The template was successfully uploaded."
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "template:update"
            ]
          }
        ],
        "requestBody": {
          "content": {}
        }
      }
    },
    "/templates/{templateId}/excel/download": {
      "parameters": [
        {
          "name": "templateId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "Template ID."
        }
      ],
      "get": {
        "description": "Downloads the Excel template file.",
        "responses": {
          "200": {
            "description": "The template is successfully retrieved and prepared for download.",
            "headers": {
              "Content-Disposition": {
                "description": "The filename of the downloaded Excel template.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {}
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "template:read"
            ]
          }
        ]
      }
    },
    "/templates/{templateId}/tables": {
      "parameters": [
        {
          "name": "templateId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "Template ID."
        }
      ],
      "post": {
        "description": "Creates a new item.",
        "responses": {
          "201": {
            "description": "Item is successfully created.",
            "headers": {
              "Location": {
                "description": "URI in format `{schema}://{host}/rs/api/v1/templates/{templateId}/tables`",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "template:table:create"
            ]
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertRequest"
              },
              "example": {
                "name": "Sensor humidity readings",
                "description": "Sensor FMC-500",
                "query": {
                  "dimensions": [
                    {
                      "source": "METADATA",
                      "path": "name",
                      "type": "STRING",
                      "useDefaultValue": true,
                      "defaultValue": "unknown"
                    },
                    {
                      "source": "TIME_SERIES",
                      "path": "endpointId",
                      "type": "NUMBER"
                    },
                    {
                      "source": "TIME_SERIES",
                      "name": "humidity",
                      "path": "auto~humidity",
                      "type": "NUMBER"
                    }
                  ],
                  "application": "cnc5h752908c73fp4pd0",
                  "from": "now-1h",
                  "to": "now"
                }
              }
            }
          }
        }
      }
    },
    "/templates/{templateId}/tables/{tableId}": {
      "parameters": [
        {
          "name": "templateId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "Template ID."
        },
        {
          "name": "tableId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "Table ID."
        }
      ],
      "put": {
        "description": "Updates item.",
        "responses": {
          "204": {
            "description": "Item is successfully updated."
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "template:table:update"
            ]
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "name": "Sensor humidity readings",
                "description": "Sensor FMC-500",
                "query": {
                  "dimensions": [
                    {
                      "source": "METADATA",
                      "path": "name",
                      "type": "STRING",
                      "useDefaultValue": true,
                      "defaultValue": "unknown"
                    },
                    {
                      "source": "TIME_SERIES",
                      "path": "endpointId",
                      "type": "NUMBER"
                    },
                    {
                      "source": "TIME_SERIES",
                      "name": "humidity",
                      "path": "auto~humidity",
                      "type": "NUMBER"
                    }
                  ],
                  "application": "cnc5h752908c73fp4pd0",
                  "from": "now-1h",
                  "to": "now"
                }
              }
            }
          }
        }
      },
      "get": {
        "description": "Retrieves item.",
        "responses": {
          "200": {
            "description": "Item is successfully retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "id": "768b5afe-2437-468b-b77b-1335b499f588",
                  "name": "Sensor humidity readings",
                  "description": "Sensor FMC-500",
                  "query": {
                    "dimensions": [
                      {
                        "source": "METADATA",
                        "path": "name",
                        "type": "STRING"
                      },
                      {
                        "source": "TIME_SERIES",
                        "path": "endpointId",
                        "type": "NUMBER"
                      },
                      {
                        "source": "TIME_SERIES",
                        "name": "humidity",
                        "path": "auto~humidity",
                        "type": "NUMBER"
                      }
                    ],
                    "application": "cnc5h752908c73fp4pd0",
                    "from": "now-1M",
                    "to": "now"
                  },
                  "createdAt": "2024-02-20T17:00:00.000Z",
                  "updatedAt": "2024-02-20T17:00:00.000Z"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "template:table:read"
            ]
          }
        ]
      },
      "delete": {
        "description": "Deletes.",
        "responses": {
          "204": {
            "description": "Item is successfully deleted."
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "template:table:delete"
            ]
          }
        ]
      }
    },
    "/templates/default/email": {
      "get": {
        "description": "Retrieves default email template and subject.",
        "responses": {
          "200": {
            "description": "Item is successfully retrieved.",
            "content": {
              "example": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/templates/default/pdf": {
      "get": {
        "description": "Retrieves default pdf template and.",
        "responses": {
          "200": {
            "description": "Item is successfully retrieved.",
            "content": {
              "example": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/templates/default/csv": {
      "get": {
        "description": "Retrieves default csv template.",
        "responses": {
          "200": {
            "description": "Item is successfully retrieved.",
            "content": {
              "example": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/templates/default/excel": {
      "get": {
        "description": "Downloads default Excel template file.",
        "responses": {
          "200": {
            "description": "The default template is successfully retrieved and prepared for download.",
            "headers": {
              "Content-Disposition": {
                "description": "The filename of the downloaded Excel template.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {}
          }
        }
      }
    },
    "/triggers": {
      "post": {
        "description": "Creates a new item.",
        "responses": {
          "201": {
            "description": "Item is successfully created.",
            "headers": {
              "Location": {
                "description": "URI in format `{schema}://{host}/rs/api/v1/triggers/{triggerId}`",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "trigger:create"
            ]
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRequest"
              },
              "example": {
                "name": "Monthly Trigger",
                "description": "On the last day of the month, every month",
                "type": "CRON",
                "cronLine": "0 0 0 L * ?",
                "poolIds": [
                  "aXJuOnJjNzNkYmg3cTA6aWFtY29yZTo0YXRjaWNuaXNnOjpwb29sL2Rldg=="
                ]
              }
            }
          }
        }
      },
      "get": {
        "description": "Retrieves list.",
        "responses": {
          "200": {
            "description": "List is successfully retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "totalElements": 1,
                  "content": [
                    {
                      "id": "aa3f7b8d-3a22-46e8-8803-e89480ff73f1",
                      "tenantId": "qs73c8ovqg",
                      "name": "Monthly Trigger",
                      "description": "On the last day of the month, every month",
                      "type": "CRON",
                      "cronLine": "0 0 0 L * ?",
                      "createdAt": "2024-04-26T15:48:00.889Z",
                      "updatedAt": "2024-04-26T15:48:00.889Z"
                    }
                  ]
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "trigger:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "triggerId",
            "in": "query",
            "description": "Trigger Ids.",
            "required": false,
            "schema": {
              "type": "string[]"
            }
          },
          {
            "name": "name",
            "in": "query",
            "description": "Trigger name. Supports partial match.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/triggers/{triggerId}": {
      "parameters": [
        {
          "name": "triggerId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "Trigger ID."
        }
      ],
      "put": {
        "description": "Updates item.",
        "responses": {
          "204": {
            "description": "Item is successfully updated."
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "trigger:update"
            ]
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "name": "Monthly Trigger",
                "description": "On the last day of the month, every month",
                "type": "CRON",
                "cronLine": "0 0 0 L * ?"
              }
            }
          }
        }
      },
      "get": {
        "description": "Retrieves item.",
        "responses": {
          "200": {
            "description": "Item is successfully retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "id": "aa3f7b8d-3a22-46e8-8803-e89480ff73f1",
                  "tenantId": "qs73c8ovqg",
                  "name": "Monthly Trigger",
                  "description": "On the last day of the month, every month",
                  "type": "CRON",
                  "cronLine": "0 0 0 L * ?",
                  "poolIds": [
                    "aXJuOnJjNzNkYmg3cTA6aWFtY29yZTo0YXRjaWNuaXNnOjpwb29sL2Rldg=="
                  ],
                  "createdAt": "2024-04-26T15:48:00.889Z",
                  "updatedAt": "2024-04-26T15:48:00.889Z"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "trigger:read"
            ]
          }
        ]
      },
      "delete": {
        "description": "Deletes.",
        "responses": {
          "204": {
            "description": "Item is successfully deleted."
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "trigger:delete"
            ]
          }
        ]
      }
    },
    "/tasks/status": {
      "get": {
        "description": "Retrieves list.",
        "responses": {
          "200": {
            "description": "List is successfully retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "totalElements": 2,
                  "content": [
                    {
                      "id": "3d419acb-f38e-416c-b47d-4230190df6c6",
                      "status": "DONE",
                      "templateId": "3d37097f-3258-4b16-b2e7-2e6df97a303b",
                      "templateName": "Monthly Sensor Readings",
                      "triggerId": "aa3f7b8d-3a22-46e8-8803-e89480ff73f1",
                      "triggerName": "Monthly Trigger",
                      "reportId": "d1466785-6498-4a7b-ae5b-b1bbc14986ff",
                      "createdAt": "2024-04-10T11:00:00.000Z",
                      "startedAt": "2024-04-10T11:00:10.000Z",
                      "finishedAt": "2024-04-10T11:00:20.000Z"
                    },
                    {
                      "id": "b1e42223-69ef-459f-8b9a-9b41b981284a",
                      "status": "FAILED",
                      "errorMessage": "Error sending notification",
                      "templateId": "3d37097f-3258-4b16-b2e7-2e6df97a303b",
                      "templateName": "Monthly Sensor Readings",
                      "createdAt": "2024-04-10T12:00:00.000Z",
                      "startedAt": "2024-04-10T12:00:10.000Z",
                      "finishedAt": "2024-04-10T12:00:20.000Z"
                    },
                    {
                      "id": "d0c36ba7-94ec-423d-bfdd-c8b2a807d5bc",
                      "status": "DONE",
                      "reportId": "8a7c2efd-d262-4733-a046-0c1ca46f4ed7",
                      "createdAt": "2024-04-10T13:00:00.000Z",
                      "startedAt": "2024-04-10T13:00:10.000Z",
                      "finishedAt": "2024-04-10T13:00:20.000Z"
                    }
                  ]
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "template:task:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "taskId",
            "in": "query",
            "description": "Task IDs.",
            "required": false,
            "schema": {
              "type": "string[]"
            }
          },
          {
            "name": "templateId",
            "in": "query",
            "description": "Template IDs.",
            "required": false,
            "schema": {
              "type": "string[]"
            }
          },
          {
            "name": "templateName",
            "in": "query",
            "description": "Template name. Supports partial match.",
            "required": false,
            "schema": {
              "type": "string[]"
            }
          },
          {
            "name": "triggerId",
            "in": "query",
            "description": "Trigger ID.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "triggerName",
            "in": "query",
            "description": "Trigger name. Supports partial match.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "type",
            "in": "query",
            "description": "Trigger type.",
            "required": false,
            "schema": {
              "type": "task.TaskState"
            }
          }
        ]
      }
    },
    "/tasks/templates": {
      "post": {
        "description": "Execute template.",
        "responses": {
          "202": {
            "description": "Template execution task is accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskAcceptedResponse"
                },
                "example": {
                  "taskId": "3d419acb-f38e-416c-b47d-4230190df6c6"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "template:task:create"
            ]
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExecuteRequest"
              },
              "example": {
                "reportName": "sensor__readings__{{createdDate}}",
                "exportType": "PDF",
                "exportTemplate": {
                  "pdfTemplate": "<html><head><table><thead><tr><#list table.headers as header><th>${header}</th></#list></tr></thead></table></#list></body></html>",
                  "csvTemplate": "${table.headers?join(\",\")}"
                },
                "emailTemplate": {
                  "subject": "Sensor Readings Report",
                  "template": "<html><body><p>{{report_name}}</p></body></html>",
                  "recipients": [
                    "example@kaaiot.io"
                  ]
                },
                "tables": [
                  {
                    "name": "Sensor humidity readings",
                    "description": "Sensor FMC-500",
                    "query": {
                      "dimensions": [
                        {
                          "source": "METADATA",
                          "path": "name",
                          "type": "STRING"
                        },
                        {
                          "source": "TIME_SERIES",
                          "path": "endpointId",
                          "type": "NUMBER"
                        },
                        {
                          "source": "TIME_SERIES",
                          "name": "humidity",
                          "path": "auto~humidity",
                          "type": "NUMBER"
                        }
                      ],
                      "application": "cnc5h752908c73fp4pd0",
                      "from": "now-1M",
                      "to": "now"
                    }
                  }
                ]
              }
            }
          }
        }
      }
    },
    "/tasks/templates/{templateId}": {
      "parameters": [
        {
          "name": "templateId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "Template ID."
        }
      ],
      "post": {
        "description": "Execute template.",
        "responses": {
          "202": {
            "description": "Template execution task is accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "taskId": "3d419acb-f38e-416c-b47d-4230190df6c6"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "template:task:create"
            ]
          }
        ]
      }
    },
    "/reports": {
      "get": {
        "description": "Returns reports that match query parameters.",
        "responses": {
          "200": {
            "description": "Reports are successfully retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "content": [
                    {
                      "id": "d1466785-6498-4a7b-ae5b-b1bbc14986ff",
                      "name": "Sensor Readings Report",
                      "templateId": "3d37097f-3258-4b16-b2e7-2e6df97a303b",
                      "createdAt": "2024-04-26T15:00:00.000Z"
                    },
                    {
                      "id": "118bed3b-2d2d-4502-8f25-6d2b78227ac1",
                      "name": "Sensor Readings Report",
                      "templateId": "177d15c7-74c4-4649-b262-d578ab29ddb9",
                      "createdAt": "2024-03-20T15:00:00.000Z"
                    }
                  ],
                  "totalElements": 2
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "report:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "reportId",
            "in": "query",
            "description": "Report identifier, can be one or multiple.",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "d1466785-6498-4a7b-ae5b-b1bbc14986ff"
          },
          {
            "name": "templateId",
            "in": "query",
            "description": "Template identifier, can be one or multiple.",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "4a2ab67a-b5d7-4919-96e0-127d7d558e5a"
          },
          {
            "name": "name",
            "in": "query",
            "description": "Report name. Supports partial match.",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "Monitoring"
          }
        ]
      }
    },
    "/reports/{reportId}": {
      "parameters": [
        {
          "name": "reportId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "Identifier of the report to operate on.",
          "example": "d1466785-6498-4a7b-ae5b-b1bbc14986ff"
        }
      ],
      "get": {
        "description": "Retrieves report.",
        "responses": {
          "200": {
            "description": "Report is successfully retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "id": "d1466785-6498-4a7b-ae5b-b1bbc14986ff",
                  "name": "Sensor Readings Report",
                  "templateId": "3d37097f-3258-4b16-b2e7-2e6df97a303b",
                  "createdAt": "2024-04-26T15:00:00.000Z",
                  "tables": [
                    {
                      "name": "Sensor humidity readings",
                      "description": "Sensor FMC-500",
                      "application": "cnc5h752908c73fp4pd0",
                      "from": "2024-03-26T15:00:00.000Z",
                      "to": "2024-04-26T15:00:00.000Z",
                      "headers": [
                        "name",
                        "endpointId",
                        "humidity"
                      ],
                      "data": [
                        {
                          "name": "FMC-500",
                          "endpointId": "568b5afe-2437-468b-b57b-1335b499f589",
                          "humidity": "73"
                        },
                        {
                          "name": "FMC-500",
                          "endpointId": "568b5afe-2437-468b-b57b-1335b499f589",
                          "humidity": "75"
                        }
                      ]
                    }
                  ],
                  "poolIds": [
                    "aXJuOnJjNzNkYmg3cTA6aWFtY29yZTo0YXRjaWNuaXNnOjpwb29sL2Rldg=="
                  ]
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "report:read"
            ]
          }
        ]
      }
    },
    "/reports/{reportId}/download": {
      "parameters": [
        {
          "name": "reportId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "Identifier of the report to operate on.",
          "example": "d1466785-6498-4a7b-ae5b-b1bbc14986ff"
        }
      ],
      "get": {
        "description": "Retrieves link to download the report.",
        "responses": {
          "200": {
            "description": "Link successfully retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LinkResponse"
                },
                "example": {
                  "downloadLink": "https://minio.cloud.kaaiot.com/{tenantId}/reports/{templateId}/{reportId}/{reportName}.pdf"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth_2_0": [
              "report:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "exportType",
            "in": "query",
            "description": "Report export type.",
            "required": true,
            "schema": {
              "type": "template.ExportType"
            }
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "oauth_2_0": {
        "type": "oauth2",
        "description": "AM supports OAuth 2.0 for authenticating all API requests.\n",
        "flows": {
          "implicit": {
            "authorizationUrl": "https://auth.example.com/oauth/authorize",
            "scopes": {}
          }
        }
      }
    },
    "schemas": {
      "DataSource": {
        "type": "string"
      },
      "ColumnType": {
        "type": "string"
      },
      "Expression": {
        "type": "string",
        "description": "A Mustache expression used to transform or format a column value. The expression is applied per row\nand replaces the column's existing value with the expression result. Any other column in the same row\ncan be referenced by name (e.g. `{{speed}}`), and the built-in lambdas below can be applied as\nMustache sections. Lambdas may be nested, and column references / lambdas inside another lambda's\nbody are resolved before the outer lambda is applied.\n\nBuilt-in lambdas:\n  `{{column}}`                                    Raw value of the referenced column.\n  `{{#round}}{{column}}{{/round}}`                Round down to 0 decimal places.\n  `{{#round1}}{{column}}{{/round1}}`              Round down to 1 decimal place.\n  `{{#round2}}{{column}}{{/round2}}`              Round down to 2 decimal places.\n  `{{#dateTime}}{{column}}{{/dateTime}}`          Format an epoch-millis or ISO timestamp as `d MMM yyyy HH:mm`.\n  `{{#dateOnly}}{{column}}{{/dateOnly}}`          Format an epoch-millis or ISO timestamp as `dd MMM yyyy`.\n  `{{#timeOnly}}{{column}}{{/timeOnly}}`          Format an epoch-millis or ISO timestamp as `HH:mm:ss`.\n  `{{#iff}}{{column}}|trueText|falseText{{/iff}}` Conditional (ternary) expression. Renders `trueText` when the\n                                                  value is truthy, otherwise `falseText`. Falsy values: empty,\n                                                  `0`, `0.0`, any numeric zero, `false`, `null` (case-insensitive).\n                                                  All other values are truthy. Whitespace around each of the three\n                                                  parts is trimmed; the false branch may be omitted\n                                                  (`{{column}}|trueText|`) and renders as empty. Pipe characters\n                                                  inside the branch text are preserved.\n\nNote: an expression is only applied when the column has a present, non-null value in the row. For\naggregation columns that may yield null (for example AVG over documents missing the field), set\n`useDefaultValue` together with `defaultValue` on the column so the expression is evaluated on every row.\n"
      },
      "DimensionColumn": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Column display name. Path defaults to column name if not provided."
          },
          "source": {
            "$ref": "#/components/schemas/DataSource"
          },
          "path": {
            "type": "string",
            "description": "Path for the target metric in the datasource."
          },
          "type": {
            "$ref": "#/components/schemas/ColumnType"
          },
          "expression": {
            "$ref": "#/components/schemas/Expression"
          },
          "orderIndex": {
            "type": "number",
            "description": "Specifies the sequence or position of the column in the table."
          },
          "defaultValue": {
            "description": "Value substituted when the dimension's source value is absent, null, or empty string.\nMust be consistent with `type` (NUMBER -> number, BOOL -> boolean, DATE -> ISO-8601 string,\nSTRING -> string). Only applied when `useDefaultValue` is true.\n"
          },
          "useDefaultValue": {
            "type": "boolean",
            "description": "When true, missing/null/empty dimension values are replaced with `defaultValue`.\nDefaults to false (existing behaviour preserved).\n"
          }
        },
        "required": [
          "source"
        ]
      },
      "AggregationFunction": {
        "type": "string",
        "description": "Aggregation applied to the column. `LAST` returns the value of the most recent document\n(sorted by `timestampColumn`, default `@timestamp`) within each dimension bucket.\nOnly supported on the ANALYTICS data source.\n"
      },
      "AggregationColumn": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Column display name. Path defaults to column name if not provided."
          },
          "source": {
            "type": "object",
            "description": "Origin from which this column will be queried."
          },
          "path": {
            "type": "string",
            "description": "Path for the target metric in the datasource."
          },
          "type": {
            "type": "object",
            "description": "Expected column type."
          },
          "function": {
            "$ref": "#/components/schemas/AggregationFunction"
          },
          "expression": {
            "type": "object"
          },
          "orderIndex": {
            "type": "number",
            "description": "Specifies the sequence or position of the column in the table."
          },
          "defaultValue": {
            "description": "Value substituted when the aggregation result is absent or null.\nMust be consistent with `type` (NUMBER -> number, BOOL -> boolean, DATE -> ISO-8601 string,\nSTRING -> string). Only applied when `useDefaultValue` is true.\n"
          },
          "useDefaultValue": {
            "type": "boolean",
            "description": "When true, null/absent aggregation results are replaced with `defaultValue`.\nAdditionally, when at least one aggregation column has this enabled, rows are\ncreated for dimension members (e.g. from metadata) that have no analytics data,\nwith aggregation columns filled from their configured defaults.\nDefaults to false (existing behaviour preserved).\n"
          }
        },
        "required": [
          "source"
        ]
      },
      "TimeHistDimensionColumn": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Column display name. Path defaults to column name if not provided."
          },
          "source": {
            "type": "object",
            "description": "Origin from which this column will be queried."
          },
          "path": {
            "type": "string",
            "description": "Path for the target metric in the datasource."
          },
          "type": {
            "type": "object",
            "description": "Expected column type."
          },
          "calendarInterval": {
            "type": "string",
            "description": "Calendar interval passed to the elasticsearch."
          },
          "expression": {
            "type": "object"
          },
          "orderIndex": {
            "type": "number",
            "description": "Specifies the sequence or position of the column in the table."
          }
        },
        "required": [
          "source"
        ]
      },
      "FilterType": {
        "type": "string"
      },
      "WhereColumn": {
        "type": "object",
        "properties": {
          "source": {
            "type": "object",
            "description": "Origin from which this column will be queried."
          },
          "path": {
            "type": "string",
            "description": "Path for the target metric in the datasource."
          },
          "type": {
            "type": "object",
            "description": "Column type."
          },
          "function": {
            "$ref": "#/components/schemas/FilterType"
          },
          "value": {
            "type": "object",
            "description": "Value to be applied for filtering."
          },
          "from": {
            "type": "string",
            "description": "Used for filtering in the IN_RANGE function."
          },
          "to": {
            "type": "string",
            "description": "Used for filtering in the IN_RANGE function."
          }
        },
        "required": [
          "source"
        ]
      },
      "Query": {
        "type": "object",
        "properties": {
          "application": {
            "type": "string",
            "description": "Application name."
          },
          "timestampColumn": {
            "type": "string",
            "description": "Elastic timestamp column name to search."
          },
          "from": {
            "type": "string",
            "description": "Specify the start of the time window using date expressions (e.g., `now`, `now-1h`) \nor a specific timestamp in ISO 8601 format.\n"
          },
          "to": {
            "type": "string",
            "description": "Specify the end of the time window using date expressions (e.g., `now`, `now-1h`) \nor a specific timestamp in ISO 8601 format.\n"
          },
          "dimensions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DimensionColumn"
            },
            "description": "List of columns that going to be used as group by queries dimensions."
          },
          "columns": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AggregationColumn"
            },
            "description": "Specifies the aggregation columns."
          },
          "timeDimension": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TimeHistDimensionColumn"
            },
            "description": "Time histogram component of the group by queries dimensions."
          },
          "where": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WhereColumn"
            },
            "description": "Filter conditions to be applied to the data."
          }
        },
        "required": [
          "application",
          "from",
          "to",
          "dimensions",
          "columns",
          "timeDimension",
          "where"
        ]
      },
      "ReportName": {
        "type": "string",
        "description": "The name of the report to be generated. If not provided, the template name will be used.\n\nCan include the following placeholders:\n   - \"{{createdDate}}\"\n   - \"{{createdDateTime}}\"\n   - \"{{fromDate}}\"    \n   - \"{{fromDateTime}}\"    \n   - \"{{toDate}}\"    \n   - \"{{toDateTime}}\"   \n"
      },
      "ExecutionState": {
        "type": "string"
      },
      "ExportType": {
        "type": "string"
      },
      "ExportTemplate": {
        "type": "object",
        "properties": {
          "pdfTemplate": {
            "type": "string",
            "description": "Content of the FreeMarker template for customizing PDF report exports."
          },
          "csvTemplate": {
            "type": "string",
            "description": "Content of the FreeMarker template for customizing CSV report exports."
          }
        },
        "description": "Offers customization options to define the layout and content of report exports.\n\nPlaceholders for report data:\n- \"${reportName}\": The name of the report.\n- \"${reportCreatedDate}\": The creation date of the report.\n- \"${reportCreatedDateTime}\": The creation date and time of the report.\n\nPlaceholders for each table:\n- \"${table.name}\": Table name.\n- \"${table.description}\": Table description.\n- \"${table.application}\": Application name.\n- \"${table.fromDate}\": Start date of the table data.\n- \"${table.fromDateTime}\": Start date and time of the table data.\n- \"${table.toDate}\": End date of the table data.\n- \"${table.toDateTime}\": End date and time of the table data.\n- \"${table.headers}\": Table headers.\n- \"${table.data}\": Table data.\n\nIf not provided, a default template will be used.  \n"
      },
      "EmailTemplate": {
        "type": "object",
        "properties": {
          "recipients": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "A list of email addresses of the recipients."
          },
          "subject": {
            "type": "string",
            "description": "The subject line of the email notification."
          },
          "template": {
            "type": "string",
            "description": "The HTML content of the email notification. If not provided, a default template will be used.\n\nCan include the following placeholders:\n  - \"{{report_download_link}}\": Link to download the report.\n  - \"{{report_name}}\": Name of the generated report.\n  - \"{{year}}\": Current year.\n"
          }
        },
        "description": "Notifies recipients that a report has been generated and is available for download."
      },
      "CreationRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Template name."
          },
          "reportName": {
            "$ref": "#/components/schemas/ReportName"
          },
          "executionState": {
            "$ref": "#/components/schemas/ExecutionState"
          },
          "triggers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "IDs of triggers associated with this template.\nThese trigger IDs define when the report should be generated.\n"
          },
          "exportType": {
            "$ref": "#/components/schemas/ExportType"
          },
          "exportTemplate": {
            "$ref": "#/components/schemas/ExportTemplate"
          },
          "emailTemplate": {
            "$ref": "#/components/schemas/EmailTemplate"
          },
          "poolIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "An array of the unique identifiers of the pools to which the template will be attached."
          }
        },
        "required": [
          "name"
        ]
      },
      "ItemResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Report ID."
          },
          "name": {
            "type": "string",
            "description": "Report name."
          },
          "templateId": {
            "type": "string",
            "description": "The identifier of the template used to generate the report."
          },
          "poolIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Pool IDs the report attached to."
          },
          "createdAt": {
            "type": "string",
            "format": "rfc3339",
            "description": "Timestamp in ISO 8601 format (UTC timezone) showing when the report was generated."
          }
        },
        "required": [
          "id",
          "name",
          "createdAt"
        ]
      },
      "ListResponse": {
        "type": "object",
        "properties": {
          "totalElements": {
            "type": "integer",
            "description": "Total number of elements available for retrieval."
          },
          "content": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ItemResponse"
            }
          }
        },
        "required": [
          "totalElements"
        ]
      },
      "ItemTable": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Table name."
          },
          "application": {
            "type": "string",
            "description": "The name of the application associated with the report table."
          },
          "description": {
            "type": "string",
            "description": "Notes or context about this report table."
          },
          "from": {
            "type": "string",
            "description": "The starting timestamp for the data included in the report table."
          },
          "to": {
            "type": "string",
            "description": "The ending timestamp for the data included in the report table."
          },
          "headers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "List of column headers for the report table."
          },
          "data": {
            "type": "object",
            "description": "The data contained within the report table."
          }
        },
        "required": [
          "name",
          "application",
          "from",
          "to",
          "headers",
          "data"
        ]
      },
      "ItemDetailsResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Report ID."
          },
          "name": {
            "type": "string",
            "description": "Report name."
          },
          "templateId": {
            "type": "string",
            "description": "The identifier of the template used to generate the report."
          },
          "createdAt": {
            "type": "string",
            "format": "rfc3339",
            "description": "Timestamp in ISO 8601 format (UTC timezone) showing when the report was generated."
          },
          "tables": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ItemTable"
            },
            "description": "A list of tables containing the data for the report."
          }
        },
        "required": [
          "id",
          "name",
          "createdAt",
          "tables"
        ]
      },
      "TriggerType": {
        "type": "string"
      },
      "UpdateRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Trigger name."
          },
          "type": {
            "$ref": "#/components/schemas/TriggerType"
          },
          "description": {
            "type": "string",
            "description": "Description and notes for this trigger."
          },
          "cronLine": {
            "type": "string",
            "description": "Quartz cron line."
          }
        },
        "required": [
          "name",
          "type",
          "cronLine"
        ]
      },
      "UpsertRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Table name.",
            "pattern": "^.{1,30}$"
          },
          "description": {
            "type": "string",
            "description": "Description and notes for this table."
          },
          "orderIndex": {
            "type": "number",
            "description": "Specifies the sequence or position of the table in the report."
          },
          "query": {
            "type": "object",
            "description": "The query used to retrieve data for the table."
          }
        },
        "required": [
          "name",
          "query"
        ]
      },
      "CreateRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Trigger name."
          },
          "type": {
            "type": "object",
            "description": "Specifies the type of trigger mechanism."
          },
          "description": {
            "type": "string",
            "description": "Description and notes for this trigger."
          },
          "cronLine": {
            "type": "string",
            "description": "Quartz cron line."
          },
          "poolIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "An array of the unique identifiers of the pools to which the trigger should be attached."
          }
        },
        "required": [
          "name",
          "type",
          "cronLine"
        ]
      },
      "ExecuteRequest": {
        "type": "object",
        "properties": {
          "reportName": {
            "type": "string",
            "description": "The name of the report to be generated. \n\nCan include the following placeholders:         \n- \"{{createdDate}}\"\n- \"{{createdDateTime}}\"\n- \"{{fromDate}}\"    \n- \"{{fromDateTime}}\"    \n- \"{{toDate}}\"    \n- \"{{toDateTime}}\"\n"
          },
          "exportType": {
            "type": "object",
            "description": "The format of the report in which the notification will be sent."
          },
          "exportTemplate": {
            "type": "object"
          },
          "emailTemplate": {
            "type": "object"
          },
          "tables": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "List of table templates."
          }
        },
        "required": [
          "reportName",
          "tables"
        ]
      },
      "TaskAcceptedResponse": {
        "type": "object",
        "properties": {
          "taskId": {
            "type": "string",
            "description": "Template execution task ID."
          }
        },
        "required": [
          "taskId"
        ]
      },
      "LinkResponse": {
        "type": "object",
        "properties": {
          "downloadLink": {
            "type": "string",
            "description": "Link to download report."
          }
        },
        "required": [
          "downloadLink"
        ]
      },
      "EmailTemplateResponse": {
        "type": "object",
        "properties": {
          "subject": {
            "type": "string",
            "description": "The subject line of the email notification."
          },
          "template": {
            "type": "string",
            "description": "The HTML content of the email notification."
          },
          "recipients": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "A list of email addresses of the recipients."
          }
        },
        "description": "Notifies recipients that a report has been generated and is available for download."
      },
      "ExportTemplateResponse": {
        "type": "object",
        "properties": {
          "pdfTemplate": {
            "type": "string",
            "description": "Content of the FreeMarker template for customizing PDF report exports."
          },
          "csvTemplate": {
            "type": "string",
            "description": "Content of the FreeMarker template for customizing CSV report exports."
          }
        },
        "description": "Offers customization options to define the layout and content of report exports."
      },
      "TaskState": {
        "type": "string"
      },
      "ClientErrorResponse": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "Detailed error description."
          }
        },
        "required": [
          "message"
        ]
      }
    }
  }
}