- rename "cimfile" to "file"

- fix API documentation
- move /uploads POST endpoint to /files POST
- add /files/FileID PUT endpoint for updating files
- mark removed and new endpoints in API doc
This commit is contained in:
Sonja Happ 2019-05-16 09:27:44 +02:00
parent 0438cfadea
commit e03f076161
3 changed files with 119 additions and 45 deletions

View file

@ -172,6 +172,28 @@ paths:
500: 500:
description: Could not retrieve user's files description: Could not retrieve user's files
content: {} 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}: /files/{FileID}:
get: get:
tags: tags:
@ -195,6 +217,32 @@ paths:
400: 400:
description: GET Unknown file for ID description: GET Unknown file for ID
content: {} 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: delete:
tags: tags:
- files - files
@ -427,33 +475,12 @@ paths:
500: 500:
description: Unable to find Simulation or unable to save changed simulation or unable to remove SimulationModel description: Unable to find Simulation or unable to save changed simulation or unable to remove SimulationModel
content: {} content: {}
/models/{SimulationModelID}/cimfile: /models/{SimulationModelID}/file:
get: get:
tags: tags:
- simulationmodels - simulationmodels
summary: Get CIM model file from SimulationModel with ID SimulationModelID summary: Get file from SimulationModel with ID SimulationModelID (NEW)
operationId: getCIMFileFromSimulationModel operationId: getFileFromSimulationModel
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
parameters: parameters:
- in: path - in: path
name: SimulationModelID name: SimulationModelID
@ -462,12 +489,60 @@ paths:
schema: schema:
type: integer type: integer
requestBody: 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 required: true
content: content:
model/x-cim.zip: model/x-cim.zip:
Zipped model file in CIM format schema:
type: string
format: byte
responses: responses:
200:
description: Update of File successful
400: 400:
description: PUT SimulationModel Unknown for ID or unable to save simulation or Model not associated with Simulation description: PUT SimulationModel Unknown for ID or unable to save simulation or Model not associated with Simulation
content: {} content: {}
@ -605,7 +680,7 @@ paths:
post: post:
tags: tags:
- uploads - uploads
summary: Upload a new file to the database summary: Upload a new file to the database (REMOVED)
operationId: uploadFile operationId: uploadFile
requestBody: requestBody:
description: "File object to upload TODO CHANGE TO FORM" description: "File object to upload TODO CHANGE TO FORM"
@ -1006,6 +1081,7 @@ components:
- Type - Type
- Size - Size
- Date - Date
- UserID
type: object type: object
properties: properties:
Name: Name:

View file

@ -7,8 +7,8 @@ import (
func FilesRegister(r *gin.RouterGroup) { func FilesRegister(r *gin.RouterGroup) {
r.GET("/", filesReadEp) r.GET("/", filesReadEp)
//r.POST("/", fileRegistrationEp) // TODO to be added to API r.POST("/", fileRegistrationEp) // NEW in API
//r.PUT("/:FileID", fileUpdateEp) // TODO to be added to API r.PUT("/:FileID", fileUpdateEp) // NEW in API
r.GET("/:FileID", fileReadEp) r.GET("/:FileID", fileReadEp)
r.DELETE("/:FileID", fileDeleteEp) r.DELETE("/:FileID", fileDeleteEp)
} }
@ -21,19 +21,17 @@ func filesReadEp(c *gin.Context) {
}) })
} }
// TODO to be added to API func fileRegistrationEp(c *gin.Context) {
//func fileRegistrationEp(c *gin.Context) { c.JSON(http.StatusOK, gin.H{
// c.JSON(http.StatusOK, gin.H{ "message": "NOT implemented",
// "message": "NOT implemented", })
// }) }
//}
// TODO to be added to API func fileUpdateEp(c *gin.Context) {
//func fileUpdateEp(c *gin.Context) { c.JSON(http.StatusOK, gin.H{
// c.JSON(http.StatusOK, gin.H{ "message": "NOT implemented",
// "message": "NOT implemented", })
// }) }
//}
func fileReadEp(c *gin.Context) { func fileReadEp(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{

View file

@ -11,8 +11,8 @@ func SimulationModelsRegister(r *gin.RouterGroup) {
r.PUT("/:SimulationModelID", simulationmodelUpdateEp) r.PUT("/:SimulationModelID", simulationmodelUpdateEp)
r.GET("/:SimulationModelID", simulationmodelReadEp) r.GET("/:SimulationModelID", simulationmodelReadEp)
r.DELETE("/:SimulationModelID", simulationmodelDeleteEp) r.DELETE("/:SimulationModelID", simulationmodelDeleteEp)
r.GET("/:SimulationModelID/cimfile", simulationmodelReadCIMfileEp) r.GET("/:SimulationModelID/file", simulationmodelReadFileEp) // NEW in API
r.PUT("/:SimulationModelID/cimfile", simulationmodelUpdateCIMfileEp) r.PUT("/:SimulationModelID/file", simulationmodelUpdateFileEp) // NEW in API
} }
func simulationmodelsReadEp(c *gin.Context) { 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{ c.JSON(http.StatusOK, gin.H{
"message": "NOT implemented", "message": "NOT implemented",
}) })
} }
func simulationmodelUpdateCIMfileEp(c *gin.Context) { func simulationmodelUpdateFileEp(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"message": "NOT implemented", "message": "NOT implemented",
}) })