Documentation
¶
Index ¶
- func CopyToNewContext(ctx context.Context) context.Context
- func CopyToNewContextWithTimeout(ctx context.Context, timeout time.Duration) (context.Context, context.CancelFunc)
- type Handler
- func (h *Handler) ApplyStack() http.HandlerFunc
- func (h *Handler) ApplyStackAsync() http.HandlerFunc
- func (h *Handler) CreateStack() http.HandlerFunc
- func (h *Handler) DeleteStack() http.HandlerFunc
- func (h *Handler) DestroyStack() http.HandlerFunc
- func (h *Handler) DestroyStackAsync() http.HandlerFunc
- func (h *Handler) GenerateStack() http.HandlerFunc
- func (h *Handler) GenerateStackAsync() http.HandlerFunc
- func (h *Handler) GetRun() http.HandlerFunc
- func (h *Handler) GetRunResult() http.HandlerFunc
- func (h *Handler) GetStack() http.HandlerFunc
- func (h *Handler) ListRuns() http.HandlerFunc
- func (h *Handler) ListStacks() http.HandlerFunc
- func (h *Handler) PreviewStack() http.HandlerFunc
- func (h *Handler) PreviewStackAsync() http.HandlerFunc
- func (h *Handler) Shutdown()
- func (h *Handler) UpdateStack() http.HandlerFunc
- type SetRunToFailedFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyToNewContextWithTimeout ¶ added in v0.14.0
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func NewHandler( stackManager *stackmanager.StackManager, maxAsyncConcurrent int, maxAsyncBuffer int, ) (*Handler, error)
func (*Handler) ApplyStack ¶
func (h *Handler) ApplyStack() http.HandlerFunc
@Id applyStack @Summary Apply stack @Description Apply stack information by stack ID @Tags stack @Produce json @Param stackID path int true "Stack ID" @Param importedResources body request.StackImportRequest false "The resources to import during the stack preview" @Param workspace query string true "The target workspace to preview the spec in." @Param importResources query bool false "Import existing resources during the stack preview" @Param specID query string false "The Spec ID to use for the apply. Will generate a new spec if omitted." @Param force query bool false "Force the apply even when the stack is locked. May cause concurrency issues!!!" @Param dryrun query bool false "Apply in dry-run mode" @Success 200 {object} handler.Response{data=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/stacks/{stackID}/apply [post]
func (*Handler) ApplyStackAsync ¶ added in v0.14.0
func (h *Handler) ApplyStackAsync() http.HandlerFunc
@Id applyStackAsync @Summary Asynchronously apply stack @Description Start a run and asynchronously apply stack changes by stack ID @Tags stack @Produce json @Param stackID path int true "Stack ID" @Param importedResources body request.StackImportRequest false "The resources to import during the stack preview" @Param workspace query string true "The target workspace to preview the spec in." @Param importResources query bool false "Import existing resources during the stack preview" @Param specID query string false "The Spec ID to use for the apply. Will generate a new spec if omitted." @Param force query bool false "Force the apply even when the stack is locked. May cause concurrency issues!!!" @Param dryrun query bool false "Apply in dry-run mode" @Success 200 {object} handler.Response{data=entity.Run} "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/stacks/{stackID}/apply/async [post]
func (*Handler) CreateStack ¶
func (h *Handler) CreateStack() http.HandlerFunc
@Id createStack @Summary Create stack @Description Create a new stack @Tags stack @Accept json @Produce json @Param stack body request.CreateStackRequest true "Created stack" @Param fromTemplate query bool false "Whether to create an AppConfig from template when creating the stack" @Param initTopology query bool false "Whether to initialize an AppTopology from template when creating the stack" @Success 200 {object} handler.Response{data=entity.Stack} "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/stacks [post]
func (*Handler) DeleteStack ¶
func (h *Handler) DeleteStack() http.HandlerFunc
@Id deleteStack @Summary Delete stack @Description Delete specified stack by ID @Tags stack @Produce json @Param stackID path int true "Stack ID" @Success 200 {object} handler.Response{data=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/stacks/{stackID} [delete]
func (*Handler) DestroyStack ¶
func (h *Handler) DestroyStack() http.HandlerFunc
@Id destroyStack @Summary Destroy stack @Description Destroy stack information by stack ID @Tags stack @Produce json @Param stackID path int true "Stack ID" @Param workspace query string true "The target workspace to preview the spec in." @Param force query bool false "Force the destroy even when the stack is locked. May cause concurrency issues!!!" @Param dryrun query bool false "Destroy in dry-run mode" @Success 200 {object} handler.Response{data=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/stacks/{stackID}/destroy [post]
func (*Handler) DestroyStackAsync ¶ added in v0.14.0
func (h *Handler) DestroyStackAsync() http.HandlerFunc
@Id destroyStackAsync @Summary Asynchronously destroy stack @Description Start a run and asynchronously destroy stack resources by stack ID @Tags stack @Produce json @Param stackID path int true "Stack ID" @Param workspace query string true "The target workspace to preview the spec in." @Param force query bool false "Force the destroy even when the stack is locked. May cause concurrency issues!!!" @Param dryrun query bool false "Destroy in dry-run mode" @Success 200 {object} handler.Response{data=entity.Run} "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/stacks/{stackID}/destroy/async [post]
func (*Handler) GenerateStack ¶
func (h *Handler) GenerateStack() http.HandlerFunc
@Id generateStack @Summary Generate stack @Description Generate stack information by stack ID @Tags stack @Produce json @Param stackID path int true "Stack ID" @Param workspace query string true "The target workspace to preview the spec in." @Param format query string false "The format to generate the spec in. Choices are: spec. Default to spec." @Param force query bool false "Force the generate even when the stack is locked" @Success 200 {object} handler.Response{data=v1.Spec} "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/stacks/{stackID}/generate [post]
func (*Handler) GenerateStackAsync ¶ added in v0.14.0
func (h *Handler) GenerateStackAsync() http.HandlerFunc
@Id generateStackAsync @Summary Asynchronously generate stack @Description Start a run and asynchronously generate stack spec by stack ID @Tags stack @Produce json @Param stackID path int true "Stack ID" @Param workspace query string true "The target workspace to preview the spec in." @Param format query string false "The format to generate the spec in. Choices are: spec. Default to spec." @Param force query bool false "Force the generate even when the stack is locked" @Success 200 {object} handler.Response{data=entity.Run} "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/stacks/{stackID}/generate/async [post]
func (*Handler) GetRun ¶ added in v0.14.0
func (h *Handler) GetRun() http.HandlerFunc
@Id getRun @Summary Get run @Description Get run information by run ID @Tags run @Produce json @Param runID path int true "Run ID" @Success 200 {object} handler.Response{data=entity.Run} "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/runs/{runID} [get]
func (*Handler) GetRunResult ¶ added in v0.14.0
func (h *Handler) GetRunResult() http.HandlerFunc
@Id getRunResult @Summary Get run result @Description Get run result by run ID @Tags run @Produce json @Param runID path int true "Run ID" @Success 200 {object} handler.Response{data=any} "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/runs/{runID}/result [get]
func (*Handler) GetStack ¶
func (h *Handler) GetStack() http.HandlerFunc
@Id getStack @Summary Get stack @Description Get stack information by stack ID @Tags stack @Produce json @Param stackID path int true "Stack ID" @Success 200 {object} handler.Response{data=entity.Stack} "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/stacks/{stackID} [get]
func (*Handler) ListRuns ¶ added in v0.14.0
func (h *Handler) ListRuns() http.HandlerFunc
@Id listRun @Summary List runs @Description List all runs @Tags stack @Produce json @Param projectID query uint false "ProjectID to filter runs by. Default to all" @Param type query []string false "RunType to filter runs by. Default to all" @Param status query []string false "RunStatus to filter runs by. Default to all" @Param stackID query uint false "StackID to filter runs by. Default to all" @Param workspace query string false "Workspace to filter runs by. Default to all" @Param startTime query string false "StartTime to filter runs by. Default to all. Format: RFC3339" @Param endTime query string false "EndTime to filter runs by. Default to all. Format: RFC3339" @Param page query uint false "The current page to fetch. Default to 1" @Param pageSize query uint false "The size of the page. Default to 10" @Param sortBy query string false "Which field to sort the list by. Default to id" @Param ascending query bool false "Whether to sort the list in ascending order. Default to false" @Success 200 {object} handler.Response{data=response.PaginatedRunResponse} "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/runs [get]
func (*Handler) ListStacks ¶
func (h *Handler) ListStacks() http.HandlerFunc
@Id listStack @Summary List stacks @Description List all stacks @Tags stack @Produce json @Param projectID query uint false "ProjectID to filter stacks by. Default to all" @Param orgID query uint false "OrgID to filter stacks by. Default to all" @Param projectName query string false "ProjectName to filter stacks by. Default to all" @Param path query string false "Path to filter stacks by. Default to all" @Param page query uint false "The current page to fetch. Default to 1" @Param pageSize query uint false "The size of the page. Default to 10" @Param sortBy query string false "Which field to sort the list by. Default to id" @Param ascending query bool false "Whether to sort the list in ascending order. Default to false" @Success 200 {object} handler.Response{data=response.PaginatedStackResponse} "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/stacks [get]
func (*Handler) PreviewStack ¶
func (h *Handler) PreviewStack() http.HandlerFunc
@Id previewStack @Summary Preview stack @Description Preview stack information by stack ID @Tags stack @Produce json @Param stackID path int true "Stack ID" @Param importedResources body request.StackImportRequest false "The resources to import during the stack preview" @Param workspace query string true "The target workspace to preview the spec in." @Param importResources query bool false "Import existing resources during the stack preview" @Param output query string false "Output format. Choices are: json, default. Default to default output format in Kusion." @Param detail query bool false "Show detailed output" @Param specID query string false "The Spec ID to use for the preview. Default to the last one generated." @Param force query bool false "Force the preview even when the stack is locked" @Success 200 {object} handler.Response{data=models.Changes} "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/stacks/{stackID}/preview [post]
func (*Handler) PreviewStackAsync ¶ added in v0.14.0
func (h *Handler) PreviewStackAsync() http.HandlerFunc
@Id previewStackAsync @Summary Asynchronously preview stack @Description Start a run and asynchronously preview stack changes by stack ID @Tags stack @Produce json @Param stackID path int true "Stack ID" @Param importedResources body request.StackImportRequest false "The resources to import during the stack preview" @Param workspace query string true "The target workspace to preview the spec in." @Param importResources query bool false "Import existing resources during the stack preview" @Param output query string false "Output format. Choices are: json, default. Default to default output format in Kusion." @Param detail query bool false "Show detailed output" @Param specID query string false "The Spec ID to use for the preview. Default to the last one generated." @Param force query bool false "Force the preview even when the stack is locked" @Success 200 {object} handler.Response{data=entity.Run} "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/stacks/{stackID}/preview/async [post]
func (*Handler) Shutdown ¶ added in v0.14.0
func (h *Handler) Shutdown()
TODO: graceful shutdown of worker pool when exiting Capture sigterm and sigint signals to shutdown the worker pool
func (*Handler) UpdateStack ¶
func (h *Handler) UpdateStack() http.HandlerFunc
@Id updateStack @Summary Update stack @Description Update the specified stack @Tags stack @Accept json @Produce json @Param stackID path int true "Stack ID" @Param stack body request.UpdateStackRequest true "Updated stack" @Success 200 {object} handler.Response{data=entity.Stack} "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/stacks/{stackID} [put]