project.go 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053
  1. package router
  2. import (
  3. "fmt"
  4. "github.com/porter-dev/porter/api/server/handlers/cloud_provider"
  5. "github.com/porter-dev/porter/api/server/handlers/neon_integration"
  6. "github.com/porter-dev/porter/api/server/handlers/upstash_integration"
  7. "github.com/porter-dev/porter/api/server/handlers/deployment_target"
  8. "github.com/go-chi/chi/v5"
  9. apiContract "github.com/porter-dev/porter/api/server/handlers/api_contract"
  10. "github.com/porter-dev/porter/api/server/handlers/api_token"
  11. "github.com/porter-dev/porter/api/server/handlers/billing"
  12. "github.com/porter-dev/porter/api/server/handlers/cluster"
  13. "github.com/porter-dev/porter/api/server/handlers/datastore"
  14. "github.com/porter-dev/porter/api/server/handlers/gitinstallation"
  15. "github.com/porter-dev/porter/api/server/handlers/helmrepo"
  16. "github.com/porter-dev/porter/api/server/handlers/infra"
  17. "github.com/porter-dev/porter/api/server/handlers/policy"
  18. "github.com/porter-dev/porter/api/server/handlers/project"
  19. "github.com/porter-dev/porter/api/server/handlers/registry"
  20. "github.com/porter-dev/porter/api/server/shared"
  21. "github.com/porter-dev/porter/api/server/shared/config"
  22. "github.com/porter-dev/porter/api/server/shared/router"
  23. "github.com/porter-dev/porter/api/types"
  24. )
  25. func NewProjectScopedRegisterer(children ...*router.Registerer) *router.Registerer {
  26. return &router.Registerer{
  27. GetRoutes: GetProjectScopedRoutes,
  28. Children: children,
  29. }
  30. }
  31. func GetProjectScopedRoutes(
  32. r chi.Router,
  33. config *config.Config,
  34. basePath *types.Path,
  35. factory shared.APIEndpointFactory,
  36. children ...*router.Registerer,
  37. ) []*router.Route {
  38. routes, projPath := getProjectRoutes(r, config, basePath, factory)
  39. if len(children) > 0 {
  40. r.Route(projPath.RelativePath, func(r chi.Router) {
  41. for _, child := range children {
  42. childRoutes := child.GetRoutes(r, config, basePath, factory, child.Children...)
  43. routes = append(routes, childRoutes...)
  44. }
  45. })
  46. }
  47. return routes
  48. }
  49. func getProjectRoutes(
  50. r chi.Router,
  51. config *config.Config,
  52. basePath *types.Path,
  53. factory shared.APIEndpointFactory,
  54. ) ([]*router.Route, *types.Path) {
  55. relPath := "/projects/{project_id}"
  56. newPath := &types.Path{
  57. Parent: basePath,
  58. RelativePath: relPath,
  59. }
  60. routes := make([]*router.Route, 0)
  61. // GET /api/projects/{project_id} -> project.NewProjectGetHandler
  62. getEndpoint := factory.NewAPIEndpoint(
  63. &types.APIRequestMetadata{
  64. Verb: types.APIVerbGet,
  65. Method: types.HTTPVerbGet,
  66. Path: &types.Path{
  67. Parent: basePath,
  68. RelativePath: relPath,
  69. },
  70. Scopes: []types.PermissionScope{
  71. types.UserScope,
  72. types.ProjectScope,
  73. },
  74. },
  75. )
  76. getHandler := project.NewProjectGetHandler(
  77. config,
  78. factory.GetResultWriter(),
  79. )
  80. routes = append(routes, &router.Route{
  81. Endpoint: getEndpoint,
  82. Handler: getHandler,
  83. Router: r,
  84. })
  85. // DELETE /api/projects/{project_id} -> project.NewProjectDeleteHandler
  86. deleteEndpoint := factory.NewAPIEndpoint(
  87. &types.APIRequestMetadata{
  88. Verb: types.APIVerbDelete,
  89. Method: types.HTTPVerbDelete,
  90. Path: &types.Path{
  91. Parent: basePath,
  92. RelativePath: relPath,
  93. },
  94. Scopes: []types.PermissionScope{
  95. types.UserScope,
  96. types.ProjectScope,
  97. },
  98. },
  99. )
  100. deleteHandler := project.NewProjectDeleteHandler(
  101. config,
  102. factory.GetResultWriter(),
  103. )
  104. routes = append(routes, &router.Route{
  105. Endpoint: deleteEndpoint,
  106. Handler: deleteHandler,
  107. Router: r,
  108. })
  109. // GET /api/projects/{project_id}/policy -> project.NewProjectGetPolicyHandler
  110. getPolicyEndpoint := factory.NewAPIEndpoint(
  111. &types.APIRequestMetadata{
  112. Verb: types.APIVerbGet,
  113. Method: types.HTTPVerbGet,
  114. Path: &types.Path{
  115. Parent: basePath,
  116. RelativePath: relPath + "/policy",
  117. },
  118. Scopes: []types.PermissionScope{
  119. types.UserScope,
  120. types.ProjectScope,
  121. },
  122. },
  123. )
  124. getPolicyHandler := project.NewProjectGetPolicyHandler(
  125. config,
  126. factory.GetResultWriter(),
  127. )
  128. routes = append(routes, &router.Route{
  129. Endpoint: getPolicyEndpoint,
  130. Handler: getPolicyHandler,
  131. Router: r,
  132. })
  133. // GET /api/projects/{project_id}/onboarding -> project.NewProjectGetOnboardingHandler
  134. getOnboardingEndpoint := factory.NewAPIEndpoint(
  135. &types.APIRequestMetadata{
  136. Verb: types.APIVerbGet,
  137. Method: types.HTTPVerbGet,
  138. Path: &types.Path{
  139. Parent: basePath,
  140. RelativePath: relPath + "/onboarding",
  141. },
  142. Scopes: []types.PermissionScope{
  143. types.UserScope,
  144. types.ProjectScope,
  145. },
  146. },
  147. )
  148. getOnboardingHandler := project.NewOnboardingGetHandler(
  149. config,
  150. factory.GetDecoderValidator(),
  151. factory.GetResultWriter(),
  152. )
  153. routes = append(routes, &router.Route{
  154. Endpoint: getOnboardingEndpoint,
  155. Handler: getOnboardingHandler,
  156. Router: r,
  157. })
  158. // POST /api/projects/{project_id}/onboarding -> project.NewProjectGetOnboardingHandler
  159. updateOnboardingEndpoint := factory.NewAPIEndpoint(
  160. &types.APIRequestMetadata{
  161. Verb: types.APIVerbUpdate,
  162. Method: types.HTTPVerbPost,
  163. Path: &types.Path{
  164. Parent: basePath,
  165. RelativePath: relPath + "/onboarding",
  166. },
  167. Scopes: []types.PermissionScope{
  168. types.UserScope,
  169. types.ProjectScope,
  170. },
  171. },
  172. )
  173. updateOnboardingHandler := project.NewOnboardingUpdateHandler(
  174. config,
  175. factory.GetDecoderValidator(),
  176. factory.GetResultWriter(),
  177. )
  178. routes = append(routes, &router.Route{
  179. Endpoint: updateOnboardingEndpoint,
  180. Handler: updateOnboardingHandler,
  181. Router: r,
  182. })
  183. // POST /api/projects/{project_id}/onboarding_step -> project.UpdateOnboardingStepHandler
  184. updateOnboardingStepEndpoint := factory.NewAPIEndpoint(
  185. &types.APIRequestMetadata{
  186. Verb: types.APIVerbUpdate,
  187. Method: types.HTTPVerbPost,
  188. Path: &types.Path{
  189. Parent: basePath,
  190. RelativePath: relPath + "/onboarding_step",
  191. },
  192. Scopes: []types.PermissionScope{
  193. types.UserScope,
  194. types.ProjectScope,
  195. },
  196. },
  197. )
  198. updateOnboardingStepHandler := project.NewUpdateOnboardingStepHandler(
  199. config,
  200. factory.GetDecoderValidator(),
  201. factory.GetResultWriter(),
  202. )
  203. routes = append(routes, &router.Route{
  204. Endpoint: updateOnboardingStepEndpoint,
  205. Handler: updateOnboardingStepHandler,
  206. Router: r,
  207. })
  208. // POST /api/projects/{project_id}/invite_admin -> project.NewProjectInviteAdminHandler
  209. projectInviteAdminEndpoint := factory.NewAPIEndpoint(
  210. &types.APIRequestMetadata{
  211. Verb: types.APIVerbCreate,
  212. Method: types.HTTPVerbPost,
  213. Path: &types.Path{
  214. Parent: basePath,
  215. RelativePath: relPath + "/invite_admin",
  216. },
  217. Scopes: []types.PermissionScope{
  218. types.UserScope,
  219. types.ProjectScope,
  220. },
  221. },
  222. )
  223. projectInviteAdminHandler := project.NewProjectInviteAdminHandler(
  224. config,
  225. factory.GetDecoderValidator(),
  226. factory.GetResultWriter(),
  227. )
  228. routes = append(routes, &router.Route{
  229. Endpoint: projectInviteAdminEndpoint,
  230. Handler: projectInviteAdminHandler,
  231. Router: r,
  232. })
  233. // GET /api/projects/{project_id}/usage -> project.NewProjectGetUsageHandler
  234. getUsageEndpoint := factory.NewAPIEndpoint(
  235. &types.APIRequestMetadata{
  236. Verb: types.APIVerbGet,
  237. Method: types.HTTPVerbGet,
  238. Path: &types.Path{
  239. Parent: basePath,
  240. RelativePath: relPath + "/usage",
  241. },
  242. Scopes: []types.PermissionScope{
  243. types.UserScope,
  244. types.ProjectScope,
  245. },
  246. },
  247. )
  248. getUsageHandler := project.NewProjectGetUsageHandler(
  249. config,
  250. factory.GetResultWriter(),
  251. )
  252. routes = append(routes, &router.Route{
  253. Endpoint: getUsageEndpoint,
  254. Handler: getUsageHandler,
  255. Router: r,
  256. })
  257. // GET /api/projects/{project_id}/billing -> project.NewCheckPaymentEnabledHandler
  258. checkPaymentEndpoint := factory.NewAPIEndpoint(
  259. &types.APIRequestMetadata{
  260. Verb: types.APIVerbGet,
  261. Method: types.HTTPVerbGet,
  262. Path: &types.Path{
  263. Parent: basePath,
  264. RelativePath: relPath + "/billing",
  265. },
  266. Scopes: []types.PermissionScope{
  267. types.UserScope,
  268. types.ProjectScope,
  269. },
  270. },
  271. )
  272. checkPaymentHandler := billing.NewCheckPaymentEnabledHandler(
  273. config,
  274. factory.GetResultWriter(),
  275. )
  276. routes = append(routes, &router.Route{
  277. Endpoint: checkPaymentEndpoint,
  278. Handler: checkPaymentHandler,
  279. Router: r,
  280. })
  281. // GET /api/projects/{project_id}/billing/payment_method -> project.NewListBillingHandler
  282. listBillingEndpoint := factory.NewAPIEndpoint(
  283. &types.APIRequestMetadata{
  284. Verb: types.APIVerbGet,
  285. Method: types.HTTPVerbGet,
  286. Path: &types.Path{
  287. Parent: basePath,
  288. RelativePath: relPath + "/billing/payment_method",
  289. },
  290. Scopes: []types.PermissionScope{
  291. types.UserScope,
  292. types.ProjectScope,
  293. },
  294. },
  295. )
  296. listBillingHandler := billing.NewListBillingHandler(
  297. config,
  298. factory.GetResultWriter(),
  299. )
  300. routes = append(routes, &router.Route{
  301. Endpoint: listBillingEndpoint,
  302. Handler: listBillingHandler,
  303. Router: r,
  304. })
  305. // GET /api/projects/{project_id}/billing/plan -> project.NewListPlansHandler
  306. listPlanEndpoint := factory.NewAPIEndpoint(
  307. &types.APIRequestMetadata{
  308. Verb: types.APIVerbGet,
  309. Method: types.HTTPVerbGet,
  310. Path: &types.Path{
  311. Parent: basePath,
  312. RelativePath: relPath + "/billing/plan",
  313. },
  314. Scopes: []types.PermissionScope{
  315. types.UserScope,
  316. types.ProjectScope,
  317. },
  318. },
  319. )
  320. listPlanHandler := billing.NewListPlansHandler(
  321. config,
  322. factory.GetResultWriter(),
  323. )
  324. routes = append(routes, &router.Route{
  325. Endpoint: listPlanEndpoint,
  326. Handler: listPlanHandler,
  327. Router: r,
  328. })
  329. // GET /api/projects/{project_id}/billing/credits -> project.NewGetCreditsHandler
  330. listCreditsEndpoint := factory.NewAPIEndpoint(
  331. &types.APIRequestMetadata{
  332. Verb: types.APIVerbGet,
  333. Method: types.HTTPVerbGet,
  334. Path: &types.Path{
  335. Parent: basePath,
  336. RelativePath: relPath + "/billing/credits",
  337. },
  338. Scopes: []types.PermissionScope{
  339. types.UserScope,
  340. types.ProjectScope,
  341. },
  342. },
  343. )
  344. listCreditsHandler := billing.NewListCreditsHandler(
  345. config,
  346. factory.GetResultWriter(),
  347. )
  348. routes = append(routes, &router.Route{
  349. Endpoint: listCreditsEndpoint,
  350. Handler: listCreditsHandler,
  351. Router: r,
  352. })
  353. // GET /api/projects/{project_id}/referrals/details -> user.NewGetUserReferralDetailsHandler
  354. getReferralDetailsEndpoint := factory.NewAPIEndpoint(
  355. &types.APIRequestMetadata{
  356. Verb: types.APIVerbGet,
  357. Method: types.HTTPVerbGet,
  358. Path: &types.Path{
  359. Parent: basePath,
  360. RelativePath: relPath + "/referrals/details",
  361. },
  362. Scopes: []types.PermissionScope{
  363. types.UserScope,
  364. types.ProjectScope,
  365. },
  366. },
  367. )
  368. getReferralDetailsHandler := project.NewGetProjectReferralDetailsHandler(
  369. config,
  370. factory.GetResultWriter(),
  371. )
  372. routes = append(routes, &router.Route{
  373. Endpoint: getReferralDetailsEndpoint,
  374. Handler: getReferralDetailsHandler,
  375. Router: r,
  376. })
  377. // POST /api/projects/{project_id}/billing/usage -> project.NewListCustomerUsageHandler
  378. listCustomerUsageEndpoint := factory.NewAPIEndpoint(
  379. &types.APIRequestMetadata{
  380. Verb: types.APIVerbCreate,
  381. Method: types.HTTPVerbPost,
  382. Path: &types.Path{
  383. Parent: basePath,
  384. RelativePath: relPath + "/billing/usage",
  385. },
  386. Scopes: []types.PermissionScope{
  387. types.UserScope,
  388. types.ProjectScope,
  389. },
  390. },
  391. )
  392. listCustomerUsageHandler := billing.NewListCustomerUsageHandler(
  393. config,
  394. factory.GetDecoderValidator(),
  395. factory.GetResultWriter(),
  396. )
  397. routes = append(routes, &router.Route{
  398. Endpoint: listCustomerUsageEndpoint,
  399. Handler: listCustomerUsageHandler,
  400. Router: r,
  401. })
  402. // GET /api/projects/{project_id}/billing/invoices -> project.NewListCustomerInvoicesHandler
  403. listCustomerInvoicesEndpoint := factory.NewAPIEndpoint(
  404. &types.APIRequestMetadata{
  405. Verb: types.APIVerbGet,
  406. Method: types.HTTPVerbGet,
  407. Path: &types.Path{
  408. Parent: basePath,
  409. RelativePath: relPath + "/billing/invoices",
  410. },
  411. Scopes: []types.PermissionScope{
  412. types.UserScope,
  413. types.ProjectScope,
  414. },
  415. },
  416. )
  417. listCustomerInvoicesHandler := billing.NewListCustomerInvoicesHandler(
  418. config,
  419. factory.GetDecoderValidator(),
  420. factory.GetResultWriter(),
  421. )
  422. routes = append(routes, &router.Route{
  423. Endpoint: listCustomerInvoicesEndpoint,
  424. Handler: listCustomerInvoicesHandler,
  425. Router: r,
  426. })
  427. // POST /api/projects/{project_id}/billing/ingest -> project.NewGetUsageDashboardHandler
  428. ingestEventsEndpoint := factory.NewAPIEndpoint(
  429. &types.APIRequestMetadata{
  430. Verb: types.APIVerbCreate,
  431. Method: types.HTTPVerbPost,
  432. Path: &types.Path{
  433. Parent: basePath,
  434. RelativePath: relPath + "/billing/ingest",
  435. },
  436. Scopes: []types.PermissionScope{
  437. types.UserScope,
  438. types.ProjectScope,
  439. },
  440. },
  441. )
  442. ingestEventsHandler := billing.NewIngestEventsHandler(
  443. config,
  444. factory.GetDecoderValidator(),
  445. factory.GetResultWriter(),
  446. )
  447. routes = append(routes, &router.Route{
  448. Endpoint: ingestEventsEndpoint,
  449. Handler: ingestEventsHandler,
  450. Router: r,
  451. })
  452. // POST /api/projects/{project_id}/billing/payment_method -> project.NewCreateBillingHandler
  453. createBillingEndpoint := factory.NewAPIEndpoint(
  454. &types.APIRequestMetadata{
  455. Verb: types.APIVerbCreate,
  456. Method: types.HTTPVerbPost,
  457. Path: &types.Path{
  458. Parent: basePath,
  459. RelativePath: relPath + "/billing/payment_method",
  460. },
  461. Scopes: []types.PermissionScope{
  462. types.UserScope,
  463. types.ProjectScope,
  464. },
  465. },
  466. )
  467. createBillingHandler := billing.NewCreateBillingHandler(
  468. config,
  469. factory.GetDecoderValidator(),
  470. factory.GetResultWriter(),
  471. )
  472. routes = append(routes, &router.Route{
  473. Endpoint: createBillingEndpoint,
  474. Handler: createBillingHandler,
  475. Router: r,
  476. })
  477. // PUT /api/projects/{project_id}/billing/payment_method/{payment_method_id}/default -> project.NewSetDefaultBillingHandler
  478. setDefaultBillingEndpoint := factory.NewAPIEndpoint(
  479. &types.APIRequestMetadata{
  480. Verb: types.APIVerbUpdate,
  481. Method: types.HTTPVerbPut,
  482. Path: &types.Path{
  483. Parent: basePath,
  484. RelativePath: fmt.Sprintf("%s/billing/payment_method/{%s}/default", relPath, types.URLParamPaymentMethodID),
  485. },
  486. Scopes: []types.PermissionScope{
  487. types.UserScope,
  488. types.ProjectScope,
  489. },
  490. },
  491. )
  492. setDefaultBillingHandler := billing.NewSetDefaultBillingHandler(
  493. config,
  494. factory.GetResultWriter(),
  495. )
  496. routes = append(routes, &router.Route{
  497. Endpoint: setDefaultBillingEndpoint,
  498. Handler: setDefaultBillingHandler,
  499. Router: r,
  500. })
  501. // DELETE /api/projects/{project_id}/billing/payment_method/{payment_method_id} -> project.NewDeleteBillingHandler
  502. deleteBillingEndpoint := factory.NewAPIEndpoint(
  503. &types.APIRequestMetadata{
  504. Verb: types.APIVerbDelete,
  505. Method: types.HTTPVerbDelete,
  506. Path: &types.Path{
  507. Parent: basePath,
  508. RelativePath: fmt.Sprintf("%s/billing/payment_method/{%s}", relPath, types.URLParamPaymentMethodID),
  509. },
  510. Scopes: []types.PermissionScope{
  511. types.UserScope,
  512. types.ProjectScope,
  513. },
  514. },
  515. )
  516. deleteBillingHandler := billing.NewDeleteBillingHandler(
  517. config,
  518. factory.GetResultWriter(),
  519. )
  520. routes = append(routes, &router.Route{
  521. Endpoint: deleteBillingEndpoint,
  522. Handler: deleteBillingHandler,
  523. Router: r,
  524. })
  525. // GET /api/projects/{project_id}/billing/publishable_key -> project.NewGetPublishableKeyHandler
  526. publishableKeyEndpoint := factory.NewAPIEndpoint(
  527. &types.APIRequestMetadata{
  528. Verb: types.APIVerbGet,
  529. Method: types.HTTPVerbGet,
  530. Path: &types.Path{
  531. Parent: basePath,
  532. RelativePath: relPath + "/billing/publishable_key",
  533. },
  534. Scopes: []types.PermissionScope{
  535. types.UserScope,
  536. types.ProjectScope,
  537. },
  538. },
  539. )
  540. publishableKeyHandler := billing.NewGetPublishableKeyHandler(
  541. config,
  542. factory.GetDecoderValidator(),
  543. factory.GetResultWriter(),
  544. )
  545. routes = append(routes, &router.Route{
  546. Endpoint: publishableKeyEndpoint,
  547. Handler: publishableKeyHandler,
  548. Router: r,
  549. })
  550. // GET /api/projects/{project_id}/clusters -> cluster.NewClusterListHandler
  551. listClusterEndpoint := factory.NewAPIEndpoint(
  552. &types.APIRequestMetadata{
  553. Verb: types.APIVerbList,
  554. Method: types.HTTPVerbGet,
  555. Path: &types.Path{
  556. Parent: basePath,
  557. RelativePath: relPath + "/clusters",
  558. },
  559. Scopes: []types.PermissionScope{
  560. types.UserScope,
  561. types.ProjectScope,
  562. },
  563. },
  564. )
  565. listClusterHandler := cluster.NewClusterListHandler(
  566. config,
  567. factory.GetResultWriter(),
  568. )
  569. routes = append(routes, &router.Route{
  570. Endpoint: listClusterEndpoint,
  571. Handler: listClusterHandler,
  572. Router: r,
  573. })
  574. // GET /api/projects/{project_id}/gitrepos -> gitinstallation.NewGitRepoListHandler
  575. listGitReposEndpoint := factory.NewAPIEndpoint(
  576. &types.APIRequestMetadata{
  577. Verb: types.APIVerbList,
  578. Method: types.HTTPVerbGet,
  579. Path: &types.Path{
  580. Parent: basePath,
  581. RelativePath: relPath + "/gitrepos",
  582. },
  583. Scopes: []types.PermissionScope{
  584. types.UserScope,
  585. types.ProjectScope,
  586. },
  587. },
  588. )
  589. listGitReposHandler := gitinstallation.NewGitRepoListHandler(
  590. config,
  591. factory.GetResultWriter(),
  592. )
  593. routes = append(routes, &router.Route{
  594. Endpoint: listGitReposEndpoint,
  595. Handler: listGitReposHandler,
  596. Router: r,
  597. })
  598. // GET /api/projects/{project_id}/collaborators -> project.NewCollaboratorsListHandler
  599. listCollaboratorsEndpoint := factory.NewAPIEndpoint(
  600. &types.APIRequestMetadata{
  601. Verb: types.APIVerbList,
  602. Method: types.HTTPVerbGet,
  603. Path: &types.Path{
  604. Parent: basePath,
  605. RelativePath: relPath + "/collaborators",
  606. },
  607. Scopes: []types.PermissionScope{
  608. types.UserScope,
  609. types.ProjectScope,
  610. },
  611. },
  612. )
  613. listCollaboratorsHandler := project.NewCollaboratorsListHandler(
  614. config,
  615. factory.GetResultWriter(),
  616. )
  617. routes = append(routes, &router.Route{
  618. Endpoint: listCollaboratorsEndpoint,
  619. Handler: listCollaboratorsHandler,
  620. Router: r,
  621. })
  622. // GET /api/projects/{project_id}/roles -> project.NewRolesListHandler
  623. listRolesEndpoint := factory.NewAPIEndpoint(
  624. &types.APIRequestMetadata{
  625. Verb: types.APIVerbList,
  626. Method: types.HTTPVerbGet,
  627. Path: &types.Path{
  628. Parent: basePath,
  629. RelativePath: relPath + "/roles",
  630. },
  631. Scopes: []types.PermissionScope{
  632. types.UserScope,
  633. types.ProjectScope,
  634. },
  635. },
  636. )
  637. listRolesHandler := project.NewRolesListHandler(
  638. config,
  639. factory.GetResultWriter(),
  640. )
  641. routes = append(routes, &router.Route{
  642. Endpoint: listRolesEndpoint,
  643. Handler: listRolesHandler,
  644. Router: r,
  645. })
  646. // GET /api/projects/{project_id}/datastores -> datastore.NewListAllDatastoresForProjectHandler
  647. listDatastoresEndpoint := factory.NewAPIEndpoint(
  648. &types.APIRequestMetadata{
  649. Verb: types.APIVerbList,
  650. Method: types.HTTPVerbGet,
  651. Path: &types.Path{
  652. Parent: basePath,
  653. RelativePath: relPath + "/datastores",
  654. },
  655. Scopes: []types.PermissionScope{
  656. types.UserScope,
  657. types.ProjectScope,
  658. },
  659. },
  660. )
  661. listDatastoresHandler := datastore.NewListDatastoresHandler(
  662. config,
  663. factory.GetDecoderValidator(),
  664. factory.GetResultWriter(),
  665. )
  666. routes = append(routes, &router.Route{
  667. Endpoint: listDatastoresEndpoint,
  668. Handler: listDatastoresHandler,
  669. Router: r,
  670. })
  671. // GET /api/projects/{project_id}/datastores -> datastore.NewGetDatastoreHandler
  672. getDatastoreEndpoint := factory.NewAPIEndpoint(
  673. &types.APIRequestMetadata{
  674. Verb: types.APIVerbList,
  675. Method: types.HTTPVerbGet,
  676. Path: &types.Path{
  677. Parent: basePath,
  678. RelativePath: fmt.Sprintf("%s/datastores/{%s}", relPath, types.URLParamDatastoreName),
  679. },
  680. Scopes: []types.PermissionScope{
  681. types.UserScope,
  682. types.ProjectScope,
  683. },
  684. },
  685. )
  686. getDatastoreHandler := datastore.NewGetDatastoreHandler(
  687. config,
  688. factory.GetDecoderValidator(),
  689. factory.GetResultWriter(),
  690. )
  691. routes = append(routes, &router.Route{
  692. Endpoint: getDatastoreEndpoint,
  693. Handler: getDatastoreHandler,
  694. Router: r,
  695. })
  696. // GET /api/projects/{project_id}/datastores -> datastore.NewGetDatastoreCredentialHandler
  697. getDatastoreCredentialEndpoint := factory.NewAPIEndpoint(
  698. &types.APIRequestMetadata{
  699. Verb: types.APIVerbList,
  700. Method: types.HTTPVerbGet,
  701. Path: &types.Path{
  702. Parent: basePath,
  703. RelativePath: fmt.Sprintf("%s/datastores/{%s}/credential", relPath, types.URLParamDatastoreName),
  704. },
  705. Scopes: []types.PermissionScope{
  706. types.UserScope,
  707. types.ProjectScope,
  708. },
  709. },
  710. )
  711. getDatastoreCredentialHandler := datastore.NewGetDatastoreCredentialHandler(
  712. config,
  713. factory.GetDecoderValidator(),
  714. factory.GetResultWriter(),
  715. )
  716. routes = append(routes, &router.Route{
  717. Endpoint: getDatastoreCredentialEndpoint,
  718. Handler: getDatastoreCredentialHandler,
  719. Router: r,
  720. })
  721. // POST /api/projects/{project_id}/datastores/{datastore_name}/create-proxy -> cluster.NewCreateDatastoreProxyHandler
  722. createDatastoreProxyEndpoint := factory.NewAPIEndpoint(
  723. &types.APIRequestMetadata{
  724. Verb: types.APIVerbUpdate,
  725. Method: types.HTTPVerbPost,
  726. Path: &types.Path{
  727. Parent: basePath,
  728. RelativePath: fmt.Sprintf("%s/datastores/{%s}/create-proxy", relPath, types.URLParamDatastoreName),
  729. },
  730. Scopes: []types.PermissionScope{
  731. types.UserScope,
  732. types.ProjectScope,
  733. },
  734. },
  735. )
  736. createDatastoreProxyHandler := datastore.NewCreateDatastoreProxyHandler(
  737. config,
  738. factory.GetDecoderValidator(),
  739. factory.GetResultWriter(),
  740. )
  741. routes = append(routes, &router.Route{
  742. Endpoint: createDatastoreProxyEndpoint,
  743. Handler: createDatastoreProxyHandler,
  744. Router: r,
  745. })
  746. // DELETE /api/projects/{project_id}/datastores/{datastore_name} -> cloud_provider.NewDeleteDatastoreHandler
  747. deleteDatastoreEndpoint := factory.NewAPIEndpoint(
  748. &types.APIRequestMetadata{
  749. Verb: types.APIVerbDelete,
  750. Method: types.HTTPVerbDelete,
  751. Path: &types.Path{
  752. Parent: basePath,
  753. RelativePath: fmt.Sprintf("%s/datastores/{%s}", relPath, types.URLParamDatastoreName),
  754. },
  755. Scopes: []types.PermissionScope{
  756. types.UserScope,
  757. types.ProjectScope,
  758. },
  759. },
  760. )
  761. deleteDatastoreHandler := datastore.NewDeleteDatastoreHandler(
  762. config,
  763. factory.GetDecoderValidator(),
  764. factory.GetResultWriter(),
  765. )
  766. routes = append(routes, &router.Route{
  767. Endpoint: deleteDatastoreEndpoint,
  768. Handler: deleteDatastoreHandler,
  769. Router: r,
  770. })
  771. // POST /api/projects/{project_id}/roles -> project.NewRoleUpdateHandler
  772. updateRoleEndpoint := factory.NewAPIEndpoint(
  773. &types.APIRequestMetadata{
  774. Verb: types.APIVerbUpdate,
  775. Method: types.HTTPVerbPost,
  776. Path: &types.Path{
  777. Parent: basePath,
  778. RelativePath: relPath + "/roles",
  779. },
  780. Scopes: []types.PermissionScope{
  781. types.UserScope,
  782. types.ProjectScope,
  783. },
  784. },
  785. )
  786. updateRoleHandler := project.NewRoleUpdateHandler(
  787. config,
  788. factory.GetDecoderValidator(),
  789. factory.GetResultWriter(),
  790. )
  791. routes = append(routes, &router.Route{
  792. Endpoint: updateRoleEndpoint,
  793. Handler: updateRoleHandler,
  794. Router: r,
  795. })
  796. // DELETE /api/projects/{project_id}/roles -> project.NewRoleDeleteHandler
  797. deleteRoleEndpoint := factory.NewAPIEndpoint(
  798. &types.APIRequestMetadata{
  799. Verb: types.APIVerbDelete,
  800. Method: types.HTTPVerbDelete,
  801. Path: &types.Path{
  802. Parent: basePath,
  803. RelativePath: relPath + "/roles",
  804. },
  805. Scopes: []types.PermissionScope{
  806. types.UserScope,
  807. types.ProjectScope,
  808. },
  809. },
  810. )
  811. deleteRoleHandler := project.NewRoleDeleteHandler(
  812. config,
  813. factory.GetDecoderValidator(),
  814. factory.GetResultWriter(),
  815. )
  816. routes = append(routes, &router.Route{
  817. Endpoint: deleteRoleEndpoint,
  818. Handler: deleteRoleHandler,
  819. Router: r,
  820. })
  821. // GET /api/projects/{project_id}/registries -> registry.NewRegistryListHandler
  822. listRegistriesEndpoint := factory.NewAPIEndpoint(
  823. &types.APIRequestMetadata{
  824. Verb: types.APIVerbList,
  825. Method: types.HTTPVerbGet,
  826. Path: &types.Path{
  827. Parent: basePath,
  828. RelativePath: relPath + "/registries",
  829. },
  830. Scopes: []types.PermissionScope{
  831. types.UserScope,
  832. types.ProjectScope,
  833. },
  834. },
  835. )
  836. listRegistriesHandler := registry.NewRegistryListHandler(
  837. config,
  838. factory.GetResultWriter(),
  839. )
  840. routes = append(routes, &router.Route{
  841. Endpoint: listRegistriesEndpoint,
  842. Handler: listRegistriesHandler,
  843. Router: r,
  844. })
  845. // POST /api/projects/{project_id}/registries -> registry.NewRegistryCreateHandler
  846. createRegistryEndpoint := factory.NewAPIEndpoint(
  847. &types.APIRequestMetadata{
  848. Verb: types.APIVerbCreate,
  849. Method: types.HTTPVerbPost,
  850. Path: &types.Path{
  851. Parent: basePath,
  852. RelativePath: relPath + "/registries",
  853. },
  854. Scopes: []types.PermissionScope{
  855. types.UserScope,
  856. types.ProjectScope,
  857. },
  858. },
  859. )
  860. createRegistryHandler := registry.NewRegistryCreateHandler(
  861. config,
  862. factory.GetDecoderValidator(),
  863. factory.GetResultWriter(),
  864. )
  865. routes = append(routes, &router.Route{
  866. Endpoint: createRegistryEndpoint,
  867. Handler: createRegistryHandler,
  868. Router: r,
  869. })
  870. // GET /api/projects/{project_id}/registries/ecr/token -> registry.NewRegistryGetECRTokenHandler
  871. getECRTokenEndpoint := factory.NewAPIEndpoint(
  872. &types.APIRequestMetadata{
  873. Verb: types.APIVerbGet,
  874. Method: types.HTTPVerbGet,
  875. Path: &types.Path{
  876. Parent: basePath,
  877. RelativePath: relPath + "/registries/ecr/token",
  878. },
  879. Scopes: []types.PermissionScope{
  880. types.UserScope,
  881. types.ProjectScope,
  882. },
  883. },
  884. )
  885. getECRTokenHandler := registry.NewRegistryGetECRTokenHandler(
  886. config,
  887. factory.GetDecoderValidator(),
  888. factory.GetResultWriter(),
  889. )
  890. routes = append(routes, &router.Route{
  891. Endpoint: getECRTokenEndpoint,
  892. Handler: getECRTokenHandler,
  893. Router: r,
  894. })
  895. // GET /api/projects/{project_id}/registries/docr/token -> registry.NewRegistryGetDOCRTokenHandler
  896. getDOCRTokenEndpoint := factory.NewAPIEndpoint(
  897. &types.APIRequestMetadata{
  898. Verb: types.APIVerbGet,
  899. Method: types.HTTPVerbGet,
  900. Path: &types.Path{
  901. Parent: basePath,
  902. RelativePath: relPath + "/registries/docr/token",
  903. },
  904. Scopes: []types.PermissionScope{
  905. types.UserScope,
  906. types.ProjectScope,
  907. },
  908. },
  909. )
  910. getDOCRTokenHandler := registry.NewRegistryGetDOCRTokenHandler(
  911. config,
  912. factory.GetDecoderValidator(),
  913. factory.GetResultWriter(),
  914. )
  915. routes = append(routes, &router.Route{
  916. Endpoint: getDOCRTokenEndpoint,
  917. Handler: getDOCRTokenHandler,
  918. Router: r,
  919. })
  920. // GET /api/projects/{project_id}/registries/gcr/token -> registry.NewRegistryGetGCRTokenHandler
  921. getGCRTokenEndpoint := factory.NewAPIEndpoint(
  922. &types.APIRequestMetadata{
  923. Verb: types.APIVerbGet,
  924. Method: types.HTTPVerbGet,
  925. Path: &types.Path{
  926. Parent: basePath,
  927. RelativePath: relPath + "/registries/gcr/token",
  928. },
  929. Scopes: []types.PermissionScope{
  930. types.UserScope,
  931. types.ProjectScope,
  932. },
  933. },
  934. )
  935. getGCRTokenHandler := registry.NewRegistryGetGCRTokenHandler(
  936. config,
  937. factory.GetDecoderValidator(),
  938. factory.GetResultWriter(),
  939. )
  940. routes = append(routes, &router.Route{
  941. Endpoint: getGCRTokenEndpoint,
  942. Handler: getGCRTokenHandler,
  943. Router: r,
  944. })
  945. // GET /api/projects/{project_id}/registries/gar/token -> registry.NewRegistryGetGARTokenHandler
  946. getGARTokenEndpoint := factory.NewAPIEndpoint(
  947. &types.APIRequestMetadata{
  948. Verb: types.APIVerbGet,
  949. Method: types.HTTPVerbGet,
  950. Path: &types.Path{
  951. Parent: basePath,
  952. RelativePath: relPath + "/registries/gar/token",
  953. },
  954. Scopes: []types.PermissionScope{
  955. types.UserScope,
  956. types.ProjectScope,
  957. },
  958. },
  959. )
  960. getGARTokenHandler := registry.NewRegistryGetGARTokenHandler(
  961. config,
  962. factory.GetDecoderValidator(),
  963. factory.GetResultWriter(),
  964. )
  965. routes = append(routes, &router.Route{
  966. Endpoint: getGARTokenEndpoint,
  967. Handler: getGARTokenHandler,
  968. Router: r,
  969. })
  970. // GET /api/projects/{project_id}/registries/acr/token -> registry.NewRegistryGetACRTokenHandler
  971. getACRTokenEndpoint := factory.NewAPIEndpoint(
  972. &types.APIRequestMetadata{
  973. Verb: types.APIVerbGet,
  974. Method: types.HTTPVerbGet,
  975. Path: &types.Path{
  976. Parent: basePath,
  977. RelativePath: relPath + "/registries/acr/token",
  978. },
  979. Scopes: []types.PermissionScope{
  980. types.UserScope,
  981. types.ProjectScope,
  982. },
  983. },
  984. )
  985. getACRTokenHandler := registry.NewRegistryGetACRTokenHandler(
  986. config,
  987. factory.GetDecoderValidator(),
  988. factory.GetResultWriter(),
  989. )
  990. routes = append(routes, &router.Route{
  991. Endpoint: getACRTokenEndpoint,
  992. Handler: getACRTokenHandler,
  993. Router: r,
  994. })
  995. // GET /api/projects/{project_id}/registries/dockerhub/token -> registry.NewRegistryGetDockerhubTokenHandler
  996. getDockerhubTokenEndpoint := factory.NewAPIEndpoint(
  997. &types.APIRequestMetadata{
  998. Verb: types.APIVerbGet,
  999. Method: types.HTTPVerbGet,
  1000. Path: &types.Path{
  1001. Parent: basePath,
  1002. RelativePath: relPath + "/registries/dockerhub/token",
  1003. },
  1004. Scopes: []types.PermissionScope{
  1005. types.UserScope,
  1006. types.ProjectScope,
  1007. },
  1008. },
  1009. )
  1010. getDockerhubTokenHandler := registry.NewRegistryGetDockerhubTokenHandler(
  1011. config,
  1012. factory.GetDecoderValidator(),
  1013. factory.GetResultWriter(),
  1014. )
  1015. routes = append(routes, &router.Route{
  1016. Endpoint: getDockerhubTokenEndpoint,
  1017. Handler: getDockerhubTokenHandler,
  1018. Router: r,
  1019. })
  1020. // POST /api/projects/{project_id}/infras -> infra.NewInfraCreateHandler
  1021. createInfraEndpoint := factory.NewAPIEndpoint(
  1022. &types.APIRequestMetadata{
  1023. Verb: types.APIVerbCreate,
  1024. Method: types.HTTPVerbPost,
  1025. Path: &types.Path{
  1026. Parent: basePath,
  1027. RelativePath: relPath + "/infras",
  1028. },
  1029. Scopes: []types.PermissionScope{
  1030. types.UserScope,
  1031. types.ProjectScope,
  1032. },
  1033. },
  1034. )
  1035. createInfraHandler := infra.NewInfraCreateHandler(
  1036. config,
  1037. factory.GetDecoderValidator(),
  1038. factory.GetResultWriter(),
  1039. )
  1040. routes = append(routes, &router.Route{
  1041. Endpoint: createInfraEndpoint,
  1042. Handler: createInfraHandler,
  1043. Router: r,
  1044. })
  1045. // GET /api/projects/{project_id}/infras/templates -> infra.NewInfraGetHandler
  1046. getTemplatesEndpoint := factory.NewAPIEndpoint(
  1047. &types.APIRequestMetadata{
  1048. Verb: types.APIVerbGet,
  1049. Method: types.HTTPVerbGet,
  1050. Path: &types.Path{
  1051. Parent: basePath,
  1052. RelativePath: relPath + "/infras/templates",
  1053. },
  1054. Scopes: []types.PermissionScope{
  1055. types.UserScope,
  1056. types.ProjectScope,
  1057. },
  1058. },
  1059. )
  1060. getTemplatesHandler := infra.NewInfraListTemplateHandler(
  1061. config,
  1062. factory.GetResultWriter(),
  1063. )
  1064. routes = append(routes, &router.Route{
  1065. Endpoint: getTemplatesEndpoint,
  1066. Handler: getTemplatesHandler,
  1067. Router: r,
  1068. })
  1069. // GET /api/projects/{project_id}/infras/templates -> infra.NewInfraGetHandler
  1070. getTemplateEndpoint := factory.NewAPIEndpoint(
  1071. &types.APIRequestMetadata{
  1072. Verb: types.APIVerbGet,
  1073. Method: types.HTTPVerbGet,
  1074. Path: &types.Path{
  1075. Parent: basePath,
  1076. RelativePath: fmt.Sprintf("%s/infras/templates/{%s}/{%s}", relPath, types.URLParamTemplateName, types.URLParamTemplateVersion),
  1077. },
  1078. Scopes: []types.PermissionScope{
  1079. types.UserScope,
  1080. types.ProjectScope,
  1081. },
  1082. },
  1083. )
  1084. getTemplateHandler := infra.NewInfraGetTemplateHandler(
  1085. config,
  1086. factory.GetResultWriter(),
  1087. )
  1088. routes = append(routes, &router.Route{
  1089. Endpoint: getTemplateEndpoint,
  1090. Handler: getTemplateHandler,
  1091. Router: r,
  1092. })
  1093. // // POST /api/projects/{project_id}/provision/ecr -> provision.NewProvisionECRHandler
  1094. // provisionECREndpoint := factory.NewAPIEndpoint(
  1095. // &types.APIRequestMetadata{
  1096. // Verb: types.APIVerbCreate,
  1097. // Method: types.HTTPVerbPost,
  1098. // Path: &types.Path{
  1099. // Parent: basePath,
  1100. // RelativePath: relPath + "/provision/ecr",
  1101. // },
  1102. // Scopes: []types.PermissionScope{
  1103. // types.UserScope,
  1104. // types.ProjectScope,
  1105. // },
  1106. // },
  1107. // )
  1108. // provisionECRHandler := provision.NewProvisionECRHandler(
  1109. // config,
  1110. // factory.GetDecoderValidator(),
  1111. // factory.GetResultWriter(),
  1112. // )
  1113. // routes = append(routes, &router.Route{
  1114. // Endpoint: provisionECREndpoint,
  1115. // Handler: provisionECRHandler,
  1116. // Router: r,
  1117. // })
  1118. // // POST /api/projects/{project_id}/provision/eks -> provision.NewProvisionEKSHandler
  1119. // provisionEKSEndpoint := factory.NewAPIEndpoint(
  1120. // &types.APIRequestMetadata{
  1121. // Verb: types.APIVerbCreate,
  1122. // Method: types.HTTPVerbPost,
  1123. // Path: &types.Path{
  1124. // Parent: basePath,
  1125. // RelativePath: relPath + "/provision/eks",
  1126. // },
  1127. // Scopes: []types.PermissionScope{
  1128. // types.UserScope,
  1129. // types.ProjectScope,
  1130. // },
  1131. // CheckUsage: true,
  1132. // UsageMetric: types.Clusters,
  1133. // },
  1134. // )
  1135. // provisionEKSHandler := provision.NewProvisionEKSHandler(
  1136. // config,
  1137. // factory.GetDecoderValidator(),
  1138. // factory.GetResultWriter(),
  1139. // )
  1140. // routes = append(routes, &router.Route{
  1141. // Endpoint: provisionEKSEndpoint,
  1142. // Handler: provisionEKSHandler,
  1143. // Router: r,
  1144. // })
  1145. // // POST /api/projects/{project_id}/provision/docr -> provision.NewProvisionDOCRHandler
  1146. // provisionDOCREndpoint := factory.NewAPIEndpoint(
  1147. // &types.APIRequestMetadata{
  1148. // Verb: types.APIVerbCreate,
  1149. // Method: types.HTTPVerbPost,
  1150. // Path: &types.Path{
  1151. // Parent: basePath,
  1152. // RelativePath: relPath + "/provision/docr",
  1153. // },
  1154. // Scopes: []types.PermissionScope{
  1155. // types.UserScope,
  1156. // types.ProjectScope,
  1157. // },
  1158. // },
  1159. // )
  1160. // provisionDOCRHandler := provision.NewProvisionDOCRHandler(
  1161. // config,
  1162. // factory.GetDecoderValidator(),
  1163. // factory.GetResultWriter(),
  1164. // )
  1165. // routes = append(routes, &router.Route{
  1166. // Endpoint: provisionDOCREndpoint,
  1167. // Handler: provisionDOCRHandler,
  1168. // Router: r,
  1169. // })
  1170. // // POST /api/projects/{project_id}/provision/doks -> provision.NewProvisionDOKSHandler
  1171. // provisionDOKSEndpoint := factory.NewAPIEndpoint(
  1172. // &types.APIRequestMetadata{
  1173. // Verb: types.APIVerbCreate,
  1174. // Method: types.HTTPVerbPost,
  1175. // Path: &types.Path{
  1176. // Parent: basePath,
  1177. // RelativePath: relPath + "/provision/doks",
  1178. // },
  1179. // Scopes: []types.PermissionScope{
  1180. // types.UserScope,
  1181. // types.ProjectScope,
  1182. // },
  1183. // CheckUsage: true,
  1184. // UsageMetric: types.Clusters,
  1185. // },
  1186. // )
  1187. // provisionDOKSHandler := provision.NewProvisionDOKSHandler(
  1188. // config,
  1189. // factory.GetDecoderValidator(),
  1190. // factory.GetResultWriter(),
  1191. // )
  1192. // routes = append(routes, &router.Route{
  1193. // Endpoint: provisionDOKSEndpoint,
  1194. // Handler: provisionDOKSHandler,
  1195. // Router: r,
  1196. // })
  1197. // // POST /api/projects/{project_id}/provision/gcr -> provision.NewProvisionGCRHandler
  1198. // provisionGCREndpoint := factory.NewAPIEndpoint(
  1199. // &types.APIRequestMetadata{
  1200. // Verb: types.APIVerbCreate,
  1201. // Method: types.HTTPVerbPost,
  1202. // Path: &types.Path{
  1203. // Parent: basePath,
  1204. // RelativePath: relPath + "/provision/gcr",
  1205. // },
  1206. // Scopes: []types.PermissionScope{
  1207. // types.UserScope,
  1208. // types.ProjectScope,
  1209. // },
  1210. // },
  1211. // )
  1212. // provisionGCRHandler := provision.NewProvisionGCRHandler(
  1213. // config,
  1214. // factory.GetDecoderValidator(),
  1215. // factory.GetResultWriter(),
  1216. // )
  1217. // routes = append(routes, &router.Route{
  1218. // Endpoint: provisionGCREndpoint,
  1219. // Handler: provisionGCRHandler,
  1220. // Router: r,
  1221. // })
  1222. // // POST /api/projects/{project_id}/provision/gke -> provision.NewProvisionGKEHandler
  1223. // provisionGKEEndpoint := factory.NewAPIEndpoint(
  1224. // &types.APIRequestMetadata{
  1225. // Verb: types.APIVerbCreate,
  1226. // Method: types.HTTPVerbPost,
  1227. // Path: &types.Path{
  1228. // Parent: basePath,
  1229. // RelativePath: relPath + "/provision/gke",
  1230. // },
  1231. // Scopes: []types.PermissionScope{
  1232. // types.UserScope,
  1233. // types.ProjectScope,
  1234. // },
  1235. // CheckUsage: true,
  1236. // UsageMetric: types.Clusters,
  1237. // },
  1238. // )
  1239. // provisionGKEHandler := provision.NewProvisionGKEHandler(
  1240. // config,
  1241. // factory.GetDecoderValidator(),
  1242. // factory.GetResultWriter(),
  1243. // )
  1244. // routes = append(routes, &router.Route{
  1245. // Endpoint: provisionGKEEndpoint,
  1246. // Handler: provisionGKEHandler,
  1247. // Router: r,
  1248. // })
  1249. // POST /api/projects/{project_id}/connect -> project.NewProjectConnectHandler
  1250. connectEndpoint := factory.NewAPIEndpoint(
  1251. &types.APIRequestMetadata{
  1252. Verb: types.APIVerbCreate,
  1253. Method: types.HTTPVerbPost,
  1254. Path: &types.Path{
  1255. Parent: basePath,
  1256. RelativePath: relPath + "/connect",
  1257. },
  1258. Scopes: []types.PermissionScope{
  1259. types.UserScope,
  1260. types.ProjectScope,
  1261. types.SettingsScope,
  1262. },
  1263. },
  1264. )
  1265. connectHandler := project.NewConnectHandler(
  1266. config,
  1267. factory.GetDecoderValidator(),
  1268. factory.GetResultWriter(),
  1269. )
  1270. routes = append(routes, &router.Route{
  1271. Endpoint: connectEndpoint,
  1272. Handler: connectHandler,
  1273. Router: r,
  1274. })
  1275. // POST /api/projects/{project_id}/policy -> policy.NewPolicyCreateHandler
  1276. policyCreateEndpoint := factory.NewAPIEndpoint(
  1277. &types.APIRequestMetadata{
  1278. Verb: types.APIVerbCreate,
  1279. Method: types.HTTPVerbPost,
  1280. Path: &types.Path{
  1281. Parent: basePath,
  1282. RelativePath: relPath + "/policy",
  1283. },
  1284. Scopes: []types.PermissionScope{
  1285. types.UserScope,
  1286. types.ProjectScope,
  1287. types.SettingsScope,
  1288. },
  1289. },
  1290. )
  1291. policyCreateHandler := policy.NewPolicyCreateHandler(
  1292. config,
  1293. factory.GetDecoderValidator(),
  1294. factory.GetResultWriter(),
  1295. )
  1296. routes = append(routes, &router.Route{
  1297. Endpoint: policyCreateEndpoint,
  1298. Handler: policyCreateHandler,
  1299. Router: r,
  1300. })
  1301. // GET /api/projects/{project_id}/policies -> policy.NewPolicyListHandler
  1302. policyListEndpoint := factory.NewAPIEndpoint(
  1303. &types.APIRequestMetadata{
  1304. Verb: types.APIVerbList,
  1305. Method: types.HTTPVerbGet,
  1306. Path: &types.Path{
  1307. Parent: basePath,
  1308. RelativePath: relPath + "/policies",
  1309. },
  1310. Scopes: []types.PermissionScope{
  1311. types.UserScope,
  1312. types.ProjectScope,
  1313. types.SettingsScope,
  1314. },
  1315. },
  1316. )
  1317. policyListHandler := policy.NewPolicyListHandler(
  1318. config,
  1319. factory.GetDecoderValidator(),
  1320. factory.GetResultWriter(),
  1321. )
  1322. routes = append(routes, &router.Route{
  1323. Endpoint: policyListEndpoint,
  1324. Handler: policyListHandler,
  1325. Router: r,
  1326. })
  1327. // GET /api/projects/{project_id}/policy/{policy_id} -> policy.NewPolicyGetHandler
  1328. policyGetEndpoint := factory.NewAPIEndpoint(
  1329. &types.APIRequestMetadata{
  1330. Verb: types.APIVerbGet,
  1331. Method: types.HTTPVerbGet,
  1332. Path: &types.Path{
  1333. Parent: basePath,
  1334. RelativePath: fmt.Sprintf("%s/policy/{%s}", relPath, types.URLParamPolicyID),
  1335. },
  1336. Scopes: []types.PermissionScope{
  1337. types.UserScope,
  1338. types.ProjectScope,
  1339. types.SettingsScope,
  1340. },
  1341. },
  1342. )
  1343. policyGetHandler := policy.NewPolicyGetHandler(
  1344. config,
  1345. factory.GetDecoderValidator(),
  1346. factory.GetResultWriter(),
  1347. )
  1348. routes = append(routes, &router.Route{
  1349. Endpoint: policyGetEndpoint,
  1350. Handler: policyGetHandler,
  1351. Router: r,
  1352. })
  1353. // POST /api/projects/{project_id}/api_token -> api_token.NewAPITokenCreateHandler
  1354. apiTokenCreateEndpoint := factory.NewAPIEndpoint(
  1355. &types.APIRequestMetadata{
  1356. Verb: types.APIVerbCreate,
  1357. Method: types.HTTPVerbPost,
  1358. Path: &types.Path{
  1359. Parent: basePath,
  1360. RelativePath: relPath + "/api_token",
  1361. },
  1362. Scopes: []types.PermissionScope{
  1363. types.UserScope,
  1364. types.ProjectScope,
  1365. types.SettingsScope,
  1366. },
  1367. },
  1368. )
  1369. apiTokenCreateHandler := api_token.NewAPITokenCreateHandler(
  1370. config,
  1371. factory.GetDecoderValidator(),
  1372. factory.GetResultWriter(),
  1373. )
  1374. routes = append(routes, &router.Route{
  1375. Endpoint: apiTokenCreateEndpoint,
  1376. Handler: apiTokenCreateHandler,
  1377. Router: r,
  1378. })
  1379. // GET /api/projects/{project_id}/api_token -> api_token.NewAPITokenListHandler
  1380. apiTokenListEndpoint := factory.NewAPIEndpoint(
  1381. &types.APIRequestMetadata{
  1382. Verb: types.APIVerbList,
  1383. Method: types.HTTPVerbGet,
  1384. Path: &types.Path{
  1385. Parent: basePath,
  1386. RelativePath: fmt.Sprintf("%s/api_token", relPath),
  1387. },
  1388. Scopes: []types.PermissionScope{
  1389. types.UserScope,
  1390. types.ProjectScope,
  1391. types.SettingsScope,
  1392. },
  1393. },
  1394. )
  1395. apiTokenListHandler := api_token.NewAPITokenListHandler(
  1396. config,
  1397. factory.GetDecoderValidator(),
  1398. factory.GetResultWriter(),
  1399. )
  1400. routes = append(routes, &router.Route{
  1401. Endpoint: apiTokenListEndpoint,
  1402. Handler: apiTokenListHandler,
  1403. Router: r,
  1404. })
  1405. // GET /api/projects/{project_id}/api_token/{api_token_id} -> api_token.NewAPITokenGetHandler
  1406. apiTokenGetEndpoint := factory.NewAPIEndpoint(
  1407. &types.APIRequestMetadata{
  1408. Verb: types.APIVerbGet,
  1409. Method: types.HTTPVerbGet,
  1410. Path: &types.Path{
  1411. Parent: basePath,
  1412. RelativePath: fmt.Sprintf("%s/api_token/{%s}", relPath, types.URLParamTokenID),
  1413. },
  1414. Scopes: []types.PermissionScope{
  1415. types.UserScope,
  1416. types.ProjectScope,
  1417. types.SettingsScope,
  1418. },
  1419. },
  1420. )
  1421. apiTokenGetHandler := api_token.NewAPITokenGetHandler(
  1422. config,
  1423. factory.GetDecoderValidator(),
  1424. factory.GetResultWriter(),
  1425. )
  1426. routes = append(routes, &router.Route{
  1427. Endpoint: apiTokenGetEndpoint,
  1428. Handler: apiTokenGetHandler,
  1429. Router: r,
  1430. })
  1431. // POST /api/projects/{project_id}/api_token/{api_token_id}/revoke -> api_token.NewAPITokenRevokeHandler
  1432. apiTokenRevokeEndpoint := factory.NewAPIEndpoint(
  1433. &types.APIRequestMetadata{
  1434. Verb: types.APIVerbUpdate,
  1435. Method: types.HTTPVerbPost,
  1436. Path: &types.Path{
  1437. Parent: basePath,
  1438. RelativePath: fmt.Sprintf("%s/api_token/{%s}/revoke", relPath, types.URLParamTokenID),
  1439. },
  1440. Scopes: []types.PermissionScope{
  1441. types.UserScope,
  1442. types.ProjectScope,
  1443. types.SettingsScope,
  1444. },
  1445. },
  1446. )
  1447. apiTokenRevokeHandler := api_token.NewAPITokenRevokeHandler(
  1448. config,
  1449. factory.GetDecoderValidator(),
  1450. factory.GetResultWriter(),
  1451. )
  1452. routes = append(routes, &router.Route{
  1453. Endpoint: apiTokenRevokeEndpoint,
  1454. Handler: apiTokenRevokeHandler,
  1455. Router: r,
  1456. })
  1457. // POST /api/projects/{project_id}/helmrepos -> helmrepo.NewHelmRepoCreateHandler
  1458. hrCreateEndpoint := factory.NewAPIEndpoint(
  1459. &types.APIRequestMetadata{
  1460. Verb: types.APIVerbCreate,
  1461. Method: types.HTTPVerbPost,
  1462. Path: &types.Path{
  1463. Parent: basePath,
  1464. RelativePath: relPath + "/helmrepos",
  1465. },
  1466. Scopes: []types.PermissionScope{
  1467. types.UserScope,
  1468. types.ProjectScope,
  1469. },
  1470. },
  1471. )
  1472. hrCreateHandler := helmrepo.NewHelmRepoCreateHandler(
  1473. config,
  1474. factory.GetDecoderValidator(),
  1475. factory.GetResultWriter(),
  1476. )
  1477. routes = append(routes, &router.Route{
  1478. Endpoint: hrCreateEndpoint,
  1479. Handler: hrCreateHandler,
  1480. Router: r,
  1481. })
  1482. // GET /api/projects/{project_id}/helmrepos -> helmrepo.NewHelmRepoListHandler
  1483. hrListEndpoint := factory.NewAPIEndpoint(
  1484. &types.APIRequestMetadata{
  1485. Verb: types.APIVerbList,
  1486. Method: types.HTTPVerbGet,
  1487. Path: &types.Path{
  1488. Parent: basePath,
  1489. RelativePath: relPath + "/helmrepos",
  1490. },
  1491. Scopes: []types.PermissionScope{
  1492. types.UserScope,
  1493. types.ProjectScope,
  1494. },
  1495. },
  1496. )
  1497. hrListHandler := helmrepo.NewHelmRepoListHandler(
  1498. config,
  1499. factory.GetResultWriter(),
  1500. )
  1501. routes = append(routes, &router.Route{
  1502. Endpoint: hrListEndpoint,
  1503. Handler: hrListHandler,
  1504. Router: r,
  1505. })
  1506. // GET /api/projects/{project_id}/tags -> project.NewGetTagsHandler
  1507. getTagsEndpoint := factory.NewAPIEndpoint(
  1508. &types.APIRequestMetadata{
  1509. Verb: types.APIVerbGet,
  1510. Method: types.HTTPVerbGet,
  1511. Path: &types.Path{
  1512. Parent: basePath,
  1513. RelativePath: relPath + "/tags",
  1514. },
  1515. Scopes: []types.PermissionScope{
  1516. types.UserScope,
  1517. types.ProjectScope,
  1518. },
  1519. },
  1520. )
  1521. getTagsHandler := project.NewGetTagsHandler(
  1522. config,
  1523. factory.GetResultWriter(),
  1524. )
  1525. routes = append(routes, &router.Route{
  1526. Endpoint: getTagsEndpoint,
  1527. Handler: getTagsHandler,
  1528. Router: r,
  1529. })
  1530. // POST /api/projects/{project_id}/tags -> project.NewCreateTagHandler
  1531. createTagEndpoint := factory.NewAPIEndpoint(
  1532. &types.APIRequestMetadata{
  1533. Verb: types.APIVerbCreate,
  1534. Method: types.HTTPVerbPost,
  1535. Path: &types.Path{
  1536. Parent: basePath,
  1537. RelativePath: relPath + "/tags",
  1538. },
  1539. Scopes: []types.PermissionScope{
  1540. types.UserScope,
  1541. types.ProjectScope,
  1542. },
  1543. },
  1544. )
  1545. createTagHandler := project.NewCreateTagHandler(
  1546. config,
  1547. factory.GetDecoderValidator(),
  1548. factory.GetResultWriter(),
  1549. )
  1550. routes = append(routes, &router.Route{
  1551. Endpoint: createTagEndpoint,
  1552. Handler: createTagHandler,
  1553. Router: r,
  1554. })
  1555. // POST /api/projects/{project_id}/contract -> apiContract.NewAPIContractUpdateHandler
  1556. updateAPIContractEndpoint := factory.NewAPIEndpoint(
  1557. &types.APIRequestMetadata{
  1558. Verb: types.APIVerbCreate,
  1559. Method: types.HTTPVerbPost,
  1560. Path: &types.Path{
  1561. Parent: basePath,
  1562. RelativePath: relPath + "/contract",
  1563. },
  1564. Scopes: []types.PermissionScope{
  1565. types.UserScope,
  1566. types.ProjectScope,
  1567. },
  1568. },
  1569. )
  1570. updateAPIContractHandler := apiContract.NewAPIContractUpdateHandler(
  1571. config,
  1572. factory.GetDecoderValidator(),
  1573. factory.GetResultWriter(),
  1574. )
  1575. routes = append(routes, &router.Route{
  1576. Endpoint: updateAPIContractEndpoint,
  1577. Handler: updateAPIContractHandler,
  1578. Router: r,
  1579. })
  1580. // GET /api/projects/{project_id}/contracts -> apiContract.NewAPIContractRevisionListHandler
  1581. listAPIContractRevisionsEndpoint := factory.NewAPIEndpoint(
  1582. &types.APIRequestMetadata{
  1583. Verb: types.APIVerbGet,
  1584. Method: types.HTTPVerbGet,
  1585. Path: &types.Path{
  1586. Parent: basePath,
  1587. RelativePath: relPath + "/contracts",
  1588. },
  1589. Scopes: []types.PermissionScope{
  1590. types.UserScope,
  1591. types.ProjectScope,
  1592. },
  1593. },
  1594. )
  1595. listAPIContractRevisionHandler := apiContract.NewAPIContractRevisionListHandler(
  1596. config,
  1597. factory.GetDecoderValidator(),
  1598. factory.GetResultWriter(),
  1599. )
  1600. routes = append(routes, &router.Route{
  1601. Endpoint: listAPIContractRevisionsEndpoint,
  1602. Handler: listAPIContractRevisionHandler,
  1603. Router: r,
  1604. })
  1605. // DELETE /api/projects/{project_id}/contracts/{revision_id} -> apiContract.NewAPIContractUpdateHandler
  1606. deleteAPIContractRevisionsEndpoint := factory.NewAPIEndpoint(
  1607. &types.APIRequestMetadata{
  1608. Verb: types.APIVerbDelete,
  1609. Method: types.HTTPVerbDelete,
  1610. Path: &types.Path{
  1611. Parent: basePath,
  1612. RelativePath: fmt.Sprintf("%s/contracts/{%s}", relPath, types.URLParamAPIContractRevisionID),
  1613. },
  1614. Scopes: []types.PermissionScope{
  1615. types.UserScope,
  1616. types.ProjectScope,
  1617. types.APIContractRevisionScope,
  1618. },
  1619. },
  1620. )
  1621. deleteAPIContractRevisionHandler := apiContract.NewAPIContractRevisionDeleteHandler(
  1622. config,
  1623. factory.GetDecoderValidator(),
  1624. factory.GetResultWriter(),
  1625. )
  1626. routes = append(routes, &router.Route{
  1627. Endpoint: deleteAPIContractRevisionsEndpoint,
  1628. Handler: deleteAPIContractRevisionHandler,
  1629. Router: r,
  1630. })
  1631. // POST /api/projects/{project_id}/contract/preflight -> apiContract.NewPreflightCheckHandler
  1632. preflightCheckEndpoint := factory.NewAPIEndpoint(
  1633. &types.APIRequestMetadata{
  1634. Verb: types.APIVerbCreate,
  1635. Method: types.HTTPVerbPost,
  1636. Path: &types.Path{
  1637. Parent: basePath,
  1638. RelativePath: fmt.Sprintf("%s/contract/preflight", relPath),
  1639. },
  1640. Scopes: []types.PermissionScope{
  1641. types.UserScope,
  1642. types.ProjectScope,
  1643. },
  1644. },
  1645. )
  1646. preflightCheckHandler := apiContract.NewPreflightCheckHandler(
  1647. config,
  1648. factory.GetDecoderValidator(),
  1649. factory.GetResultWriter(),
  1650. )
  1651. routes = append(routes, &router.Route{
  1652. Endpoint: preflightCheckEndpoint,
  1653. Handler: preflightCheckHandler,
  1654. Router: r,
  1655. })
  1656. // GET /api/projects/{project_id}/cloud/machines -> apiContract.NewCloudProviderMachineTypesHandler
  1657. machineTypeEndpoint := factory.NewAPIEndpoint(
  1658. &types.APIRequestMetadata{
  1659. Verb: types.APIVerbGet,
  1660. Method: types.HTTPVerbGet,
  1661. Path: &types.Path{
  1662. Parent: basePath,
  1663. RelativePath: fmt.Sprintf("%s/cloud/machines", relPath),
  1664. },
  1665. Scopes: []types.PermissionScope{
  1666. types.UserScope,
  1667. types.ProjectScope,
  1668. },
  1669. },
  1670. )
  1671. machineTypeHandler := cloud_provider.NewCloudProviderMachineTypesHandler(
  1672. config,
  1673. factory.GetDecoderValidator(),
  1674. factory.GetResultWriter(),
  1675. )
  1676. routes = append(routes, &router.Route{
  1677. Endpoint: machineTypeEndpoint,
  1678. Handler: machineTypeHandler,
  1679. Router: r,
  1680. })
  1681. // POST /api/projects/{project_id}/rename -> cluster.newRenamProject
  1682. renameProjectEndpoint := factory.NewAPIEndpoint(
  1683. &types.APIRequestMetadata{
  1684. Verb: types.APIVerbCreate,
  1685. Method: types.HTTPVerbPost,
  1686. Path: &types.Path{
  1687. Parent: basePath,
  1688. RelativePath: relPath + "/rename",
  1689. },
  1690. Scopes: []types.PermissionScope{
  1691. types.UserScope,
  1692. types.ProjectScope,
  1693. },
  1694. },
  1695. )
  1696. renameProjectHandler := project.NewRenameProjectHandler(
  1697. config,
  1698. factory.GetDecoderValidator(),
  1699. factory.GetResultWriter(),
  1700. )
  1701. routes = append(routes, &router.Route{
  1702. Endpoint: renameProjectEndpoint,
  1703. Handler: renameProjectHandler,
  1704. Router: r,
  1705. })
  1706. // GET /api/projects/{project_id}/images -> project.ImagesHandler
  1707. imagesEndpoint := factory.NewAPIEndpoint(
  1708. &types.APIRequestMetadata{
  1709. Verb: types.APIVerbList,
  1710. Method: types.HTTPVerbGet,
  1711. Path: &types.Path{
  1712. Parent: basePath,
  1713. RelativePath: relPath + "/images",
  1714. },
  1715. Scopes: []types.PermissionScope{
  1716. types.UserScope,
  1717. types.ProjectScope,
  1718. },
  1719. },
  1720. )
  1721. imagesHandler := project.NewImagesHandler(
  1722. config,
  1723. factory.GetResultWriter(),
  1724. )
  1725. routes = append(routes, &router.Route{
  1726. Endpoint: imagesEndpoint,
  1727. Handler: imagesHandler,
  1728. Router: r,
  1729. })
  1730. // GET /api/projects/{project_id}/targets -> deployment_target.ListDeploymentTargetHandler
  1731. listDeploymentTargetEndpoint := factory.NewAPIEndpoint(
  1732. &types.APIRequestMetadata{
  1733. Verb: types.APIVerbGet,
  1734. Method: types.HTTPVerbGet,
  1735. Path: &types.Path{
  1736. Parent: basePath,
  1737. RelativePath: fmt.Sprintf("%s/targets", relPath),
  1738. },
  1739. Scopes: []types.PermissionScope{
  1740. types.UserScope,
  1741. types.ProjectScope,
  1742. },
  1743. },
  1744. )
  1745. listDeploymentTargetHandler := deployment_target.NewListDeploymentTargetsHandler(
  1746. config,
  1747. factory.GetDecoderValidator(),
  1748. factory.GetResultWriter(),
  1749. )
  1750. routes = append(routes, &router.Route{
  1751. Endpoint: listDeploymentTargetEndpoint,
  1752. Handler: listDeploymentTargetHandler,
  1753. Router: r,
  1754. })
  1755. // GET /api/projects/{project_id}/targets -> deployment_target.ListDeploymentTargetHandler
  1756. createDeploymentTargetEndpoint := factory.NewAPIEndpoint(
  1757. &types.APIRequestMetadata{
  1758. Verb: types.APIVerbCreate,
  1759. Method: types.HTTPVerbPost,
  1760. Path: &types.Path{
  1761. Parent: basePath,
  1762. RelativePath: fmt.Sprintf("%s/targets", relPath),
  1763. },
  1764. Scopes: []types.PermissionScope{
  1765. types.UserScope,
  1766. types.ProjectScope,
  1767. },
  1768. },
  1769. )
  1770. createDeploymentTargetHandler := deployment_target.NewCreateDeploymentTargetHandler(
  1771. config,
  1772. factory.GetDecoderValidator(),
  1773. factory.GetResultWriter(),
  1774. )
  1775. routes = append(routes, &router.Route{
  1776. Endpoint: createDeploymentTargetEndpoint,
  1777. Handler: createDeploymentTargetHandler,
  1778. Router: r,
  1779. })
  1780. // GET /api/projects/{project_id}/neon-integrations -> apiContract.NewListNeonIntegrationsHandler
  1781. listNeonIntegrationsEndpoint := factory.NewAPIEndpoint(
  1782. &types.APIRequestMetadata{
  1783. Verb: types.APIVerbGet,
  1784. Method: types.HTTPVerbGet,
  1785. Path: &types.Path{
  1786. Parent: basePath,
  1787. RelativePath: relPath + "/neon-integrations",
  1788. },
  1789. Scopes: []types.PermissionScope{
  1790. types.UserScope,
  1791. types.ProjectScope,
  1792. },
  1793. },
  1794. )
  1795. listNeonIntegrationsHandler := neon_integration.NewListNeonIntegrationsHandler(
  1796. config,
  1797. factory.GetDecoderValidator(),
  1798. factory.GetResultWriter(),
  1799. )
  1800. routes = append(routes, &router.Route{
  1801. Endpoint: listNeonIntegrationsEndpoint,
  1802. Handler: listNeonIntegrationsHandler,
  1803. Router: r,
  1804. })
  1805. // GET /api/projects/{project_id}/upstash-integrations -> apiContract.NewListUpstashIntegrationsHandler
  1806. listUpstashIntegrationsEndpoint := factory.NewAPIEndpoint(
  1807. &types.APIRequestMetadata{
  1808. Verb: types.APIVerbGet,
  1809. Method: types.HTTPVerbGet,
  1810. Path: &types.Path{
  1811. Parent: basePath,
  1812. RelativePath: relPath + "/upstash-integrations",
  1813. },
  1814. Scopes: []types.PermissionScope{
  1815. types.UserScope,
  1816. types.ProjectScope,
  1817. },
  1818. },
  1819. )
  1820. listUpstashIntegrationsHandler := upstash_integration.NewListUpstashIntegrationsHandler(
  1821. config,
  1822. factory.GetDecoderValidator(),
  1823. factory.GetResultWriter(),
  1824. )
  1825. routes = append(routes, &router.Route{
  1826. Endpoint: listUpstashIntegrationsEndpoint,
  1827. Handler: listUpstashIntegrationsHandler,
  1828. Router: r,
  1829. })
  1830. return routes, newPath
  1831. }