| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880 |
- package v1
- import (
- "github.com/go-chi/chi/v5"
- "github.com/porter-dev/porter/api/server/handlers/stack"
- "github.com/porter-dev/porter/api/server/shared"
- "github.com/porter-dev/porter/api/server/shared/config"
- "github.com/porter-dev/porter/api/server/shared/router"
- "github.com/porter-dev/porter/api/types"
- )
- // swagger:parameters getStack deleteStack putStackSource rollbackStack listStackRevisions addApplication addEnvGroup updateStack
- type stackPathParams struct {
- // The project id
- // in: path
- // required: true
- // minimum: 1
- ProjectID uint `json:"project_id"`
- // The cluster id
- // in: path
- // required: true
- // minimum: 1
- ClusterID uint `json:"cluster_id"`
- // The namespace
- // in: path
- // required: true
- Namespace string `json:"namespace"`
- // The stack id
- // in: path
- // required: true
- StackID string `json:"stack_id"`
- }
- // swagger:parameters getStackRevision
- type stackRevisionPathParams struct {
- // The project id
- // in: path
- // required: true
- // minimum: 1
- ProjectID uint `json:"project_id"`
- // The cluster id
- // in: path
- // required: true
- // minimum: 1
- ClusterID uint `json:"cluster_id"`
- // The namespace
- // in: path
- // required: true
- Namespace string `json:"namespace"`
- // The stack id
- // in: path
- // required: true
- StackID string `json:"stack_id"`
- // The stack revision id
- // in: path
- // required: true
- // minimum: 1
- RevisionID string `json:"revision_id"`
- }
- // swagger:parameters removeApplication
- type stackRemoveApplicationPathParams struct {
- // The project id
- // in: path
- // required: true
- // minimum: 1
- ProjectID uint `json:"project_id"`
- // The cluster id
- // in: path
- // required: true
- // minimum: 1
- ClusterID uint `json:"cluster_id"`
- // The namespace
- // in: path
- // required: true
- Namespace string `json:"namespace"`
- // The stack id
- // in: path
- // required: true
- StackID string `json:"stack_id"`
- // The name of the application
- // in: path
- // required: true
- AppResourceName string `json:"app_resource_name"`
- }
- // swagger:parameters removeEnvGroup
- type stackRemoveEnvGroupPathParams struct {
- // The project id
- // in: path
- // required: true
- // minimum: 1
- ProjectID uint `json:"project_id"`
- // The cluster id
- // in: path
- // required: true
- // minimum: 1
- ClusterID uint `json:"cluster_id"`
- // The namespace
- // in: path
- // required: true
- Namespace string `json:"namespace"`
- // The stack id
- // in: path
- // required: true
- StackID string `json:"stack_id"`
- // The name of the environment group
- // in: path
- // required: true
- EnvGroupName string `json:"env_group_name"`
- }
- func NewV1StackScopedRegisterer(children ...*router.Registerer) *router.Registerer {
- return &router.Registerer{
- GetRoutes: GetV1StackScopedRoutes,
- Children: children,
- }
- }
- func GetV1StackScopedRoutes(
- r chi.Router,
- config *config.Config,
- basePath *types.Path,
- factory shared.APIEndpointFactory,
- children ...*router.Registerer,
- ) []*router.Route {
- routes, projPath := getV1StackRoutes(r, config, basePath, factory)
- if len(children) > 0 {
- r.Route(projPath.RelativePath, func(r chi.Router) {
- for _, child := range children {
- childRoutes := child.GetRoutes(r, config, basePath, factory, child.Children...)
- routes = append(routes, childRoutes...)
- }
- })
- }
- return routes
- }
- func getV1StackRoutes(
- r chi.Router,
- config *config.Config,
- basePath *types.Path,
- factory shared.APIEndpointFactory,
- ) ([]*router.Route, *types.Path) {
- relPath := "/stacks"
- newPath := &types.Path{
- Parent: basePath,
- RelativePath: relPath,
- }
- var routes []*router.Route
- // POST /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks -> stack.NewStackCreateHandler
- // swagger:operation POST /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks createStack
- //
- // Creates a new stack and triggers a deployment for all resources in the stack.
- //
- // ---
- // produces:
- // - application/json
- // summary: Create a stack
- // tags:
- // - Stacks
- // parameters:
- // - name: project_id
- // - name: cluster_id
- // - name: namespace
- // - in: body
- // name: CreateStackRequest
- // description: The stack to create
- // schema:
- // $ref: '#/definitions/CreateStackRequest'
- // responses:
- // '201':
- // description: Successfully created the stack
- // schema:
- // $ref: '#/definitions/Stack'
- // '403':
- // description: Forbidden
- createEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbCreate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath,
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.ClusterScope,
- types.NamespaceScope,
- },
- },
- )
- createHandler := stack.NewStackCreateHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: createEndpoint,
- Handler: createHandler,
- Router: r,
- })
- // GET /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks -> stack.NewStackListHandler
- // swagger:operation GET /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks listStacks
- //
- // Lists stacks in a namespace
- //
- // ---
- // produces:
- // - application/json
- // summary: List stacks
- // tags:
- // - Stacks
- // parameters:
- // - name: project_id
- // - name: cluster_id
- // - name: namespace
- // responses:
- // '200':
- // description: Successfully listed stacks
- // schema:
- // $ref: '#/definitions/StackListResponse'
- // '403':
- // description: Forbidden
- listEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath,
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.ClusterScope,
- types.NamespaceScope,
- },
- },
- )
- listHandler := stack.NewStackListHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: listEndpoint,
- Handler: listHandler,
- Router: r,
- })
- // GET /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id} -> stack.NewStackGetHandler
- // swagger:operation GET /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id} getStack
- //
- // Gets a stack
- //
- // ---
- // produces:
- // - application/json
- // summary: Get a stack
- // tags:
- // - Stacks
- // parameters:
- // - name: project_id
- // - name: cluster_id
- // - name: namespace
- // - name: stack_id
- // responses:
- // '200':
- // description: Successfully got the stack
- // schema:
- // $ref: '#/definitions/Stack'
- // '403':
- // description: Forbidden
- getEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/{stack_id}",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.ClusterScope,
- types.NamespaceScope,
- types.StackScope,
- },
- },
- )
- getHandler := stack.NewStackGetHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: getEndpoint,
- Handler: getHandler,
- Router: r,
- })
- // GET /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id}/revisions -> stack.NewStackListRevisionsHandler
- // swagger:operation GET /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id}/revisions listStackRevisions
- //
- // Lists revisions in a stack. A max of 100 revisions will be returned, sorted from most recent to least recent.
- //
- // ---
- // produces:
- // - application/json
- // summary: List stack revisions
- // tags:
- // - Stacks
- // parameters:
- // - name: project_id
- // - name: cluster_id
- // - name: namespace
- // - name: stack_id
- // responses:
- // '200':
- // description: Successfully listed stack revisions
- // schema:
- // $ref: '#/definitions/ListStackRevisionsResponse'
- // '403':
- // description: Forbidden
- listRevisionsEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/{stack_id}/revisions",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.ClusterScope,
- types.NamespaceScope,
- types.StackScope,
- },
- },
- )
- listRevisionsHandler := stack.NewStackListRevisionsHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: listRevisionsEndpoint,
- Handler: listRevisionsHandler,
- Router: r,
- })
- // GET /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id}/{revision_id} -> stack.NewStackGetRevisionHandler
- // swagger:operation GET /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id}/{revision_id} getStackRevision
- //
- // Gets a stack revision
- //
- // ---
- // produces:
- // - application/json
- // summary: Get a stack revision
- // tags:
- // - Stacks
- // parameters:
- // - name: project_id
- // - name: cluster_id
- // - name: namespace
- // - name: stack_id
- // - name: revision_id
- // responses:
- // '200':
- // description: Successfully got the stack revision
- // schema:
- // $ref: '#/definitions/StackRevision'
- // '403':
- // description: Forbidden
- getRevisionEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/{stack_id}/{stack_revision_number}",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.ClusterScope,
- types.NamespaceScope,
- types.StackScope,
- },
- },
- )
- getRevisionHandler := stack.NewStackGetRevisionHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: getRevisionEndpoint,
- Handler: getRevisionHandler,
- Router: r,
- })
- // PUT /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id}/source -> stack.NewStackPutSourceConfig
- // swagger:operation PUT /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id}/source putStackSource
- //
- // Updates a stack's source configuration
- //
- // ---
- // produces:
- // - application/json
- // summary: Update source configuration
- // tags:
- // - Stacks
- // parameters:
- // - name: project_id
- // - name: cluster_id
- // - name: namespace
- // - name: stack_id
- // - in: body
- // name: PutStackSourceConfigRequest
- // description: The source configurations to update
- // schema:
- // $ref: '#/definitions/PutStackSourceConfigRequest'
- // responses:
- // '200':
- // description: Successfully updated the source configuration
- // schema:
- // $ref: '#/definitions/Stack'
- // '403':
- // description: Forbidden
- putSourceEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbUpdate,
- Method: types.HTTPVerbPut,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/{stack_id}/source",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.ClusterScope,
- types.NamespaceScope,
- types.StackScope,
- },
- },
- )
- putSourceHandler := stack.NewStackPutSourceConfigHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: putSourceEndpoint,
- Handler: putSourceHandler,
- Router: r,
- })
- // POST /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id}/rollback -> stack.NewStackRollbackHandler
- // swagger:operation POST /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id}/rollback rollbackStack
- //
- // Performs a rollback for a stack
- //
- // ---
- // produces:
- // - application/json
- // summary: Rollback stack
- // tags:
- // - Stacks
- // parameters:
- // - name: project_id
- // - name: cluster_id
- // - name: namespace
- // - name: stack_id
- // - in: body
- // name: StackRollbackRequest
- // description: The target revision to roll back to
- // schema:
- // $ref: '#/definitions/StackRollbackRequest'
- // responses:
- // '200':
- // description: Successfully rolled the stack back
- // schema:
- // $ref: '#/definitions/Stack'
- // '403':
- // description: Forbidden
- rollbackEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbUpdate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/{stack_id}/rollback",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.ClusterScope,
- types.NamespaceScope,
- types.StackScope,
- },
- },
- )
- rollbackHandler := stack.NewStackRollbackHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: rollbackEndpoint,
- Handler: rollbackHandler,
- Router: r,
- })
- // DELETE /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id} -> stack.NewStackDeleteHandler
- // swagger:operation DELETE /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id} deleteStack
- //
- // Deletes a stack
- //
- // ---
- // produces:
- // - application/json
- // summary: Delete a stack
- // tags:
- // - Stacks
- // parameters:
- // - name: project_id
- // - name: cluster_id
- // - name: namespace
- // - name: stack_id
- // responses:
- // '200':
- // description: Successfully deleted the stack
- // '403':
- // description: Forbidden
- deleteEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbDelete,
- Method: types.HTTPVerbDelete,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/{stack_id}",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.ClusterScope,
- types.NamespaceScope,
- types.StackScope,
- },
- },
- )
- deleteHandler := stack.NewStackDeleteHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: deleteEndpoint,
- Handler: deleteHandler,
- Router: r,
- })
- // PATCH /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id}/add_application -> stack.NewStackAddApplicationHandler
- // swagger:operation PATCH /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id}/add_application addApplication
- //
- // Adds an application to an existing stack
- //
- // ---
- // produces:
- // - application/json
- // summary: Add an application to a stack
- // tags:
- // - Stacks
- // parameters:
- // - name: project_id
- // - name: cluster_id
- // - name: namespace
- // - name: stack_id
- // - in: body
- // name: AddApplicationToStack
- // description: The application to add
- // schema:
- // $ref: '#/definitions/CreateStackAppResourceRequest'
- // responses:
- // '200':
- // description: Successfully added the application to the stack
- // '400':
- // description: Stack does not have any revisions
- // '403':
- // description: Forbidden
- addApplicationEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbUpdate,
- Method: types.HTTPVerbPatch,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/{stack_id}/add_application",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.ClusterScope,
- types.NamespaceScope,
- types.StackScope,
- },
- },
- )
- addApplicationHandler := stack.NewStackAddApplicationHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: addApplicationEndpoint,
- Handler: addApplicationHandler,
- Router: r,
- })
- // DELETE /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id}/remove_application/{app_resource_name} -> stack.NewStackRemoveApplicationHandler
- // swagger:operation DELETE /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id}/remove_application/{app_resource_name} removeApplication
- //
- // Removes an existing application from a stack
- //
- // ---
- // produces:
- // - application/json
- // summary: Remove an application from a stack
- // tags:
- // - Stacks
- // parameters:
- // - name: project_id
- // - name: cluster_id
- // - name: namespace
- // - name: stack_id
- // - name: app_resource_name
- // responses:
- // '200':
- // description: Successfully deleted the application from the stack
- // '400':
- // description: Stack does not have any revisions
- // '403':
- // description: Forbidden
- removeApplicationEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbDelete,
- Method: types.HTTPVerbDelete,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/{stack_id}/remove_application/{app_resource_name}",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.ClusterScope,
- types.NamespaceScope,
- types.StackScope,
- },
- },
- )
- removeApplicationHandler := stack.NewStackRemoveApplicationHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: removeApplicationEndpoint,
- Handler: removeApplicationHandler,
- Router: r,
- })
- // PATCH /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id}/add_env_group -> stack.NewStackAddEnvGroupHandler
- // swagger:operation PATCH /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id}/add_env_group addEnvGroup
- //
- // Adds an environment group to an existing stack
- //
- // ---
- // produces:
- // - application/json
- // summary: Add an environment group to a stack
- // tags:
- // - Stacks
- // parameters:
- // - name: project_id
- // - name: cluster_id
- // - name: namespace
- // - name: stack_id
- // - in: body
- // name: AddEnvGroupToStack
- // description: The environment group to add
- // schema:
- // $ref: '#/definitions/CreateStackEnvGroupRequest'
- // responses:
- // '200':
- // description: Successfully added the environment group to the stack
- // '400':
- // description: Stack does not have any revisions
- // '403':
- // description: Forbidden
- addEnvGroupEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbUpdate,
- Method: types.HTTPVerbPatch,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/{stack_id}/add_env_group",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.ClusterScope,
- types.NamespaceScope,
- types.StackScope,
- },
- },
- )
- addEnvGroupHandler := stack.NewStackAddEnvGroupHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: addEnvGroupEndpoint,
- Handler: addEnvGroupHandler,
- Router: r,
- })
- // DELETE /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id}/remove_env_group/{env_group_name} -> stack.NewStackRemoveEnvGroupHandler
- // swagger:operation DELETE /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id}/remove_env_group/{env_group_name} removeEnvGroup
- //
- // Removes an existing environment group from a stack
- //
- // ---
- // produces:
- // - application/json
- // summary: Remove an environment group from a stack
- // tags:
- // - Stacks
- // parameters:
- // - name: project_id
- // - name: cluster_id
- // - name: namespace
- // - name: stack_id
- // - name: env_group_name
- // responses:
- // '200':
- // description: Successfully deleted the environment group from the stack
- // '400':
- // description: Stack does not have any revisions
- // '403':
- // description: Forbidden
- removeEnvGroupEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbDelete,
- Method: types.HTTPVerbDelete,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/{stack_id}/remove_env_group/{env_group_name}",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.ClusterScope,
- types.NamespaceScope,
- types.StackScope,
- },
- },
- )
- removeEnvGroupHandler := stack.NewStackRemoveEnvGroupHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: removeEnvGroupEndpoint,
- Handler: removeEnvGroupHandler,
- Router: r,
- })
- // PATCH /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id} -> stack.NewStackUpdateStackHandler
- // swagger:operation PATCH /api/v1/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/stacks/{stack_id} updateStack
- //
- // Updates a stack. Currently the only value available to update is the stack name.
- //
- // ---
- // produces:
- // - application/json
- // summary: Update Stack
- // tags:
- // - Stacks
- // parameters:
- // - name: project_id
- // - name: cluster_id
- // - name: namespace
- // - name: stack_id
- // - in: body
- // name: UpdateStack
- // description: The stack to update
- // schema:
- // $ref: '#/definitions/UpdateStackRequest'
- // responses:
- // '200':
- // description: Successfully updated the stack
- // '403':
- // description: Forbidden
- updateStackEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbUpdate,
- Method: types.HTTPVerbPatch,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/{stack_id}",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.ClusterScope,
- types.NamespaceScope,
- types.StackScope,
- },
- },
- )
- updateStackHandler := stack.NewStackUpdateStackHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: updateStackEndpoint,
- Handler: updateStackHandler,
- Router: r,
- })
- return routes, newPath
- }
|