diff --git a/api/design_api.partials.yml b/api/design_api.partials.yml index 0ccde6eea..2eb1c9f59 100644 --- a/api/design_api.partials.yml +++ b/api/design_api.partials.yml @@ -459,3 +459,49 @@ summary: Update a design code tags: - designCodes + #------------------------------------# + # Delete Code Zip + #------------------------------------# + delete: + operationId: deleteDesignCode + summary: Delete code of a specified version from a given design + tags: + - designCodes + parameters: + - name: user + description: user name + explode: false + in: path + required: true + schema: + type: string + style: simple + - name: designId + description: design id + explode: false + in: path + required: true + schema: + type: string + style: simple + - name: version + description: version string + explode: false + in: path + required: true + schema: + type: string + style: simple + responses: + '200': + description: Deleted + '404': + description: Design id not found + '401': + description: Unauthorized + default: + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: unexpected error diff --git a/pkg/openapi/api.go b/pkg/openapi/api.go index 1c17c47c1..dd3271d3c 100644 --- a/pkg/openapi/api.go +++ b/pkg/openapi/api.go @@ -62,6 +62,7 @@ type DatasetsApiRouter interface { // pass the data to a DesignCodesApiServicer to perform the required actions, then write the service results to the http response. type DesignCodesApiRouter interface { CreateDesignCode(http.ResponseWriter, *http.Request) + DeleteDesignCode(http.ResponseWriter, *http.Request) GetDesignCode(http.ResponseWriter, *http.Request) UpdateDesignCode(http.ResponseWriter, *http.Request) } @@ -136,6 +137,7 @@ type DatasetsApiServicer interface { // and updated with the logic required for the API. type DesignCodesApiServicer interface { CreateDesignCode(context.Context, string, string, string, string, *os.File) (ImplResponse, error) + DeleteDesignCode(context.Context, string, string, string) (ImplResponse, error) GetDesignCode(context.Context, string, string, string) (ImplResponse, error) UpdateDesignCode(context.Context, string, string, string, string, string, *os.File) (ImplResponse, error) } diff --git a/pkg/openapi/api_design_codes.go b/pkg/openapi/api_design_codes.go index 4bcf980f8..18d04e162 100644 --- a/pkg/openapi/api_design_codes.go +++ b/pkg/openapi/api_design_codes.go @@ -53,6 +53,12 @@ func (c *DesignCodesApiController) Routes() Routes { "/users/{user}/designs/{designId}/codes", c.CreateDesignCode, }, + { + "DeleteDesignCode", + strings.ToUpper("Delete"), + "/users/{user}/designs/{designId}/codes/{version}", + c.DeleteDesignCode, + }, { "GetDesignCode", strings.ToUpper("Get"), @@ -98,6 +104,25 @@ func (c *DesignCodesApiController) CreateDesignCode(w http.ResponseWriter, r *ht EncodeJSONResponse(result.Body, &result.Code, w) } +// DeleteDesignCode - Delete code of a specified version from a given design +func (c *DesignCodesApiController) DeleteDesignCode(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + userParam := params["user"] + + designIdParam := params["designId"] + + versionParam := params["version"] + + result, err := c.service.DeleteDesignCode(r.Context(), userParam, designIdParam, versionParam) + // If an error occurred, encode the error with the status code + if err != nil { + EncodeJSONResponse(err.Error(), &result.Code, w) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} + // GetDesignCode - Get a zipped design code file owned by user func (c *DesignCodesApiController) GetDesignCode(w http.ResponseWriter, r *http.Request) { params := mux.Vars(r) diff --git a/pkg/openapi/apiserver/api_design_codes_service.go b/pkg/openapi/apiserver/api_design_codes_service.go index 5723a22c9..c0fa229c9 100644 --- a/pkg/openapi/apiserver/api_design_codes_service.go +++ b/pkg/openapi/apiserver/api_design_codes_service.go @@ -94,6 +94,28 @@ func (s *DesignCodesApiService) CreateDesignCode(ctx context.Context, user strin return openapi.Response(http.StatusCreated, nil), nil } +// DeleteDesignCode - Delete a zipped design code file owned by user +func (s *DesignCodesApiService) DeleteDesignCode(ctx context.Context, user string, designId string, + version string) (openapi.ImplResponse, error) { + // TODO - update DeleteDesignCode with the required logic for this service method. + // Add api_design_codes_service.go to the .openapi-generator-ignore + // to avoid overwriting this service implementation when updating open api generation. + + //TODO: Uncomment the next line to return response Response(200, {}) or use other options such as http.Ok ... + //return openapi.Response(200, nil),nil + + //TODO: Uncomment the next line to return response Response(404, {}) or use other options such as http.Ok ... + //return openapi.Response(404, nil),nil + + //TODO: Uncomment the next line to return response Response(401, {}) or use other options such as http.Ok ... + //return openapi.Response(401, nil),nil + + //TODO: Uncomment the next line to return response Response(0, Error{}) or use other options such as http.Ok ... + //return openapi.Response(0, Error{}), nil + + return openapi.Response(http.StatusNotImplemented, nil), errors.New("DeleteDesignCode method not implemented") +} + // GetDesignCode - Get a zipped design code file owned by user func (s *DesignCodesApiService) GetDesignCode(ctx context.Context, user string, designId string, version string) (openapi.ImplResponse, error) { diff --git a/pkg/openapi/controller/api_design_codes_service.go b/pkg/openapi/controller/api_design_codes_service.go index b9dbd2507..aab799628 100644 --- a/pkg/openapi/controller/api_design_codes_service.go +++ b/pkg/openapi/controller/api_design_codes_service.go @@ -68,6 +68,28 @@ func (s *DesignCodesApiService) CreateDesignCode(ctx context.Context, user strin return openapi.Response(http.StatusCreated, nil), nil } +// DeleteDesignCode - Delete a zipped design code file owned by user +func (s *DesignCodesApiService) DeleteDesignCode(ctx context.Context, user string, designId string, + version string) (openapi.ImplResponse, error) { + // TODO - update DeleteDesignCode with the required logic for this service method. + // Add api_design_codes_service.go to the .openapi-generator-ignore + // to avoid overwriting this service implementation when updating open api generation. + + //TODO: Uncomment the next line to return response Response(200, {}) or use other options such as http.Ok ... + //return openapi.Response(200, nil),nil + + //TODO: Uncomment the next line to return response Response(404, {}) or use other options such as http.Ok ... + //return openapi.Response(404, nil),nil + + //TODO: Uncomment the next line to return response Response(401, {}) or use other options such as http.Ok ... + //return openapi.Response(401, nil),nil + + //TODO: Uncomment the next line to return response Response(0, Error{}) or use other options such as http.Ok ... + //return openapi.Response(0, Error{}), nil + + return openapi.Response(http.StatusNotImplemented, nil), errors.New("DeleteDesignCode method not implemented") +} + // GetDesignCode - Get a zipped design code file owned by user func (s *DesignCodesApiService) GetDesignCode(ctx context.Context, user string, designId string, version string) (openapi.ImplResponse, error) {