Skip to content

Commit

Permalink
feat: support creating module dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
liu-hm19 committed Nov 13, 2024
1 parent e72d33e commit 1d37a02
Show file tree
Hide file tree
Showing 7 changed files with 365 additions and 110 deletions.
53 changes: 53 additions & 0 deletions api/openapispec/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2054,6 +2054,59 @@ const docTemplate = `{
}
}
},
"/api/v1/workspaces/configs/mod-deps/{id}": {
"post": {
"description": "Create the module dependencies in kcl.mod of the specified workspace",
"consumes": [
"application/json"
],
"produces": [
"text/plain"
],
"tags": [
"workspace"
],
"summary": "Create the module dependencies of the workspace",
"operationId": "createWorkspaceModDeps",
"parameters": [
{
"type": "integer",
"description": "Workspace ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"type": "string"
}
},
"400": {
"description": "Bad Request",
"schema": {}
},
"401": {
"description": "Unauthorized",
"schema": {}
},
"404": {
"description": "Not Found",
"schema": {}
},
"429": {
"description": "Too Many Requests",
"schema": {}
},
"500": {
"description": "Internal Server Error",
"schema": {}
}
}
}
},
"/api/v1/workspaces/configs/validate": {
"post": {
"description": "Validate the configurations in the specified workspace",
Expand Down
53 changes: 53 additions & 0 deletions api/openapispec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2043,6 +2043,59 @@
}
}
},
"/api/v1/workspaces/configs/mod-deps/{id}": {
"post": {
"description": "Create the module dependencies in kcl.mod of the specified workspace",
"consumes": [
"application/json"
],
"produces": [
"text/plain"
],
"tags": [
"workspace"
],
"summary": "Create the module dependencies of the workspace",
"operationId": "createWorkspaceModDeps",
"parameters": [
{
"type": "integer",
"description": "Workspace ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"type": "string"
}
},
"400": {
"description": "Bad Request",
"schema": {}
},
"401": {
"description": "Unauthorized",
"schema": {}
},
"404": {
"description": "Not Found",
"schema": {}
},
"429": {
"description": "Too Many Requests",
"schema": {}
},
"500": {
"description": "Internal Server Error",
"schema": {}
}
}
}
},
"/api/v1/workspaces/configs/validate": {
"post": {
"description": "Validate the configurations in the specified workspace",
Expand Down
37 changes: 37 additions & 0 deletions api/openapispec/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2726,6 +2726,43 @@ paths:
summary: Update workspace configurations
tags:
- workspace
/api/v1/workspaces/configs/mod-deps/{id}:
post:
consumes:
- application/json
description: Create the module dependencies in kcl.mod of the specified workspace
operationId: createWorkspaceModDeps
parameters:
- description: Workspace ID
in: path
name: id
required: true
type: integer
produces:
- text/plain
responses:
"200":
description: Success
schema:
type: string
"400":
description: Bad Request
schema: {}
"401":
description: Unauthorized
schema: {}
"404":
description: Not Found
schema: {}
"429":
description: Too Many Requests
schema: {}
"500":
description: Internal Server Error
schema: {}
summary: Create the module dependencies of the workspace
tags:
- workspace
/api/v1/workspaces/configs/validate:
post:
consumes:
Expand Down
134 changes: 67 additions & 67 deletions pkg/server/handler/module/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ import (
logutil "kusionstack.io/kusion/pkg/server/util/logging"
)

// @Id createModule
// @Summary Create module
// @Description Create a new Kusion module
// @Tags module
// @Accept json
// @Produce json
// @Param module body request.CreateModuleRequest true "Created module"
// @Success 200 {object} entity.Module "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/modules [post]
// @Id createModule

Check failure on line 16 in pkg/server/handler/module/handler.go

View workflow job for this annotation

GitHub Actions / Golang Lint

File is not `gofumpt`-ed (gofumpt)
// @Summary Create module
// @Description Create a new Kusion module
// @Tags module
// @Accept json
// @Produce json
// @Param module body request.CreateModuleRequest true "Created module"
// @Success 200 {object} entity.Module "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/modules [post]
func (h *Handler) CreateModule() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Getting stuff from context.
Expand All @@ -47,19 +47,19 @@ func (h *Handler) CreateModule() http.HandlerFunc {
}
}

// @Id deleteModule
// @Summary Delete module
// @Description Delete the specified module by name
// @Tags module
// @Produce json
// @Param name path string true "Module Name"
// @Success 200 {object} string "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/modules/{name} [delete]
// @Id deleteModule

Check failure on line 50 in pkg/server/handler/module/handler.go

View workflow job for this annotation

GitHub Actions / Golang Lint

File is not `gofumpt`-ed (gofumpt)
// @Summary Delete module
// @Description Delete the specified module by name
// @Tags module
// @Produce json
// @Param name path string true "Module Name"
// @Success 200 {object} string "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/modules/{name} [delete]
func (h *Handler) DeleteModule() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Getting stuff from context.
Expand All @@ -75,21 +75,21 @@ func (h *Handler) DeleteModule() http.HandlerFunc {
}
}

// @Id updateModule
// @Summary Update module
// @Description Update the specified module
// @Tags module
// @Accept json
// @Produce json
// @Param name path string true "Module Name"
// @Param module body request.UpdateModuleRequest true "Updated module"
// @Success 200 {object} entity.Module "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/modules/{name} [put]
// @Id updateModule

Check failure on line 78 in pkg/server/handler/module/handler.go

View workflow job for this annotation

GitHub Actions / Golang Lint

File is not `gofumpt`-ed (gofumpt)
// @Summary Update module
// @Description Update the specified module
// @Tags module
// @Accept json
// @Produce json
// @Param name path string true "Module Name"
// @Param module body request.UpdateModuleRequest true "Updated module"
// @Success 200 {object} entity.Module "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/modules/{name} [put]
func (h *Handler) UpdateModule() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Getting stuff from context.
Expand All @@ -113,19 +113,19 @@ func (h *Handler) UpdateModule() http.HandlerFunc {
}
}

// @Id getModule
// @Summary Get module
// @Description Get module information by module name
// @Tags module
// @Produce json
// @Param name path string true "Module Name"
// @Success 200 {object} entity.Module "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/modules/{name} [get]
// @Id getModule
// @Summary Get module
// @Description Get module information by module name
// @Tags module
// @Produce json
// @Param name path string true "Module Name"
// @Success 200 {object} entity.Module "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/modules/{name} [get]
func (h *Handler) GetModule() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Getting stuff from context.
Expand All @@ -141,18 +141,18 @@ func (h *Handler) GetModule() http.HandlerFunc {
}
}

// @Id listModule
// @Summary List module
// @Description List module information
// @Tags module
// @Produce json
// @Success 200 {object} []entity.Module "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/modules [get]
// @Id listModule
// @Summary List module
// @Description List module information
// @Tags module
// @Produce json
// @Success 200 {object} []entity.Module "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/modules [get]
func (h *Handler) ListModules() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Getting stuff from context.
Expand Down
Loading

0 comments on commit 1d37a02

Please sign in to comment.