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