mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
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:
parent
4f62b52d9f
commit
a8a43f8512
19 changed files with 1534 additions and 186 deletions
519
doc/api/docs.go
519
doc/api/docs.go
|
@ -1,6 +1,6 @@
|
|||
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
||||
// 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
|
||||
|
||||
|
@ -16,7 +16,7 @@ var doc = `{
|
|||
"schemes": {{ marshal .Schemes }},
|
||||
"swagger": "2.0",
|
||||
"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",
|
||||
"contact": {
|
||||
"name": "Sonja Happ",
|
||||
|
@ -92,6 +92,13 @@ var doc = `{
|
|||
"summary": "Get all dashboards of scenario",
|
||||
"operationId": "getDashboards",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Scenario ID",
|
||||
|
@ -144,6 +151,13 @@ var doc = `{
|
|||
"summary": "Add a dashboard to a scenario",
|
||||
"operationId": "addDashboard",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Dashboard to be added incl. ID of Scenario",
|
||||
"name": "inputDab",
|
||||
|
@ -151,7 +165,7 @@ var doc = `{
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/dashboard.validNewDashboard"
|
||||
"$ref": "#/definitions/dashboard.addDashboardRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -205,6 +219,13 @@ var doc = `{
|
|||
"summary": "Get a dashboard",
|
||||
"operationId": "getDashboard",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Dashboard ID",
|
||||
|
@ -264,6 +285,13 @@ var doc = `{
|
|||
"summary": "Update a dashboard",
|
||||
"operationId": "updateDashboard",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Dashboard to be updated",
|
||||
"name": "inputDab",
|
||||
|
@ -271,7 +299,7 @@ var doc = `{
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/dashboard.validUpdatedDashboard"
|
||||
"$ref": "#/definitions/dashboard.updateDashboardRequest"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -330,6 +358,13 @@ var doc = `{
|
|||
"summary": "Delete a dashboard",
|
||||
"operationId": "deleteDashboard",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Dashboard ID",
|
||||
|
@ -388,6 +423,13 @@ var doc = `{
|
|||
"summary": "Get all files of a specific model or widget",
|
||||
"operationId": "getFiles",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"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",
|
||||
"operationId": "addFile",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"description": "File to be uploaded",
|
||||
|
@ -529,6 +578,13 @@ var doc = `{
|
|||
"summary": "Download a file",
|
||||
"operationId": "getFile",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "ID of the file to download",
|
||||
|
@ -593,6 +649,13 @@ var doc = `{
|
|||
"summary": "Update a file",
|
||||
"operationId": "updateFile",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"description": "File to be uploaded",
|
||||
|
@ -656,6 +719,13 @@ var doc = `{
|
|||
"summary": "Delete a file",
|
||||
"operationId": "deleteFile",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"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": {
|
||||
"get": {
|
||||
"produces": [
|
||||
|
@ -714,6 +817,13 @@ var doc = `{
|
|||
"summary": "Get all simulation models of scenario",
|
||||
"operationId": "getSimulationModels",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Scenario ID",
|
||||
|
@ -766,6 +876,13 @@ var doc = `{
|
|||
"summary": "Add a simulation model to a scenario",
|
||||
"operationId": "addSimulationModel",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Simulation model to be added incl. IDs of scenario and simulator",
|
||||
"name": "inputSimulationModel",
|
||||
|
@ -773,7 +890,7 @@ var doc = `{
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/simulationmodel.validNewSimulationModel"
|
||||
"$ref": "#/definitions/simulationmodel.addSimulationModelRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -827,6 +944,13 @@ var doc = `{
|
|||
"summary": "Get a simulation model",
|
||||
"operationId": "getSimulationModel",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Model ID",
|
||||
|
@ -886,6 +1010,13 @@ var doc = `{
|
|||
"summary": "Update a simulation model",
|
||||
"operationId": "updateSimulationModel",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Simulation model to be updated",
|
||||
"name": "inputSimulationModel",
|
||||
|
@ -893,7 +1024,7 @@ var doc = `{
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/simulationmodel.validUpdatedSimulationModel"
|
||||
"$ref": "#/definitions/simulationmodel.updateSimulationModelRequest"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -952,6 +1083,13 @@ var doc = `{
|
|||
"summary": "Delete a simulation model",
|
||||
"operationId": "deleteSimulationModel",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Model ID",
|
||||
|
@ -1009,6 +1147,15 @@ var doc = `{
|
|||
],
|
||||
"summary": "Get all scenarios of requesting user",
|
||||
"operationId": "getScenarios",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Scenarios to which user has access",
|
||||
|
@ -1053,6 +1200,13 @@ var doc = `{
|
|||
"summary": "Add a scenario",
|
||||
"operationId": "addScenario",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Scenario to be added",
|
||||
"name": "inputScenario",
|
||||
|
@ -1060,7 +1214,7 @@ var doc = `{
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/scenario.validNewScenario"
|
||||
"$ref": "#/definitions/scenario.addScenarioRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -1114,6 +1268,13 @@ var doc = `{
|
|||
"summary": "Get scenario",
|
||||
"operationId": "getScenario",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Scenario ID",
|
||||
|
@ -1166,6 +1327,13 @@ var doc = `{
|
|||
"summary": "Update a scenario",
|
||||
"operationId": "updateScenario",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Scenario to be updated",
|
||||
"name": "inputScenario",
|
||||
|
@ -1173,7 +1341,7 @@ var doc = `{
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/scenario.validUpdatedScenario"
|
||||
"$ref": "#/definitions/scenario.updateScenarioRequest"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -1232,6 +1400,13 @@ var doc = `{
|
|||
"summary": "Delete a scenario",
|
||||
"operationId": "deleteScenario",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Scenario ID",
|
||||
|
@ -1283,6 +1458,13 @@ var doc = `{
|
|||
"summary": "Add a user to a a scenario",
|
||||
"operationId": "addUserToScenario",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Scenario ID",
|
||||
|
@ -1339,6 +1521,13 @@ var doc = `{
|
|||
"summary": "Delete a user from a scenario",
|
||||
"operationId": "deleteUserFromScenario",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Scenario ID",
|
||||
|
@ -1397,6 +1586,13 @@ var doc = `{
|
|||
"summary": "Get users of a scenario",
|
||||
"operationId": "getUsersOfScenario",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Scenario ID",
|
||||
|
@ -1461,6 +1657,13 @@ var doc = `{
|
|||
"name": "modelID",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
|
@ -1507,6 +1710,13 @@ var doc = `{
|
|||
"summary": "Add a signal to a signal mapping of a model",
|
||||
"operationId": "AddSignal",
|
||||
"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",
|
||||
"name": "inputSignal",
|
||||
|
@ -1514,7 +1724,7 @@ var doc = `{
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/signal.validNewSignal"
|
||||
"$ref": "#/definitions/signal.addSignalRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -1568,6 +1778,13 @@ var doc = `{
|
|||
"summary": "Get a signal",
|
||||
"operationId": "getSignal",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "ID of signal to be obtained",
|
||||
|
@ -1624,6 +1841,13 @@ var doc = `{
|
|||
"summary": "Update a signal",
|
||||
"operationId": "updateSignal",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "A signal to be updated",
|
||||
"name": "inputSignal",
|
||||
|
@ -1631,7 +1855,7 @@ var doc = `{
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/signal.validUpdatedSignal"
|
||||
"$ref": "#/definitions/signal.updateSignalRequest"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -1690,6 +1914,13 @@ var doc = `{
|
|||
"summary": "Delete a signal",
|
||||
"operationId": "deleteSignal",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "ID of signal to be deleted",
|
||||
|
@ -1747,6 +1978,15 @@ var doc = `{
|
|||
],
|
||||
"summary": "Get all simulators",
|
||||
"operationId": "getSimulators",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Simulators requested",
|
||||
|
@ -1791,6 +2031,13 @@ var doc = `{
|
|||
"summary": "Add a simulator",
|
||||
"operationId": "addSimulator",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Simulator to be added",
|
||||
"name": "inputSimulator",
|
||||
|
@ -1798,7 +2045,7 @@ var doc = `{
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/simulator.validNewSimulator"
|
||||
"$ref": "#/definitions/simulator.addSimulatorRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -1852,6 +2099,13 @@ var doc = `{
|
|||
"summary": "Get simulator",
|
||||
"operationId": "getSimulator",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Simulator ID",
|
||||
|
@ -1911,6 +2165,13 @@ var doc = `{
|
|||
"summary": "Update a simulator",
|
||||
"operationId": "updateSimulator",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Simulator to be updated",
|
||||
"name": "inputSimulator",
|
||||
|
@ -1918,7 +2179,7 @@ var doc = `{
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/simulator.validUpdatedSimulator"
|
||||
"$ref": "#/definitions/simulator.updateSimulatorRequest"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -1977,6 +2238,13 @@ var doc = `{
|
|||
"summary": "Delete a simulator",
|
||||
"operationId": "deleteSimulator",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Simulator ID",
|
||||
|
@ -2100,6 +2368,13 @@ var doc = `{
|
|||
"summary": "Get all simulation models in which the simulator is used",
|
||||
"operationId": "getModelsOfSimulator",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Simulator ID",
|
||||
|
@ -2157,6 +2432,15 @@ var doc = `{
|
|||
],
|
||||
"summary": "Get all users",
|
||||
"operationId": "GetUsers",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Array of users",
|
||||
|
@ -2208,8 +2492,15 @@ var doc = `{
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/user.validNewUser"
|
||||
"$ref": "#/definitions/user.addUserRequest"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
|
@ -2255,6 +2546,13 @@ var doc = `{
|
|||
"summary": "Get user",
|
||||
"operationId": "GetUser",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "User ID",
|
||||
|
@ -2314,6 +2612,13 @@ var doc = `{
|
|||
"summary": "Update a user",
|
||||
"operationId": "UpdateUser",
|
||||
"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)",
|
||||
"name": "inputUser",
|
||||
|
@ -2321,7 +2626,7 @@ var doc = `{
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/user.validUpdatedRequest"
|
||||
"$ref": "#/definitions/user.updateUserRequest"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -2387,6 +2692,13 @@ var doc = `{
|
|||
"summary": "Delete a user",
|
||||
"operationId": "DeleteUser",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "User ID",
|
||||
|
@ -2438,6 +2750,13 @@ var doc = `{
|
|||
"summary": "Get all widgets of dashboard",
|
||||
"operationId": "getWidgets",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Dashboard ID",
|
||||
|
@ -2490,6 +2809,13 @@ var doc = `{
|
|||
"summary": "Add a widget to a dashboard",
|
||||
"operationId": "addWidget",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Widget to be added incl. ID of dashboard",
|
||||
"name": "inputWidget",
|
||||
|
@ -2497,7 +2823,7 @@ var doc = `{
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/widget.validNewWidget"
|
||||
"$ref": "#/definitions/widget.addWidgetRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -2551,6 +2877,13 @@ var doc = `{
|
|||
"summary": "Get a widget",
|
||||
"operationId": "getWidget",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Widget ID",
|
||||
|
@ -2610,6 +2943,13 @@ var doc = `{
|
|||
"summary": "Update a widget",
|
||||
"operationId": "updateWidget",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Widget to be updated",
|
||||
"name": "inputWidget",
|
||||
|
@ -2617,7 +2957,7 @@ var doc = `{
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/widget.validUpdatedWidget"
|
||||
"$ref": "#/definitions/widget.updateWidgetRequest"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -2676,6 +3016,13 @@ var doc = `{
|
|||
"summary": "Delete a widget",
|
||||
"operationId": "deleteWidget",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Widget ID",
|
||||
|
@ -2725,6 +3072,24 @@ var doc = `{
|
|||
}
|
||||
},
|
||||
"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": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -2747,10 +3112,10 @@ var doc = `{
|
|||
"dashboard.validUpdatedDashboard": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Grid": {
|
||||
"grid": {
|
||||
"type": "integer"
|
||||
},
|
||||
"Name": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
|
@ -2938,6 +3303,10 @@ var doc = `{
|
|||
"database.User": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"active": {
|
||||
"description": "Indicating status of user (false means user is inactive and should not be able to login)",
|
||||
"type": "boolean"
|
||||
},
|
||||
"id": {
|
||||
"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": {
|
||||
"type": "object",
|
||||
"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": {
|
||||
"type": "object",
|
||||
"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": {
|
||||
"type": "object",
|
||||
"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": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -3355,6 +3796,15 @@ var doc = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"user.addUserRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"user": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/user.validNewUser"
|
||||
}
|
||||
}
|
||||
},
|
||||
"user.loginRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -3370,6 +3820,15 @@ var doc = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"user.updateUserRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"user": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/user.validUpdatedRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
"user.validNewUser": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -3396,9 +3855,15 @@ var doc = `{
|
|||
"user.validUpdatedRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Active": {
|
||||
"type": "string"
|
||||
},
|
||||
"Mail": {
|
||||
"type": "string"
|
||||
},
|
||||
"OldPassword": {
|
||||
"type": "string"
|
||||
},
|
||||
"Password": {
|
||||
"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": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"swagger": "2.0",
|
||||
"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",
|
||||
"contact": {
|
||||
"name": "Sonja Happ",
|
||||
|
@ -77,6 +77,13 @@
|
|||
"summary": "Get all dashboards of scenario",
|
||||
"operationId": "getDashboards",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Scenario ID",
|
||||
|
@ -129,6 +136,13 @@
|
|||
"summary": "Add a dashboard to a scenario",
|
||||
"operationId": "addDashboard",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Dashboard to be added incl. ID of Scenario",
|
||||
"name": "inputDab",
|
||||
|
@ -136,7 +150,7 @@
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/dashboard.validNewDashboard"
|
||||
"$ref": "#/definitions/dashboard.addDashboardRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -190,6 +204,13 @@
|
|||
"summary": "Get a dashboard",
|
||||
"operationId": "getDashboard",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Dashboard ID",
|
||||
|
@ -249,6 +270,13 @@
|
|||
"summary": "Update a dashboard",
|
||||
"operationId": "updateDashboard",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Dashboard to be updated",
|
||||
"name": "inputDab",
|
||||
|
@ -256,7 +284,7 @@
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/dashboard.validUpdatedDashboard"
|
||||
"$ref": "#/definitions/dashboard.updateDashboardRequest"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -315,6 +343,13 @@
|
|||
"summary": "Delete a dashboard",
|
||||
"operationId": "deleteDashboard",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Dashboard ID",
|
||||
|
@ -373,6 +408,13 @@
|
|||
"summary": "Get all files of a specific model or widget",
|
||||
"operationId": "getFiles",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"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",
|
||||
"operationId": "addFile",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"description": "File to be uploaded",
|
||||
|
@ -514,6 +563,13 @@
|
|||
"summary": "Download a file",
|
||||
"operationId": "getFile",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "ID of the file to download",
|
||||
|
@ -578,6 +634,13 @@
|
|||
"summary": "Update a file",
|
||||
"operationId": "updateFile",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"description": "File to be uploaded",
|
||||
|
@ -641,6 +704,13 @@
|
|||
"summary": "Delete a file",
|
||||
"operationId": "deleteFile",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"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": {
|
||||
"get": {
|
||||
"produces": [
|
||||
|
@ -699,6 +802,13 @@
|
|||
"summary": "Get all simulation models of scenario",
|
||||
"operationId": "getSimulationModels",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Scenario ID",
|
||||
|
@ -751,6 +861,13 @@
|
|||
"summary": "Add a simulation model to a scenario",
|
||||
"operationId": "addSimulationModel",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Simulation model to be added incl. IDs of scenario and simulator",
|
||||
"name": "inputSimulationModel",
|
||||
|
@ -758,7 +875,7 @@
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/simulationmodel.validNewSimulationModel"
|
||||
"$ref": "#/definitions/simulationmodel.addSimulationModelRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -812,6 +929,13 @@
|
|||
"summary": "Get a simulation model",
|
||||
"operationId": "getSimulationModel",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Model ID",
|
||||
|
@ -871,6 +995,13 @@
|
|||
"summary": "Update a simulation model",
|
||||
"operationId": "updateSimulationModel",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Simulation model to be updated",
|
||||
"name": "inputSimulationModel",
|
||||
|
@ -878,7 +1009,7 @@
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/simulationmodel.validUpdatedSimulationModel"
|
||||
"$ref": "#/definitions/simulationmodel.updateSimulationModelRequest"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -937,6 +1068,13 @@
|
|||
"summary": "Delete a simulation model",
|
||||
"operationId": "deleteSimulationModel",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Model ID",
|
||||
|
@ -994,6 +1132,15 @@
|
|||
],
|
||||
"summary": "Get all scenarios of requesting user",
|
||||
"operationId": "getScenarios",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Scenarios to which user has access",
|
||||
|
@ -1038,6 +1185,13 @@
|
|||
"summary": "Add a scenario",
|
||||
"operationId": "addScenario",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Scenario to be added",
|
||||
"name": "inputScenario",
|
||||
|
@ -1045,7 +1199,7 @@
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/scenario.validNewScenario"
|
||||
"$ref": "#/definitions/scenario.addScenarioRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -1099,6 +1253,13 @@
|
|||
"summary": "Get scenario",
|
||||
"operationId": "getScenario",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Scenario ID",
|
||||
|
@ -1151,6 +1312,13 @@
|
|||
"summary": "Update a scenario",
|
||||
"operationId": "updateScenario",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Scenario to be updated",
|
||||
"name": "inputScenario",
|
||||
|
@ -1158,7 +1326,7 @@
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/scenario.validUpdatedScenario"
|
||||
"$ref": "#/definitions/scenario.updateScenarioRequest"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -1217,6 +1385,13 @@
|
|||
"summary": "Delete a scenario",
|
||||
"operationId": "deleteScenario",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Scenario ID",
|
||||
|
@ -1268,6 +1443,13 @@
|
|||
"summary": "Add a user to a a scenario",
|
||||
"operationId": "addUserToScenario",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Scenario ID",
|
||||
|
@ -1324,6 +1506,13 @@
|
|||
"summary": "Delete a user from a scenario",
|
||||
"operationId": "deleteUserFromScenario",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Scenario ID",
|
||||
|
@ -1382,6 +1571,13 @@
|
|||
"summary": "Get users of a scenario",
|
||||
"operationId": "getUsersOfScenario",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Scenario ID",
|
||||
|
@ -1446,6 +1642,13 @@
|
|||
"name": "modelID",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
|
@ -1492,6 +1695,13 @@
|
|||
"summary": "Add a signal to a signal mapping of a model",
|
||||
"operationId": "AddSignal",
|
||||
"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",
|
||||
"name": "inputSignal",
|
||||
|
@ -1499,7 +1709,7 @@
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/signal.validNewSignal"
|
||||
"$ref": "#/definitions/signal.addSignalRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -1553,6 +1763,13 @@
|
|||
"summary": "Get a signal",
|
||||
"operationId": "getSignal",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "ID of signal to be obtained",
|
||||
|
@ -1609,6 +1826,13 @@
|
|||
"summary": "Update a signal",
|
||||
"operationId": "updateSignal",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "A signal to be updated",
|
||||
"name": "inputSignal",
|
||||
|
@ -1616,7 +1840,7 @@
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/signal.validUpdatedSignal"
|
||||
"$ref": "#/definitions/signal.updateSignalRequest"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -1675,6 +1899,13 @@
|
|||
"summary": "Delete a signal",
|
||||
"operationId": "deleteSignal",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "ID of signal to be deleted",
|
||||
|
@ -1732,6 +1963,15 @@
|
|||
],
|
||||
"summary": "Get all simulators",
|
||||
"operationId": "getSimulators",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Simulators requested",
|
||||
|
@ -1776,6 +2016,13 @@
|
|||
"summary": "Add a simulator",
|
||||
"operationId": "addSimulator",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Simulator to be added",
|
||||
"name": "inputSimulator",
|
||||
|
@ -1783,7 +2030,7 @@
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/simulator.validNewSimulator"
|
||||
"$ref": "#/definitions/simulator.addSimulatorRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -1837,6 +2084,13 @@
|
|||
"summary": "Get simulator",
|
||||
"operationId": "getSimulator",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Simulator ID",
|
||||
|
@ -1896,6 +2150,13 @@
|
|||
"summary": "Update a simulator",
|
||||
"operationId": "updateSimulator",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Simulator to be updated",
|
||||
"name": "inputSimulator",
|
||||
|
@ -1903,7 +2164,7 @@
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/simulator.validUpdatedSimulator"
|
||||
"$ref": "#/definitions/simulator.updateSimulatorRequest"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -1962,6 +2223,13 @@
|
|||
"summary": "Delete a simulator",
|
||||
"operationId": "deleteSimulator",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Simulator ID",
|
||||
|
@ -2085,6 +2353,13 @@
|
|||
"summary": "Get all simulation models in which the simulator is used",
|
||||
"operationId": "getModelsOfSimulator",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Simulator ID",
|
||||
|
@ -2142,6 +2417,15 @@
|
|||
],
|
||||
"summary": "Get all users",
|
||||
"operationId": "GetUsers",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Array of users",
|
||||
|
@ -2193,8 +2477,15 @@
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/user.validNewUser"
|
||||
"$ref": "#/definitions/user.addUserRequest"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
|
@ -2240,6 +2531,13 @@
|
|||
"summary": "Get user",
|
||||
"operationId": "GetUser",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "User ID",
|
||||
|
@ -2299,6 +2597,13 @@
|
|||
"summary": "Update a user",
|
||||
"operationId": "UpdateUser",
|
||||
"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)",
|
||||
"name": "inputUser",
|
||||
|
@ -2306,7 +2611,7 @@
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/user.validUpdatedRequest"
|
||||
"$ref": "#/definitions/user.updateUserRequest"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -2372,6 +2677,13 @@
|
|||
"summary": "Delete a user",
|
||||
"operationId": "DeleteUser",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "User ID",
|
||||
|
@ -2423,6 +2735,13 @@
|
|||
"summary": "Get all widgets of dashboard",
|
||||
"operationId": "getWidgets",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Dashboard ID",
|
||||
|
@ -2475,6 +2794,13 @@
|
|||
"summary": "Add a widget to a dashboard",
|
||||
"operationId": "addWidget",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Widget to be added incl. ID of dashboard",
|
||||
"name": "inputWidget",
|
||||
|
@ -2482,7 +2808,7 @@
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/widget.validNewWidget"
|
||||
"$ref": "#/definitions/widget.addWidgetRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -2536,6 +2862,13 @@
|
|||
"summary": "Get a widget",
|
||||
"operationId": "getWidget",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Widget ID",
|
||||
|
@ -2595,6 +2928,13 @@
|
|||
"summary": "Update a widget",
|
||||
"operationId": "updateWidget",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Widget to be updated",
|
||||
"name": "inputWidget",
|
||||
|
@ -2602,7 +2942,7 @@
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/widget.validUpdatedWidget"
|
||||
"$ref": "#/definitions/widget.updateWidgetRequest"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -2661,6 +3001,13 @@
|
|||
"summary": "Delete a widget",
|
||||
"operationId": "deleteWidget",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Widget ID",
|
||||
|
@ -2710,6 +3057,24 @@
|
|||
}
|
||||
},
|
||||
"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": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -2732,10 +3097,10 @@
|
|||
"dashboard.validUpdatedDashboard": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Grid": {
|
||||
"grid": {
|
||||
"type": "integer"
|
||||
},
|
||||
"Name": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
|
@ -2923,6 +3288,10 @@
|
|||
"database.User": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"active": {
|
||||
"description": "Indicating status of user (false means user is inactive and should not be able to login)",
|
||||
"type": "boolean"
|
||||
},
|
||||
"id": {
|
||||
"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": {
|
||||
"type": "object",
|
||||
"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": {
|
||||
"type": "object",
|
||||
"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": {
|
||||
"type": "object",
|
||||
"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": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -3340,6 +3781,15 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"user.addUserRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"user": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/user.validNewUser"
|
||||
}
|
||||
}
|
||||
},
|
||||
"user.loginRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -3355,6 +3805,15 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"user.updateUserRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"user": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/user.validUpdatedRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
"user.validNewUser": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -3381,9 +3840,15 @@
|
|||
"user.validUpdatedRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Active": {
|
||||
"type": "string"
|
||||
},
|
||||
"Mail": {
|
||||
"type": "string"
|
||||
},
|
||||
"OldPassword": {
|
||||
"type": "string"
|
||||
},
|
||||
"Password": {
|
||||
"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": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
@ -1,5 +1,17 @@
|
|||
basePath: /api/v2
|
||||
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:
|
||||
properties:
|
||||
Grid:
|
||||
|
@ -15,9 +27,9 @@ definitions:
|
|||
type: object
|
||||
dashboard.validUpdatedDashboard:
|
||||
properties:
|
||||
Grid:
|
||||
grid:
|
||||
type: integer
|
||||
Name:
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
database.Dashboard:
|
||||
|
@ -151,6 +163,10 @@ definitions:
|
|||
type: object
|
||||
database.User:
|
||||
properties:
|
||||
active:
|
||||
description: Indicating status of user (false means user is inactive and should
|
||||
not be able to login)
|
||||
type: boolean
|
||||
id:
|
||||
type: integer
|
||||
mail:
|
||||
|
@ -327,6 +343,18 @@ definitions:
|
|||
$ref: '#/definitions/database.Widget'
|
||||
type: array
|
||||
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:
|
||||
properties:
|
||||
Name:
|
||||
|
@ -348,6 +376,18 @@ definitions:
|
|||
StartParameters:
|
||||
type: string
|
||||
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:
|
||||
properties:
|
||||
Direction:
|
||||
|
@ -375,6 +415,18 @@ definitions:
|
|||
Unit:
|
||||
type: string
|
||||
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:
|
||||
properties:
|
||||
Name:
|
||||
|
@ -400,6 +452,18 @@ definitions:
|
|||
StartParameters:
|
||||
type: string
|
||||
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:
|
||||
properties:
|
||||
Host:
|
||||
|
@ -431,6 +495,12 @@ definitions:
|
|||
UUID:
|
||||
type: string
|
||||
type: object
|
||||
user.addUserRequest:
|
||||
properties:
|
||||
user:
|
||||
$ref: '#/definitions/user.validNewUser'
|
||||
type: object
|
||||
type: object
|
||||
user.loginRequest:
|
||||
properties:
|
||||
Password:
|
||||
|
@ -441,6 +511,12 @@ definitions:
|
|||
- Password
|
||||
- Username
|
||||
type: object
|
||||
user.updateUserRequest:
|
||||
properties:
|
||||
user:
|
||||
$ref: '#/definitions/user.validUpdatedRequest'
|
||||
type: object
|
||||
type: object
|
||||
user.validNewUser:
|
||||
properties:
|
||||
Mail:
|
||||
|
@ -459,8 +535,12 @@ definitions:
|
|||
type: object
|
||||
user.validUpdatedRequest:
|
||||
properties:
|
||||
Active:
|
||||
type: string
|
||||
Mail:
|
||||
type: string
|
||||
OldPassword:
|
||||
type: string
|
||||
Password:
|
||||
type: string
|
||||
Role:
|
||||
|
@ -468,6 +548,18 @@ definitions:
|
|||
Username:
|
||||
type: string
|
||||
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:
|
||||
properties:
|
||||
CustomProperties:
|
||||
|
@ -532,9 +624,8 @@ info:
|
|||
email: sonja.happ@eonerc.rwth-aachen.de
|
||||
name: Sonja Happ
|
||||
description: |-
|
||||
This is the API of the VILLASweb Backend
|
||||
WORK IN PROGRESS! PLEASE BE PATIENT!
|
||||
The tool https://github.com/swaggo/swag is used to auto-generate API docs for gin.
|
||||
This is the VILLASweb Backend API v2.0.
|
||||
Parts of this API are still in development. Please check https://git.rwth-aachen.de/acs/public/villas/web-backend-go for more information.
|
||||
license:
|
||||
name: GNU GPL 3.0
|
||||
url: http://www.gnu.de/documents/gpl-3.0.en.html
|
||||
|
@ -580,6 +671,11 @@ paths:
|
|||
get:
|
||||
operationId: getDashboards
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Scenario ID
|
||||
in: query
|
||||
name: scenarioID
|
||||
|
@ -616,12 +712,17 @@ paths:
|
|||
- application/json
|
||||
operationId: addDashboard
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Dashboard to be added incl. ID of Scenario
|
||||
in: body
|
||||
name: inputDab
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dashboard.validNewDashboard'
|
||||
$ref: '#/definitions/dashboard.addDashboardRequest'
|
||||
type: object
|
||||
produces:
|
||||
- application/json
|
||||
|
@ -658,6 +759,11 @@ paths:
|
|||
delete:
|
||||
operationId: deleteDashboard
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Dashboard ID
|
||||
in: path
|
||||
name: dashboardID
|
||||
|
@ -697,6 +803,11 @@ paths:
|
|||
get:
|
||||
operationId: getDashboard
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Dashboard ID
|
||||
in: path
|
||||
name: dashboardID
|
||||
|
@ -738,12 +849,17 @@ paths:
|
|||
- application/json
|
||||
operationId: updateDashboard
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Dashboard to be updated
|
||||
in: body
|
||||
name: inputDab
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dashboard.validUpdatedDashboard'
|
||||
$ref: '#/definitions/dashboard.updateDashboardRequest'
|
||||
type: object
|
||||
- description: Dashboard ID
|
||||
in: path
|
||||
|
@ -785,6 +901,11 @@ paths:
|
|||
get:
|
||||
operationId: getFiles
|
||||
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
|
||||
in: query
|
||||
name: objectType
|
||||
|
@ -831,6 +952,11 @@ paths:
|
|||
- model/x-cim.zip
|
||||
operationId: addFile
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: File to be uploaded
|
||||
in: formData
|
||||
name: inputFile
|
||||
|
@ -881,6 +1007,11 @@ paths:
|
|||
delete:
|
||||
operationId: deleteFile
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: ID of the file to update
|
||||
in: path
|
||||
name: fileID
|
||||
|
@ -920,6 +1051,11 @@ paths:
|
|||
get:
|
||||
operationId: getFile
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: ID of the file to download
|
||||
in: path
|
||||
name: fileID
|
||||
|
@ -971,6 +1107,11 @@ paths:
|
|||
- model/x-cim.zip
|
||||
operationId: updateFile
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: File to be uploaded
|
||||
in: formData
|
||||
name: inputFile
|
||||
|
@ -1012,10 +1153,38 @@ paths:
|
|||
summary: Update a file
|
||||
tags:
|
||||
- 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:
|
||||
get:
|
||||
operationId: getSimulationModels
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Scenario ID
|
||||
in: query
|
||||
name: scenarioID
|
||||
|
@ -1052,12 +1221,17 @@ paths:
|
|||
- application/json
|
||||
operationId: addSimulationModel
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Simulation model to be added incl. IDs of scenario and simulator
|
||||
in: body
|
||||
name: inputSimulationModel
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/simulationmodel.validNewSimulationModel'
|
||||
$ref: '#/definitions/simulationmodel.addSimulationModelRequest'
|
||||
type: object
|
||||
produces:
|
||||
- application/json
|
||||
|
@ -1094,6 +1268,11 @@ paths:
|
|||
delete:
|
||||
operationId: deleteSimulationModel
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Model ID
|
||||
in: path
|
||||
name: modelID
|
||||
|
@ -1133,6 +1312,11 @@ paths:
|
|||
get:
|
||||
operationId: getSimulationModel
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Model ID
|
||||
in: path
|
||||
name: modelID
|
||||
|
@ -1174,12 +1358,17 @@ paths:
|
|||
- application/json
|
||||
operationId: updateSimulationModel
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Simulation model to be updated
|
||||
in: body
|
||||
name: inputSimulationModel
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/simulationmodel.validUpdatedSimulationModel'
|
||||
$ref: '#/definitions/simulationmodel.updateSimulationModelRequest'
|
||||
type: object
|
||||
- description: Model ID
|
||||
in: path
|
||||
|
@ -1220,6 +1409,12 @@ paths:
|
|||
/scenarios:
|
||||
get:
|
||||
operationId: getScenarios
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
|
@ -1251,12 +1446,17 @@ paths:
|
|||
- application/json
|
||||
operationId: addScenario
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Scenario to be added
|
||||
in: body
|
||||
name: inputScenario
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/scenario.validNewScenario'
|
||||
$ref: '#/definitions/scenario.addScenarioRequest'
|
||||
type: object
|
||||
produces:
|
||||
- application/json
|
||||
|
@ -1293,6 +1493,11 @@ paths:
|
|||
delete:
|
||||
operationId: deleteScenario
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Scenario ID
|
||||
in: path
|
||||
name: scenarioID
|
||||
|
@ -1327,6 +1532,11 @@ paths:
|
|||
get:
|
||||
operationId: getScenario
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Scenario ID
|
||||
in: path
|
||||
name: scenarioID
|
||||
|
@ -1363,12 +1573,17 @@ paths:
|
|||
- application/json
|
||||
operationId: updateScenario
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Scenario to be updated
|
||||
in: body
|
||||
name: inputScenario
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/scenario.validUpdatedScenario'
|
||||
$ref: '#/definitions/scenario.updateScenarioRequest'
|
||||
type: object
|
||||
- description: Scenario ID
|
||||
in: path
|
||||
|
@ -1410,6 +1625,11 @@ paths:
|
|||
delete:
|
||||
operationId: deleteUserFromScenario
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Scenario ID
|
||||
in: path
|
||||
name: scenarioID
|
||||
|
@ -1449,6 +1669,11 @@ paths:
|
|||
put:
|
||||
operationId: addUserToScenario
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Scenario ID
|
||||
in: path
|
||||
name: scenarioID
|
||||
|
@ -1489,6 +1714,11 @@ paths:
|
|||
get:
|
||||
operationId: getUsersOfScenario
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Scenario ID
|
||||
in: path
|
||||
name: scenarioID
|
||||
|
@ -1534,6 +1764,11 @@ paths:
|
|||
name: modelID
|
||||
required: true
|
||||
type: string
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
|
@ -1565,13 +1800,18 @@ paths:
|
|||
- application/json
|
||||
operationId: AddSignal
|
||||
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
|
||||
to which signal shall be added
|
||||
in: body
|
||||
name: inputSignal
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/signal.validNewSignal'
|
||||
$ref: '#/definitions/signal.addSignalRequest'
|
||||
type: object
|
||||
produces:
|
||||
- application/json
|
||||
|
@ -1608,6 +1848,11 @@ paths:
|
|||
delete:
|
||||
operationId: deleteSignal
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: ID of signal to be deleted
|
||||
in: path
|
||||
name: signalID
|
||||
|
@ -1647,6 +1892,11 @@ paths:
|
|||
get:
|
||||
operationId: getSignal
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: ID of signal to be obtained
|
||||
in: path
|
||||
name: signalID
|
||||
|
@ -1686,12 +1936,17 @@ paths:
|
|||
put:
|
||||
operationId: updateSignal
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: A signal to be updated
|
||||
in: body
|
||||
name: inputSignal
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/signal.validUpdatedSignal'
|
||||
$ref: '#/definitions/signal.updateSignalRequest'
|
||||
type: object
|
||||
- description: ID of signal to be updated
|
||||
in: path
|
||||
|
@ -1732,6 +1987,12 @@ paths:
|
|||
/simulators:
|
||||
get:
|
||||
operationId: getSimulators
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
|
@ -1763,12 +2024,17 @@ paths:
|
|||
- application/json
|
||||
operationId: addSimulator
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Simulator to be added
|
||||
in: body
|
||||
name: inputSimulator
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/simulator.validNewSimulator'
|
||||
$ref: '#/definitions/simulator.addSimulatorRequest'
|
||||
type: object
|
||||
produces:
|
||||
- application/json
|
||||
|
@ -1805,6 +2071,11 @@ paths:
|
|||
delete:
|
||||
operationId: deleteSimulator
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Simulator ID
|
||||
in: path
|
||||
name: simulatorID
|
||||
|
@ -1844,6 +2115,11 @@ paths:
|
|||
get:
|
||||
operationId: getSimulator
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Simulator ID
|
||||
in: path
|
||||
name: simulatorID
|
||||
|
@ -1885,12 +2161,17 @@ paths:
|
|||
- application/json
|
||||
operationId: updateSimulator
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Simulator to be updated
|
||||
in: body
|
||||
name: inputSimulator
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/simulator.validUpdatedSimulator'
|
||||
$ref: '#/definitions/simulator.updateSimulatorRequest'
|
||||
type: object
|
||||
- description: Simulator ID
|
||||
in: path
|
||||
|
@ -1978,6 +2259,11 @@ paths:
|
|||
get:
|
||||
operationId: getModelsOfSimulator
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Simulator ID
|
||||
in: path
|
||||
name: simulatorID
|
||||
|
@ -2017,6 +2303,12 @@ paths:
|
|||
/users:
|
||||
get:
|
||||
operationId: GetUsers
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
|
@ -2053,8 +2345,13 @@ paths:
|
|||
name: inputUser
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/user.validNewUser'
|
||||
$ref: '#/definitions/user.addUserRequest'
|
||||
type: object
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
|
@ -2085,6 +2382,11 @@ paths:
|
|||
delete:
|
||||
operationId: DeleteUser
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: User ID
|
||||
in: path
|
||||
name: userID
|
||||
|
@ -2119,6 +2421,11 @@ paths:
|
|||
get:
|
||||
operationId: GetUser
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: User ID
|
||||
in: path
|
||||
name: userID
|
||||
|
@ -2160,13 +2467,18 @@ paths:
|
|||
- application/json
|
||||
operationId: UpdateUser
|
||||
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
|
||||
can only be change by admin)
|
||||
in: body
|
||||
name: inputUser
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/user.validUpdatedRequest'
|
||||
$ref: '#/definitions/user.updateUserRequest'
|
||||
type: object
|
||||
- description: User ID
|
||||
in: path
|
||||
|
@ -2213,6 +2525,11 @@ paths:
|
|||
get:
|
||||
operationId: getWidgets
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Dashboard ID
|
||||
in: query
|
||||
name: dashboardID
|
||||
|
@ -2249,12 +2566,17 @@ paths:
|
|||
- application/json
|
||||
operationId: addWidget
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Widget to be added incl. ID of dashboard
|
||||
in: body
|
||||
name: inputWidget
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/widget.validNewWidget'
|
||||
$ref: '#/definitions/widget.addWidgetRequest'
|
||||
type: object
|
||||
produces:
|
||||
- application/json
|
||||
|
@ -2291,6 +2613,11 @@ paths:
|
|||
delete:
|
||||
operationId: deleteWidget
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Widget ID
|
||||
in: path
|
||||
name: widgetID
|
||||
|
@ -2330,6 +2657,11 @@ paths:
|
|||
get:
|
||||
operationId: getWidget
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Widget ID
|
||||
in: path
|
||||
name: widgetID
|
||||
|
@ -2371,12 +2703,17 @@ paths:
|
|||
- application/json
|
||||
operationId: updateWidget
|
||||
parameters:
|
||||
- description: Authorization token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Widget to be updated
|
||||
in: body
|
||||
name: inputWidget
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/widget.validUpdatedWidget'
|
||||
$ref: '#/definitions/widget.updateWidgetRequest'
|
||||
type: object
|
||||
- description: Widget ID
|
||||
in: path
|
||||
|
|
|
@ -28,6 +28,7 @@ func RegisterDashboardEndpoints(r *gin.RouterGroup) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Param scenarioID query int true "Scenario ID"
|
||||
// @Router /dashboards [get]
|
||||
func getDashboards(c *gin.Context) {
|
||||
|
@ -52,12 +53,13 @@ func getDashboards(c *gin.Context) {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @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"
|
||||
// @Failure 400 {object} docs.ResponseError "Bad request"
|
||||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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]
|
||||
func addDashboard(c *gin.Context) {
|
||||
|
||||
|
@ -97,12 +99,13 @@ func addDashboard(c *gin.Context) {
|
|||
// @Tags dashboards
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param inputDab body dashboard.validUpdatedDashboard true "Dashboard to be updated"
|
||||
// @Success 200 {object} docs.ResponseDashboard "Dashboard that was updated"
|
||||
// @Failure 400 {object} docs.ResponseError "Bad request"
|
||||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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"
|
||||
// @Router /dashboards/{dashboardID} [put]
|
||||
func updateDashboard(c *gin.Context) {
|
||||
|
@ -119,7 +122,7 @@ func updateDashboard(c *gin.Context) {
|
|||
}
|
||||
|
||||
// Validate the request
|
||||
if err := req.validate(); err != nil {
|
||||
if err := req.Dashboard.validate(); err != nil {
|
||||
helper.BadRequestError(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
@ -144,6 +147,7 @@ func updateDashboard(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Param dashboardID path int true "Dashboard ID"
|
||||
// @Router /dashboards/{dashboardID} [get]
|
||||
func getDashboard(c *gin.Context) {
|
||||
|
@ -166,6 +170,7 @@ func getDashboard(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Param dashboardID path int true "Dashboard ID"
|
||||
// @Router /dashboards/{dashboardID} [delete]
|
||||
func deleteDashboard(c *gin.Context) {
|
||||
|
|
|
@ -13,16 +13,16 @@ type validNewDashboard struct {
|
|||
}
|
||||
|
||||
type validUpdatedDashboard struct {
|
||||
Name string `form:"Name" validate:"omitempty"`
|
||||
Grid int `form:"Grid" validate:"omitempty"`
|
||||
Name string `form:"Name" validate:"omitempty" json:"name"`
|
||||
Grid int `form:"Grid" validate:"omitempty" json:"grid"`
|
||||
}
|
||||
|
||||
type addDashboardRequest struct {
|
||||
validNewDashboard `json:"dashboard"`
|
||||
Dashboard validNewDashboard `json:"dashboard"`
|
||||
}
|
||||
|
||||
type updateDashboardRequest struct {
|
||||
validUpdatedDashboard `json:"dashboard"`
|
||||
Dashboard validUpdatedDashboard `json:"dashboard"`
|
||||
}
|
||||
|
||||
func (r *addDashboardRequest) validate() error {
|
||||
|
@ -40,9 +40,9 @@ func (r *validUpdatedDashboard) validate() error {
|
|||
func (r *addDashboardRequest) createDashboard() Dashboard {
|
||||
var s Dashboard
|
||||
|
||||
s.Name = r.Name
|
||||
s.Grid = r.Grid
|
||||
s.ScenarioID = r.ScenarioID
|
||||
s.Name = r.Dashboard.Name
|
||||
s.Grid = r.Dashboard.Grid
|
||||
s.ScenarioID = r.Dashboard.ScenarioID
|
||||
|
||||
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`
|
||||
s := oldDashboard
|
||||
|
||||
if r.Name != "" {
|
||||
s.Name = r.Name
|
||||
if r.Dashboard.Name != "" {
|
||||
s.Name = r.Dashboard.Name
|
||||
}
|
||||
|
||||
if r.Grid != 0 {
|
||||
s.Grid = r.Grid
|
||||
if r.Dashboard.Grid != 0 {
|
||||
s.Grid = r.Dashboard.Grid
|
||||
}
|
||||
|
||||
return s
|
||||
|
|
|
@ -30,6 +30,7 @@ func RegisterFileEndpoints(r *gin.RouterGroup) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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 objectID query int true "ID of either model or widget of which files are requested"
|
||||
// @Router /files [get]
|
||||
|
@ -94,6 +95,7 @@ func getFiles(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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 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"
|
||||
|
@ -156,6 +158,7 @@ func addFile(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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"
|
||||
// @Router /files/{fileID} [get]
|
||||
func getFile(c *gin.Context) {
|
||||
|
@ -186,6 +189,7 @@ func getFile(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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 fileID path int true "ID of the file to update"
|
||||
// @Router /files/{fileID} [put]
|
||||
|
@ -220,6 +224,7 @@ func updateFile(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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"
|
||||
// @Router /files/{fileID} [delete]
|
||||
func deleteFile(c *gin.Context) {
|
||||
|
|
|
@ -20,6 +20,7 @@ func RegisterHealthzEndpoint(r *gin.RouterGroup) {
|
|||
// @Tags healthz
|
||||
// @Success 200 "Backend is healthy, database and AMQP broker connections are alive"
|
||||
// @Failure 500 {object} docs.ResponseError "Backend is NOT healthy"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Router /healthz [get]
|
||||
func getHealth(c *gin.Context) {
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ func RegisterScenarioEndpoints(r *gin.RouterGroup) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Router /scenarios [get]
|
||||
func getScenarios(c *gin.Context) {
|
||||
|
||||
|
@ -70,12 +71,13 @@ func getScenarios(c *gin.Context) {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Tags scenarios
|
||||
// @Param inputScenario body scenario.validNewScenario true "Scenario to be added"
|
||||
// @Success 200 {object} docs.ResponseScenario "scenario that was added"
|
||||
// @Failure 400 {object} docs.ResponseError "Bad request"
|
||||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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]
|
||||
func addScenario(c *gin.Context) {
|
||||
|
||||
|
@ -128,12 +130,13 @@ func addScenario(c *gin.Context) {
|
|||
// @Tags scenarios
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param inputScenario body scenario.validUpdatedScenario true "Scenario to be updated"
|
||||
// @Success 200 {object} docs.ResponseScenario "Updated scenario."
|
||||
// @Failure 400 {object} docs.ResponseError "Bad request"
|
||||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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"
|
||||
// @Router /scenarios/{scenarioID} [put]
|
||||
func updateScenario(c *gin.Context) {
|
||||
|
@ -151,7 +154,7 @@ func updateScenario(c *gin.Context) {
|
|||
}
|
||||
|
||||
// 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())
|
||||
return
|
||||
}
|
||||
|
@ -177,6 +180,7 @@ func updateScenario(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Param scenarioID path int true "Scenario ID"
|
||||
// @Router /scenarios/{scenarioID} [get]
|
||||
func getScenario(c *gin.Context) {
|
||||
|
@ -199,6 +203,7 @@ func getScenario(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Param scenarioID path int true "Scenario ID"
|
||||
// @Router /scenarios/{scenarioID} [delete]
|
||||
func deleteScenario(c *gin.Context) {
|
||||
|
@ -225,6 +230,7 @@ func deleteScenario(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Param scenarioID path int true "Scenario ID"
|
||||
// @Router /scenarios/{scenarioID}/users/ [get]
|
||||
func getUsersOfScenario(c *gin.Context) {
|
||||
|
@ -252,6 +258,7 @@ func getUsersOfScenario(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Param scenarioID path int true "Scenario ID"
|
||||
// @Param username query string true "User name"
|
||||
// @Router /scenarios/{scenarioID}/user [put]
|
||||
|
@ -292,6 +299,7 @@ func addUserToScenario(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Param scenarioID path int true "Scenario ID"
|
||||
// @Param username query string true "User name"
|
||||
// @Router /scenarios/{scenarioID}/user [delete]
|
||||
|
|
|
@ -22,11 +22,11 @@ type validUpdatedScenario struct {
|
|||
}
|
||||
|
||||
type addScenarioRequest struct {
|
||||
validNewScenario `json:"scenario"`
|
||||
Scenario validNewScenario `json:"scenario"`
|
||||
}
|
||||
|
||||
type updateScenarioRequest struct {
|
||||
validUpdatedScenario `json:"scenario"`
|
||||
Scenario validUpdatedScenario `json:"scenario"`
|
||||
}
|
||||
|
||||
func (r *addScenarioRequest) validate() error {
|
||||
|
@ -44,9 +44,9 @@ func (r *validUpdatedScenario) validate() error {
|
|||
func (r *addScenarioRequest) createScenario() Scenario {
|
||||
var s Scenario
|
||||
|
||||
s.Name = r.Name
|
||||
s.Running = r.Running
|
||||
s.StartParameters = r.StartParameters
|
||||
s.Name = r.Scenario.Name
|
||||
s.Running = r.Scenario.Running
|
||||
s.StartParameters = r.Scenario.StartParameters
|
||||
|
||||
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`
|
||||
s := oldScenario
|
||||
|
||||
if r.Name != "" {
|
||||
s.Name = r.Name
|
||||
if r.Scenario.Name != "" {
|
||||
s.Name = r.Scenario.Name
|
||||
}
|
||||
|
||||
s.Running = r.Running
|
||||
s.Running = r.Scenario.Running
|
||||
|
||||
// only update Params if not empty
|
||||
var emptyJson postgres.Jsonb
|
||||
// Serialize empty json and params
|
||||
emptyJson_ser, _ := json.Marshal(emptyJson)
|
||||
startParams_ser, _ := json.Marshal(r.StartParameters)
|
||||
startParams_ser, _ := json.Marshal(r.Scenario.StartParameters)
|
||||
opts := jsondiff.DefaultConsoleOptions()
|
||||
diff, _ := jsondiff.Compare(emptyJson_ser, startParams_ser, &opts)
|
||||
if diff.String() != "FullMatch" {
|
||||
s.StartParameters = r.StartParameters
|
||||
s.StartParameters = r.Scenario.StartParameters
|
||||
}
|
||||
|
||||
return s
|
||||
|
|
|
@ -29,6 +29,7 @@ func RegisterSignalEndpoints(r *gin.RouterGroup) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Router /signals [get]
|
||||
func getSignals(c *gin.Context) {
|
||||
|
||||
|
@ -63,12 +64,13 @@ func getSignals(c *gin.Context) {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @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"
|
||||
// @Failure 400 {object} docs.ResponseError "Bad request"
|
||||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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]
|
||||
func addSignal(c *gin.Context) {
|
||||
|
||||
|
@ -105,12 +107,13 @@ func addSignal(c *gin.Context) {
|
|||
// @ID updateSignal
|
||||
// @Tags signals
|
||||
// @Produce json
|
||||
// @Param inputSignal body signal.validUpdatedSignal true "A signal to be updated"
|
||||
// @Success 200 {object} docs.ResponseSignal "Signal that was updated"
|
||||
// @Failure 400 {object} docs.ResponseError "Bad request"
|
||||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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"
|
||||
// @Router /signals/{signalID} [put]
|
||||
func updateSignal(c *gin.Context) {
|
||||
|
@ -126,7 +129,7 @@ func updateSignal(c *gin.Context) {
|
|||
}
|
||||
|
||||
// Validate the request
|
||||
if err := req.validate(); err != nil {
|
||||
if err := req.Signal.validate(); err != nil {
|
||||
helper.BadRequestError(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
@ -152,6 +155,7 @@ func updateSignal(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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"
|
||||
// @Router /signals/{signalID} [get]
|
||||
func getSignal(c *gin.Context) {
|
||||
|
@ -173,6 +177,7 @@ func getSignal(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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"
|
||||
// @Router /signals/{signalID} [delete]
|
||||
func deleteSignal(c *gin.Context) {
|
||||
|
|
|
@ -21,11 +21,11 @@ type validUpdatedSignal struct {
|
|||
}
|
||||
|
||||
type addSignalRequest struct {
|
||||
validNewSignal `json:"signal"`
|
||||
Signal validNewSignal `json:"signal"`
|
||||
}
|
||||
|
||||
type updateSignalRequest struct {
|
||||
validUpdatedSignal `json:"signal"`
|
||||
Signal validUpdatedSignal `json:"signal"`
|
||||
}
|
||||
|
||||
func (r *addSignalRequest) validate() error {
|
||||
|
@ -43,11 +43,11 @@ func (r *validUpdatedSignal) validate() error {
|
|||
func (r *addSignalRequest) createSignal() Signal {
|
||||
var s Signal
|
||||
|
||||
s.Name = r.Name
|
||||
s.Unit = r.Unit
|
||||
s.Index = r.Index
|
||||
s.Direction = r.Direction
|
||||
s.SimulationModelID = r.SimulationModelID
|
||||
s.Name = r.Signal.Name
|
||||
s.Unit = r.Signal.Unit
|
||||
s.Index = r.Signal.Index
|
||||
s.Direction = r.Signal.Direction
|
||||
s.SimulationModelID = r.Signal.SimulationModelID
|
||||
|
||||
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`
|
||||
s := oldSignal
|
||||
|
||||
if r.Name != "" {
|
||||
s.Name = r.Name
|
||||
if r.Signal.Name != "" {
|
||||
s.Name = r.Signal.Name
|
||||
}
|
||||
|
||||
if r.Index != 0 {
|
||||
if r.Signal.Index != 0 {
|
||||
// TODO this implies that we start indexing at 1
|
||||
s.Index = r.Index
|
||||
s.Index = r.Signal.Index
|
||||
}
|
||||
|
||||
if r.Unit != "" {
|
||||
s.Unit = r.Unit
|
||||
if r.Signal.Unit != "" {
|
||||
s.Unit = r.Signal.Unit
|
||||
}
|
||||
|
||||
return s
|
||||
|
|
|
@ -27,6 +27,7 @@ func RegisterSimulationModelEndpoints(r *gin.RouterGroup) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Param scenarioID query int true "Scenario ID"
|
||||
// @Router /models [get]
|
||||
func getSimulationModels(c *gin.Context) {
|
||||
|
@ -51,12 +52,13 @@ func getSimulationModels(c *gin.Context) {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @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"
|
||||
// @Failure 400 {object} docs.ResponseError "Bad request"
|
||||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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]
|
||||
func addSimulationModel(c *gin.Context) {
|
||||
|
||||
|
@ -97,12 +99,13 @@ func addSimulationModel(c *gin.Context) {
|
|||
// @Tags models
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param inputSimulationModel body simulationmodel.validUpdatedSimulationModel true "Simulation model to be updated"
|
||||
// @Success 200 {object} docs.ResponseSimulationModel "simulation model that was added"
|
||||
// @Failure 400 {object} docs.ResponseError "Bad request"
|
||||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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"
|
||||
// @Router /models/{modelID} [put]
|
||||
func updateSimulationModel(c *gin.Context) {
|
||||
|
@ -120,7 +123,7 @@ func updateSimulationModel(c *gin.Context) {
|
|||
}
|
||||
|
||||
// Validate the request
|
||||
if err := req.validate(); err != nil {
|
||||
if err := req.Model.validate(); err != nil {
|
||||
helper.BadRequestError(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
@ -146,6 +149,7 @@ func updateSimulationModel(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Param modelID path int true "Model ID"
|
||||
// @Router /models/{modelID} [get]
|
||||
func getSimulationModel(c *gin.Context) {
|
||||
|
@ -168,6 +172,7 @@ func getSimulationModel(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Param modelID path int true "Model ID"
|
||||
// @Router /models/{modelID} [delete]
|
||||
func deleteSimulationModel(c *gin.Context) {
|
||||
|
|
|
@ -23,11 +23,11 @@ type validUpdatedSimulationModel struct {
|
|||
}
|
||||
|
||||
type addSimulationModelRequest struct {
|
||||
validNewSimulationModel `json:"model"`
|
||||
Model validNewSimulationModel `json:"model"`
|
||||
}
|
||||
|
||||
type updateSimulationModelRequest struct {
|
||||
validUpdatedSimulationModel `json:"model"`
|
||||
Model validUpdatedSimulationModel `json:"model"`
|
||||
}
|
||||
|
||||
func (r *addSimulationModelRequest) validate() error {
|
||||
|
@ -45,10 +45,10 @@ func (r *validUpdatedSimulationModel) validate() error {
|
|||
func (r *addSimulationModelRequest) createSimulationModel() SimulationModel {
|
||||
var s SimulationModel
|
||||
|
||||
s.Name = r.Name
|
||||
s.ScenarioID = r.ScenarioID
|
||||
s.SimulatorID = r.SimulatorID
|
||||
s.StartParameters = r.StartParameters
|
||||
s.Name = r.Model.Name
|
||||
s.ScenarioID = r.Model.ScenarioID
|
||||
s.SimulatorID = r.Model.SimulatorID
|
||||
s.StartParameters = r.Model.StartParameters
|
||||
|
||||
return s
|
||||
}
|
||||
|
@ -57,23 +57,23 @@ func (r *updateSimulationModelRequest) updatedSimulationModel(oldSimulationModel
|
|||
// Use the old SimulationModel as a basis for the updated Simulation model
|
||||
s := oldSimulationModel
|
||||
|
||||
if r.Name != "" {
|
||||
s.Name = r.Name
|
||||
if r.Model.Name != "" {
|
||||
s.Name = r.Model.Name
|
||||
}
|
||||
|
||||
if r.SimulatorID != 0 {
|
||||
s.SimulatorID = r.SimulatorID
|
||||
if r.Model.SimulatorID != 0 {
|
||||
s.SimulatorID = r.Model.SimulatorID
|
||||
}
|
||||
|
||||
// only update Params if not empty
|
||||
var emptyJson postgres.Jsonb
|
||||
// Serialize empty json and params
|
||||
emptyJson_ser, _ := json.Marshal(emptyJson)
|
||||
startParams_ser, _ := json.Marshal(r.StartParameters)
|
||||
startParams_ser, _ := json.Marshal(r.Model.StartParameters)
|
||||
opts := jsondiff.DefaultConsoleOptions()
|
||||
diff, _ := jsondiff.Compare(emptyJson_ser, startParams_ser, &opts)
|
||||
if diff.String() != "FullMatch" {
|
||||
s.StartParameters = r.StartParameters
|
||||
s.StartParameters = r.Model.StartParameters
|
||||
}
|
||||
|
||||
return s
|
||||
|
|
|
@ -26,6 +26,7 @@ func RegisterSimulatorEndpoints(r *gin.RouterGroup) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Router /simulators [get]
|
||||
func getSimulators(c *gin.Context) {
|
||||
|
||||
|
@ -46,12 +47,13 @@ func getSimulators(c *gin.Context) {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Tags simulators
|
||||
// @Param inputSimulator body simulator.validNewSimulator true "Simulator to be added"
|
||||
// @Success 200 {object} docs.ResponseSimulator "Simulator that was added"
|
||||
// @Failure 400 {object} docs.ResponseError "Bad request"
|
||||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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]
|
||||
func addSimulator(c *gin.Context) {
|
||||
|
||||
|
@ -90,12 +92,13 @@ func addSimulator(c *gin.Context) {
|
|||
// @Tags simulators
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param inputSimulator body simulator.validUpdatedSimulator true "Simulator to be updated"
|
||||
// @Success 200 {object} docs.ResponseSimulator "Simulator that was updated"
|
||||
// @Failure 400 {object} docs.ResponseError "Bad request"
|
||||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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"
|
||||
// @Router /simulators/{simulatorID} [put]
|
||||
func updateSimulator(c *gin.Context) {
|
||||
|
@ -113,7 +116,7 @@ func updateSimulator(c *gin.Context) {
|
|||
}
|
||||
|
||||
// Validate the request
|
||||
if err = req.validate(); err != nil {
|
||||
if err = req.Simulator.validate(); err != nil {
|
||||
helper.UnprocessableEntityError(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
@ -139,6 +142,7 @@ func updateSimulator(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Param simulatorID path int true "Simulator ID"
|
||||
// @Router /simulators/{simulatorID} [get]
|
||||
func getSimulator(c *gin.Context) {
|
||||
|
@ -161,6 +165,7 @@ func getSimulator(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Param simulatorID path int true "Simulator ID"
|
||||
// @Router /simulators/{simulatorID} [delete]
|
||||
func deleteSimulator(c *gin.Context) {
|
||||
|
@ -188,6 +193,7 @@ func deleteSimulator(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Param simulatorID path int true "Simulator ID"
|
||||
// @Router /simulators/{simulatorID}/models [get]
|
||||
func getModelsOfSimulator(c *gin.Context) {
|
||||
|
|
|
@ -26,11 +26,11 @@ type validUpdatedSimulator struct {
|
|||
}
|
||||
|
||||
type addSimulatorRequest struct {
|
||||
validNewSimulator `json:"simulator"`
|
||||
Simulator validNewSimulator `json:"simulator"`
|
||||
}
|
||||
|
||||
type updateSimulatorRequest struct {
|
||||
validUpdatedSimulator `json:"simulator"`
|
||||
Simulator validUpdatedSimulator `json:"simulator"`
|
||||
}
|
||||
|
||||
func (r *addSimulatorRequest) validate() error {
|
||||
|
@ -48,12 +48,12 @@ func (r *validUpdatedSimulator) validate() error {
|
|||
func (r *addSimulatorRequest) createSimulator() Simulator {
|
||||
var s Simulator
|
||||
|
||||
s.UUID = r.UUID
|
||||
s.Host = r.Host
|
||||
s.Modeltype = r.Modeltype
|
||||
s.Properties = r.Properties
|
||||
if r.State != "" {
|
||||
s.State = r.State
|
||||
s.UUID = r.Simulator.UUID
|
||||
s.Host = r.Simulator.Host
|
||||
s.Modeltype = r.Simulator.Modeltype
|
||||
s.Properties = r.Simulator.Properties
|
||||
if r.Simulator.State != "" {
|
||||
s.State = r.Simulator.State
|
||||
}
|
||||
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`
|
||||
s := oldSimulator
|
||||
|
||||
if r.UUID != "" {
|
||||
s.UUID = r.UUID
|
||||
if r.Simulator.UUID != "" {
|
||||
s.UUID = r.Simulator.UUID
|
||||
}
|
||||
|
||||
if r.Host != "" {
|
||||
s.Host = r.Host
|
||||
if r.Simulator.Host != "" {
|
||||
s.Host = r.Simulator.Host
|
||||
}
|
||||
|
||||
if r.Modeltype != "" {
|
||||
s.Modeltype = r.Modeltype
|
||||
if r.Simulator.Modeltype != "" {
|
||||
s.Modeltype = r.Simulator.Modeltype
|
||||
}
|
||||
|
||||
if r.State != "" {
|
||||
s.State = r.State
|
||||
if r.Simulator.State != "" {
|
||||
s.State = r.Simulator.State
|
||||
}
|
||||
|
||||
// only update props if not empty
|
||||
var emptyJson postgres.Jsonb
|
||||
// Serialize empty json and params
|
||||
emptyJson_ser, _ := json.Marshal(emptyJson)
|
||||
startParams_ser, _ := json.Marshal(r.Properties)
|
||||
startParams_ser, _ := json.Marshal(r.Simulator.Properties)
|
||||
opts := jsondiff.DefaultConsoleOptions()
|
||||
diff, _ := jsondiff.Compare(emptyJson_ser, startParams_ser, &opts)
|
||||
if diff.String() != "FullMatch" {
|
||||
s.Properties = r.Properties
|
||||
s.Properties = r.Simulator.Properties
|
||||
}
|
||||
|
||||
return s
|
||||
|
|
|
@ -33,6 +33,7 @@ func RegisterUserEndpoints(r *gin.RouterGroup) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Router /users [get]
|
||||
func getUsers(c *gin.Context) {
|
||||
|
||||
|
@ -57,11 +58,12 @@ func getUsers(c *gin.Context) {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @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"
|
||||
// @Failure 400 {object} docs.ResponseError "Bad request"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Router /users [post]
|
||||
func addUser(c *gin.Context) {
|
||||
|
||||
|
@ -115,13 +117,14 @@ func addUser(c *gin.Context) {
|
|||
// @Tags users
|
||||
// @Accept 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"
|
||||
// @Failure 400 {object} docs.ResponseError "Bad request."
|
||||
// @Failure 403 {object} docs.ResponseError "Access forbidden."
|
||||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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"
|
||||
// @Router /users/{userID} [put]
|
||||
func updateUser(c *gin.Context) {
|
||||
|
@ -211,6 +214,7 @@ func updateUser(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Param userID path int true "User ID"
|
||||
// @Router /users/{userID} [get]
|
||||
func getUser(c *gin.Context) {
|
||||
|
@ -252,6 +256,7 @@ func getUser(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Param userID path int true "User ID"
|
||||
// @Router /users/{userID} [delete]
|
||||
func deleteUser(c *gin.Context) {
|
||||
|
|
|
@ -22,7 +22,7 @@ type validUpdatedRequest struct {
|
|||
}
|
||||
|
||||
type updateUserRequest struct {
|
||||
validUpdatedRequest `json:"user"`
|
||||
User validUpdatedRequest `json:"user"`
|
||||
}
|
||||
|
||||
type validNewUser struct {
|
||||
|
@ -33,7 +33,7 @@ type validNewUser struct {
|
|||
}
|
||||
|
||||
type addUserRequest struct {
|
||||
validNewUser `json:"user"`
|
||||
User validNewUser `json:"user"`
|
||||
}
|
||||
|
||||
func (r *loginRequest) validate() error {
|
||||
|
@ -58,16 +58,16 @@ func (r *updateUserRequest) updatedUser(callerID interface{}, role interface{},
|
|||
u := oldUser
|
||||
|
||||
// Only the Admin must be able to update user's role
|
||||
if role != "Admin" && r.Role != "" {
|
||||
if r.Role != u.Role {
|
||||
if role != "Admin" && r.User.Role != "" {
|
||||
if r.User.Role != u.Role {
|
||||
return u, fmt.Errorf("Only Admin can update user's Role")
|
||||
}
|
||||
} else if role == "Admin" && r.Role != "" {
|
||||
u.Role = r.Role
|
||||
} else if role == "Admin" && r.User.Role != "" {
|
||||
u.Role = r.User.Role
|
||||
}
|
||||
|
||||
// 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" {
|
||||
return u, fmt.Errorf("Only Admin can update user's Active state")
|
||||
} else {
|
||||
|
@ -77,18 +77,18 @@ func (r *updateUserRequest) updatedUser(callerID interface{}, role interface{},
|
|||
|
||||
// Update the username making sure it is NOT taken
|
||||
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")
|
||||
}
|
||||
|
||||
if r.Username != "" {
|
||||
u.Username = r.Username
|
||||
if r.User.Username != "" {
|
||||
u.Username = r.User.Username
|
||||
}
|
||||
|
||||
// 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")
|
||||
}
|
||||
|
||||
|
@ -99,28 +99,28 @@ func (r *updateUserRequest) updatedUser(callerID interface{}, role interface{},
|
|||
return u, err
|
||||
}
|
||||
|
||||
err = adminUser.validatePassword(r.OldPassword)
|
||||
err = adminUser.validatePassword(r.User.OldPassword)
|
||||
if err != nil {
|
||||
return u, fmt.Errorf("admin password not correct, pw not changed")
|
||||
}
|
||||
|
||||
} else { //normal or guest user has to enter old password
|
||||
|
||||
err := oldUser.validatePassword(r.OldPassword)
|
||||
err := oldUser.validatePassword(r.User.OldPassword)
|
||||
if err != nil {
|
||||
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 {
|
||||
return u, fmt.Errorf("unable to encrypt new password")
|
||||
}
|
||||
}
|
||||
|
||||
// Update mail
|
||||
if r.Mail != "" {
|
||||
u.Mail = r.Mail
|
||||
if r.User.Mail != "" {
|
||||
u.Mail = r.User.Mail
|
||||
}
|
||||
|
||||
return u, nil
|
||||
|
@ -135,10 +135,10 @@ func (r *addUserRequest) validate() error {
|
|||
func (r *addUserRequest) createUser() User {
|
||||
var u User
|
||||
|
||||
u.Username = r.Username
|
||||
u.Password = r.Password
|
||||
u.Mail = r.Mail
|
||||
u.Role = r.Role
|
||||
u.Username = r.User.Username
|
||||
u.Password = r.User.Password
|
||||
u.Mail = r.User.Mail
|
||||
u.Role = r.User.Role
|
||||
u.Active = true
|
||||
|
||||
return u
|
||||
|
|
|
@ -27,6 +27,7 @@ func RegisterWidgetEndpoints(r *gin.RouterGroup) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Param dashboardID query int true "Dashboard ID"
|
||||
// @Router /widgets [get]
|
||||
func getWidgets(c *gin.Context) {
|
||||
|
@ -51,12 +52,13 @@ func getWidgets(c *gin.Context) {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @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"
|
||||
// @Failure 400 {object} docs.ResponseError "Bad request"
|
||||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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]
|
||||
func addWidget(c *gin.Context) {
|
||||
|
||||
|
@ -94,12 +96,13 @@ func addWidget(c *gin.Context) {
|
|||
// @Tags widgets
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param inputWidget body widget.validUpdatedWidget true "Widget to be updated"
|
||||
// @Success 200 {object} docs.ResponseWidget "Widget that was updated"
|
||||
// @Failure 400 {object} docs.ResponseError "Bad request"
|
||||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @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"
|
||||
// @Router /widgets/{widgetID} [put]
|
||||
func updateWidget(c *gin.Context) {
|
||||
|
@ -116,7 +119,7 @@ func updateWidget(c *gin.Context) {
|
|||
}
|
||||
|
||||
// Validate the request
|
||||
if err := req.validate(); err != nil {
|
||||
if err := req.Widget.validate(); err != nil {
|
||||
helper.BadRequestError(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
@ -142,6 +145,7 @@ func updateWidget(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Param widgetID path int true "Widget ID"
|
||||
// @Router /widgets/{widgetID} [get]
|
||||
func getWidget(c *gin.Context) {
|
||||
|
@ -164,6 +168,7 @@ func getWidget(c *gin.Context) {
|
|||
// @Failure 404 {object} docs.ResponseError "Not found"
|
||||
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
|
||||
// @Failure 500 {object} docs.ResponseError "Internal server error"
|
||||
// @Param Authorization header string true "Authorization token"
|
||||
// @Param widgetID path int true "Widget ID"
|
||||
// @Router /widgets/{widgetID} [delete]
|
||||
func deleteWidget(c *gin.Context) {
|
||||
|
|
|
@ -39,11 +39,11 @@ type validUpdatedWidget struct {
|
|||
}
|
||||
|
||||
type addWidgetRequest struct {
|
||||
validNewWidget `json:"widget"`
|
||||
Widget validNewWidget `json:"widget"`
|
||||
}
|
||||
|
||||
type updateWidgetRequest struct {
|
||||
validUpdatedWidget `json:"widget"`
|
||||
Widget validUpdatedWidget `json:"widget"`
|
||||
}
|
||||
|
||||
func (r *addWidgetRequest) validate() error {
|
||||
|
@ -61,18 +61,18 @@ func (r *validUpdatedWidget) validate() error {
|
|||
func (r *addWidgetRequest) createWidget() Widget {
|
||||
var s Widget
|
||||
|
||||
s.Name = r.Name
|
||||
s.Type = r.Type
|
||||
s.Width = r.Width
|
||||
s.Height = r.Height
|
||||
s.MinWidth = r.MinWidth
|
||||
s.MinHeight = r.MinHeight
|
||||
s.X = r.X
|
||||
s.Y = r.Y
|
||||
s.Z = r.Z
|
||||
s.IsLocked = r.IsLocked
|
||||
s.CustomProperties = r.CustomProperties
|
||||
s.DashboardID = r.DashboardID
|
||||
s.Name = r.Widget.Name
|
||||
s.Type = r.Widget.Type
|
||||
s.Width = r.Widget.Width
|
||||
s.Height = r.Widget.Height
|
||||
s.MinWidth = r.Widget.MinWidth
|
||||
s.MinHeight = r.Widget.MinHeight
|
||||
s.X = r.Widget.X
|
||||
s.Y = r.Widget.Y
|
||||
s.Z = r.Widget.Z
|
||||
s.IsLocked = r.Widget.IsLocked
|
||||
s.CustomProperties = r.Widget.CustomProperties
|
||||
s.DashboardID = r.Widget.DashboardID
|
||||
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`
|
||||
s := oldWidget
|
||||
|
||||
if r.Name != "" {
|
||||
s.Name = r.Name
|
||||
if r.Widget.Name != "" {
|
||||
s.Name = r.Widget.Name
|
||||
}
|
||||
|
||||
s.Type = r.Type
|
||||
s.Width = r.Width
|
||||
s.Height = r.Height
|
||||
s.MinWidth = r.MinWidth
|
||||
s.MinHeight = r.MinHeight
|
||||
s.X = r.X
|
||||
s.Y = r.Y
|
||||
s.Z = r.Z
|
||||
s.IsLocked = r.IsLocked
|
||||
s.Type = r.Widget.Type
|
||||
s.Width = r.Widget.Width
|
||||
s.Height = r.Widget.Height
|
||||
s.MinWidth = r.Widget.MinWidth
|
||||
s.MinHeight = r.Widget.MinHeight
|
||||
s.X = r.Widget.X
|
||||
s.Y = r.Widget.Y
|
||||
s.Z = r.Widget.Z
|
||||
s.IsLocked = r.Widget.IsLocked
|
||||
|
||||
// only update custom props if not empty
|
||||
var emptyJson postgres.Jsonb
|
||||
// Serialize empty json and params
|
||||
emptyJson_ser, _ := json.Marshal(emptyJson)
|
||||
customprops_ser, _ := json.Marshal(r.CustomProperties)
|
||||
customprops_ser, _ := json.Marshal(r.Widget.CustomProperties)
|
||||
opts := jsondiff.DefaultConsoleOptions()
|
||||
diff, _ := jsondiff.Compare(emptyJson_ser, customprops_ser, &opts)
|
||||
if diff.String() != "FullMatch" {
|
||||
s.CustomProperties = r.CustomProperties
|
||||
s.CustomProperties = r.Widget.CustomProperties
|
||||
}
|
||||
|
||||
return s
|
||||
|
|
Loading…
Add table
Reference in a new issue