{
  "swagger": "2.0",
  "info": {
    "description": "",
    "version": "1.0.0",
    "title": "Swagger Simulator"
  },
  "host": "localhost:9090",
  "basePath": "/simulation",
  "tags": [
    {
      "name": "simulator",
      "description": "API for event simulation",
      "externalDocs": {
        "description": "Find out more",
        "url": "https://docs.wso2.com/display/SP400/Simulating+Events"
      }
    }
  ],
  "schemes": [
    "http"
  ],
  "paths": {
    "/logs": {
      "get": {
        "tags": [
          "simulator"
        ],
        "summary": "Retrieve all logged events.",
        "description": "",
        "operationId": "getInitialLogs",
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "Successfully retrieved all logged events.",
            "schema": {
              "type": "array",
              "items": {
                "type": "object"
              }
            }
          }
        }
      }
    },
    "/logs/{timestamp}": {
      "get": {
        "tags": [
          "simulator"
        ],
        "summary": "Retrieve logged events from the given timestamp",
        "description": "",
        "operationId": "getLogsFromTimestamp",
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "timestamp",
            "in": "path",
            "description": "Starting timestamp of the retrieving logged events",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully retrieved logged events from given timestamp.",
            "schema": {
              "type": "array",
              "items": {
                "type": "object"
              }
            }
          }
        }
      }
    },
    "/single": {
      "post": {
        "tags": [
          "simulator"
        ],
        "summary": "Send single event for simulation",
        "description": "",
        "operationId": "runSingleSimulation",
        "consumes": [
          "text/plain"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "Simulation object which is need to be run",
            "required": true,
            "schema": {
              "type": "string",
              "example": {
                "streamName": "FooStream",
                "siddhiAppName": "TestSiddhiApp",
                "timestamp": "1500319950004",
                "data": [
                  "foo",
                  "bar",
                  "12345"
                ]
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Single Event simulation started successfully"
          }
        }
      }
    },
    "/feed": {
      "post": {
        "tags": [
          "simulator"
        ],
        "summary": "Upload feed simulation configuration to the system",
        "description": "",
        "operationId": "addFeedSimulation",
        "consumes": [
          "text/plain"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "Simulation object which is need to be saved",
            "required": true,
            "schema": {
              "type": "string",
              "example": {
                "properties": {
                  "simulationName": "TestSimulation",
                  "startTimestamp": 1500319950003,
                  "endTimestamp": 1500319950009,
                  "timeInterval": 1000,
                  "noOfEvents": 10,
                  "description": "This simulation is used to simulate events through FooStream"
                },
                "sources": [
                  {
                    "simulationType": "RANDOM_DATA_SIMULATION",
                    "streamName": "FooStream",
                    "siddhiAppName": "TestSiddhiApp",
                    "timeInterval": "1000",
                    "attributeConfiguration": [
                      {
                        "type": "PROPERTY_BASED",
                        "property": "ALTITUDE"
                      },
                      {
                        "type": "REGEX_BASED",
                        "pattern": "[0-9]*"
                      },
                      {
                        "type": "PRIMITIVE_BASED",
                        "min": "1500000",
                        "max": "30000000"
                      },
                      {
                        "type": "CUSTOM_DATA_BASED",
                        "list": [
                          "WSO2",
                          "AAA",
                          "DDD",
                          "IBM"
                        ]
                      }
                    ]
                  },
                  {
                    "simulationType": "DATABASE_SIMULATION",
                    "streamName": "FooStream",
                    "siddhiAppName": "TestSiddhiApp",
                    "dataSourceLocation": "jdbc:mysql://localhost:3306/DatabaseFeedSimulation",
                    "noOfEvents": 10,
                    "driver": "com.mysql.jdbc.Driver",
                    "username": "root",
                    "password": "password",
                    "tableName": "simulation_data_table",
                    "timestampAttribute": "timestamp_column_name",
                    "columnNamesList": "symbol,price,volume,timestamp_column_name"
                  },
                  {
                    "simulationType": "CSV_SIMULATION",
                    "streamName": "FooStream",
                    "siddhiAppName": "TestSiddhiApp",
                    "fileName": "foostream.csv",
                    "timestampAttribute": 1,
                    "isOrdered": false,
                    "delimiter": ",",
                    "indices": "0,1,2"
                  }
                ]
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully uploaded simulation"
          }
        }
      },
      "get": {
        "tags": [
          "simulator"
        ],
        "summary": "Retrieve all feed simulation configurations",
        "description": "Some desc.",
        "operationId": "getFeedSimulations",
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "Successfully updated simulation configuration.",
            "schema": {
              "type": "string",
              "example": [
                {
                  "activeSimulations": [
                    {
                      "properties": {
                        "simulationName": "TestSimulation",
                        "startTimestamp": 1500319950004,
                        "endTimestamp": 1500319950009,
                        "timeInterval": 1000,
                        "noOfEvents": 10,
                        "description": "This simulation is used to simulate events through FooStream"
                      },
                      "sources": [
                        {
                          "simulationType": "RANDOM_DATA_SIMULATION",
                          "streamName": "FooStream",
                          "siddhiAppName": "TestSiddhiApp",
                          "timeInterval": "1000",
                          "attributeConfiguration": [
                            {
                              "type": "PROPERTY_BASED",
                              "property": "ALTITUDE"
                            },
                            {
                              "type": "REGEX_BASED",
                              "pattern": "[0-9]*"
                            },
                            {
                              "type": "PRIMITIVE_BASED",
                              "min": "1500000",
                              "max": "30000000"
                            },
                            {
                              "type": "CUSTOM_DATA_BASED",
                              "list": [
                                "WSO2",
                                "AAA",
                                "DDD",
                                "IBM"
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ],
                  "inActiveSimulations": [
                    {
                      "properties": {
                        "simulationName": "TestSimulation",
                        "startTimestamp": 1500319950003,
                        "endTimestamp": 1500319950009,
                        "timeInterval": 1000,
                        "noOfEvents": 10,
                        "description": "This simulation is used to simulate events through FooStream"
                      },
                      "sources": [
                        {
                          "simulationType": "DATABASE_SIMULATION",
                          "streamName": "FooStream",
                          "siddhiAppName": "TestSiddhiApp",
                          "dataSourceLocation": "jdbc:mysql://localhost:3306/DatabaseFeedSimulation",
                          "noOfEvents": 10,
                          "driver": "com.mysql.jdbc.Driver",
                          "username": "root",
                          "password": "password",
                          "tableName": "simulation_data_table",
                          "timestampAttribute": "timestamp_column_name",
                          "columnNamesList": "symbol,price,volume,timestamp_column_name"
                        },
                        {
                          "simulationType": "CSV_SIMULATION",
                          "streamName": "FooStream",
                          "siddhiAppName": "TestSiddhiApp",
                          "fileName": "foostream.csv",
                          "timestampAttribute": 2,
                          "isOrdered": false,
                          "delimiter": ",",
                          "indices": "0,1,2"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          },
          "404": {
            "description": "No simulation configurations available."
          }
        }
      }
    },
    "/feed/{simulationName}": {
      "put": {
        "tags": [
          "simulator"
        ],
        "summary": "Update an uploaded simulation configuration",
        "description": "Some description",
        "operationId": "updateFeedSimulation",
        "consumes": [
          "text/plain"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "simulationName",
            "in": "path",
            "description": "Feed Simulation configuration name",
            "required": true,
            "type": "string"
          },
          {
            "in": "body",
            "name": "body",
            "description": "Simulation object which is need to be updated",
            "required": true,
            "schema": {
              "type": "string",
              "example": {
                "properties": {
                  "simulationName": "TestSimulation",
                  "startTimestamp": 1500319950003,
                  "endTimestamp": 1500319950009,
                  "timeInterval": 1000,
                  "noOfEvents": 10,
                  "description": "This simulation is used to simulate events through FooStream"
                },
                "sources": [
                  {
                    "simulationType": "RANDOM_DATA_SIMULATION",
                    "streamName": "FooStream",
                    "siddhiAppName": "TestSiddhiApp",
                    "timeInterval": "1000",
                    "attributeConfiguration": [
                      {
                        "type": "PROPERTY_BASED",
                        "property": "ALTITUDE"
                      },
                      {
                        "type": "REGEX_BASED",
                        "pattern": "[0-9]*"
                      },
                      {
                        "type": "PRIMITIVE_BASED",
                        "min": "1500000",
                        "max": "30000000"
                      },
                      {
                        "type": "CUSTOM_DATA_BASED",
                        "list": [
                          "WSO2",
                          "AAA",
                          "DDD",
                          "IBM"
                        ]
                      }
                    ]
                  },
                  {
                    "simulationType": "DATABASE_SIMULATION",
                    "streamName": "FooStream",
                    "siddhiAppName": "TestSiddhiApp",
                    "dataSourceLocation": "jdbc:mysql://localhost:3306/DatabaseFeedSimulation",
                    "noOfEvents": 10,
                    "driver": "com.mysql.jdbc.Driver",
                    "username": "root",
                    "password": "password",
                    "tableName": "simulation_data_table",
                    "timestampAttribute": "timestamp_column_name",
                    "columnNamesList": "symbol,price,volume,timestamp_column_name"
                  },
                  {
                    "simulationType": "CSV_SIMULATION",
                    "streamName": "FooStream",
                    "siddhiAppName": "TestSiddhiApp",
                    "fileName": "foostream.csv",
                    "timestampAttribute": 1,
                    "isOrdered": false,
                    "delimiter": ",",
                    "indices": "0,1,2"
                  }
                ]
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully updated simulation configuration.",
            "schema": {
              "$ref": "#/definitions/ApiResponse"
            }
          },
          "404": {
            "description": "No event simulation configuration available under simulation name"
          }
        }
      },
      "get": {
        "tags": [
          "simulator"
        ],
        "summary": "Retrieve a simulation configuration by name.",
        "description": "Some desc",
        "operationId": "getFeedSimulation",
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "simulationName",
            "in": "path",
            "description": "Simulation name to get the configuration.",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully sent simulation configuration.",
            "schema": {
              "type": "string",
              "example": {
                "properties": {
                  "simulationName": "TestSimulation",
                  "startTimestamp": 1500319950003,
                  "endTimestamp": 1500319950009,
                  "timeInterval": 1000,
                  "noOfEvents": 10,
                  "description": "This simulation is used to simulate events through FooStream"
                },
                "sources": [
                  {
                    "simulationType": "RANDOM_DATA_SIMULATION",
                    "streamName": "FooStream",
                    "siddhiAppName": "TestSiddhiApp",
                    "timeInterval": "1000",
                    "attributeConfiguration": [
                      {
                        "type": "PROPERTY_BASED",
                        "property": "ALTITUDE"
                      },
                      {
                        "type": "REGEX_BASED",
                        "pattern": "[0-9]*"
                      },
                      {
                        "type": "PRIMITIVE_BASED",
                        "min": "1500000",
                        "max": "30000000"
                      },
                      {
                        "type": "CUSTOM_DATA_BASED",
                        "list": [
                          "WSO2",
                          "AAA",
                          "DDD",
                          "IBM"
                        ]
                      }
                    ]
                  },
                  {
                    "simulationType": "DATABASE_SIMULATION",
                    "streamName": "FooStream",
                    "siddhiAppName": "TestSiddhiApp",
                    "dataSourceLocation": "jdbc:mysql://localhost:3306/DatabaseFeedSimulation",
                    "noOfEvents": 10,
                    "driver": "com.mysql.jdbc.Driver",
                    "username": "root",
                    "password": "password",
                    "tableName": "simulation_data_table",
                    "timestampAttribute": "timestamp_column_name",
                    "columnNamesList": "symbol,price,volume,timestamp_column_name"
                  },
                  {
                    "simulationType": "CSV_SIMULATION",
                    "streamName": "FooStream",
                    "siddhiAppName": "TestSiddhiApp",
                    "fileName": "foostream.csv",
                    "timestampAttribute": 1,
                    "isOrdered": false,
                    "delimiter": ",",
                    "indices": "0,1,2"
                  }
                ]
              }
            }
          },
          "404": {
            "description": "No simulation configuration available under simulation name"
          }
        }
      },
      "delete": {
        "tags": [
          "simulator"
        ],
        "summary": "Delete a simulation configuration by name",
        "description": "For valid response try integer IDs with positive integer value.         Negative or non-integer values will generate API errors",
        "operationId": "deleteFeedSimulation",
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "simulationName",
            "in": "path",
            "description": "Simulation name to delete the configuration.",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully deleted simulation configuration"
          },
          "404": {
            "description": "No event simulation configuration available under simulation name"
          }
        }
      },
      "post": {
        "tags": [
          "simulator"
        ],
        "summary": "Operate a simulation configuration by name",
        "description": "some desc",
        "operationId": "operateFeedSimulation",
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "query",
            "name": "action",
            "description": "Action to be perform on the feed simulation eg: run, pause, resume, stop",
            "required": true,
            "type": "string"
          },
          {
            "name": "simulationName",
            "in": "path",
            "description": "Simulation name to execute the action on the configuration.",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully performed action on the feed simulation configuration"
          },
          "400": {
            "description": "Invalid action specified for simulation. Actions supported are run, pause, resume, stop."
          }
        }
      }
    },
    "/feed/{simulationName}/status": {
      "get": {
        "tags": [
          "simulator"
        ],
        "summary": "Retrieve a simulation configuration status by name.",
        "description": "Some desc",
        "operationId": "getFeedSimulationStatus",
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "simulationName",
            "in": "path",
            "description": "Simulation name to get the configuration.",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully sent simulation status.",
            "schema": {
              "type": "string",
              "example": {
                "status": "OK",
                "message": "RUN"
              }
            }
          },
          "404": {
            "description": "No simulation configuration available under simulation name"
          }
        }
      }
    },
    "/files": {
      "post": {
        "tags": [
          "simulator"
        ],
        "summary": "Upload CSV file to simulate event flow",
        "description": "",
        "operationId": "uploadFile",
        "consumes": [
          "multipart/form-data"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "file",
            "in": "formData",
            "description": "CSV File for simulation",
            "required": true,
            "type": "file"
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully uploaded file"
          },
          "404": {
            "description": "No event simulation configuration available under simulation name"
          }
        }
      },
      "get": {
        "tags": [
          "simulator"
        ],
        "summary": "Get CSV file names",
        "description": "",
        "operationId": "getFileNames",
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "Successfully retrieved file names",
            "schema": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "integer",
                  "format": "int32",
                  "example": "200"
                },
                "message": {
                  "type": "string",
                  "example": [
                    "FooStream.csv",
                    "BarStream.csv"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "No event simulation configuration available under simulation name"
          }
        }
      }
    },
    "/files/{fileName}": {
      "put": {
        "tags": [
          "simulator"
        ],
        "summary": "Update CSV file to simulate event flow",
        "description": "",
        "operationId": "updateFile",
        "consumes": [
          "multipart/form-data"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "fileName",
            "in": "path",
            "description": "CSV File for name to update",
            "required": true,
            "type": "string"
          },
          {
            "name": "file",
            "in": "formData",
            "description": "CSV File for simulation",
            "required": true,
            "type": "file"
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully updated the csv file"
          },
          "404": {
            "description": "No event simulation configuration available under simulation name"
          }
        }
      },
      "delete": {
        "tags": [
          "simulator"
        ],
        "summary": "Update CSV file to simulate event flow",
        "description": "",
        "operationId": "deleteFile",
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "fileName",
            "in": "path",
            "description": "CSV File for name to update",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully deleted the csv file"
          },
          "404": {
            "description": "No event simulation configuration available under simulation name"
          }
        }
      }
    },
    "/connectToDatabase": {
      "post": {
        "tags": [
          "simulator"
        ],
        "summary": "Test a database connection.",
        "description": "",
        "operationId": "testDBConnection",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "Database connection parameters to test the database connection",
            "required": true,
            "schema": {
              "$ref": "#/definitions/DBConnectionModel"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully connected to the database"
          },
          "400": {
            "description": "Database Connection has been failed"
          }
        }
      }
    },
    "/connectToDatabase/retrieveTableNames": {
      "post": {
        "tags": [
          "simulator"
        ],
        "summary": "Retreive database tables",
        "description": "",
        "operationId": "getDatabaseTables",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "Database connection parameters to get the database tables",
            "required": true,
            "schema": {
              "$ref": "#/definitions/DBConnectionModel"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully retrieved the database tables"
          },
          "400": {
            "description": "Database Connection has been failed"
          }
        }
      }
    },
    "/connectToDatabase/{tableName}/retrieveColumnNames": {
      "post": {
        "tags": [
          "simulator"
        ],
        "summary": "Retreive database table columns",
        "description": "",
        "operationId": "getDatabaseTableColumns",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "Database connection parameters to get the database tables",
            "required": true,
            "schema": {
              "$ref": "#/definitions/DBConnectionModel"
            }
          },
          {
            "name": "tableName",
            "in": "path",
            "description": "Table name to get the columns",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully retrieved the database tables"
          },
          "400": {
            "description": "Database Connection has been failed"
          }
        }
      }
    }
  },
  "definitions": {
    "DBConnectionModel": {
      "type": "object",
      "required": [
        "dataSourceLocation",
        "driver",
        "username",
        "password"
      ],
      "properties": {
        "dataSourceLocation": {
          "type": "string",
          "example": "jdbc:mysql://localhost:3306/DatabaseFeedSimulation"
        },
        "driver": {
          "type": "string",
          "example": "com.mysql.jdbc.Driver"
        },
        "username": {
          "type": "string",
          "example": "root"
        },
        "password": {
          "type": "string",
          "example": "password"
        }
      }
    },
    "FileNamesResponse": {
      "type": "object",
      "properties": {
        "code": {
          "type": "integer",
          "format": "int32",
          "example": "200"
        },
        "message": {
          "type": "string",
          "example": [
            "FooStream.csv",
            "BarStream.csv"
          ]
        }
      }
    },
    "ApiResponse": {
      "type": "object",
      "properties": {
        "code": {
          "type": "integer",
          "format": "int32"
        },
        "type": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      }
    }
  },
  "externalDocs": {
    "description": "Find out more about Simulation",
    "url": "https://docs.wso2.com/display/SP400/Simulating+Events"
  }
}