diff --git a/doc/api/api.yaml b/doc/api/api.yaml index 7f7f33f..73e1c00 100644 --- a/doc/api/api.yaml +++ b/doc/api/api.yaml @@ -172,6 +172,28 @@ paths: 500: description: Could not retrieve user's files content: {} + post: + tags: + - files + summary: Add a new file to the database (NEW, was /uploads before)) + operationId: addFile + requestBody: + description: "File object to be added" + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/File' + responses: + 200: + description: File upload successful! + content: {} + 500: + description: File could not be uploaded and GET unable to find user or unable to save reference file or unable to save user or unable to create directory + content: {} + 400: + description: File could not be uploaded because unable to process incoming form + content: {} /files/{FileID}: get: tags: @@ -195,6 +217,32 @@ paths: 400: description: GET Unknown file for ID content: {} + put: + tags: + - files + summary: Update properties of file with ID FileID (NEW) + operationId: updateFileProperties + requestBody: + description: "File object to be updated" + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/File' + parameters: + - in: path + name: FileID + description: ID of a file + required: true + schema: + type: integer + responses: + 200: + description: File updated successfully + content: {} + 400: + description: PUT Unknown file for ID + content: {} delete: tags: - files @@ -427,33 +475,12 @@ paths: 500: description: Unable to find Simulation or unable to save changed simulation or unable to remove SimulationModel content: {} - /models/{SimulationModelID}/cimfile: + /models/{SimulationModelID}/file: get: tags: - simulationmodels - summary: Get CIM model file from SimulationModel with ID SimulationModelID - operationId: getCIMFileFromSimulationModel - parameters: - - in: path - name: SimulationModelID - description: ID of a SimulationModel - required: true - schema: - type: integer - responses: - 200: - description: "Model file in zip format" - content: - model/x-cim.zip: - Zipped model file in CIM format - 400: - description: PUT Simulation Unknown for ID or unable to save simulation or Model not associated with Simulation - content: {} - put: - tags: - - simulationmodels - summary: Update (Overwrite) CIM model file from SimulationModel with ID SimulationModelID - operationId: updateCIMFileForSimulationModel + summary: Get file from SimulationModel with ID SimulationModelID (NEW) + operationId: getFileFromSimulationModel parameters: - in: path name: SimulationModelID @@ -462,12 +489,60 @@ paths: schema: type: integer requestBody: - description: "Model file in zip format" + description: "Info about file to download" + required: true + content: + application/json: + schema: + required: + - NumberOfFiles + - MIMEType + type: object + properties: + NumberOfFiles: + type: integer + MIMEType: + type: string + examples: + cim: + summary: "An example for CIM file" + value: + NumberOfFiles: 1 + MIMEType: "model/x-cim.zip" + responses: + 200: + description: "File from simulation model" + content: + model/x-cim.zip: + schema: + type: string + format: byte + 400: + description: PUT Simulation Unknown for ID or unable to save simulation or Model not associated with Simulation + content: {} + put: + tags: + - simulationmodels + summary: Update (Overwrite) file of SimulationModel with ID SimulationModelID, File object has to be in database (NEW) + operationId: updateFileForSimulationModel + parameters: + - in: path + name: SimulationModelID + description: ID of a SimulationModel + required: true + schema: + type: integer + requestBody: + description: "File to be updated for simulation model" required: true content: model/x-cim.zip: - Zipped model file in CIM format + schema: + type: string + format: byte responses: + 200: + description: Update of File successful 400: description: PUT SimulationModel Unknown for ID or unable to save simulation or Model not associated with Simulation content: {} @@ -605,7 +680,7 @@ paths: post: tags: - uploads - summary: Upload a new file to the database + summary: Upload a new file to the database (REMOVED) operationId: uploadFile requestBody: description: "File object to upload TODO CHANGE TO FORM" @@ -1006,6 +1081,7 @@ components: - Type - Size - Date + - UserID type: object properties: Name: diff --git a/routes/file/fileEndpoints.go b/routes/file/fileEndpoints.go index 51f45a2..afdaa41 100644 --- a/routes/file/fileEndpoints.go +++ b/routes/file/fileEndpoints.go @@ -7,8 +7,8 @@ import ( func FilesRegister(r *gin.RouterGroup) { r.GET("/", filesReadEp) - //r.POST("/", fileRegistrationEp) // TODO to be added to API - //r.PUT("/:FileID", fileUpdateEp) // TODO to be added to API + r.POST("/", fileRegistrationEp) // NEW in API + r.PUT("/:FileID", fileUpdateEp) // NEW in API r.GET("/:FileID", fileReadEp) r.DELETE("/:FileID", fileDeleteEp) } @@ -21,19 +21,17 @@ func filesReadEp(c *gin.Context) { }) } -// TODO to be added to API -//func fileRegistrationEp(c *gin.Context) { -// c.JSON(http.StatusOK, gin.H{ -// "message": "NOT implemented", -// }) -//} +func fileRegistrationEp(c *gin.Context) { + c.JSON(http.StatusOK, gin.H{ + "message": "NOT implemented", + }) +} -// TODO to be added to API -//func fileUpdateEp(c *gin.Context) { -// c.JSON(http.StatusOK, gin.H{ -// "message": "NOT implemented", -// }) -//} +func fileUpdateEp(c *gin.Context) { + c.JSON(http.StatusOK, gin.H{ + "message": "NOT implemented", + }) +} func fileReadEp(c *gin.Context) { c.JSON(http.StatusOK, gin.H{ diff --git a/routes/simulationmodel/simulationmodelEnpoints.go b/routes/simulationmodel/simulationmodelEnpoints.go index 51b59ae..7f41593 100644 --- a/routes/simulationmodel/simulationmodelEnpoints.go +++ b/routes/simulationmodel/simulationmodelEnpoints.go @@ -11,8 +11,8 @@ func SimulationModelsRegister(r *gin.RouterGroup) { r.PUT("/:SimulationModelID", simulationmodelUpdateEp) r.GET("/:SimulationModelID", simulationmodelReadEp) r.DELETE("/:SimulationModelID", simulationmodelDeleteEp) - r.GET("/:SimulationModelID/cimfile", simulationmodelReadCIMfileEp) - r.PUT("/:SimulationModelID/cimfile", simulationmodelUpdateCIMfileEp) + r.GET("/:SimulationModelID/file", simulationmodelReadFileEp) // NEW in API + r.PUT("/:SimulationModelID/file", simulationmodelUpdateFileEp) // NEW in API } func simulationmodelsReadEp(c *gin.Context) { @@ -47,13 +47,13 @@ func simulationmodelDeleteEp(c *gin.Context) { }) } -func simulationmodelReadCIMfileEp(c *gin.Context) { +func simulationmodelReadFileEp(c *gin.Context) { c.JSON(http.StatusOK, gin.H{ "message": "NOT implemented", }) } -func simulationmodelUpdateCIMfileEp(c *gin.Context) { +func simulationmodelUpdateFileEp(c *gin.Context) { c.JSON(http.StatusOK, gin.H{ "message": "NOT implemented", })