Improvements for swagger API documentation

- Adds Authorization token as required header param to all endpoints (except authenticate itself)
- Documents correct data format for request bodies (relevant for updating and adding elements)
- No functional changes applied
This commit is contained in:
Sonja Happ 2019-11-13 14:48:08 +01:00
parent 4f62b52d9f
commit a8a43f8512
19 changed files with 1534 additions and 186 deletions

View file

@ -1,6 +1,6 @@
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag at // This file was generated by swaggo/swag at
// 2019-09-16 09:02:12.199345062 +0200 CEST m=+0.112506596 // 2019-11-13 14:42:05.026935847 +0100 CET m=+0.107167406
package docs package docs
@ -16,7 +16,7 @@ var doc = `{
"schemes": {{ marshal .Schemes }}, "schemes": {{ marshal .Schemes }},
"swagger": "2.0", "swagger": "2.0",
"info": { "info": {
"description": "This is the API of the VILLASweb Backend\nWORK IN PROGRESS! PLEASE BE PATIENT!\nThe tool https://github.com/swaggo/swag is used to auto-generate API docs for gin.", "description": "This is the VILLASweb Backend API v2.0.\nParts of this API are still in development. Please check https://git.rwth-aachen.de/acs/public/villas/web-backend-go for more information.",
"title": "VILLASweb Backend API", "title": "VILLASweb Backend API",
"contact": { "contact": {
"name": "Sonja Happ", "name": "Sonja Happ",
@ -92,6 +92,13 @@ var doc = `{
"summary": "Get all dashboards of scenario", "summary": "Get all dashboards of scenario",
"operationId": "getDashboards", "operationId": "getDashboards",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Scenario ID", "description": "Scenario ID",
@ -144,6 +151,13 @@ var doc = `{
"summary": "Add a dashboard to a scenario", "summary": "Add a dashboard to a scenario",
"operationId": "addDashboard", "operationId": "addDashboard",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Dashboard to be added incl. ID of Scenario", "description": "Dashboard to be added incl. ID of Scenario",
"name": "inputDab", "name": "inputDab",
@ -151,7 +165,7 @@ var doc = `{
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/dashboard.validNewDashboard" "$ref": "#/definitions/dashboard.addDashboardRequest"
} }
} }
], ],
@ -205,6 +219,13 @@ var doc = `{
"summary": "Get a dashboard", "summary": "Get a dashboard",
"operationId": "getDashboard", "operationId": "getDashboard",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Dashboard ID", "description": "Dashboard ID",
@ -264,6 +285,13 @@ var doc = `{
"summary": "Update a dashboard", "summary": "Update a dashboard",
"operationId": "updateDashboard", "operationId": "updateDashboard",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Dashboard to be updated", "description": "Dashboard to be updated",
"name": "inputDab", "name": "inputDab",
@ -271,7 +299,7 @@ var doc = `{
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/dashboard.validUpdatedDashboard" "$ref": "#/definitions/dashboard.updateDashboardRequest"
} }
}, },
{ {
@ -330,6 +358,13 @@ var doc = `{
"summary": "Delete a dashboard", "summary": "Delete a dashboard",
"operationId": "deleteDashboard", "operationId": "deleteDashboard",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Dashboard ID", "description": "Dashboard ID",
@ -388,6 +423,13 @@ var doc = `{
"summary": "Get all files of a specific model or widget", "summary": "Get all files of a specific model or widget",
"operationId": "getFiles", "operationId": "getFiles",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Set to model for files of model, set to widget for files of widget", "description": "Set to model for files of model, set to widget for files of widget",
@ -452,6 +494,13 @@ var doc = `{
"summary": "Add a file to a specific model or widget", "summary": "Add a file to a specific model or widget",
"operationId": "addFile", "operationId": "addFile",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "file", "type": "file",
"description": "File to be uploaded", "description": "File to be uploaded",
@ -529,6 +578,13 @@ var doc = `{
"summary": "Download a file", "summary": "Download a file",
"operationId": "getFile", "operationId": "getFile",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "ID of the file to download", "description": "ID of the file to download",
@ -593,6 +649,13 @@ var doc = `{
"summary": "Update a file", "summary": "Update a file",
"operationId": "updateFile", "operationId": "updateFile",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "file", "type": "file",
"description": "File to be uploaded", "description": "File to be uploaded",
@ -656,6 +719,13 @@ var doc = `{
"summary": "Delete a file", "summary": "Delete a file",
"operationId": "deleteFile", "operationId": "deleteFile",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "ID of the file to update", "description": "ID of the file to update",
@ -703,6 +773,39 @@ var doc = `{
} }
} }
}, },
"/healthz": {
"get": {
"produces": [
"application/json"
],
"tags": [
"healthz"
],
"summary": "Get health status of backend",
"operationId": "getHealth",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "Backend is healthy, database and AMQP broker connections are alive"
},
"500": {
"description": "Backend is NOT healthy",
"schema": {
"type": "object",
"$ref": "#/definitions/docs.ResponseError"
}
}
}
}
},
"/models": { "/models": {
"get": { "get": {
"produces": [ "produces": [
@ -714,6 +817,13 @@ var doc = `{
"summary": "Get all simulation models of scenario", "summary": "Get all simulation models of scenario",
"operationId": "getSimulationModels", "operationId": "getSimulationModels",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Scenario ID", "description": "Scenario ID",
@ -766,6 +876,13 @@ var doc = `{
"summary": "Add a simulation model to a scenario", "summary": "Add a simulation model to a scenario",
"operationId": "addSimulationModel", "operationId": "addSimulationModel",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Simulation model to be added incl. IDs of scenario and simulator", "description": "Simulation model to be added incl. IDs of scenario and simulator",
"name": "inputSimulationModel", "name": "inputSimulationModel",
@ -773,7 +890,7 @@ var doc = `{
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/simulationmodel.validNewSimulationModel" "$ref": "#/definitions/simulationmodel.addSimulationModelRequest"
} }
} }
], ],
@ -827,6 +944,13 @@ var doc = `{
"summary": "Get a simulation model", "summary": "Get a simulation model",
"operationId": "getSimulationModel", "operationId": "getSimulationModel",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Model ID", "description": "Model ID",
@ -886,6 +1010,13 @@ var doc = `{
"summary": "Update a simulation model", "summary": "Update a simulation model",
"operationId": "updateSimulationModel", "operationId": "updateSimulationModel",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Simulation model to be updated", "description": "Simulation model to be updated",
"name": "inputSimulationModel", "name": "inputSimulationModel",
@ -893,7 +1024,7 @@ var doc = `{
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/simulationmodel.validUpdatedSimulationModel" "$ref": "#/definitions/simulationmodel.updateSimulationModelRequest"
} }
}, },
{ {
@ -952,6 +1083,13 @@ var doc = `{
"summary": "Delete a simulation model", "summary": "Delete a simulation model",
"operationId": "deleteSimulationModel", "operationId": "deleteSimulationModel",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Model ID", "description": "Model ID",
@ -1009,6 +1147,15 @@ var doc = `{
], ],
"summary": "Get all scenarios of requesting user", "summary": "Get all scenarios of requesting user",
"operationId": "getScenarios", "operationId": "getScenarios",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": { "responses": {
"200": { "200": {
"description": "Scenarios to which user has access", "description": "Scenarios to which user has access",
@ -1053,6 +1200,13 @@ var doc = `{
"summary": "Add a scenario", "summary": "Add a scenario",
"operationId": "addScenario", "operationId": "addScenario",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Scenario to be added", "description": "Scenario to be added",
"name": "inputScenario", "name": "inputScenario",
@ -1060,7 +1214,7 @@ var doc = `{
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/scenario.validNewScenario" "$ref": "#/definitions/scenario.addScenarioRequest"
} }
} }
], ],
@ -1114,6 +1268,13 @@ var doc = `{
"summary": "Get scenario", "summary": "Get scenario",
"operationId": "getScenario", "operationId": "getScenario",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Scenario ID", "description": "Scenario ID",
@ -1166,6 +1327,13 @@ var doc = `{
"summary": "Update a scenario", "summary": "Update a scenario",
"operationId": "updateScenario", "operationId": "updateScenario",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Scenario to be updated", "description": "Scenario to be updated",
"name": "inputScenario", "name": "inputScenario",
@ -1173,7 +1341,7 @@ var doc = `{
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/scenario.validUpdatedScenario" "$ref": "#/definitions/scenario.updateScenarioRequest"
} }
}, },
{ {
@ -1232,6 +1400,13 @@ var doc = `{
"summary": "Delete a scenario", "summary": "Delete a scenario",
"operationId": "deleteScenario", "operationId": "deleteScenario",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Scenario ID", "description": "Scenario ID",
@ -1283,6 +1458,13 @@ var doc = `{
"summary": "Add a user to a a scenario", "summary": "Add a user to a a scenario",
"operationId": "addUserToScenario", "operationId": "addUserToScenario",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Scenario ID", "description": "Scenario ID",
@ -1339,6 +1521,13 @@ var doc = `{
"summary": "Delete a user from a scenario", "summary": "Delete a user from a scenario",
"operationId": "deleteUserFromScenario", "operationId": "deleteUserFromScenario",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Scenario ID", "description": "Scenario ID",
@ -1397,6 +1586,13 @@ var doc = `{
"summary": "Get users of a scenario", "summary": "Get users of a scenario",
"operationId": "getUsersOfScenario", "operationId": "getUsersOfScenario",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Scenario ID", "description": "Scenario ID",
@ -1461,6 +1657,13 @@ var doc = `{
"name": "modelID", "name": "modelID",
"in": "query", "in": "query",
"required": true "required": true
},
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
} }
], ],
"responses": { "responses": {
@ -1507,6 +1710,13 @@ var doc = `{
"summary": "Add a signal to a signal mapping of a model", "summary": "Add a signal to a signal mapping of a model",
"operationId": "AddSignal", "operationId": "AddSignal",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "A signal to be added to the model incl. direction and model ID to which signal shall be added", "description": "A signal to be added to the model incl. direction and model ID to which signal shall be added",
"name": "inputSignal", "name": "inputSignal",
@ -1514,7 +1724,7 @@ var doc = `{
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/signal.validNewSignal" "$ref": "#/definitions/signal.addSignalRequest"
} }
} }
], ],
@ -1568,6 +1778,13 @@ var doc = `{
"summary": "Get a signal", "summary": "Get a signal",
"operationId": "getSignal", "operationId": "getSignal",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "ID of signal to be obtained", "description": "ID of signal to be obtained",
@ -1624,6 +1841,13 @@ var doc = `{
"summary": "Update a signal", "summary": "Update a signal",
"operationId": "updateSignal", "operationId": "updateSignal",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "A signal to be updated", "description": "A signal to be updated",
"name": "inputSignal", "name": "inputSignal",
@ -1631,7 +1855,7 @@ var doc = `{
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/signal.validUpdatedSignal" "$ref": "#/definitions/signal.updateSignalRequest"
} }
}, },
{ {
@ -1690,6 +1914,13 @@ var doc = `{
"summary": "Delete a signal", "summary": "Delete a signal",
"operationId": "deleteSignal", "operationId": "deleteSignal",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "ID of signal to be deleted", "description": "ID of signal to be deleted",
@ -1747,6 +1978,15 @@ var doc = `{
], ],
"summary": "Get all simulators", "summary": "Get all simulators",
"operationId": "getSimulators", "operationId": "getSimulators",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": { "responses": {
"200": { "200": {
"description": "Simulators requested", "description": "Simulators requested",
@ -1791,6 +2031,13 @@ var doc = `{
"summary": "Add a simulator", "summary": "Add a simulator",
"operationId": "addSimulator", "operationId": "addSimulator",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Simulator to be added", "description": "Simulator to be added",
"name": "inputSimulator", "name": "inputSimulator",
@ -1798,7 +2045,7 @@ var doc = `{
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/simulator.validNewSimulator" "$ref": "#/definitions/simulator.addSimulatorRequest"
} }
} }
], ],
@ -1852,6 +2099,13 @@ var doc = `{
"summary": "Get simulator", "summary": "Get simulator",
"operationId": "getSimulator", "operationId": "getSimulator",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Simulator ID", "description": "Simulator ID",
@ -1911,6 +2165,13 @@ var doc = `{
"summary": "Update a simulator", "summary": "Update a simulator",
"operationId": "updateSimulator", "operationId": "updateSimulator",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Simulator to be updated", "description": "Simulator to be updated",
"name": "inputSimulator", "name": "inputSimulator",
@ -1918,7 +2179,7 @@ var doc = `{
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/simulator.validUpdatedSimulator" "$ref": "#/definitions/simulator.updateSimulatorRequest"
} }
}, },
{ {
@ -1977,6 +2238,13 @@ var doc = `{
"summary": "Delete a simulator", "summary": "Delete a simulator",
"operationId": "deleteSimulator", "operationId": "deleteSimulator",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Simulator ID", "description": "Simulator ID",
@ -2100,6 +2368,13 @@ var doc = `{
"summary": "Get all simulation models in which the simulator is used", "summary": "Get all simulation models in which the simulator is used",
"operationId": "getModelsOfSimulator", "operationId": "getModelsOfSimulator",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Simulator ID", "description": "Simulator ID",
@ -2157,6 +2432,15 @@ var doc = `{
], ],
"summary": "Get all users", "summary": "Get all users",
"operationId": "GetUsers", "operationId": "GetUsers",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": { "responses": {
"200": { "200": {
"description": "Array of users", "description": "Array of users",
@ -2208,8 +2492,15 @@ var doc = `{
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/user.validNewUser" "$ref": "#/definitions/user.addUserRequest"
} }
},
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
} }
], ],
"responses": { "responses": {
@ -2255,6 +2546,13 @@ var doc = `{
"summary": "Get user", "summary": "Get user",
"operationId": "GetUser", "operationId": "GetUser",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "User ID", "description": "User ID",
@ -2314,6 +2612,13 @@ var doc = `{
"summary": "Update a user", "summary": "Update a user",
"operationId": "UpdateUser", "operationId": "UpdateUser",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "User to be updated (anything except for ID can be changed, role can only be change by admin)", "description": "User to be updated (anything except for ID can be changed, role can only be change by admin)",
"name": "inputUser", "name": "inputUser",
@ -2321,7 +2626,7 @@ var doc = `{
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/user.validUpdatedRequest" "$ref": "#/definitions/user.updateUserRequest"
} }
}, },
{ {
@ -2387,6 +2692,13 @@ var doc = `{
"summary": "Delete a user", "summary": "Delete a user",
"operationId": "DeleteUser", "operationId": "DeleteUser",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "User ID", "description": "User ID",
@ -2438,6 +2750,13 @@ var doc = `{
"summary": "Get all widgets of dashboard", "summary": "Get all widgets of dashboard",
"operationId": "getWidgets", "operationId": "getWidgets",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Dashboard ID", "description": "Dashboard ID",
@ -2490,6 +2809,13 @@ var doc = `{
"summary": "Add a widget to a dashboard", "summary": "Add a widget to a dashboard",
"operationId": "addWidget", "operationId": "addWidget",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Widget to be added incl. ID of dashboard", "description": "Widget to be added incl. ID of dashboard",
"name": "inputWidget", "name": "inputWidget",
@ -2497,7 +2823,7 @@ var doc = `{
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/widget.validNewWidget" "$ref": "#/definitions/widget.addWidgetRequest"
} }
} }
], ],
@ -2551,6 +2877,13 @@ var doc = `{
"summary": "Get a widget", "summary": "Get a widget",
"operationId": "getWidget", "operationId": "getWidget",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Widget ID", "description": "Widget ID",
@ -2610,6 +2943,13 @@ var doc = `{
"summary": "Update a widget", "summary": "Update a widget",
"operationId": "updateWidget", "operationId": "updateWidget",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Widget to be updated", "description": "Widget to be updated",
"name": "inputWidget", "name": "inputWidget",
@ -2617,7 +2957,7 @@ var doc = `{
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/widget.validUpdatedWidget" "$ref": "#/definitions/widget.updateWidgetRequest"
} }
}, },
{ {
@ -2676,6 +3016,13 @@ var doc = `{
"summary": "Delete a widget", "summary": "Delete a widget",
"operationId": "deleteWidget", "operationId": "deleteWidget",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Widget ID", "description": "Widget ID",
@ -2725,6 +3072,24 @@ var doc = `{
} }
}, },
"definitions": { "definitions": {
"dashboard.addDashboardRequest": {
"type": "object",
"properties": {
"dashboard": {
"type": "object",
"$ref": "#/definitions/dashboard.validNewDashboard"
}
}
},
"dashboard.updateDashboardRequest": {
"type": "object",
"properties": {
"dashboard": {
"type": "object",
"$ref": "#/definitions/dashboard.validUpdatedDashboard"
}
}
},
"dashboard.validNewDashboard": { "dashboard.validNewDashboard": {
"type": "object", "type": "object",
"required": [ "required": [
@ -2747,10 +3112,10 @@ var doc = `{
"dashboard.validUpdatedDashboard": { "dashboard.validUpdatedDashboard": {
"type": "object", "type": "object",
"properties": { "properties": {
"Grid": { "grid": {
"type": "integer" "type": "integer"
}, },
"Name": { "name": {
"type": "string" "type": "string"
} }
} }
@ -2938,6 +3303,10 @@ var doc = `{
"database.User": { "database.User": {
"type": "object", "type": "object",
"properties": { "properties": {
"active": {
"description": "Indicating status of user (false means user is inactive and should not be able to login)",
"type": "boolean"
},
"id": { "id": {
"type": "integer" "type": "integer"
}, },
@ -3200,6 +3569,24 @@ var doc = `{
} }
} }
}, },
"scenario.addScenarioRequest": {
"type": "object",
"properties": {
"scenario": {
"type": "object",
"$ref": "#/definitions/scenario.validNewScenario"
}
}
},
"scenario.updateScenarioRequest": {
"type": "object",
"properties": {
"scenario": {
"type": "object",
"$ref": "#/definitions/scenario.validUpdatedScenario"
}
}
},
"scenario.validNewScenario": { "scenario.validNewScenario": {
"type": "object", "type": "object",
"required": [ "required": [
@ -3232,6 +3619,24 @@ var doc = `{
} }
} }
}, },
"signal.addSignalRequest": {
"type": "object",
"properties": {
"signal": {
"type": "object",
"$ref": "#/definitions/signal.validNewSignal"
}
}
},
"signal.updateSignalRequest": {
"type": "object",
"properties": {
"signal": {
"type": "object",
"$ref": "#/definitions/signal.validUpdatedSignal"
}
}
},
"signal.validNewSignal": { "signal.validNewSignal": {
"type": "object", "type": "object",
"required": [ "required": [
@ -3272,6 +3677,24 @@ var doc = `{
} }
} }
}, },
"simulationmodel.addSimulationModelRequest": {
"type": "object",
"properties": {
"model": {
"type": "object",
"$ref": "#/definitions/simulationmodel.validNewSimulationModel"
}
}
},
"simulationmodel.updateSimulationModelRequest": {
"type": "object",
"properties": {
"model": {
"type": "object",
"$ref": "#/definitions/simulationmodel.validUpdatedSimulationModel"
}
}
},
"simulationmodel.validNewSimulationModel": { "simulationmodel.validNewSimulationModel": {
"type": "object", "type": "object",
"required": [ "required": [
@ -3309,6 +3732,24 @@ var doc = `{
} }
} }
}, },
"simulator.addSimulatorRequest": {
"type": "object",
"properties": {
"simulator": {
"type": "object",
"$ref": "#/definitions/simulator.validNewSimulator"
}
}
},
"simulator.updateSimulatorRequest": {
"type": "object",
"properties": {
"simulator": {
"type": "object",
"$ref": "#/definitions/simulator.validUpdatedSimulator"
}
}
},
"simulator.validNewSimulator": { "simulator.validNewSimulator": {
"type": "object", "type": "object",
"required": [ "required": [
@ -3355,6 +3796,15 @@ var doc = `{
} }
} }
}, },
"user.addUserRequest": {
"type": "object",
"properties": {
"user": {
"type": "object",
"$ref": "#/definitions/user.validNewUser"
}
}
},
"user.loginRequest": { "user.loginRequest": {
"type": "object", "type": "object",
"required": [ "required": [
@ -3370,6 +3820,15 @@ var doc = `{
} }
} }
}, },
"user.updateUserRequest": {
"type": "object",
"properties": {
"user": {
"type": "object",
"$ref": "#/definitions/user.validUpdatedRequest"
}
}
},
"user.validNewUser": { "user.validNewUser": {
"type": "object", "type": "object",
"required": [ "required": [
@ -3396,9 +3855,15 @@ var doc = `{
"user.validUpdatedRequest": { "user.validUpdatedRequest": {
"type": "object", "type": "object",
"properties": { "properties": {
"Active": {
"type": "string"
},
"Mail": { "Mail": {
"type": "string" "type": "string"
}, },
"OldPassword": {
"type": "string"
},
"Password": { "Password": {
"type": "string" "type": "string"
}, },
@ -3410,6 +3875,24 @@ var doc = `{
} }
} }
}, },
"widget.addWidgetRequest": {
"type": "object",
"properties": {
"widget": {
"type": "object",
"$ref": "#/definitions/widget.validNewWidget"
}
}
},
"widget.updateWidgetRequest": {
"type": "object",
"properties": {
"widget": {
"type": "object",
"$ref": "#/definitions/widget.validUpdatedWidget"
}
}
},
"widget.validNewWidget": { "widget.validNewWidget": {
"type": "object", "type": "object",
"required": [ "required": [

View file

@ -1,7 +1,7 @@
{ {
"swagger": "2.0", "swagger": "2.0",
"info": { "info": {
"description": "This is the API of the VILLASweb Backend\nWORK IN PROGRESS! PLEASE BE PATIENT!\nThe tool https://github.com/swaggo/swag is used to auto-generate API docs for gin.", "description": "This is the VILLASweb Backend API v2.0.\nParts of this API are still in development. Please check https://git.rwth-aachen.de/acs/public/villas/web-backend-go for more information.",
"title": "VILLASweb Backend API", "title": "VILLASweb Backend API",
"contact": { "contact": {
"name": "Sonja Happ", "name": "Sonja Happ",
@ -77,6 +77,13 @@
"summary": "Get all dashboards of scenario", "summary": "Get all dashboards of scenario",
"operationId": "getDashboards", "operationId": "getDashboards",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Scenario ID", "description": "Scenario ID",
@ -129,6 +136,13 @@
"summary": "Add a dashboard to a scenario", "summary": "Add a dashboard to a scenario",
"operationId": "addDashboard", "operationId": "addDashboard",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Dashboard to be added incl. ID of Scenario", "description": "Dashboard to be added incl. ID of Scenario",
"name": "inputDab", "name": "inputDab",
@ -136,7 +150,7 @@
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/dashboard.validNewDashboard" "$ref": "#/definitions/dashboard.addDashboardRequest"
} }
} }
], ],
@ -190,6 +204,13 @@
"summary": "Get a dashboard", "summary": "Get a dashboard",
"operationId": "getDashboard", "operationId": "getDashboard",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Dashboard ID", "description": "Dashboard ID",
@ -249,6 +270,13 @@
"summary": "Update a dashboard", "summary": "Update a dashboard",
"operationId": "updateDashboard", "operationId": "updateDashboard",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Dashboard to be updated", "description": "Dashboard to be updated",
"name": "inputDab", "name": "inputDab",
@ -256,7 +284,7 @@
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/dashboard.validUpdatedDashboard" "$ref": "#/definitions/dashboard.updateDashboardRequest"
} }
}, },
{ {
@ -315,6 +343,13 @@
"summary": "Delete a dashboard", "summary": "Delete a dashboard",
"operationId": "deleteDashboard", "operationId": "deleteDashboard",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Dashboard ID", "description": "Dashboard ID",
@ -373,6 +408,13 @@
"summary": "Get all files of a specific model or widget", "summary": "Get all files of a specific model or widget",
"operationId": "getFiles", "operationId": "getFiles",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "string", "type": "string",
"description": "Set to model for files of model, set to widget for files of widget", "description": "Set to model for files of model, set to widget for files of widget",
@ -437,6 +479,13 @@
"summary": "Add a file to a specific model or widget", "summary": "Add a file to a specific model or widget",
"operationId": "addFile", "operationId": "addFile",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "file", "type": "file",
"description": "File to be uploaded", "description": "File to be uploaded",
@ -514,6 +563,13 @@
"summary": "Download a file", "summary": "Download a file",
"operationId": "getFile", "operationId": "getFile",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "ID of the file to download", "description": "ID of the file to download",
@ -578,6 +634,13 @@
"summary": "Update a file", "summary": "Update a file",
"operationId": "updateFile", "operationId": "updateFile",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "file", "type": "file",
"description": "File to be uploaded", "description": "File to be uploaded",
@ -641,6 +704,13 @@
"summary": "Delete a file", "summary": "Delete a file",
"operationId": "deleteFile", "operationId": "deleteFile",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "ID of the file to update", "description": "ID of the file to update",
@ -688,6 +758,39 @@
} }
} }
}, },
"/healthz": {
"get": {
"produces": [
"application/json"
],
"tags": [
"healthz"
],
"summary": "Get health status of backend",
"operationId": "getHealth",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "Backend is healthy, database and AMQP broker connections are alive"
},
"500": {
"description": "Backend is NOT healthy",
"schema": {
"type": "object",
"$ref": "#/definitions/docs.ResponseError"
}
}
}
}
},
"/models": { "/models": {
"get": { "get": {
"produces": [ "produces": [
@ -699,6 +802,13 @@
"summary": "Get all simulation models of scenario", "summary": "Get all simulation models of scenario",
"operationId": "getSimulationModels", "operationId": "getSimulationModels",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Scenario ID", "description": "Scenario ID",
@ -751,6 +861,13 @@
"summary": "Add a simulation model to a scenario", "summary": "Add a simulation model to a scenario",
"operationId": "addSimulationModel", "operationId": "addSimulationModel",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Simulation model to be added incl. IDs of scenario and simulator", "description": "Simulation model to be added incl. IDs of scenario and simulator",
"name": "inputSimulationModel", "name": "inputSimulationModel",
@ -758,7 +875,7 @@
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/simulationmodel.validNewSimulationModel" "$ref": "#/definitions/simulationmodel.addSimulationModelRequest"
} }
} }
], ],
@ -812,6 +929,13 @@
"summary": "Get a simulation model", "summary": "Get a simulation model",
"operationId": "getSimulationModel", "operationId": "getSimulationModel",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Model ID", "description": "Model ID",
@ -871,6 +995,13 @@
"summary": "Update a simulation model", "summary": "Update a simulation model",
"operationId": "updateSimulationModel", "operationId": "updateSimulationModel",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Simulation model to be updated", "description": "Simulation model to be updated",
"name": "inputSimulationModel", "name": "inputSimulationModel",
@ -878,7 +1009,7 @@
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/simulationmodel.validUpdatedSimulationModel" "$ref": "#/definitions/simulationmodel.updateSimulationModelRequest"
} }
}, },
{ {
@ -937,6 +1068,13 @@
"summary": "Delete a simulation model", "summary": "Delete a simulation model",
"operationId": "deleteSimulationModel", "operationId": "deleteSimulationModel",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Model ID", "description": "Model ID",
@ -994,6 +1132,15 @@
], ],
"summary": "Get all scenarios of requesting user", "summary": "Get all scenarios of requesting user",
"operationId": "getScenarios", "operationId": "getScenarios",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": { "responses": {
"200": { "200": {
"description": "Scenarios to which user has access", "description": "Scenarios to which user has access",
@ -1038,6 +1185,13 @@
"summary": "Add a scenario", "summary": "Add a scenario",
"operationId": "addScenario", "operationId": "addScenario",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Scenario to be added", "description": "Scenario to be added",
"name": "inputScenario", "name": "inputScenario",
@ -1045,7 +1199,7 @@
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/scenario.validNewScenario" "$ref": "#/definitions/scenario.addScenarioRequest"
} }
} }
], ],
@ -1099,6 +1253,13 @@
"summary": "Get scenario", "summary": "Get scenario",
"operationId": "getScenario", "operationId": "getScenario",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Scenario ID", "description": "Scenario ID",
@ -1151,6 +1312,13 @@
"summary": "Update a scenario", "summary": "Update a scenario",
"operationId": "updateScenario", "operationId": "updateScenario",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Scenario to be updated", "description": "Scenario to be updated",
"name": "inputScenario", "name": "inputScenario",
@ -1158,7 +1326,7 @@
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/scenario.validUpdatedScenario" "$ref": "#/definitions/scenario.updateScenarioRequest"
} }
}, },
{ {
@ -1217,6 +1385,13 @@
"summary": "Delete a scenario", "summary": "Delete a scenario",
"operationId": "deleteScenario", "operationId": "deleteScenario",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Scenario ID", "description": "Scenario ID",
@ -1268,6 +1443,13 @@
"summary": "Add a user to a a scenario", "summary": "Add a user to a a scenario",
"operationId": "addUserToScenario", "operationId": "addUserToScenario",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Scenario ID", "description": "Scenario ID",
@ -1324,6 +1506,13 @@
"summary": "Delete a user from a scenario", "summary": "Delete a user from a scenario",
"operationId": "deleteUserFromScenario", "operationId": "deleteUserFromScenario",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Scenario ID", "description": "Scenario ID",
@ -1382,6 +1571,13 @@
"summary": "Get users of a scenario", "summary": "Get users of a scenario",
"operationId": "getUsersOfScenario", "operationId": "getUsersOfScenario",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Scenario ID", "description": "Scenario ID",
@ -1446,6 +1642,13 @@
"name": "modelID", "name": "modelID",
"in": "query", "in": "query",
"required": true "required": true
},
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
} }
], ],
"responses": { "responses": {
@ -1492,6 +1695,13 @@
"summary": "Add a signal to a signal mapping of a model", "summary": "Add a signal to a signal mapping of a model",
"operationId": "AddSignal", "operationId": "AddSignal",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "A signal to be added to the model incl. direction and model ID to which signal shall be added", "description": "A signal to be added to the model incl. direction and model ID to which signal shall be added",
"name": "inputSignal", "name": "inputSignal",
@ -1499,7 +1709,7 @@
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/signal.validNewSignal" "$ref": "#/definitions/signal.addSignalRequest"
} }
} }
], ],
@ -1553,6 +1763,13 @@
"summary": "Get a signal", "summary": "Get a signal",
"operationId": "getSignal", "operationId": "getSignal",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "ID of signal to be obtained", "description": "ID of signal to be obtained",
@ -1609,6 +1826,13 @@
"summary": "Update a signal", "summary": "Update a signal",
"operationId": "updateSignal", "operationId": "updateSignal",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "A signal to be updated", "description": "A signal to be updated",
"name": "inputSignal", "name": "inputSignal",
@ -1616,7 +1840,7 @@
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/signal.validUpdatedSignal" "$ref": "#/definitions/signal.updateSignalRequest"
} }
}, },
{ {
@ -1675,6 +1899,13 @@
"summary": "Delete a signal", "summary": "Delete a signal",
"operationId": "deleteSignal", "operationId": "deleteSignal",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "ID of signal to be deleted", "description": "ID of signal to be deleted",
@ -1732,6 +1963,15 @@
], ],
"summary": "Get all simulators", "summary": "Get all simulators",
"operationId": "getSimulators", "operationId": "getSimulators",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": { "responses": {
"200": { "200": {
"description": "Simulators requested", "description": "Simulators requested",
@ -1776,6 +2016,13 @@
"summary": "Add a simulator", "summary": "Add a simulator",
"operationId": "addSimulator", "operationId": "addSimulator",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Simulator to be added", "description": "Simulator to be added",
"name": "inputSimulator", "name": "inputSimulator",
@ -1783,7 +2030,7 @@
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/simulator.validNewSimulator" "$ref": "#/definitions/simulator.addSimulatorRequest"
} }
} }
], ],
@ -1837,6 +2084,13 @@
"summary": "Get simulator", "summary": "Get simulator",
"operationId": "getSimulator", "operationId": "getSimulator",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Simulator ID", "description": "Simulator ID",
@ -1896,6 +2150,13 @@
"summary": "Update a simulator", "summary": "Update a simulator",
"operationId": "updateSimulator", "operationId": "updateSimulator",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Simulator to be updated", "description": "Simulator to be updated",
"name": "inputSimulator", "name": "inputSimulator",
@ -1903,7 +2164,7 @@
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/simulator.validUpdatedSimulator" "$ref": "#/definitions/simulator.updateSimulatorRequest"
} }
}, },
{ {
@ -1962,6 +2223,13 @@
"summary": "Delete a simulator", "summary": "Delete a simulator",
"operationId": "deleteSimulator", "operationId": "deleteSimulator",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Simulator ID", "description": "Simulator ID",
@ -2085,6 +2353,13 @@
"summary": "Get all simulation models in which the simulator is used", "summary": "Get all simulation models in which the simulator is used",
"operationId": "getModelsOfSimulator", "operationId": "getModelsOfSimulator",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Simulator ID", "description": "Simulator ID",
@ -2142,6 +2417,15 @@
], ],
"summary": "Get all users", "summary": "Get all users",
"operationId": "GetUsers", "operationId": "GetUsers",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": { "responses": {
"200": { "200": {
"description": "Array of users", "description": "Array of users",
@ -2193,8 +2477,15 @@
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/user.validNewUser" "$ref": "#/definitions/user.addUserRequest"
} }
},
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
} }
], ],
"responses": { "responses": {
@ -2240,6 +2531,13 @@
"summary": "Get user", "summary": "Get user",
"operationId": "GetUser", "operationId": "GetUser",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "User ID", "description": "User ID",
@ -2299,6 +2597,13 @@
"summary": "Update a user", "summary": "Update a user",
"operationId": "UpdateUser", "operationId": "UpdateUser",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "User to be updated (anything except for ID can be changed, role can only be change by admin)", "description": "User to be updated (anything except for ID can be changed, role can only be change by admin)",
"name": "inputUser", "name": "inputUser",
@ -2306,7 +2611,7 @@
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/user.validUpdatedRequest" "$ref": "#/definitions/user.updateUserRequest"
} }
}, },
{ {
@ -2372,6 +2677,13 @@
"summary": "Delete a user", "summary": "Delete a user",
"operationId": "DeleteUser", "operationId": "DeleteUser",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "User ID", "description": "User ID",
@ -2423,6 +2735,13 @@
"summary": "Get all widgets of dashboard", "summary": "Get all widgets of dashboard",
"operationId": "getWidgets", "operationId": "getWidgets",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Dashboard ID", "description": "Dashboard ID",
@ -2475,6 +2794,13 @@
"summary": "Add a widget to a dashboard", "summary": "Add a widget to a dashboard",
"operationId": "addWidget", "operationId": "addWidget",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Widget to be added incl. ID of dashboard", "description": "Widget to be added incl. ID of dashboard",
"name": "inputWidget", "name": "inputWidget",
@ -2482,7 +2808,7 @@
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/widget.validNewWidget" "$ref": "#/definitions/widget.addWidgetRequest"
} }
} }
], ],
@ -2536,6 +2862,13 @@
"summary": "Get a widget", "summary": "Get a widget",
"operationId": "getWidget", "operationId": "getWidget",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Widget ID", "description": "Widget ID",
@ -2595,6 +2928,13 @@
"summary": "Update a widget", "summary": "Update a widget",
"operationId": "updateWidget", "operationId": "updateWidget",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"description": "Widget to be updated", "description": "Widget to be updated",
"name": "inputWidget", "name": "inputWidget",
@ -2602,7 +2942,7 @@
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/widget.validUpdatedWidget" "$ref": "#/definitions/widget.updateWidgetRequest"
} }
}, },
{ {
@ -2661,6 +3001,13 @@
"summary": "Delete a widget", "summary": "Delete a widget",
"operationId": "deleteWidget", "operationId": "deleteWidget",
"parameters": [ "parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{ {
"type": "integer", "type": "integer",
"description": "Widget ID", "description": "Widget ID",
@ -2710,6 +3057,24 @@
} }
}, },
"definitions": { "definitions": {
"dashboard.addDashboardRequest": {
"type": "object",
"properties": {
"dashboard": {
"type": "object",
"$ref": "#/definitions/dashboard.validNewDashboard"
}
}
},
"dashboard.updateDashboardRequest": {
"type": "object",
"properties": {
"dashboard": {
"type": "object",
"$ref": "#/definitions/dashboard.validUpdatedDashboard"
}
}
},
"dashboard.validNewDashboard": { "dashboard.validNewDashboard": {
"type": "object", "type": "object",
"required": [ "required": [
@ -2732,10 +3097,10 @@
"dashboard.validUpdatedDashboard": { "dashboard.validUpdatedDashboard": {
"type": "object", "type": "object",
"properties": { "properties": {
"Grid": { "grid": {
"type": "integer" "type": "integer"
}, },
"Name": { "name": {
"type": "string" "type": "string"
} }
} }
@ -2923,6 +3288,10 @@
"database.User": { "database.User": {
"type": "object", "type": "object",
"properties": { "properties": {
"active": {
"description": "Indicating status of user (false means user is inactive and should not be able to login)",
"type": "boolean"
},
"id": { "id": {
"type": "integer" "type": "integer"
}, },
@ -3185,6 +3554,24 @@
} }
} }
}, },
"scenario.addScenarioRequest": {
"type": "object",
"properties": {
"scenario": {
"type": "object",
"$ref": "#/definitions/scenario.validNewScenario"
}
}
},
"scenario.updateScenarioRequest": {
"type": "object",
"properties": {
"scenario": {
"type": "object",
"$ref": "#/definitions/scenario.validUpdatedScenario"
}
}
},
"scenario.validNewScenario": { "scenario.validNewScenario": {
"type": "object", "type": "object",
"required": [ "required": [
@ -3217,6 +3604,24 @@
} }
} }
}, },
"signal.addSignalRequest": {
"type": "object",
"properties": {
"signal": {
"type": "object",
"$ref": "#/definitions/signal.validNewSignal"
}
}
},
"signal.updateSignalRequest": {
"type": "object",
"properties": {
"signal": {
"type": "object",
"$ref": "#/definitions/signal.validUpdatedSignal"
}
}
},
"signal.validNewSignal": { "signal.validNewSignal": {
"type": "object", "type": "object",
"required": [ "required": [
@ -3257,6 +3662,24 @@
} }
} }
}, },
"simulationmodel.addSimulationModelRequest": {
"type": "object",
"properties": {
"model": {
"type": "object",
"$ref": "#/definitions/simulationmodel.validNewSimulationModel"
}
}
},
"simulationmodel.updateSimulationModelRequest": {
"type": "object",
"properties": {
"model": {
"type": "object",
"$ref": "#/definitions/simulationmodel.validUpdatedSimulationModel"
}
}
},
"simulationmodel.validNewSimulationModel": { "simulationmodel.validNewSimulationModel": {
"type": "object", "type": "object",
"required": [ "required": [
@ -3294,6 +3717,24 @@
} }
} }
}, },
"simulator.addSimulatorRequest": {
"type": "object",
"properties": {
"simulator": {
"type": "object",
"$ref": "#/definitions/simulator.validNewSimulator"
}
}
},
"simulator.updateSimulatorRequest": {
"type": "object",
"properties": {
"simulator": {
"type": "object",
"$ref": "#/definitions/simulator.validUpdatedSimulator"
}
}
},
"simulator.validNewSimulator": { "simulator.validNewSimulator": {
"type": "object", "type": "object",
"required": [ "required": [
@ -3340,6 +3781,15 @@
} }
} }
}, },
"user.addUserRequest": {
"type": "object",
"properties": {
"user": {
"type": "object",
"$ref": "#/definitions/user.validNewUser"
}
}
},
"user.loginRequest": { "user.loginRequest": {
"type": "object", "type": "object",
"required": [ "required": [
@ -3355,6 +3805,15 @@
} }
} }
}, },
"user.updateUserRequest": {
"type": "object",
"properties": {
"user": {
"type": "object",
"$ref": "#/definitions/user.validUpdatedRequest"
}
}
},
"user.validNewUser": { "user.validNewUser": {
"type": "object", "type": "object",
"required": [ "required": [
@ -3381,9 +3840,15 @@
"user.validUpdatedRequest": { "user.validUpdatedRequest": {
"type": "object", "type": "object",
"properties": { "properties": {
"Active": {
"type": "string"
},
"Mail": { "Mail": {
"type": "string" "type": "string"
}, },
"OldPassword": {
"type": "string"
},
"Password": { "Password": {
"type": "string" "type": "string"
}, },
@ -3395,6 +3860,24 @@
} }
} }
}, },
"widget.addWidgetRequest": {
"type": "object",
"properties": {
"widget": {
"type": "object",
"$ref": "#/definitions/widget.validNewWidget"
}
}
},
"widget.updateWidgetRequest": {
"type": "object",
"properties": {
"widget": {
"type": "object",
"$ref": "#/definitions/widget.validUpdatedWidget"
}
}
},
"widget.validNewWidget": { "widget.validNewWidget": {
"type": "object", "type": "object",
"required": [ "required": [

View file

@ -1,5 +1,17 @@
basePath: /api/v2 basePath: /api/v2
definitions: definitions:
dashboard.addDashboardRequest:
properties:
dashboard:
$ref: '#/definitions/dashboard.validNewDashboard'
type: object
type: object
dashboard.updateDashboardRequest:
properties:
dashboard:
$ref: '#/definitions/dashboard.validUpdatedDashboard'
type: object
type: object
dashboard.validNewDashboard: dashboard.validNewDashboard:
properties: properties:
Grid: Grid:
@ -15,9 +27,9 @@ definitions:
type: object type: object
dashboard.validUpdatedDashboard: dashboard.validUpdatedDashboard:
properties: properties:
Grid: grid:
type: integer type: integer
Name: name:
type: string type: string
type: object type: object
database.Dashboard: database.Dashboard:
@ -151,6 +163,10 @@ definitions:
type: object type: object
database.User: database.User:
properties: properties:
active:
description: Indicating status of user (false means user is inactive and should
not be able to login)
type: boolean
id: id:
type: integer type: integer
mail: mail:
@ -327,6 +343,18 @@ definitions:
$ref: '#/definitions/database.Widget' $ref: '#/definitions/database.Widget'
type: array type: array
type: object type: object
scenario.addScenarioRequest:
properties:
scenario:
$ref: '#/definitions/scenario.validNewScenario'
type: object
type: object
scenario.updateScenarioRequest:
properties:
scenario:
$ref: '#/definitions/scenario.validUpdatedScenario'
type: object
type: object
scenario.validNewScenario: scenario.validNewScenario:
properties: properties:
Name: Name:
@ -348,6 +376,18 @@ definitions:
StartParameters: StartParameters:
type: string type: string
type: object type: object
signal.addSignalRequest:
properties:
signal:
$ref: '#/definitions/signal.validNewSignal'
type: object
type: object
signal.updateSignalRequest:
properties:
signal:
$ref: '#/definitions/signal.validUpdatedSignal'
type: object
type: object
signal.validNewSignal: signal.validNewSignal:
properties: properties:
Direction: Direction:
@ -375,6 +415,18 @@ definitions:
Unit: Unit:
type: string type: string
type: object type: object
simulationmodel.addSimulationModelRequest:
properties:
model:
$ref: '#/definitions/simulationmodel.validNewSimulationModel'
type: object
type: object
simulationmodel.updateSimulationModelRequest:
properties:
model:
$ref: '#/definitions/simulationmodel.validUpdatedSimulationModel'
type: object
type: object
simulationmodel.validNewSimulationModel: simulationmodel.validNewSimulationModel:
properties: properties:
Name: Name:
@ -400,6 +452,18 @@ definitions:
StartParameters: StartParameters:
type: string type: string
type: object type: object
simulator.addSimulatorRequest:
properties:
simulator:
$ref: '#/definitions/simulator.validNewSimulator'
type: object
type: object
simulator.updateSimulatorRequest:
properties:
simulator:
$ref: '#/definitions/simulator.validUpdatedSimulator'
type: object
type: object
simulator.validNewSimulator: simulator.validNewSimulator:
properties: properties:
Host: Host:
@ -431,6 +495,12 @@ definitions:
UUID: UUID:
type: string type: string
type: object type: object
user.addUserRequest:
properties:
user:
$ref: '#/definitions/user.validNewUser'
type: object
type: object
user.loginRequest: user.loginRequest:
properties: properties:
Password: Password:
@ -441,6 +511,12 @@ definitions:
- Password - Password
- Username - Username
type: object type: object
user.updateUserRequest:
properties:
user:
$ref: '#/definitions/user.validUpdatedRequest'
type: object
type: object
user.validNewUser: user.validNewUser:
properties: properties:
Mail: Mail:
@ -459,8 +535,12 @@ definitions:
type: object type: object
user.validUpdatedRequest: user.validUpdatedRequest:
properties: properties:
Active:
type: string
Mail: Mail:
type: string type: string
OldPassword:
type: string
Password: Password:
type: string type: string
Role: Role:
@ -468,6 +548,18 @@ definitions:
Username: Username:
type: string type: string
type: object type: object
widget.addWidgetRequest:
properties:
widget:
$ref: '#/definitions/widget.validNewWidget'
type: object
type: object
widget.updateWidgetRequest:
properties:
widget:
$ref: '#/definitions/widget.validUpdatedWidget'
type: object
type: object
widget.validNewWidget: widget.validNewWidget:
properties: properties:
CustomProperties: CustomProperties:
@ -532,9 +624,8 @@ info:
email: sonja.happ@eonerc.rwth-aachen.de email: sonja.happ@eonerc.rwth-aachen.de
name: Sonja Happ name: Sonja Happ
description: |- description: |-
This is the API of the VILLASweb Backend This is the VILLASweb Backend API v2.0.
WORK IN PROGRESS! PLEASE BE PATIENT! Parts of this API are still in development. Please check https://git.rwth-aachen.de/acs/public/villas/web-backend-go for more information.
The tool https://github.com/swaggo/swag is used to auto-generate API docs for gin.
license: license:
name: GNU GPL 3.0 name: GNU GPL 3.0
url: http://www.gnu.de/documents/gpl-3.0.en.html url: http://www.gnu.de/documents/gpl-3.0.en.html
@ -580,6 +671,11 @@ paths:
get: get:
operationId: getDashboards operationId: getDashboards
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Scenario ID - description: Scenario ID
in: query in: query
name: scenarioID name: scenarioID
@ -616,12 +712,17 @@ paths:
- application/json - application/json
operationId: addDashboard operationId: addDashboard
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Dashboard to be added incl. ID of Scenario - description: Dashboard to be added incl. ID of Scenario
in: body in: body
name: inputDab name: inputDab
required: true required: true
schema: schema:
$ref: '#/definitions/dashboard.validNewDashboard' $ref: '#/definitions/dashboard.addDashboardRequest'
type: object type: object
produces: produces:
- application/json - application/json
@ -658,6 +759,11 @@ paths:
delete: delete:
operationId: deleteDashboard operationId: deleteDashboard
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Dashboard ID - description: Dashboard ID
in: path in: path
name: dashboardID name: dashboardID
@ -697,6 +803,11 @@ paths:
get: get:
operationId: getDashboard operationId: getDashboard
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Dashboard ID - description: Dashboard ID
in: path in: path
name: dashboardID name: dashboardID
@ -738,12 +849,17 @@ paths:
- application/json - application/json
operationId: updateDashboard operationId: updateDashboard
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Dashboard to be updated - description: Dashboard to be updated
in: body in: body
name: inputDab name: inputDab
required: true required: true
schema: schema:
$ref: '#/definitions/dashboard.validUpdatedDashboard' $ref: '#/definitions/dashboard.updateDashboardRequest'
type: object type: object
- description: Dashboard ID - description: Dashboard ID
in: path in: path
@ -785,6 +901,11 @@ paths:
get: get:
operationId: getFiles operationId: getFiles
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Set to model for files of model, set to widget for files of widget - description: Set to model for files of model, set to widget for files of widget
in: query in: query
name: objectType name: objectType
@ -831,6 +952,11 @@ paths:
- model/x-cim.zip - model/x-cim.zip
operationId: addFile operationId: addFile
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: File to be uploaded - description: File to be uploaded
in: formData in: formData
name: inputFile name: inputFile
@ -881,6 +1007,11 @@ paths:
delete: delete:
operationId: deleteFile operationId: deleteFile
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: ID of the file to update - description: ID of the file to update
in: path in: path
name: fileID name: fileID
@ -920,6 +1051,11 @@ paths:
get: get:
operationId: getFile operationId: getFile
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: ID of the file to download - description: ID of the file to download
in: path in: path
name: fileID name: fileID
@ -971,6 +1107,11 @@ paths:
- model/x-cim.zip - model/x-cim.zip
operationId: updateFile operationId: updateFile
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: File to be uploaded - description: File to be uploaded
in: formData in: formData
name: inputFile name: inputFile
@ -1012,10 +1153,38 @@ paths:
summary: Update a file summary: Update a file
tags: tags:
- files - files
/healthz:
get:
operationId: getHealth
parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: Backend is healthy, database and AMQP broker connections are
alive
"500":
description: Backend is NOT healthy
schema:
$ref: '#/definitions/docs.ResponseError'
type: object
summary: Get health status of backend
tags:
- healthz
/models: /models:
get: get:
operationId: getSimulationModels operationId: getSimulationModels
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Scenario ID - description: Scenario ID
in: query in: query
name: scenarioID name: scenarioID
@ -1052,12 +1221,17 @@ paths:
- application/json - application/json
operationId: addSimulationModel operationId: addSimulationModel
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Simulation model to be added incl. IDs of scenario and simulator - description: Simulation model to be added incl. IDs of scenario and simulator
in: body in: body
name: inputSimulationModel name: inputSimulationModel
required: true required: true
schema: schema:
$ref: '#/definitions/simulationmodel.validNewSimulationModel' $ref: '#/definitions/simulationmodel.addSimulationModelRequest'
type: object type: object
produces: produces:
- application/json - application/json
@ -1094,6 +1268,11 @@ paths:
delete: delete:
operationId: deleteSimulationModel operationId: deleteSimulationModel
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Model ID - description: Model ID
in: path in: path
name: modelID name: modelID
@ -1133,6 +1312,11 @@ paths:
get: get:
operationId: getSimulationModel operationId: getSimulationModel
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Model ID - description: Model ID
in: path in: path
name: modelID name: modelID
@ -1174,12 +1358,17 @@ paths:
- application/json - application/json
operationId: updateSimulationModel operationId: updateSimulationModel
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Simulation model to be updated - description: Simulation model to be updated
in: body in: body
name: inputSimulationModel name: inputSimulationModel
required: true required: true
schema: schema:
$ref: '#/definitions/simulationmodel.validUpdatedSimulationModel' $ref: '#/definitions/simulationmodel.updateSimulationModelRequest'
type: object type: object
- description: Model ID - description: Model ID
in: path in: path
@ -1220,6 +1409,12 @@ paths:
/scenarios: /scenarios:
get: get:
operationId: getScenarios operationId: getScenarios
parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
produces: produces:
- application/json - application/json
responses: responses:
@ -1251,12 +1446,17 @@ paths:
- application/json - application/json
operationId: addScenario operationId: addScenario
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Scenario to be added - description: Scenario to be added
in: body in: body
name: inputScenario name: inputScenario
required: true required: true
schema: schema:
$ref: '#/definitions/scenario.validNewScenario' $ref: '#/definitions/scenario.addScenarioRequest'
type: object type: object
produces: produces:
- application/json - application/json
@ -1293,6 +1493,11 @@ paths:
delete: delete:
operationId: deleteScenario operationId: deleteScenario
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Scenario ID - description: Scenario ID
in: path in: path
name: scenarioID name: scenarioID
@ -1327,6 +1532,11 @@ paths:
get: get:
operationId: getScenario operationId: getScenario
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Scenario ID - description: Scenario ID
in: path in: path
name: scenarioID name: scenarioID
@ -1363,12 +1573,17 @@ paths:
- application/json - application/json
operationId: updateScenario operationId: updateScenario
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Scenario to be updated - description: Scenario to be updated
in: body in: body
name: inputScenario name: inputScenario
required: true required: true
schema: schema:
$ref: '#/definitions/scenario.validUpdatedScenario' $ref: '#/definitions/scenario.updateScenarioRequest'
type: object type: object
- description: Scenario ID - description: Scenario ID
in: path in: path
@ -1410,6 +1625,11 @@ paths:
delete: delete:
operationId: deleteUserFromScenario operationId: deleteUserFromScenario
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Scenario ID - description: Scenario ID
in: path in: path
name: scenarioID name: scenarioID
@ -1449,6 +1669,11 @@ paths:
put: put:
operationId: addUserToScenario operationId: addUserToScenario
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Scenario ID - description: Scenario ID
in: path in: path
name: scenarioID name: scenarioID
@ -1489,6 +1714,11 @@ paths:
get: get:
operationId: getUsersOfScenario operationId: getUsersOfScenario
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Scenario ID - description: Scenario ID
in: path in: path
name: scenarioID name: scenarioID
@ -1534,6 +1764,11 @@ paths:
name: modelID name: modelID
required: true required: true
type: string type: string
- description: Authorization token
in: header
name: Authorization
required: true
type: string
produces: produces:
- application/json - application/json
responses: responses:
@ -1565,13 +1800,18 @@ paths:
- application/json - application/json
operationId: AddSignal operationId: AddSignal
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: A signal to be added to the model incl. direction and model ID - description: A signal to be added to the model incl. direction and model ID
to which signal shall be added to which signal shall be added
in: body in: body
name: inputSignal name: inputSignal
required: true required: true
schema: schema:
$ref: '#/definitions/signal.validNewSignal' $ref: '#/definitions/signal.addSignalRequest'
type: object type: object
produces: produces:
- application/json - application/json
@ -1608,6 +1848,11 @@ paths:
delete: delete:
operationId: deleteSignal operationId: deleteSignal
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: ID of signal to be deleted - description: ID of signal to be deleted
in: path in: path
name: signalID name: signalID
@ -1647,6 +1892,11 @@ paths:
get: get:
operationId: getSignal operationId: getSignal
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: ID of signal to be obtained - description: ID of signal to be obtained
in: path in: path
name: signalID name: signalID
@ -1686,12 +1936,17 @@ paths:
put: put:
operationId: updateSignal operationId: updateSignal
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: A signal to be updated - description: A signal to be updated
in: body in: body
name: inputSignal name: inputSignal
required: true required: true
schema: schema:
$ref: '#/definitions/signal.validUpdatedSignal' $ref: '#/definitions/signal.updateSignalRequest'
type: object type: object
- description: ID of signal to be updated - description: ID of signal to be updated
in: path in: path
@ -1732,6 +1987,12 @@ paths:
/simulators: /simulators:
get: get:
operationId: getSimulators operationId: getSimulators
parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
produces: produces:
- application/json - application/json
responses: responses:
@ -1763,12 +2024,17 @@ paths:
- application/json - application/json
operationId: addSimulator operationId: addSimulator
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Simulator to be added - description: Simulator to be added
in: body in: body
name: inputSimulator name: inputSimulator
required: true required: true
schema: schema:
$ref: '#/definitions/simulator.validNewSimulator' $ref: '#/definitions/simulator.addSimulatorRequest'
type: object type: object
produces: produces:
- application/json - application/json
@ -1805,6 +2071,11 @@ paths:
delete: delete:
operationId: deleteSimulator operationId: deleteSimulator
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Simulator ID - description: Simulator ID
in: path in: path
name: simulatorID name: simulatorID
@ -1844,6 +2115,11 @@ paths:
get: get:
operationId: getSimulator operationId: getSimulator
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Simulator ID - description: Simulator ID
in: path in: path
name: simulatorID name: simulatorID
@ -1885,12 +2161,17 @@ paths:
- application/json - application/json
operationId: updateSimulator operationId: updateSimulator
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Simulator to be updated - description: Simulator to be updated
in: body in: body
name: inputSimulator name: inputSimulator
required: true required: true
schema: schema:
$ref: '#/definitions/simulator.validUpdatedSimulator' $ref: '#/definitions/simulator.updateSimulatorRequest'
type: object type: object
- description: Simulator ID - description: Simulator ID
in: path in: path
@ -1978,6 +2259,11 @@ paths:
get: get:
operationId: getModelsOfSimulator operationId: getModelsOfSimulator
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Simulator ID - description: Simulator ID
in: path in: path
name: simulatorID name: simulatorID
@ -2017,6 +2303,12 @@ paths:
/users: /users:
get: get:
operationId: GetUsers operationId: GetUsers
parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
produces: produces:
- application/json - application/json
responses: responses:
@ -2053,8 +2345,13 @@ paths:
name: inputUser name: inputUser
required: true required: true
schema: schema:
$ref: '#/definitions/user.validNewUser' $ref: '#/definitions/user.addUserRequest'
type: object type: object
- description: Authorization token
in: header
name: Authorization
required: true
type: string
produces: produces:
- application/json - application/json
responses: responses:
@ -2085,6 +2382,11 @@ paths:
delete: delete:
operationId: DeleteUser operationId: DeleteUser
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: User ID - description: User ID
in: path in: path
name: userID name: userID
@ -2119,6 +2421,11 @@ paths:
get: get:
operationId: GetUser operationId: GetUser
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: User ID - description: User ID
in: path in: path
name: userID name: userID
@ -2160,13 +2467,18 @@ paths:
- application/json - application/json
operationId: UpdateUser operationId: UpdateUser
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: User to be updated (anything except for ID can be changed, role - description: User to be updated (anything except for ID can be changed, role
can only be change by admin) can only be change by admin)
in: body in: body
name: inputUser name: inputUser
required: true required: true
schema: schema:
$ref: '#/definitions/user.validUpdatedRequest' $ref: '#/definitions/user.updateUserRequest'
type: object type: object
- description: User ID - description: User ID
in: path in: path
@ -2213,6 +2525,11 @@ paths:
get: get:
operationId: getWidgets operationId: getWidgets
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Dashboard ID - description: Dashboard ID
in: query in: query
name: dashboardID name: dashboardID
@ -2249,12 +2566,17 @@ paths:
- application/json - application/json
operationId: addWidget operationId: addWidget
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Widget to be added incl. ID of dashboard - description: Widget to be added incl. ID of dashboard
in: body in: body
name: inputWidget name: inputWidget
required: true required: true
schema: schema:
$ref: '#/definitions/widget.validNewWidget' $ref: '#/definitions/widget.addWidgetRequest'
type: object type: object
produces: produces:
- application/json - application/json
@ -2291,6 +2613,11 @@ paths:
delete: delete:
operationId: deleteWidget operationId: deleteWidget
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Widget ID - description: Widget ID
in: path in: path
name: widgetID name: widgetID
@ -2330,6 +2657,11 @@ paths:
get: get:
operationId: getWidget operationId: getWidget
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Widget ID - description: Widget ID
in: path in: path
name: widgetID name: widgetID
@ -2371,12 +2703,17 @@ paths:
- application/json - application/json
operationId: updateWidget operationId: updateWidget
parameters: parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: Widget to be updated - description: Widget to be updated
in: body in: body
name: inputWidget name: inputWidget
required: true required: true
schema: schema:
$ref: '#/definitions/widget.validUpdatedWidget' $ref: '#/definitions/widget.updateWidgetRequest'
type: object type: object
- description: Widget ID - description: Widget ID
in: path in: path

View file

@ -28,6 +28,7 @@ func RegisterDashboardEndpoints(r *gin.RouterGroup) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param scenarioID query int true "Scenario ID" // @Param scenarioID query int true "Scenario ID"
// @Router /dashboards [get] // @Router /dashboards [get]
func getDashboards(c *gin.Context) { func getDashboards(c *gin.Context) {
@ -52,12 +53,13 @@ func getDashboards(c *gin.Context) {
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Tags dashboards // @Tags dashboards
// @Param inputDab body dashboard.validNewDashboard true "Dashboard to be added incl. ID of Scenario"
// @Success 200 {object} docs.ResponseDashboard "Dashboard that was added" // @Success 200 {object} docs.ResponseDashboard "Dashboard that was added"
// @Failure 400 {object} docs.ResponseError "Bad request" // @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param inputDab body dashboard.addDashboardRequest true "Dashboard to be added incl. ID of Scenario"
// @Router /dashboards [post] // @Router /dashboards [post]
func addDashboard(c *gin.Context) { func addDashboard(c *gin.Context) {
@ -97,12 +99,13 @@ func addDashboard(c *gin.Context) {
// @Tags dashboards // @Tags dashboards
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param inputDab body dashboard.validUpdatedDashboard true "Dashboard to be updated"
// @Success 200 {object} docs.ResponseDashboard "Dashboard that was updated" // @Success 200 {object} docs.ResponseDashboard "Dashboard that was updated"
// @Failure 400 {object} docs.ResponseError "Bad request" // @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param inputDab body dashboard.updateDashboardRequest true "Dashboard to be updated"
// @Param dashboardID path int true "Dashboard ID" // @Param dashboardID path int true "Dashboard ID"
// @Router /dashboards/{dashboardID} [put] // @Router /dashboards/{dashboardID} [put]
func updateDashboard(c *gin.Context) { func updateDashboard(c *gin.Context) {
@ -119,7 +122,7 @@ func updateDashboard(c *gin.Context) {
} }
// Validate the request // Validate the request
if err := req.validate(); err != nil { if err := req.Dashboard.validate(); err != nil {
helper.BadRequestError(c, err.Error()) helper.BadRequestError(c, err.Error())
return return
} }
@ -144,6 +147,7 @@ func updateDashboard(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param dashboardID path int true "Dashboard ID" // @Param dashboardID path int true "Dashboard ID"
// @Router /dashboards/{dashboardID} [get] // @Router /dashboards/{dashboardID} [get]
func getDashboard(c *gin.Context) { func getDashboard(c *gin.Context) {
@ -166,6 +170,7 @@ func getDashboard(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param dashboardID path int true "Dashboard ID" // @Param dashboardID path int true "Dashboard ID"
// @Router /dashboards/{dashboardID} [delete] // @Router /dashboards/{dashboardID} [delete]
func deleteDashboard(c *gin.Context) { func deleteDashboard(c *gin.Context) {

View file

@ -13,16 +13,16 @@ type validNewDashboard struct {
} }
type validUpdatedDashboard struct { type validUpdatedDashboard struct {
Name string `form:"Name" validate:"omitempty"` Name string `form:"Name" validate:"omitempty" json:"name"`
Grid int `form:"Grid" validate:"omitempty"` Grid int `form:"Grid" validate:"omitempty" json:"grid"`
} }
type addDashboardRequest struct { type addDashboardRequest struct {
validNewDashboard `json:"dashboard"` Dashboard validNewDashboard `json:"dashboard"`
} }
type updateDashboardRequest struct { type updateDashboardRequest struct {
validUpdatedDashboard `json:"dashboard"` Dashboard validUpdatedDashboard `json:"dashboard"`
} }
func (r *addDashboardRequest) validate() error { func (r *addDashboardRequest) validate() error {
@ -40,9 +40,9 @@ func (r *validUpdatedDashboard) validate() error {
func (r *addDashboardRequest) createDashboard() Dashboard { func (r *addDashboardRequest) createDashboard() Dashboard {
var s Dashboard var s Dashboard
s.Name = r.Name s.Name = r.Dashboard.Name
s.Grid = r.Grid s.Grid = r.Dashboard.Grid
s.ScenarioID = r.ScenarioID s.ScenarioID = r.Dashboard.ScenarioID
return s return s
} }
@ -51,12 +51,12 @@ func (r *updateDashboardRequest) updatedDashboard(oldDashboard Dashboard) Dashbo
// Use the old Dashboard as a basis for the updated Dashboard `s` // Use the old Dashboard as a basis for the updated Dashboard `s`
s := oldDashboard s := oldDashboard
if r.Name != "" { if r.Dashboard.Name != "" {
s.Name = r.Name s.Name = r.Dashboard.Name
} }
if r.Grid != 0 { if r.Dashboard.Grid != 0 {
s.Grid = r.Grid s.Grid = r.Dashboard.Grid
} }
return s return s

View file

@ -30,6 +30,7 @@ func RegisterFileEndpoints(r *gin.RouterGroup) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param objectType query string true "Set to model for files of model, set to widget for files of widget" // @Param objectType query string true "Set to model for files of model, set to widget for files of widget"
// @Param objectID query int true "ID of either model or widget of which files are requested" // @Param objectID query int true "ID of either model or widget of which files are requested"
// @Router /files [get] // @Router /files [get]
@ -94,6 +95,7 @@ func getFiles(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param inputFile formData file true "File to be uploaded" // @Param inputFile formData file true "File to be uploaded"
// @Param objectType query string true "Set to model for files of model, set to widget for files of widget" // @Param objectType query string true "Set to model for files of model, set to widget for files of widget"
// @Param objectID query int true "ID of either model or widget of which files are requested" // @Param objectID query int true "ID of either model or widget of which files are requested"
@ -156,6 +158,7 @@ func addFile(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param fileID path int true "ID of the file to download" // @Param fileID path int true "ID of the file to download"
// @Router /files/{fileID} [get] // @Router /files/{fileID} [get]
func getFile(c *gin.Context) { func getFile(c *gin.Context) {
@ -186,6 +189,7 @@ func getFile(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param inputFile formData file true "File to be uploaded" // @Param inputFile formData file true "File to be uploaded"
// @Param fileID path int true "ID of the file to update" // @Param fileID path int true "ID of the file to update"
// @Router /files/{fileID} [put] // @Router /files/{fileID} [put]
@ -220,6 +224,7 @@ func updateFile(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param fileID path int true "ID of the file to update" // @Param fileID path int true "ID of the file to update"
// @Router /files/{fileID} [delete] // @Router /files/{fileID} [delete]
func deleteFile(c *gin.Context) { func deleteFile(c *gin.Context) {

View file

@ -20,6 +20,7 @@ func RegisterHealthzEndpoint(r *gin.RouterGroup) {
// @Tags healthz // @Tags healthz
// @Success 200 "Backend is healthy, database and AMQP broker connections are alive" // @Success 200 "Backend is healthy, database and AMQP broker connections are alive"
// @Failure 500 {object} docs.ResponseError "Backend is NOT healthy" // @Failure 500 {object} docs.ResponseError "Backend is NOT healthy"
// @Param Authorization header string true "Authorization token"
// @Router /healthz [get] // @Router /healthz [get]
func getHealth(c *gin.Context) { func getHealth(c *gin.Context) {

View file

@ -30,6 +30,7 @@ func RegisterScenarioEndpoints(r *gin.RouterGroup) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Router /scenarios [get] // @Router /scenarios [get]
func getScenarios(c *gin.Context) { func getScenarios(c *gin.Context) {
@ -70,12 +71,13 @@ func getScenarios(c *gin.Context) {
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Tags scenarios // @Tags scenarios
// @Param inputScenario body scenario.validNewScenario true "Scenario to be added"
// @Success 200 {object} docs.ResponseScenario "scenario that was added" // @Success 200 {object} docs.ResponseScenario "scenario that was added"
// @Failure 400 {object} docs.ResponseError "Bad request" // @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param inputScenario body scenario.addScenarioRequest true "Scenario to be added"
// @Router /scenarios [post] // @Router /scenarios [post]
func addScenario(c *gin.Context) { func addScenario(c *gin.Context) {
@ -128,12 +130,13 @@ func addScenario(c *gin.Context) {
// @Tags scenarios // @Tags scenarios
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param inputScenario body scenario.validUpdatedScenario true "Scenario to be updated"
// @Success 200 {object} docs.ResponseScenario "Updated scenario." // @Success 200 {object} docs.ResponseScenario "Updated scenario."
// @Failure 400 {object} docs.ResponseError "Bad request" // @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param inputScenario body scenario.updateScenarioRequest true "Scenario to be updated"
// @Param scenarioID path int true "Scenario ID" // @Param scenarioID path int true "Scenario ID"
// @Router /scenarios/{scenarioID} [put] // @Router /scenarios/{scenarioID} [put]
func updateScenario(c *gin.Context) { func updateScenario(c *gin.Context) {
@ -151,7 +154,7 @@ func updateScenario(c *gin.Context) {
} }
// Validate the request based on struct updateScenarioRequest json tags // Validate the request based on struct updateScenarioRequest json tags
if err := req.validate(); err != nil { if err := req.Scenario.validate(); err != nil {
helper.BadRequestError(c, err.Error()) helper.BadRequestError(c, err.Error())
return return
} }
@ -177,6 +180,7 @@ func updateScenario(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param scenarioID path int true "Scenario ID" // @Param scenarioID path int true "Scenario ID"
// @Router /scenarios/{scenarioID} [get] // @Router /scenarios/{scenarioID} [get]
func getScenario(c *gin.Context) { func getScenario(c *gin.Context) {
@ -199,6 +203,7 @@ func getScenario(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param scenarioID path int true "Scenario ID" // @Param scenarioID path int true "Scenario ID"
// @Router /scenarios/{scenarioID} [delete] // @Router /scenarios/{scenarioID} [delete]
func deleteScenario(c *gin.Context) { func deleteScenario(c *gin.Context) {
@ -225,6 +230,7 @@ func deleteScenario(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param scenarioID path int true "Scenario ID" // @Param scenarioID path int true "Scenario ID"
// @Router /scenarios/{scenarioID}/users/ [get] // @Router /scenarios/{scenarioID}/users/ [get]
func getUsersOfScenario(c *gin.Context) { func getUsersOfScenario(c *gin.Context) {
@ -252,6 +258,7 @@ func getUsersOfScenario(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param scenarioID path int true "Scenario ID" // @Param scenarioID path int true "Scenario ID"
// @Param username query string true "User name" // @Param username query string true "User name"
// @Router /scenarios/{scenarioID}/user [put] // @Router /scenarios/{scenarioID}/user [put]
@ -292,6 +299,7 @@ func addUserToScenario(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param scenarioID path int true "Scenario ID" // @Param scenarioID path int true "Scenario ID"
// @Param username query string true "User name" // @Param username query string true "User name"
// @Router /scenarios/{scenarioID}/user [delete] // @Router /scenarios/{scenarioID}/user [delete]

View file

@ -22,11 +22,11 @@ type validUpdatedScenario struct {
} }
type addScenarioRequest struct { type addScenarioRequest struct {
validNewScenario `json:"scenario"` Scenario validNewScenario `json:"scenario"`
} }
type updateScenarioRequest struct { type updateScenarioRequest struct {
validUpdatedScenario `json:"scenario"` Scenario validUpdatedScenario `json:"scenario"`
} }
func (r *addScenarioRequest) validate() error { func (r *addScenarioRequest) validate() error {
@ -44,9 +44,9 @@ func (r *validUpdatedScenario) validate() error {
func (r *addScenarioRequest) createScenario() Scenario { func (r *addScenarioRequest) createScenario() Scenario {
var s Scenario var s Scenario
s.Name = r.Name s.Name = r.Scenario.Name
s.Running = r.Running s.Running = r.Scenario.Running
s.StartParameters = r.StartParameters s.StartParameters = r.Scenario.StartParameters
return s return s
} }
@ -55,21 +55,21 @@ func (r *updateScenarioRequest) updatedScenario(oldScenario Scenario) Scenario {
// Use the old Scenario as a basis for the updated Scenario `s` // Use the old Scenario as a basis for the updated Scenario `s`
s := oldScenario s := oldScenario
if r.Name != "" { if r.Scenario.Name != "" {
s.Name = r.Name s.Name = r.Scenario.Name
} }
s.Running = r.Running s.Running = r.Scenario.Running
// only update Params if not empty // only update Params if not empty
var emptyJson postgres.Jsonb var emptyJson postgres.Jsonb
// Serialize empty json and params // Serialize empty json and params
emptyJson_ser, _ := json.Marshal(emptyJson) emptyJson_ser, _ := json.Marshal(emptyJson)
startParams_ser, _ := json.Marshal(r.StartParameters) startParams_ser, _ := json.Marshal(r.Scenario.StartParameters)
opts := jsondiff.DefaultConsoleOptions() opts := jsondiff.DefaultConsoleOptions()
diff, _ := jsondiff.Compare(emptyJson_ser, startParams_ser, &opts) diff, _ := jsondiff.Compare(emptyJson_ser, startParams_ser, &opts)
if diff.String() != "FullMatch" { if diff.String() != "FullMatch" {
s.StartParameters = r.StartParameters s.StartParameters = r.Scenario.StartParameters
} }
return s return s

View file

@ -29,6 +29,7 @@ func RegisterSignalEndpoints(r *gin.RouterGroup) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Router /signals [get] // @Router /signals [get]
func getSignals(c *gin.Context) { func getSignals(c *gin.Context) {
@ -63,12 +64,13 @@ func getSignals(c *gin.Context) {
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Tags signals // @Tags signals
// @Param inputSignal body signal.validNewSignal true "A signal to be added to the model incl. direction and model ID to which signal shall be added"
// @Success 200 {object} docs.ResponseSignal "Signal that was added" // @Success 200 {object} docs.ResponseSignal "Signal that was added"
// @Failure 400 {object} docs.ResponseError "Bad request" // @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param inputSignal body signal.addSignalRequest true "A signal to be added to the model incl. direction and model ID to which signal shall be added"
// @Router /signals [post] // @Router /signals [post]
func addSignal(c *gin.Context) { func addSignal(c *gin.Context) {
@ -105,12 +107,13 @@ func addSignal(c *gin.Context) {
// @ID updateSignal // @ID updateSignal
// @Tags signals // @Tags signals
// @Produce json // @Produce json
// @Param inputSignal body signal.validUpdatedSignal true "A signal to be updated"
// @Success 200 {object} docs.ResponseSignal "Signal that was updated" // @Success 200 {object} docs.ResponseSignal "Signal that was updated"
// @Failure 400 {object} docs.ResponseError "Bad request" // @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param inputSignal body signal.updateSignalRequest true "A signal to be updated"
// @Param signalID path int true "ID of signal to be updated" // @Param signalID path int true "ID of signal to be updated"
// @Router /signals/{signalID} [put] // @Router /signals/{signalID} [put]
func updateSignal(c *gin.Context) { func updateSignal(c *gin.Context) {
@ -126,7 +129,7 @@ func updateSignal(c *gin.Context) {
} }
// Validate the request // Validate the request
if err := req.validate(); err != nil { if err := req.Signal.validate(); err != nil {
helper.BadRequestError(c, err.Error()) helper.BadRequestError(c, err.Error())
return return
} }
@ -152,6 +155,7 @@ func updateSignal(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param signalID path int true "ID of signal to be obtained" // @Param signalID path int true "ID of signal to be obtained"
// @Router /signals/{signalID} [get] // @Router /signals/{signalID} [get]
func getSignal(c *gin.Context) { func getSignal(c *gin.Context) {
@ -173,6 +177,7 @@ func getSignal(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param signalID path int true "ID of signal to be deleted" // @Param signalID path int true "ID of signal to be deleted"
// @Router /signals/{signalID} [delete] // @Router /signals/{signalID} [delete]
func deleteSignal(c *gin.Context) { func deleteSignal(c *gin.Context) {

View file

@ -21,11 +21,11 @@ type validUpdatedSignal struct {
} }
type addSignalRequest struct { type addSignalRequest struct {
validNewSignal `json:"signal"` Signal validNewSignal `json:"signal"`
} }
type updateSignalRequest struct { type updateSignalRequest struct {
validUpdatedSignal `json:"signal"` Signal validUpdatedSignal `json:"signal"`
} }
func (r *addSignalRequest) validate() error { func (r *addSignalRequest) validate() error {
@ -43,11 +43,11 @@ func (r *validUpdatedSignal) validate() error {
func (r *addSignalRequest) createSignal() Signal { func (r *addSignalRequest) createSignal() Signal {
var s Signal var s Signal
s.Name = r.Name s.Name = r.Signal.Name
s.Unit = r.Unit s.Unit = r.Signal.Unit
s.Index = r.Index s.Index = r.Signal.Index
s.Direction = r.Direction s.Direction = r.Signal.Direction
s.SimulationModelID = r.SimulationModelID s.SimulationModelID = r.Signal.SimulationModelID
return s return s
} }
@ -56,17 +56,17 @@ func (r *updateSignalRequest) updatedSignal(oldSignal Signal) Signal {
// Use the old Signal as a basis for the updated Signal `s` // Use the old Signal as a basis for the updated Signal `s`
s := oldSignal s := oldSignal
if r.Name != "" { if r.Signal.Name != "" {
s.Name = r.Name s.Name = r.Signal.Name
} }
if r.Index != 0 { if r.Signal.Index != 0 {
// TODO this implies that we start indexing at 1 // TODO this implies that we start indexing at 1
s.Index = r.Index s.Index = r.Signal.Index
} }
if r.Unit != "" { if r.Signal.Unit != "" {
s.Unit = r.Unit s.Unit = r.Signal.Unit
} }
return s return s

View file

@ -27,6 +27,7 @@ func RegisterSimulationModelEndpoints(r *gin.RouterGroup) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param scenarioID query int true "Scenario ID" // @Param scenarioID query int true "Scenario ID"
// @Router /models [get] // @Router /models [get]
func getSimulationModels(c *gin.Context) { func getSimulationModels(c *gin.Context) {
@ -51,12 +52,13 @@ func getSimulationModels(c *gin.Context) {
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Tags models // @Tags models
// @Param inputSimulationModel body simulationmodel.validNewSimulationModel true "Simulation model to be added incl. IDs of scenario and simulator"
// @Success 200 {object} docs.ResponseSimulationModel "simulation model that was added" // @Success 200 {object} docs.ResponseSimulationModel "simulation model that was added"
// @Failure 400 {object} docs.ResponseError "Bad request" // @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param inputSimulationModel body simulationmodel.addSimulationModelRequest true "Simulation model to be added incl. IDs of scenario and simulator"
// @Router /models [post] // @Router /models [post]
func addSimulationModel(c *gin.Context) { func addSimulationModel(c *gin.Context) {
@ -97,12 +99,13 @@ func addSimulationModel(c *gin.Context) {
// @Tags models // @Tags models
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param inputSimulationModel body simulationmodel.validUpdatedSimulationModel true "Simulation model to be updated"
// @Success 200 {object} docs.ResponseSimulationModel "simulation model that was added" // @Success 200 {object} docs.ResponseSimulationModel "simulation model that was added"
// @Failure 400 {object} docs.ResponseError "Bad request" // @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param inputSimulationModel body simulationmodel.updateSimulationModelRequest true "Simulation model to be updated"
// @Param modelID path int true "Model ID" // @Param modelID path int true "Model ID"
// @Router /models/{modelID} [put] // @Router /models/{modelID} [put]
func updateSimulationModel(c *gin.Context) { func updateSimulationModel(c *gin.Context) {
@ -120,7 +123,7 @@ func updateSimulationModel(c *gin.Context) {
} }
// Validate the request // Validate the request
if err := req.validate(); err != nil { if err := req.Model.validate(); err != nil {
helper.BadRequestError(c, err.Error()) helper.BadRequestError(c, err.Error())
return return
} }
@ -146,6 +149,7 @@ func updateSimulationModel(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param modelID path int true "Model ID" // @Param modelID path int true "Model ID"
// @Router /models/{modelID} [get] // @Router /models/{modelID} [get]
func getSimulationModel(c *gin.Context) { func getSimulationModel(c *gin.Context) {
@ -168,6 +172,7 @@ func getSimulationModel(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param modelID path int true "Model ID" // @Param modelID path int true "Model ID"
// @Router /models/{modelID} [delete] // @Router /models/{modelID} [delete]
func deleteSimulationModel(c *gin.Context) { func deleteSimulationModel(c *gin.Context) {

View file

@ -23,11 +23,11 @@ type validUpdatedSimulationModel struct {
} }
type addSimulationModelRequest struct { type addSimulationModelRequest struct {
validNewSimulationModel `json:"model"` Model validNewSimulationModel `json:"model"`
} }
type updateSimulationModelRequest struct { type updateSimulationModelRequest struct {
validUpdatedSimulationModel `json:"model"` Model validUpdatedSimulationModel `json:"model"`
} }
func (r *addSimulationModelRequest) validate() error { func (r *addSimulationModelRequest) validate() error {
@ -45,10 +45,10 @@ func (r *validUpdatedSimulationModel) validate() error {
func (r *addSimulationModelRequest) createSimulationModel() SimulationModel { func (r *addSimulationModelRequest) createSimulationModel() SimulationModel {
var s SimulationModel var s SimulationModel
s.Name = r.Name s.Name = r.Model.Name
s.ScenarioID = r.ScenarioID s.ScenarioID = r.Model.ScenarioID
s.SimulatorID = r.SimulatorID s.SimulatorID = r.Model.SimulatorID
s.StartParameters = r.StartParameters s.StartParameters = r.Model.StartParameters
return s return s
} }
@ -57,23 +57,23 @@ func (r *updateSimulationModelRequest) updatedSimulationModel(oldSimulationModel
// Use the old SimulationModel as a basis for the updated Simulation model // Use the old SimulationModel as a basis for the updated Simulation model
s := oldSimulationModel s := oldSimulationModel
if r.Name != "" { if r.Model.Name != "" {
s.Name = r.Name s.Name = r.Model.Name
} }
if r.SimulatorID != 0 { if r.Model.SimulatorID != 0 {
s.SimulatorID = r.SimulatorID s.SimulatorID = r.Model.SimulatorID
} }
// only update Params if not empty // only update Params if not empty
var emptyJson postgres.Jsonb var emptyJson postgres.Jsonb
// Serialize empty json and params // Serialize empty json and params
emptyJson_ser, _ := json.Marshal(emptyJson) emptyJson_ser, _ := json.Marshal(emptyJson)
startParams_ser, _ := json.Marshal(r.StartParameters) startParams_ser, _ := json.Marshal(r.Model.StartParameters)
opts := jsondiff.DefaultConsoleOptions() opts := jsondiff.DefaultConsoleOptions()
diff, _ := jsondiff.Compare(emptyJson_ser, startParams_ser, &opts) diff, _ := jsondiff.Compare(emptyJson_ser, startParams_ser, &opts)
if diff.String() != "FullMatch" { if diff.String() != "FullMatch" {
s.StartParameters = r.StartParameters s.StartParameters = r.Model.StartParameters
} }
return s return s

View file

@ -26,6 +26,7 @@ func RegisterSimulatorEndpoints(r *gin.RouterGroup) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Router /simulators [get] // @Router /simulators [get]
func getSimulators(c *gin.Context) { func getSimulators(c *gin.Context) {
@ -46,12 +47,13 @@ func getSimulators(c *gin.Context) {
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Tags simulators // @Tags simulators
// @Param inputSimulator body simulator.validNewSimulator true "Simulator to be added"
// @Success 200 {object} docs.ResponseSimulator "Simulator that was added" // @Success 200 {object} docs.ResponseSimulator "Simulator that was added"
// @Failure 400 {object} docs.ResponseError "Bad request" // @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param inputSimulator body simulator.addSimulatorRequest true "Simulator to be added"
// @Router /simulators [post] // @Router /simulators [post]
func addSimulator(c *gin.Context) { func addSimulator(c *gin.Context) {
@ -90,12 +92,13 @@ func addSimulator(c *gin.Context) {
// @Tags simulators // @Tags simulators
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param inputSimulator body simulator.validUpdatedSimulator true "Simulator to be updated"
// @Success 200 {object} docs.ResponseSimulator "Simulator that was updated" // @Success 200 {object} docs.ResponseSimulator "Simulator that was updated"
// @Failure 400 {object} docs.ResponseError "Bad request" // @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param inputSimulator body simulator.updateSimulatorRequest true "Simulator to be updated"
// @Param simulatorID path int true "Simulator ID" // @Param simulatorID path int true "Simulator ID"
// @Router /simulators/{simulatorID} [put] // @Router /simulators/{simulatorID} [put]
func updateSimulator(c *gin.Context) { func updateSimulator(c *gin.Context) {
@ -113,7 +116,7 @@ func updateSimulator(c *gin.Context) {
} }
// Validate the request // Validate the request
if err = req.validate(); err != nil { if err = req.Simulator.validate(); err != nil {
helper.UnprocessableEntityError(c, err.Error()) helper.UnprocessableEntityError(c, err.Error())
return return
} }
@ -139,6 +142,7 @@ func updateSimulator(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param simulatorID path int true "Simulator ID" // @Param simulatorID path int true "Simulator ID"
// @Router /simulators/{simulatorID} [get] // @Router /simulators/{simulatorID} [get]
func getSimulator(c *gin.Context) { func getSimulator(c *gin.Context) {
@ -161,6 +165,7 @@ func getSimulator(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param simulatorID path int true "Simulator ID" // @Param simulatorID path int true "Simulator ID"
// @Router /simulators/{simulatorID} [delete] // @Router /simulators/{simulatorID} [delete]
func deleteSimulator(c *gin.Context) { func deleteSimulator(c *gin.Context) {
@ -188,6 +193,7 @@ func deleteSimulator(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param simulatorID path int true "Simulator ID" // @Param simulatorID path int true "Simulator ID"
// @Router /simulators/{simulatorID}/models [get] // @Router /simulators/{simulatorID}/models [get]
func getModelsOfSimulator(c *gin.Context) { func getModelsOfSimulator(c *gin.Context) {

View file

@ -26,11 +26,11 @@ type validUpdatedSimulator struct {
} }
type addSimulatorRequest struct { type addSimulatorRequest struct {
validNewSimulator `json:"simulator"` Simulator validNewSimulator `json:"simulator"`
} }
type updateSimulatorRequest struct { type updateSimulatorRequest struct {
validUpdatedSimulator `json:"simulator"` Simulator validUpdatedSimulator `json:"simulator"`
} }
func (r *addSimulatorRequest) validate() error { func (r *addSimulatorRequest) validate() error {
@ -48,12 +48,12 @@ func (r *validUpdatedSimulator) validate() error {
func (r *addSimulatorRequest) createSimulator() Simulator { func (r *addSimulatorRequest) createSimulator() Simulator {
var s Simulator var s Simulator
s.UUID = r.UUID s.UUID = r.Simulator.UUID
s.Host = r.Host s.Host = r.Simulator.Host
s.Modeltype = r.Modeltype s.Modeltype = r.Simulator.Modeltype
s.Properties = r.Properties s.Properties = r.Simulator.Properties
if r.State != "" { if r.Simulator.State != "" {
s.State = r.State s.State = r.Simulator.State
} }
return s return s
} }
@ -62,31 +62,31 @@ func (r *updateSimulatorRequest) updatedSimulator(oldSimulator Simulator) Simula
// Use the old Simulator as a basis for the updated Simulator `s` // Use the old Simulator as a basis for the updated Simulator `s`
s := oldSimulator s := oldSimulator
if r.UUID != "" { if r.Simulator.UUID != "" {
s.UUID = r.UUID s.UUID = r.Simulator.UUID
} }
if r.Host != "" { if r.Simulator.Host != "" {
s.Host = r.Host s.Host = r.Simulator.Host
} }
if r.Modeltype != "" { if r.Simulator.Modeltype != "" {
s.Modeltype = r.Modeltype s.Modeltype = r.Simulator.Modeltype
} }
if r.State != "" { if r.Simulator.State != "" {
s.State = r.State s.State = r.Simulator.State
} }
// only update props if not empty // only update props if not empty
var emptyJson postgres.Jsonb var emptyJson postgres.Jsonb
// Serialize empty json and params // Serialize empty json and params
emptyJson_ser, _ := json.Marshal(emptyJson) emptyJson_ser, _ := json.Marshal(emptyJson)
startParams_ser, _ := json.Marshal(r.Properties) startParams_ser, _ := json.Marshal(r.Simulator.Properties)
opts := jsondiff.DefaultConsoleOptions() opts := jsondiff.DefaultConsoleOptions()
diff, _ := jsondiff.Compare(emptyJson_ser, startParams_ser, &opts) diff, _ := jsondiff.Compare(emptyJson_ser, startParams_ser, &opts)
if diff.String() != "FullMatch" { if diff.String() != "FullMatch" {
s.Properties = r.Properties s.Properties = r.Simulator.Properties
} }
return s return s

View file

@ -33,6 +33,7 @@ func RegisterUserEndpoints(r *gin.RouterGroup) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Router /users [get] // @Router /users [get]
func getUsers(c *gin.Context) { func getUsers(c *gin.Context) {
@ -57,11 +58,12 @@ func getUsers(c *gin.Context) {
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Tags users // @Tags users
// @Param inputUser body user.validNewUser true "User to be added" // @Param inputUser body user.addUserRequest true "User to be added"
// @Success 200 {object} docs.ResponseUser "Contains added user object" // @Success 200 {object} docs.ResponseUser "Contains added user object"
// @Failure 400 {object} docs.ResponseError "Bad request" // @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Router /users [post] // @Router /users [post]
func addUser(c *gin.Context) { func addUser(c *gin.Context) {
@ -115,13 +117,14 @@ func addUser(c *gin.Context) {
// @Tags users // @Tags users
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param inputUser body user.validUpdatedRequest true "User to be updated (anything except for ID can be changed, role can only be change by admin)"
// @Success 200 {object} docs.ResponseUser "Contains updated user" // @Success 200 {object} docs.ResponseUser "Contains updated user"
// @Failure 400 {object} docs.ResponseError "Bad request." // @Failure 400 {object} docs.ResponseError "Bad request."
// @Failure 403 {object} docs.ResponseError "Access forbidden." // @Failure 403 {object} docs.ResponseError "Access forbidden."
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param inputUser body user.updateUserRequest true "User to be updated (anything except for ID can be changed, role can only be change by admin)"
// @Param userID path int true "User ID" // @Param userID path int true "User ID"
// @Router /users/{userID} [put] // @Router /users/{userID} [put]
func updateUser(c *gin.Context) { func updateUser(c *gin.Context) {
@ -211,6 +214,7 @@ func updateUser(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param userID path int true "User ID" // @Param userID path int true "User ID"
// @Router /users/{userID} [get] // @Router /users/{userID} [get]
func getUser(c *gin.Context) { func getUser(c *gin.Context) {
@ -252,6 +256,7 @@ func getUser(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param userID path int true "User ID" // @Param userID path int true "User ID"
// @Router /users/{userID} [delete] // @Router /users/{userID} [delete]
func deleteUser(c *gin.Context) { func deleteUser(c *gin.Context) {

View file

@ -22,7 +22,7 @@ type validUpdatedRequest struct {
} }
type updateUserRequest struct { type updateUserRequest struct {
validUpdatedRequest `json:"user"` User validUpdatedRequest `json:"user"`
} }
type validNewUser struct { type validNewUser struct {
@ -33,7 +33,7 @@ type validNewUser struct {
} }
type addUserRequest struct { type addUserRequest struct {
validNewUser `json:"user"` User validNewUser `json:"user"`
} }
func (r *loginRequest) validate() error { func (r *loginRequest) validate() error {
@ -58,16 +58,16 @@ func (r *updateUserRequest) updatedUser(callerID interface{}, role interface{},
u := oldUser u := oldUser
// Only the Admin must be able to update user's role // Only the Admin must be able to update user's role
if role != "Admin" && r.Role != "" { if role != "Admin" && r.User.Role != "" {
if r.Role != u.Role { if r.User.Role != u.Role {
return u, fmt.Errorf("Only Admin can update user's Role") return u, fmt.Errorf("Only Admin can update user's Role")
} }
} else if role == "Admin" && r.Role != "" { } else if role == "Admin" && r.User.Role != "" {
u.Role = r.Role u.Role = r.User.Role
} }
// Only the Admin must be able to update users Active state // Only the Admin must be able to update users Active state
if (r.Active == "yes" && u.Active == false) || (r.Active == "no" && u.Active == true) { if (r.User.Active == "yes" && u.Active == false) || (r.User.Active == "no" && u.Active == true) {
if role != "Admin" { if role != "Admin" {
return u, fmt.Errorf("Only Admin can update user's Active state") return u, fmt.Errorf("Only Admin can update user's Active state")
} else { } else {
@ -77,18 +77,18 @@ func (r *updateUserRequest) updatedUser(callerID interface{}, role interface{},
// Update the username making sure it is NOT taken // Update the username making sure it is NOT taken
var testUser User var testUser User
if err := testUser.ByUsername(r.Username); err == nil { if err := testUser.ByUsername(r.User.Username); err == nil {
return u, fmt.Errorf("Username is alreaday taken") return u, fmt.Errorf("Username is alreaday taken")
} }
if r.Username != "" { if r.User.Username != "" {
u.Username = r.Username u.Username = r.User.Username
} }
// If there is a new password then hash it and update it // If there is a new password then hash it and update it
if r.Password != "" { if r.User.Password != "" {
if r.OldPassword == "" { // admin or old password has to be present for pw change if r.User.OldPassword == "" { // admin or old password has to be present for pw change
return u, fmt.Errorf("old or admin password is missing in request") return u, fmt.Errorf("old or admin password is missing in request")
} }
@ -99,28 +99,28 @@ func (r *updateUserRequest) updatedUser(callerID interface{}, role interface{},
return u, err return u, err
} }
err = adminUser.validatePassword(r.OldPassword) err = adminUser.validatePassword(r.User.OldPassword)
if err != nil { if err != nil {
return u, fmt.Errorf("admin password not correct, pw not changed") return u, fmt.Errorf("admin password not correct, pw not changed")
} }
} else { //normal or guest user has to enter old password } else { //normal or guest user has to enter old password
err := oldUser.validatePassword(r.OldPassword) err := oldUser.validatePassword(r.User.OldPassword)
if err != nil { if err != nil {
return u, fmt.Errorf("previous password not correct, pw not changed") return u, fmt.Errorf("previous password not correct, pw not changed")
} }
} }
err := u.setPassword(r.Password) err := u.setPassword(r.User.Password)
if err != nil { if err != nil {
return u, fmt.Errorf("unable to encrypt new password") return u, fmt.Errorf("unable to encrypt new password")
} }
} }
// Update mail // Update mail
if r.Mail != "" { if r.User.Mail != "" {
u.Mail = r.Mail u.Mail = r.User.Mail
} }
return u, nil return u, nil
@ -135,10 +135,10 @@ func (r *addUserRequest) validate() error {
func (r *addUserRequest) createUser() User { func (r *addUserRequest) createUser() User {
var u User var u User
u.Username = r.Username u.Username = r.User.Username
u.Password = r.Password u.Password = r.User.Password
u.Mail = r.Mail u.Mail = r.User.Mail
u.Role = r.Role u.Role = r.User.Role
u.Active = true u.Active = true
return u return u

View file

@ -27,6 +27,7 @@ func RegisterWidgetEndpoints(r *gin.RouterGroup) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param dashboardID query int true "Dashboard ID" // @Param dashboardID query int true "Dashboard ID"
// @Router /widgets [get] // @Router /widgets [get]
func getWidgets(c *gin.Context) { func getWidgets(c *gin.Context) {
@ -51,12 +52,13 @@ func getWidgets(c *gin.Context) {
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Tags widgets // @Tags widgets
// @Param inputWidget body widget.validNewWidget true "Widget to be added incl. ID of dashboard"
// @Success 200 {object} docs.ResponseWidget "Widget that was added" // @Success 200 {object} docs.ResponseWidget "Widget that was added"
// @Failure 400 {object} docs.ResponseError "Bad request" // @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param inputWidget body widget.addWidgetRequest true "Widget to be added incl. ID of dashboard"
// @Router /widgets [post] // @Router /widgets [post]
func addWidget(c *gin.Context) { func addWidget(c *gin.Context) {
@ -94,12 +96,13 @@ func addWidget(c *gin.Context) {
// @Tags widgets // @Tags widgets
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param inputWidget body widget.validUpdatedWidget true "Widget to be updated"
// @Success 200 {object} docs.ResponseWidget "Widget that was updated" // @Success 200 {object} docs.ResponseWidget "Widget that was updated"
// @Failure 400 {object} docs.ResponseError "Bad request" // @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param inputWidget body widget.updateWidgetRequest true "Widget to be updated"
// @Param widgetID path int true "Widget ID" // @Param widgetID path int true "Widget ID"
// @Router /widgets/{widgetID} [put] // @Router /widgets/{widgetID} [put]
func updateWidget(c *gin.Context) { func updateWidget(c *gin.Context) {
@ -116,7 +119,7 @@ func updateWidget(c *gin.Context) {
} }
// Validate the request // Validate the request
if err := req.validate(); err != nil { if err := req.Widget.validate(); err != nil {
helper.BadRequestError(c, err.Error()) helper.BadRequestError(c, err.Error())
return return
} }
@ -142,6 +145,7 @@ func updateWidget(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param widgetID path int true "Widget ID" // @Param widgetID path int true "Widget ID"
// @Router /widgets/{widgetID} [get] // @Router /widgets/{widgetID} [get]
func getWidget(c *gin.Context) { func getWidget(c *gin.Context) {
@ -164,6 +168,7 @@ func getWidget(c *gin.Context) {
// @Failure 404 {object} docs.ResponseError "Not found" // @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error" // @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param widgetID path int true "Widget ID" // @Param widgetID path int true "Widget ID"
// @Router /widgets/{widgetID} [delete] // @Router /widgets/{widgetID} [delete]
func deleteWidget(c *gin.Context) { func deleteWidget(c *gin.Context) {

View file

@ -39,11 +39,11 @@ type validUpdatedWidget struct {
} }
type addWidgetRequest struct { type addWidgetRequest struct {
validNewWidget `json:"widget"` Widget validNewWidget `json:"widget"`
} }
type updateWidgetRequest struct { type updateWidgetRequest struct {
validUpdatedWidget `json:"widget"` Widget validUpdatedWidget `json:"widget"`
} }
func (r *addWidgetRequest) validate() error { func (r *addWidgetRequest) validate() error {
@ -61,18 +61,18 @@ func (r *validUpdatedWidget) validate() error {
func (r *addWidgetRequest) createWidget() Widget { func (r *addWidgetRequest) createWidget() Widget {
var s Widget var s Widget
s.Name = r.Name s.Name = r.Widget.Name
s.Type = r.Type s.Type = r.Widget.Type
s.Width = r.Width s.Width = r.Widget.Width
s.Height = r.Height s.Height = r.Widget.Height
s.MinWidth = r.MinWidth s.MinWidth = r.Widget.MinWidth
s.MinHeight = r.MinHeight s.MinHeight = r.Widget.MinHeight
s.X = r.X s.X = r.Widget.X
s.Y = r.Y s.Y = r.Widget.Y
s.Z = r.Z s.Z = r.Widget.Z
s.IsLocked = r.IsLocked s.IsLocked = r.Widget.IsLocked
s.CustomProperties = r.CustomProperties s.CustomProperties = r.Widget.CustomProperties
s.DashboardID = r.DashboardID s.DashboardID = r.Widget.DashboardID
return s return s
} }
@ -80,29 +80,29 @@ func (r *updateWidgetRequest) updatedWidget(oldWidget Widget) Widget {
// Use the old Widget as a basis for the updated Widget `s` // Use the old Widget as a basis for the updated Widget `s`
s := oldWidget s := oldWidget
if r.Name != "" { if r.Widget.Name != "" {
s.Name = r.Name s.Name = r.Widget.Name
} }
s.Type = r.Type s.Type = r.Widget.Type
s.Width = r.Width s.Width = r.Widget.Width
s.Height = r.Height s.Height = r.Widget.Height
s.MinWidth = r.MinWidth s.MinWidth = r.Widget.MinWidth
s.MinHeight = r.MinHeight s.MinHeight = r.Widget.MinHeight
s.X = r.X s.X = r.Widget.X
s.Y = r.Y s.Y = r.Widget.Y
s.Z = r.Z s.Z = r.Widget.Z
s.IsLocked = r.IsLocked s.IsLocked = r.Widget.IsLocked
// only update custom props if not empty // only update custom props if not empty
var emptyJson postgres.Jsonb var emptyJson postgres.Jsonb
// Serialize empty json and params // Serialize empty json and params
emptyJson_ser, _ := json.Marshal(emptyJson) emptyJson_ser, _ := json.Marshal(emptyJson)
customprops_ser, _ := json.Marshal(r.CustomProperties) customprops_ser, _ := json.Marshal(r.Widget.CustomProperties)
opts := jsondiff.DefaultConsoleOptions() opts := jsondiff.DefaultConsoleOptions()
diff, _ := jsondiff.Compare(emptyJson_ser, customprops_ser, &opts) diff, _ := jsondiff.Compare(emptyJson_ser, customprops_ser, &opts)
if diff.String() != "FullMatch" { if diff.String() != "FullMatch" {
s.CustomProperties = r.CustomProperties s.CustomProperties = r.Widget.CustomProperties
} }
return s return s