{
    "swagger": "2.0",
    "info": {
        "version": "1.0",
        "title": "Pandora REST API",
        "description": "REST API to facilitate the creation (and deletion) of database connections and the automatic loading of one or more tables from those connections."
    },
    "host": "localhost:7900",
    "basePath": "/object",
    "schemes": [
        "http"
    ],
    "consumes": [
        "application/json"
    ],
    "produces": [
        "application/json"
    ],
    "paths": {
        "/datasource": {
            "get": {
                "description": "Gets all connections Pandora is aware of.",
                "summary": "Get all connections",
                "operationId": "DatasourceGet",
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "name": "user",
                        "in": "query",
                        "required": true,
                        "type": "string",
                        "description": ""
                    },
                    {
                        "name": "pwd",
                        "in": "query",
                        "required": true,
                        "type": "string",
                        "description": ""
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "schema": {
                            "$ref": "#/definitions/ConnectionResponse"
                        }
                    },
                    "400": {
                        "description": "Bad request."
                    },
                    "401": {
                        "description": "Unauthorized"
                    },
                    "404": {
                        "description": "Not found"
                    }
                }
            }
        },
        "/datasource/{connectionName}": {
            "get": {
                "description": "Gets data for a single named connection. Note that even if a connection is stored in the Pandora repository, it does not necessarily mean that the connection is available, or is presenting tables.",
                "summary": "Get data for a single named connection",
                "operationId": "GetDatasourceNamedConnection",
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "name": "connectionName",
                        "in": "path",
                        "required": true,
                        "type": "string",
                        "description": "The name of the connection"
                    },
                    {
                        "name": "user",
                        "in": "query",
                        "required": true,
                        "type": "string",
                        "description": "Pandora username"
                    },
                    {
                        "name": "pwd",
                        "in": "query",
                        "required": true,
                        "type": "string",
                        "description": "Pandora password"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "schema": {
                            "$ref": "#/definitions/ConnectionResponse"
                        }
                    },
                    "400": {
                        "description": "Bad request."
                    },
                    "401": {
                        "description": "Unauthorized"
                    },
                    "404": {
                        "description": "Not found"
                    }
                }
            },
            "post": {
                "description": "Creates a new JDBC connection",
                "summary": "Create a connection",
                "operationId": "DatasourceNewConnectionPost",
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "name": "connectionName",
                        "in": "path",
                        "required": true,
                        "type": "string",
                        "description": "The name of the connection"
                    },
                    {
                        "name": "user",
                        "in": "query",
                        "required": true,
                        "type": "string",
                        "description": "Pandora username"
                    },
                    {
                        "name": "pwd",
                        "in": "query",
                        "required": true,
                        "type": "string",
                        "description": "Pandora password"
                    },
                    {
                        "name": "Body",
                        "in": "body",
                        "required": true,
                        "description": "The body of the request",
                        "schema": {
                            "$ref": "#/definitions/CreateConnectionRequest"
                        }
                    }
                ],
                "responses": {
                    "201": {
                        "description": "Created"
                    },
                    "400": {
                        "description": "Bad request."
                    },
                    "401": {
                        "description": "Unauthorized"
                    },
                    "404": {
                        "description": "Not found"
                    }
                }
            },
            "delete": {
                "description": "Deletes database connections",
                "summary": "Delete a connection",
                "operationId": "DatasourceForDeletionDelete",
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "name": "connectionName",
                        "in": "path",
                        "required": true,
                        "type": "string",
                        "description": "The name of the connection"
                    },
                    {
                        "name": "user",
                        "in": "query",
                        "required": true,
                        "type": "string",
                        "description": "Pandora username"
                    },
                    {
                        "name": "pwd",
                        "in": "query",
                        "required": true,
                        "type": "string",
                        "description": "Pandora password"
                    }
                ],
                "responses": {
                    "204": {
                        "description": "Success"
                    },
                    "400": {
                        "description": "Bad request."
                    },
                    "401": {
                        "description": "Unauthorized"
                    },
                    "404": {
                        "description": "Not found"
                    }
                }
            }
        },
        "/datasource/{connectionName}/list": {
            "get": {
                "description": "Gets a complete list of tables in the named connection.",
                "summary": "Get a list of tables in the named connection",
                "operationId": "GetDatasourceNamedConnectionTableList",
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "name": "connectionName",
                        "in": "path",
                        "required": true,
                        "type": "string",
                        "description": "The name of the connection"
                    },
                    {
                        "name": "user",
                        "in": "query",
                        "required": true,
                        "type": "string",
                        "description": "Pandora username"
                    },
                    {
                        "name": "pwd",
                        "in": "query",
                        "required": true,
                        "type": "string",
                        "description": "Pandora password"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "schema": {
                            "$ref": "#/definitions/ListTableResponse"
                        }
                    },
                    "400": {
                        "description": "Bad request."
                    },
                    "401": {
                        "description": "Unauthorized"
                    },
                    "404": {
                        "description": "Not found"
                    }
                }
            }
        },
        "/datasource/{connectionName}/load": {
            "post": {
                "description": "Loads a new table for the connection.",
                "summary": "Load a table for the connection",
                "operationId": "DatasourceNamedConnectionLoadPost",
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "name": "connectionName",
                        "in": "path",
                        "required": true,
                        "type": "string",
                        "description": "The name of the connection"
                    },
                    {
                        "name": "user",
                        "in": "query",
                        "required": true,
                        "type": "string",
                        "description": "Pandora username"
                    },
                    {
                        "name": "pwd",
                        "in": "query",
                        "required": true,
                        "type": "string",
                        "description": "Pandora password"
                    },
                    {
                        "name": "Body",
                        "in": "body",
                        "required": true,
                        "description": "",
                        "schema": {
                            "$ref": "#/definitions/LoadTablerequest"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success"
                    },
                    "400": {
                        "description": "Bad request."
                    },
                    "401": {
                        "description": "Unauthorized"
                    },
                    "404": {
                        "description": "Not found"
                    }
                }
            }
        }
    },
    "definitions": {
        "CreateConnectionRequest": {
            "type": "object",
            "properties": {
                "driver": {
                    "description": "Name of driver",
                    "example": "SQLServer",
                    "type": "string"
                },
                "hostname": {
                    "description": "The connection hostname",
                    "example": "localhost",
                    "type": "string"
                },
                "port": {
                    "description": "The connection port",
                    "example": 1433,
                    "type": "integer",
                    "format": "int32"
                },
                "database": {
                    "description": "The name of the database",
                    "example": "dbXYZ",
                    "type": "string"
                },
                "schema": {
                    "description": "The name of the database schema",
                    "example": "dbo",
                    "type": "string"
                },
                "username": {
                    "description": "The connection username",
                    "example": "username",
                    "type": "string"
                },
                "password": {
                    "description": "The connection password",
                    "example": "p@ssword",
                    "type": "string"
                },
                "instance": {
                    "description": "The connection instance name",
                    "example": ".",
                    "type": "string"
                }
            },
            "required": [
                "driver",
                "hostname",
                "port",
                "database",
                "schema",
                "username",
                "password",
                "instance"
            ]
        },
        "LoadTablerequest": {
            "title": "Load tableRequest",
            "type": "object",
            "properties": {
                "table": {
                    "description": "The name of the table",
                    "example": "tblRoot",
                    "type": "string"
                },
                "project": {
                    "description": "The name of the project",
                    "example": "MyProject",
                    "type": "string"
                }
            },
            "required": [
                "table",
                "project"
            ]
        },
        "ConnectionResponse": {
            "type": "object",
            "properties": {
                "datasource": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {}
                    }
                }
            }
        },
        "ListTableResponse": {
            "type": "object",
            "description": "An array of tables for the connection",
            "properties": {
                "Table" : {
                    "type": "array",
                    "items":{
                        "type": "string"
                    }
                }
            }
        }
    }
}