| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717 |
- package router
- import (
- "fmt"
- "github.com/go-chi/chi/v5"
- apiContract "github.com/porter-dev/porter/api/server/handlers/api_contract"
- "github.com/porter-dev/porter/api/server/handlers/api_token"
- "github.com/porter-dev/porter/api/server/handlers/billing"
- "github.com/porter-dev/porter/api/server/handlers/cluster"
- "github.com/porter-dev/porter/api/server/handlers/datastore"
- "github.com/porter-dev/porter/api/server/handlers/gitinstallation"
- "github.com/porter-dev/porter/api/server/handlers/helmrepo"
- "github.com/porter-dev/porter/api/server/handlers/infra"
- "github.com/porter-dev/porter/api/server/handlers/policy"
- "github.com/porter-dev/porter/api/server/handlers/project"
- "github.com/porter-dev/porter/api/server/handlers/registry"
- "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"
- )
- func NewProjectScopedRegisterer(children ...*router.Registerer) *router.Registerer {
- return &router.Registerer{
- GetRoutes: GetProjectScopedRoutes,
- Children: children,
- }
- }
- func GetProjectScopedRoutes(
- r chi.Router,
- config *config.Config,
- basePath *types.Path,
- factory shared.APIEndpointFactory,
- children ...*router.Registerer,
- ) []*router.Route {
- routes, projPath := getProjectRoutes(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 getProjectRoutes(
- r chi.Router,
- config *config.Config,
- basePath *types.Path,
- factory shared.APIEndpointFactory,
- ) ([]*router.Route, *types.Path) {
- relPath := "/projects/{project_id}"
- newPath := &types.Path{
- Parent: basePath,
- RelativePath: relPath,
- }
- routes := make([]*router.Route, 0)
- // GET /api/projects/{project_id} -> project.NewProjectGetHandler
- getEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath,
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- getHandler := project.NewProjectGetHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: getEndpoint,
- Handler: getHandler,
- Router: r,
- })
- // DELETE /api/projects/{project_id} -> project.NewProjectDeleteHandler
- deleteEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbDelete,
- Method: types.HTTPVerbDelete,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath,
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- deleteHandler := project.NewProjectDeleteHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: deleteEndpoint,
- Handler: deleteHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/policy -> project.NewProjectGetPolicyHandler
- getPolicyEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/policy",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- getPolicyHandler := project.NewProjectGetPolicyHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: getPolicyEndpoint,
- Handler: getPolicyHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/onboarding -> project.NewProjectGetOnboardingHandler
- getOnboardingEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/onboarding",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- getOnboardingHandler := project.NewOnboardingGetHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: getOnboardingEndpoint,
- Handler: getOnboardingHandler,
- Router: r,
- })
- // POST /api/projects/{project_id}/onboarding -> project.NewProjectGetOnboardingHandler
- updateOnboardingEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbUpdate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/onboarding",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- updateOnboardingHandler := project.NewOnboardingUpdateHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: updateOnboardingEndpoint,
- Handler: updateOnboardingHandler,
- Router: r,
- })
- // POST /api/projects/{project_id}/onboarding_step -> project.UpdateOnboardingStepHandler
- updateOnboardingStepEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbUpdate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/onboarding_step",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- updateOnboardingStepHandler := project.NewUpdateOnboardingStepHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: updateOnboardingStepEndpoint,
- Handler: updateOnboardingStepHandler,
- Router: r,
- })
- // POST /api/projects/{project_id}/invite_admin -> project.NewProjectInviteAdminHandler
- projectInviteAdminEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbCreate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/invite_admin",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- projectInviteAdminHandler := project.NewProjectInviteAdminHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: projectInviteAdminEndpoint,
- Handler: projectInviteAdminHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/usage -> project.NewProjectGetUsageHandler
- getUsageEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/usage",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- getUsageHandler := project.NewProjectGetUsageHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: getUsageEndpoint,
- Handler: getUsageHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/billing -> project.NewCheckPaymentEnabledHandler
- checkPaymentEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/billing",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- checkPaymentHandler := billing.NewCheckPaymentEnabledHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: checkPaymentEndpoint,
- Handler: checkPaymentHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/billing/payment_method -> project.NewListBillingHandler
- listBillingEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/billing/payment_method",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- listBillingHandler := billing.NewListBillingHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: listBillingEndpoint,
- Handler: listBillingHandler,
- Router: r,
- })
- // POST /api/projects/{project_id}/billing/payment_method -> project.NewCreateBillingHandler
- createBillingEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbCreate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/billing/payment_method",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- createBillingHandler := billing.NewCreateBillingHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: createBillingEndpoint,
- Handler: createBillingHandler,
- Router: r,
- })
- // DELETE /api/projects/{project_id}/billing/payment_method/{payment_method_id} -> project.NewDeleteBillingHandler
- deleteBillingEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbDelete,
- Method: types.HTTPVerbDelete,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: fmt.Sprintf("%s/billing/payment_method/{%s}", relPath, types.URLParamPaymentMethodID),
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- deleteBillingHandler := billing.NewDeleteBillingHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: deleteBillingEndpoint,
- Handler: deleteBillingHandler,
- Router: r,
- })
- // POST /api/projects/{project_id}/billing/customer/ -> project.NewGetOrCreateCustomerHandler
- getOrCreateBillingCustomerEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbCreate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/billing/customer",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- getOrCreateBillingCustomerHandler := billing.NewCreateBillingCustomerIfNotExists(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: getOrCreateBillingCustomerEndpoint,
- Handler: getOrCreateBillingCustomerHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/clusters -> cluster.NewClusterListHandler
- listClusterEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbList,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/clusters",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- listClusterHandler := cluster.NewClusterListHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: listClusterEndpoint,
- Handler: listClusterHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/gitrepos -> gitinstallation.NewGitRepoListHandler
- listGitReposEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbList,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/gitrepos",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- listGitReposHandler := gitinstallation.NewGitRepoListHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: listGitReposEndpoint,
- Handler: listGitReposHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/collaborators -> project.NewCollaboratorsListHandler
- listCollaboratorsEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbList,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/collaborators",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- listCollaboratorsHandler := project.NewCollaboratorsListHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: listCollaboratorsEndpoint,
- Handler: listCollaboratorsHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/roles -> project.NewRolesListHandler
- listRolesEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbList,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/roles",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- listRolesHandler := project.NewRolesListHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: listRolesEndpoint,
- Handler: listRolesHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/datastores -> datastore.NewListAllDatastoresForProjectHandler
- listDatastoresEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbList,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/datastores",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- listDatastoresHandler := datastore.NewListDatastoresHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: listDatastoresEndpoint,
- Handler: listDatastoresHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/datastores -> datastore.NewGetDatastoreHandler
- getDatastoreEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbList,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: fmt.Sprintf("%s/datastores/{%s}", relPath, types.URLParamDatastoreName),
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- getDatastoreHandler := datastore.NewGetDatastoreHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: getDatastoreEndpoint,
- Handler: getDatastoreHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/datastores -> datastore.NewGetDatastoreCredentialHandler
- getDatastoreCredentialEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbList,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: fmt.Sprintf("%s/datastores/{%s}/credential", relPath, types.URLParamDatastoreName),
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- getDatastoreCredentialHandler := datastore.NewGetDatastoreCredentialHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: getDatastoreCredentialEndpoint,
- Handler: getDatastoreCredentialHandler,
- Router: r,
- })
- // POST /api/projects/{project_id}/datastores/{datastore_name}/create-proxy -> cluster.NewCreateDatastoreProxyHandler
- createDatastoreProxyEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbUpdate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: fmt.Sprintf("%s/datastores/{%s}/create-proxy", relPath, types.URLParamDatastoreName),
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- createDatastoreProxyHandler := datastore.NewCreateDatastoreProxyHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: createDatastoreProxyEndpoint,
- Handler: createDatastoreProxyHandler,
- Router: r,
- })
- // DELETE /api/projects/{project_id}/datastores/{datastore_name} -> cloud_provider.NewDeleteDatastoreHandler
- deleteDatastoreEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbDelete,
- Method: types.HTTPVerbDelete,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: fmt.Sprintf("%s/datastores/{%s}", relPath, types.URLParamDatastoreName),
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- deleteDatastoreHandler := datastore.NewDeleteDatastoreHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: deleteDatastoreEndpoint,
- Handler: deleteDatastoreHandler,
- Router: r,
- })
- // POST /api/projects/{project_id}/roles -> project.NewRoleUpdateHandler
- updateRoleEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbUpdate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/roles",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- updateRoleHandler := project.NewRoleUpdateHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: updateRoleEndpoint,
- Handler: updateRoleHandler,
- Router: r,
- })
- // DELETE /api/projects/{project_id}/roles -> project.NewRoleDeleteHandler
- deleteRoleEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbDelete,
- Method: types.HTTPVerbDelete,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/roles",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- deleteRoleHandler := project.NewRoleDeleteHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: deleteRoleEndpoint,
- Handler: deleteRoleHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/registries -> registry.NewRegistryListHandler
- listRegistriesEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbList,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/registries",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- listRegistriesHandler := registry.NewRegistryListHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: listRegistriesEndpoint,
- Handler: listRegistriesHandler,
- Router: r,
- })
- // POST /api/projects/{project_id}/registries -> registry.NewRegistryCreateHandler
- createRegistryEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbCreate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/registries",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- createRegistryHandler := registry.NewRegistryCreateHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: createRegistryEndpoint,
- Handler: createRegistryHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/registries/ecr/token -> registry.NewRegistryGetECRTokenHandler
- getECRTokenEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/registries/ecr/token",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- getECRTokenHandler := registry.NewRegistryGetECRTokenHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: getECRTokenEndpoint,
- Handler: getECRTokenHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/registries/docr/token -> registry.NewRegistryGetDOCRTokenHandler
- getDOCRTokenEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/registries/docr/token",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- getDOCRTokenHandler := registry.NewRegistryGetDOCRTokenHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: getDOCRTokenEndpoint,
- Handler: getDOCRTokenHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/registries/gcr/token -> registry.NewRegistryGetGCRTokenHandler
- getGCRTokenEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/registries/gcr/token",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- getGCRTokenHandler := registry.NewRegistryGetGCRTokenHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: getGCRTokenEndpoint,
- Handler: getGCRTokenHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/registries/gar/token -> registry.NewRegistryGetGARTokenHandler
- getGARTokenEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/registries/gar/token",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- getGARTokenHandler := registry.NewRegistryGetGARTokenHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: getGARTokenEndpoint,
- Handler: getGARTokenHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/registries/acr/token -> registry.NewRegistryGetACRTokenHandler
- getACRTokenEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/registries/acr/token",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- getACRTokenHandler := registry.NewRegistryGetACRTokenHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: getACRTokenEndpoint,
- Handler: getACRTokenHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/registries/dockerhub/token -> registry.NewRegistryGetDockerhubTokenHandler
- getDockerhubTokenEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/registries/dockerhub/token",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- getDockerhubTokenHandler := registry.NewRegistryGetDockerhubTokenHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: getDockerhubTokenEndpoint,
- Handler: getDockerhubTokenHandler,
- Router: r,
- })
- // POST /api/projects/{project_id}/infras -> infra.NewInfraCreateHandler
- createInfraEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbCreate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/infras",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- createInfraHandler := infra.NewInfraCreateHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: createInfraEndpoint,
- Handler: createInfraHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/infras/templates -> infra.NewInfraGetHandler
- getTemplatesEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/infras/templates",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- getTemplatesHandler := infra.NewInfraListTemplateHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: getTemplatesEndpoint,
- Handler: getTemplatesHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/infras/templates -> infra.NewInfraGetHandler
- getTemplateEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: fmt.Sprintf("%s/infras/templates/{%s}/{%s}", relPath, types.URLParamTemplateName, types.URLParamTemplateVersion),
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- getTemplateHandler := infra.NewInfraGetTemplateHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: getTemplateEndpoint,
- Handler: getTemplateHandler,
- Router: r,
- })
- // // POST /api/projects/{project_id}/provision/ecr -> provision.NewProvisionECRHandler
- // provisionECREndpoint := factory.NewAPIEndpoint(
- // &types.APIRequestMetadata{
- // Verb: types.APIVerbCreate,
- // Method: types.HTTPVerbPost,
- // Path: &types.Path{
- // Parent: basePath,
- // RelativePath: relPath + "/provision/ecr",
- // },
- // Scopes: []types.PermissionScope{
- // types.UserScope,
- // types.ProjectScope,
- // },
- // },
- // )
- // provisionECRHandler := provision.NewProvisionECRHandler(
- // config,
- // factory.GetDecoderValidator(),
- // factory.GetResultWriter(),
- // )
- // routes = append(routes, &router.Route{
- // Endpoint: provisionECREndpoint,
- // Handler: provisionECRHandler,
- // Router: r,
- // })
- // // POST /api/projects/{project_id}/provision/eks -> provision.NewProvisionEKSHandler
- // provisionEKSEndpoint := factory.NewAPIEndpoint(
- // &types.APIRequestMetadata{
- // Verb: types.APIVerbCreate,
- // Method: types.HTTPVerbPost,
- // Path: &types.Path{
- // Parent: basePath,
- // RelativePath: relPath + "/provision/eks",
- // },
- // Scopes: []types.PermissionScope{
- // types.UserScope,
- // types.ProjectScope,
- // },
- // CheckUsage: true,
- // UsageMetric: types.Clusters,
- // },
- // )
- // provisionEKSHandler := provision.NewProvisionEKSHandler(
- // config,
- // factory.GetDecoderValidator(),
- // factory.GetResultWriter(),
- // )
- // routes = append(routes, &router.Route{
- // Endpoint: provisionEKSEndpoint,
- // Handler: provisionEKSHandler,
- // Router: r,
- // })
- // // POST /api/projects/{project_id}/provision/docr -> provision.NewProvisionDOCRHandler
- // provisionDOCREndpoint := factory.NewAPIEndpoint(
- // &types.APIRequestMetadata{
- // Verb: types.APIVerbCreate,
- // Method: types.HTTPVerbPost,
- // Path: &types.Path{
- // Parent: basePath,
- // RelativePath: relPath + "/provision/docr",
- // },
- // Scopes: []types.PermissionScope{
- // types.UserScope,
- // types.ProjectScope,
- // },
- // },
- // )
- // provisionDOCRHandler := provision.NewProvisionDOCRHandler(
- // config,
- // factory.GetDecoderValidator(),
- // factory.GetResultWriter(),
- // )
- // routes = append(routes, &router.Route{
- // Endpoint: provisionDOCREndpoint,
- // Handler: provisionDOCRHandler,
- // Router: r,
- // })
- // // POST /api/projects/{project_id}/provision/doks -> provision.NewProvisionDOKSHandler
- // provisionDOKSEndpoint := factory.NewAPIEndpoint(
- // &types.APIRequestMetadata{
- // Verb: types.APIVerbCreate,
- // Method: types.HTTPVerbPost,
- // Path: &types.Path{
- // Parent: basePath,
- // RelativePath: relPath + "/provision/doks",
- // },
- // Scopes: []types.PermissionScope{
- // types.UserScope,
- // types.ProjectScope,
- // },
- // CheckUsage: true,
- // UsageMetric: types.Clusters,
- // },
- // )
- // provisionDOKSHandler := provision.NewProvisionDOKSHandler(
- // config,
- // factory.GetDecoderValidator(),
- // factory.GetResultWriter(),
- // )
- // routes = append(routes, &router.Route{
- // Endpoint: provisionDOKSEndpoint,
- // Handler: provisionDOKSHandler,
- // Router: r,
- // })
- // // POST /api/projects/{project_id}/provision/gcr -> provision.NewProvisionGCRHandler
- // provisionGCREndpoint := factory.NewAPIEndpoint(
- // &types.APIRequestMetadata{
- // Verb: types.APIVerbCreate,
- // Method: types.HTTPVerbPost,
- // Path: &types.Path{
- // Parent: basePath,
- // RelativePath: relPath + "/provision/gcr",
- // },
- // Scopes: []types.PermissionScope{
- // types.UserScope,
- // types.ProjectScope,
- // },
- // },
- // )
- // provisionGCRHandler := provision.NewProvisionGCRHandler(
- // config,
- // factory.GetDecoderValidator(),
- // factory.GetResultWriter(),
- // )
- // routes = append(routes, &router.Route{
- // Endpoint: provisionGCREndpoint,
- // Handler: provisionGCRHandler,
- // Router: r,
- // })
- // // POST /api/projects/{project_id}/provision/gke -> provision.NewProvisionGKEHandler
- // provisionGKEEndpoint := factory.NewAPIEndpoint(
- // &types.APIRequestMetadata{
- // Verb: types.APIVerbCreate,
- // Method: types.HTTPVerbPost,
- // Path: &types.Path{
- // Parent: basePath,
- // RelativePath: relPath + "/provision/gke",
- // },
- // Scopes: []types.PermissionScope{
- // types.UserScope,
- // types.ProjectScope,
- // },
- // CheckUsage: true,
- // UsageMetric: types.Clusters,
- // },
- // )
- // provisionGKEHandler := provision.NewProvisionGKEHandler(
- // config,
- // factory.GetDecoderValidator(),
- // factory.GetResultWriter(),
- // )
- // routes = append(routes, &router.Route{
- // Endpoint: provisionGKEEndpoint,
- // Handler: provisionGKEHandler,
- // Router: r,
- // })
- // POST /api/projects/{project_id}/connect -> project.NewProjectConnectHandler
- connectEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbCreate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/connect",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.SettingsScope,
- },
- },
- )
- connectHandler := project.NewConnectHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: connectEndpoint,
- Handler: connectHandler,
- Router: r,
- })
- // POST /api/projects/{project_id}/policy -> policy.NewPolicyCreateHandler
- policyCreateEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbCreate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/policy",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.SettingsScope,
- },
- },
- )
- policyCreateHandler := policy.NewPolicyCreateHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: policyCreateEndpoint,
- Handler: policyCreateHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/policies -> policy.NewPolicyListHandler
- policyListEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbList,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/policies",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.SettingsScope,
- },
- },
- )
- policyListHandler := policy.NewPolicyListHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: policyListEndpoint,
- Handler: policyListHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/policy/{policy_id} -> policy.NewPolicyGetHandler
- policyGetEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: fmt.Sprintf("%s/policy/{%s}", relPath, types.URLParamPolicyID),
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.SettingsScope,
- },
- },
- )
- policyGetHandler := policy.NewPolicyGetHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: policyGetEndpoint,
- Handler: policyGetHandler,
- Router: r,
- })
- // POST /api/projects/{project_id}/api_token -> api_token.NewAPITokenCreateHandler
- apiTokenCreateEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbCreate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/api_token",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.SettingsScope,
- },
- },
- )
- apiTokenCreateHandler := api_token.NewAPITokenCreateHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: apiTokenCreateEndpoint,
- Handler: apiTokenCreateHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/api_token -> api_token.NewAPITokenListHandler
- apiTokenListEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbList,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: fmt.Sprintf("%s/api_token", relPath),
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.SettingsScope,
- },
- },
- )
- apiTokenListHandler := api_token.NewAPITokenListHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: apiTokenListEndpoint,
- Handler: apiTokenListHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/api_token/{api_token_id} -> api_token.NewAPITokenGetHandler
- apiTokenGetEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: fmt.Sprintf("%s/api_token/{%s}", relPath, types.URLParamTokenID),
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.SettingsScope,
- },
- },
- )
- apiTokenGetHandler := api_token.NewAPITokenGetHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: apiTokenGetEndpoint,
- Handler: apiTokenGetHandler,
- Router: r,
- })
- // POST /api/projects/{project_id}/api_token/{api_token_id}/revoke -> api_token.NewAPITokenRevokeHandler
- apiTokenRevokeEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbUpdate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: fmt.Sprintf("%s/api_token/{%s}/revoke", relPath, types.URLParamTokenID),
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.SettingsScope,
- },
- },
- )
- apiTokenRevokeHandler := api_token.NewAPITokenRevokeHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: apiTokenRevokeEndpoint,
- Handler: apiTokenRevokeHandler,
- Router: r,
- })
- // POST /api/projects/{project_id}/helmrepos -> helmrepo.NewHelmRepoCreateHandler
- hrCreateEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbCreate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/helmrepos",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- hrCreateHandler := helmrepo.NewHelmRepoCreateHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: hrCreateEndpoint,
- Handler: hrCreateHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/helmrepos -> helmrepo.NewHelmRepoListHandler
- hrListEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbList,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/helmrepos",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- hrListHandler := helmrepo.NewHelmRepoListHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: hrListEndpoint,
- Handler: hrListHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/tags -> project.NewGetTagsHandler
- getTagsEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/tags",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- getTagsHandler := project.NewGetTagsHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: getTagsEndpoint,
- Handler: getTagsHandler,
- Router: r,
- })
- // POST /api/projects/{project_id}/tags -> project.NewCreateTagHandler
- createTagEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbCreate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/tags",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- createTagHandler := project.NewCreateTagHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: createTagEndpoint,
- Handler: createTagHandler,
- Router: r,
- })
- // POST /api/projects/{project_id}/contract -> apiContract.NewAPIContractUpdateHandler
- updateAPIContractEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbCreate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/contract",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- updateAPIContractHandler := apiContract.NewAPIContractUpdateHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: updateAPIContractEndpoint,
- Handler: updateAPIContractHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/contracts -> apiContract.NewAPIContractRevisionListHandler
- listAPIContractRevisionsEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbGet,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/contracts",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- listAPIContractRevisionHandler := apiContract.NewAPIContractRevisionListHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: listAPIContractRevisionsEndpoint,
- Handler: listAPIContractRevisionHandler,
- Router: r,
- })
- // DELETE /api/projects/{project_id}/contracts/{revision_id} -> apiContract.NewAPIContractUpdateHandler
- deleteAPIContractRevisionsEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbDelete,
- Method: types.HTTPVerbDelete,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: fmt.Sprintf("%s/contracts/{%s}", relPath, types.URLParamAPIContractRevisionID),
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- types.APIContractRevisionScope,
- },
- },
- )
- deleteAPIContractRevisionHandler := apiContract.NewAPIContractRevisionDeleteHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: deleteAPIContractRevisionsEndpoint,
- Handler: deleteAPIContractRevisionHandler,
- Router: r,
- })
- // POST /api/projects/{project_id}/contract/preflight -> apiContract.NewPreflightCheckHandler
- preflightCheckEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbCreate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: fmt.Sprintf("%s/contract/preflight", relPath),
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- preflightCheckHandler := apiContract.NewPreflightCheckHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: preflightCheckEndpoint,
- Handler: preflightCheckHandler,
- Router: r,
- })
- // POST /api/projects/{project_id}/rename -> cluster.newRenamProject
- renameProjectEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbCreate,
- Method: types.HTTPVerbPost,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/rename",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- renameProjectHandler := project.NewRenameProjectHandler(
- config,
- factory.GetDecoderValidator(),
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: renameProjectEndpoint,
- Handler: renameProjectHandler,
- Router: r,
- })
- // GET /api/projects/{project_id}/images -> project.ImagesHandler
- imagesEndpoint := factory.NewAPIEndpoint(
- &types.APIRequestMetadata{
- Verb: types.APIVerbList,
- Method: types.HTTPVerbGet,
- Path: &types.Path{
- Parent: basePath,
- RelativePath: relPath + "/images",
- },
- Scopes: []types.PermissionScope{
- types.UserScope,
- types.ProjectScope,
- },
- },
- )
- imagesHandler := project.NewImagesHandler(
- config,
- factory.GetResultWriter(),
- )
- routes = append(routes, &router.Route{
- Endpoint: imagesEndpoint,
- Handler: imagesHandler,
- Router: r,
- })
- return routes, newPath
- }
|