From 50d6df241d539521513ac888ee140c82e40471cb Mon Sep 17 00:00:00 2001 From: xxxxibo Date: Tue, 9 Jan 2024 21:46:34 +0800 Subject: [PATCH] chore: add swagger doc for GetSuccessChunks --- apiserver/docs/docs.go | 109 ++++++++++++++++++++++++++++++ apiserver/docs/swagger.json | 109 ++++++++++++++++++++++++++++++ apiserver/docs/swagger.yaml | 73 ++++++++++++++++++++ apiserver/service/minio_server.go | 29 ++++---- 4 files changed, 307 insertions(+), 13 deletions(-) diff --git a/apiserver/docs/docs.go b/apiserver/docs/docs.go index 7790b5583..31e7846b5 100644 --- a/apiserver/docs/docs.go +++ b/apiserver/docs/docs.go @@ -261,6 +261,84 @@ const docTemplate = `{ } } } + }, + "/model/files/chunks": { + "get": { + "description": "Get success chunks of a file", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "MinioAPI" + ], + "summary": "Get success chunks of a file", + "parameters": [ + { + "type": "string", + "description": "MD5 value of the file", + "name": "md5", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "Name of the file", + "name": "fileName", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "Name of the bucket", + "name": "namespace", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "Path of the bucket", + "name": "bucketPath", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "ETag of the file", + "name": "etag", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/service.SuccessChunksResult" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } } }, "definitions": { @@ -518,6 +596,37 @@ const docTemplate = `{ "example": 0.34 } } + }, + "service.Chunk": { + "type": "object", + "properties": { + "etag": { + "type": "string" + }, + "partNubmer": { + "type": "integer" + }, + "size": { + "type": "integer" + } + } + }, + "service.SuccessChunksResult": { + "type": "object", + "properties": { + "chunks": { + "type": "array", + "items": { + "$ref": "#/definitions/service.Chunk" + } + }, + "done": { + "type": "boolean" + }, + "uploadID": { + "type": "string" + } + } } } }` diff --git a/apiserver/docs/swagger.json b/apiserver/docs/swagger.json index 3a4d96ddb..71411d574 100644 --- a/apiserver/docs/swagger.json +++ b/apiserver/docs/swagger.json @@ -250,6 +250,84 @@ } } } + }, + "/model/files/chunks": { + "get": { + "description": "Get success chunks of a file", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "MinioAPI" + ], + "summary": "Get success chunks of a file", + "parameters": [ + { + "type": "string", + "description": "MD5 value of the file", + "name": "md5", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "Name of the file", + "name": "fileName", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "Name of the bucket", + "name": "namespace", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "Path of the bucket", + "name": "bucketPath", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "ETag of the file", + "name": "etag", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/service.SuccessChunksResult" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } } }, "definitions": { @@ -507,6 +585,37 @@ "example": 0.34 } } + }, + "service.Chunk": { + "type": "object", + "properties": { + "etag": { + "type": "string" + }, + "partNubmer": { + "type": "integer" + }, + "size": { + "type": "integer" + } + } + }, + "service.SuccessChunksResult": { + "type": "object", + "properties": { + "chunks": { + "type": "array", + "items": { + "$ref": "#/definitions/service.Chunk" + } + }, + "done": { + "type": "boolean" + }, + "uploadID": { + "type": "string" + } + } } } } \ No newline at end of file diff --git a/apiserver/docs/swagger.yaml b/apiserver/docs/swagger.yaml index 4a8335b93..b82319191 100644 --- a/apiserver/docs/swagger.yaml +++ b/apiserver/docs/swagger.yaml @@ -188,6 +188,26 @@ definitions: example: 0.34 type: number type: object + service.Chunk: + properties: + etag: + type: string + partNubmer: + type: integer + size: + type: integer + type: object + service.SuccessChunksResult: + properties: + chunks: + items: + $ref: '#/definitions/service.Chunk' + type: array + done: + type: boolean + uploadID: + type: string + type: object info: contact: {} paths: @@ -354,4 +374,57 @@ paths: summary: get one message references tags: - application + /model/files/chunks: + get: + consumes: + - application/json + description: Get success chunks of a file + parameters: + - description: MD5 value of the file + in: query + name: md5 + required: true + type: string + - description: Name of the file + in: query + name: fileName + required: true + type: string + - description: Name of the bucket + in: header + name: namespace + required: true + type: string + - description: Path of the bucket + in: query + name: bucketPath + required: true + type: string + - description: ETag of the file + in: query + name: etag + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/service.SuccessChunksResult' + "400": + description: Bad Request + schema: + additionalProperties: + type: string + type: object + "500": + description: Internal Server Error + schema: + additionalProperties: + type: string + type: object + summary: Get success chunks of a file + tags: + - MinioAPI swagger: "2.0" diff --git a/apiserver/service/minio_server.go b/apiserver/service/minio_server.go index 0dfae97fa..2219bb355 100644 --- a/apiserver/service/minio_server.go +++ b/apiserver/service/minio_server.go @@ -109,19 +109,22 @@ const ( namespaceHeader = "namespace" ) -/* -GetSuccessChunks -There are three different scenarios: - -1. If the file exists, the function will return done=true and will not provide an uploadid. -In this case, no further action is required for uploading because the file is already present. - -2. If the file does not exist, the function will return done=false. -In this case, you need to request a new uploadid to initiate the upload process. - -3. If the upload is in progress, the function will return done=false, uploadid (e.g., uploadid=xx) and chunks={partNumber, etag}. -In this case, you can utilize the provided uploadid to continue requesting the upload URL and proceed with the file upload process. -*/ +// @BasePath /bff +// @Summary Get success chunks of a file +// @Schemes +// @Description Get success chunks of a file +// @Tags MinioAPI +// @Accept json +// @Produce json +// @Param md5 query string true "MD5 value of the file" +// @Param fileName query string true "Name of the file" +// @Param namespace header string true "Name of the bucket" +// @Param bucketPath query string true "Path of the bucket" +// @Param etag query string true "ETag of the file" +// @Success 200 {object} SuccessChunksResult +// @Failure 400 {object} map[string]string +// @Failure 500 {object} map[string]string +// @Router /model/files/chunks [get] func (m *minioAPI) GetSuccessChunks(ctx *gin.Context) { fildMD5 := ctx.Query(md5Query) if fildMD5 == "" {