project.go 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081
  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/costs -> project.NewListCustomerCostsHandler
  403. listCustomerCostsEndpoint := factory.NewAPIEndpoint(
  404. &types.APIRequestMetadata{
  405. Verb: types.APIVerbGet,
  406. Method: types.HTTPVerbGet,
  407. Path: &types.Path{
  408. Parent: basePath,
  409. RelativePath: relPath + "/billing/costs",
  410. },
  411. Scopes: []types.PermissionScope{
  412. types.UserScope,
  413. types.ProjectScope,
  414. },
  415. },
  416. )
  417. listCustomerCostsHandler := billing.NewListCustomerCostsHandler(
  418. config,
  419. factory.GetDecoderValidator(),
  420. factory.GetResultWriter(),
  421. )
  422. routes = append(routes, &router.Route{
  423. Endpoint: listCustomerCostsEndpoint,
  424. Handler: listCustomerCostsHandler,
  425. Router: r,
  426. })
  427. // GET /api/projects/{project_id}/billing/invoices -> project.NewListCustomerInvoicesHandler
  428. listCustomerInvoicesEndpoint := factory.NewAPIEndpoint(
  429. &types.APIRequestMetadata{
  430. Verb: types.APIVerbGet,
  431. Method: types.HTTPVerbGet,
  432. Path: &types.Path{
  433. Parent: basePath,
  434. RelativePath: relPath + "/billing/invoices",
  435. },
  436. Scopes: []types.PermissionScope{
  437. types.UserScope,
  438. types.ProjectScope,
  439. },
  440. },
  441. )
  442. listCustomerInvoicesHandler := billing.NewListCustomerInvoicesHandler(
  443. config,
  444. factory.GetDecoderValidator(),
  445. factory.GetResultWriter(),
  446. )
  447. routes = append(routes, &router.Route{
  448. Endpoint: listCustomerInvoicesEndpoint,
  449. Handler: listCustomerInvoicesHandler,
  450. Router: r,
  451. })
  452. // POST /api/projects/{project_id}/billing/ingest -> project.NewGetUsageDashboardHandler
  453. ingestEventsEndpoint := factory.NewAPIEndpoint(
  454. &types.APIRequestMetadata{
  455. Verb: types.APIVerbCreate,
  456. Method: types.HTTPVerbPost,
  457. Path: &types.Path{
  458. Parent: basePath,
  459. RelativePath: relPath + "/billing/ingest",
  460. },
  461. Scopes: []types.PermissionScope{
  462. types.UserScope,
  463. types.ProjectScope,
  464. },
  465. },
  466. )
  467. ingestEventsHandler := billing.NewIngestEventsHandler(
  468. config,
  469. factory.GetDecoderValidator(),
  470. factory.GetResultWriter(),
  471. )
  472. routes = append(routes, &router.Route{
  473. Endpoint: ingestEventsEndpoint,
  474. Handler: ingestEventsHandler,
  475. Router: r,
  476. })
  477. // POST /api/projects/{project_id}/billing/payment_method -> project.NewCreateBillingHandler
  478. createBillingEndpoint := factory.NewAPIEndpoint(
  479. &types.APIRequestMetadata{
  480. Verb: types.APIVerbCreate,
  481. Method: types.HTTPVerbPost,
  482. Path: &types.Path{
  483. Parent: basePath,
  484. RelativePath: relPath + "/billing/payment_method",
  485. },
  486. Scopes: []types.PermissionScope{
  487. types.UserScope,
  488. types.ProjectScope,
  489. },
  490. },
  491. )
  492. createBillingHandler := billing.NewCreateBillingHandler(
  493. config,
  494. factory.GetDecoderValidator(),
  495. factory.GetResultWriter(),
  496. )
  497. routes = append(routes, &router.Route{
  498. Endpoint: createBillingEndpoint,
  499. Handler: createBillingHandler,
  500. Router: r,
  501. })
  502. // PUT /api/projects/{project_id}/billing/payment_method/{payment_method_id}/default -> project.NewSetDefaultBillingHandler
  503. setDefaultBillingEndpoint := factory.NewAPIEndpoint(
  504. &types.APIRequestMetadata{
  505. Verb: types.APIVerbUpdate,
  506. Method: types.HTTPVerbPut,
  507. Path: &types.Path{
  508. Parent: basePath,
  509. RelativePath: fmt.Sprintf("%s/billing/payment_method/{%s}/default", relPath, types.URLParamPaymentMethodID),
  510. },
  511. Scopes: []types.PermissionScope{
  512. types.UserScope,
  513. types.ProjectScope,
  514. },
  515. },
  516. )
  517. setDefaultBillingHandler := billing.NewSetDefaultBillingHandler(
  518. config,
  519. factory.GetResultWriter(),
  520. )
  521. routes = append(routes, &router.Route{
  522. Endpoint: setDefaultBillingEndpoint,
  523. Handler: setDefaultBillingHandler,
  524. Router: r,
  525. })
  526. // DELETE /api/projects/{project_id}/billing/payment_method/{payment_method_id} -> project.NewDeleteBillingHandler
  527. deleteBillingEndpoint := factory.NewAPIEndpoint(
  528. &types.APIRequestMetadata{
  529. Verb: types.APIVerbDelete,
  530. Method: types.HTTPVerbDelete,
  531. Path: &types.Path{
  532. Parent: basePath,
  533. RelativePath: fmt.Sprintf("%s/billing/payment_method/{%s}", relPath, types.URLParamPaymentMethodID),
  534. },
  535. Scopes: []types.PermissionScope{
  536. types.UserScope,
  537. types.ProjectScope,
  538. },
  539. },
  540. )
  541. deleteBillingHandler := billing.NewDeleteBillingHandler(
  542. config,
  543. factory.GetResultWriter(),
  544. )
  545. routes = append(routes, &router.Route{
  546. Endpoint: deleteBillingEndpoint,
  547. Handler: deleteBillingHandler,
  548. Router: r,
  549. })
  550. // GET /api/projects/{project_id}/billing/publishable_key -> project.NewGetPublishableKeyHandler
  551. publishableKeyEndpoint := factory.NewAPIEndpoint(
  552. &types.APIRequestMetadata{
  553. Verb: types.APIVerbGet,
  554. Method: types.HTTPVerbGet,
  555. Path: &types.Path{
  556. Parent: basePath,
  557. RelativePath: relPath + "/billing/publishable_key",
  558. },
  559. Scopes: []types.PermissionScope{
  560. types.UserScope,
  561. types.ProjectScope,
  562. },
  563. },
  564. )
  565. publishableKeyHandler := billing.NewGetPublishableKeyHandler(
  566. config,
  567. factory.GetDecoderValidator(),
  568. factory.GetResultWriter(),
  569. )
  570. routes = append(routes, &router.Route{
  571. Endpoint: publishableKeyEndpoint,
  572. Handler: publishableKeyHandler,
  573. Router: r,
  574. })
  575. // GET /api/projects/{project_id}/clusters -> cluster.NewClusterListHandler
  576. listClusterEndpoint := factory.NewAPIEndpoint(
  577. &types.APIRequestMetadata{
  578. Verb: types.APIVerbList,
  579. Method: types.HTTPVerbGet,
  580. Path: &types.Path{
  581. Parent: basePath,
  582. RelativePath: relPath + "/clusters",
  583. },
  584. Scopes: []types.PermissionScope{
  585. types.UserScope,
  586. types.ProjectScope,
  587. },
  588. },
  589. )
  590. listClusterHandler := cluster.NewClusterListHandler(
  591. config,
  592. factory.GetResultWriter(),
  593. )
  594. routes = append(routes, &router.Route{
  595. Endpoint: listClusterEndpoint,
  596. Handler: listClusterHandler,
  597. Router: r,
  598. })
  599. // GET /api/projects/{project_id}/gitrepos -> gitinstallation.NewGitRepoListHandler
  600. listGitReposEndpoint := factory.NewAPIEndpoint(
  601. &types.APIRequestMetadata{
  602. Verb: types.APIVerbList,
  603. Method: types.HTTPVerbGet,
  604. Path: &types.Path{
  605. Parent: basePath,
  606. RelativePath: relPath + "/gitrepos",
  607. },
  608. Scopes: []types.PermissionScope{
  609. types.UserScope,
  610. types.ProjectScope,
  611. },
  612. },
  613. )
  614. listGitReposHandler := gitinstallation.NewGitRepoListHandler(
  615. config,
  616. factory.GetResultWriter(),
  617. )
  618. routes = append(routes, &router.Route{
  619. Endpoint: listGitReposEndpoint,
  620. Handler: listGitReposHandler,
  621. Router: r,
  622. })
  623. // GET /api/projects/{project_id}/collaborators -> project.NewCollaboratorsListHandler
  624. listCollaboratorsEndpoint := factory.NewAPIEndpoint(
  625. &types.APIRequestMetadata{
  626. Verb: types.APIVerbList,
  627. Method: types.HTTPVerbGet,
  628. Path: &types.Path{
  629. Parent: basePath,
  630. RelativePath: relPath + "/collaborators",
  631. },
  632. Scopes: []types.PermissionScope{
  633. types.UserScope,
  634. types.ProjectScope,
  635. },
  636. },
  637. )
  638. listCollaboratorsHandler := project.NewCollaboratorsListHandler(
  639. config,
  640. factory.GetResultWriter(),
  641. )
  642. routes = append(routes, &router.Route{
  643. Endpoint: listCollaboratorsEndpoint,
  644. Handler: listCollaboratorsHandler,
  645. Router: r,
  646. })
  647. // GET /api/projects/{project_id}/roles -> project.NewRolesListHandler
  648. listRolesEndpoint := factory.NewAPIEndpoint(
  649. &types.APIRequestMetadata{
  650. Verb: types.APIVerbList,
  651. Method: types.HTTPVerbGet,
  652. Path: &types.Path{
  653. Parent: basePath,
  654. RelativePath: relPath + "/roles",
  655. },
  656. Scopes: []types.PermissionScope{
  657. types.UserScope,
  658. types.ProjectScope,
  659. },
  660. },
  661. )
  662. listRolesHandler := project.NewRolesListHandler(
  663. config,
  664. factory.GetResultWriter(),
  665. )
  666. routes = append(routes, &router.Route{
  667. Endpoint: listRolesEndpoint,
  668. Handler: listRolesHandler,
  669. Router: r,
  670. })
  671. // GET /api/projects/{project_id}/datastores -> datastore.NewListAllDatastoresForProjectHandler
  672. listDatastoresEndpoint := factory.NewAPIEndpoint(
  673. &types.APIRequestMetadata{
  674. Verb: types.APIVerbList,
  675. Method: types.HTTPVerbGet,
  676. Path: &types.Path{
  677. Parent: basePath,
  678. RelativePath: relPath + "/datastores",
  679. },
  680. Scopes: []types.PermissionScope{
  681. types.UserScope,
  682. types.ProjectScope,
  683. },
  684. },
  685. )
  686. listDatastoresHandler := datastore.NewListDatastoresHandler(
  687. config,
  688. factory.GetDecoderValidator(),
  689. factory.GetResultWriter(),
  690. )
  691. routes = append(routes, &router.Route{
  692. Endpoint: listDatastoresEndpoint,
  693. Handler: listDatastoresHandler,
  694. Router: r,
  695. })
  696. // GET /api/projects/{project_id}/datastores -> datastore.NewGetDatastoreHandler
  697. getDatastoreEndpoint := 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}", relPath, types.URLParamDatastoreName),
  704. },
  705. Scopes: []types.PermissionScope{
  706. types.UserScope,
  707. types.ProjectScope,
  708. },
  709. },
  710. )
  711. getDatastoreHandler := datastore.NewGetDatastoreHandler(
  712. config,
  713. factory.GetDecoderValidator(),
  714. factory.GetResultWriter(),
  715. )
  716. routes = append(routes, &router.Route{
  717. Endpoint: getDatastoreEndpoint,
  718. Handler: getDatastoreHandler,
  719. Router: r,
  720. })
  721. // GET /api/projects/{project_id}/datastores -> datastore.NewGetDatastoreCredentialHandler
  722. getDatastoreCredentialEndpoint := factory.NewAPIEndpoint(
  723. &types.APIRequestMetadata{
  724. Verb: types.APIVerbList,
  725. Method: types.HTTPVerbGet,
  726. Path: &types.Path{
  727. Parent: basePath,
  728. RelativePath: fmt.Sprintf("%s/datastores/{%s}/credential", relPath, types.URLParamDatastoreName),
  729. },
  730. Scopes: []types.PermissionScope{
  731. types.UserScope,
  732. types.ProjectScope,
  733. },
  734. },
  735. )
  736. getDatastoreCredentialHandler := datastore.NewGetDatastoreCredentialHandler(
  737. config,
  738. factory.GetDecoderValidator(),
  739. factory.GetResultWriter(),
  740. )
  741. routes = append(routes, &router.Route{
  742. Endpoint: getDatastoreCredentialEndpoint,
  743. Handler: getDatastoreCredentialHandler,
  744. Router: r,
  745. })
  746. // POST /api/projects/{project_id}/datastores/{datastore_name}/create-proxy -> cluster.NewCreateDatastoreProxyHandler
  747. createDatastoreProxyEndpoint := factory.NewAPIEndpoint(
  748. &types.APIRequestMetadata{
  749. Verb: types.APIVerbUpdate,
  750. Method: types.HTTPVerbPost,
  751. Path: &types.Path{
  752. Parent: basePath,
  753. RelativePath: fmt.Sprintf("%s/datastores/{%s}/create-proxy", relPath, types.URLParamDatastoreName),
  754. },
  755. Scopes: []types.PermissionScope{
  756. types.UserScope,
  757. types.ProjectScope,
  758. },
  759. },
  760. )
  761. createDatastoreProxyHandler := datastore.NewCreateDatastoreProxyHandler(
  762. config,
  763. factory.GetDecoderValidator(),
  764. factory.GetResultWriter(),
  765. )
  766. routes = append(routes, &router.Route{
  767. Endpoint: createDatastoreProxyEndpoint,
  768. Handler: createDatastoreProxyHandler,
  769. Router: r,
  770. })
  771. // DELETE /api/projects/{project_id}/datastores/{datastore_name} -> cloud_provider.NewDeleteDatastoreHandler
  772. deleteDatastoreEndpoint := factory.NewAPIEndpoint(
  773. &types.APIRequestMetadata{
  774. Verb: types.APIVerbDelete,
  775. Method: types.HTTPVerbDelete,
  776. Path: &types.Path{
  777. Parent: basePath,
  778. RelativePath: fmt.Sprintf("%s/datastores/{%s}", relPath, types.URLParamDatastoreName),
  779. },
  780. Scopes: []types.PermissionScope{
  781. types.UserScope,
  782. types.ProjectScope,
  783. },
  784. },
  785. )
  786. deleteDatastoreHandler := datastore.NewDeleteDatastoreHandler(
  787. config,
  788. factory.GetDecoderValidator(),
  789. factory.GetResultWriter(),
  790. )
  791. routes = append(routes, &router.Route{
  792. Endpoint: deleteDatastoreEndpoint,
  793. Handler: deleteDatastoreHandler,
  794. Router: r,
  795. })
  796. // POST /api/projects/{project_id}/roles -> project.NewRoleUpdateHandler
  797. updateRoleEndpoint := factory.NewAPIEndpoint(
  798. &types.APIRequestMetadata{
  799. Verb: types.APIVerbUpdate,
  800. Method: types.HTTPVerbPost,
  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. updateRoleHandler := project.NewRoleUpdateHandler(
  812. config,
  813. factory.GetDecoderValidator(),
  814. factory.GetResultWriter(),
  815. )
  816. routes = append(routes, &router.Route{
  817. Endpoint: updateRoleEndpoint,
  818. Handler: updateRoleHandler,
  819. Router: r,
  820. })
  821. // DELETE /api/projects/{project_id}/roles -> project.NewRoleDeleteHandler
  822. deleteRoleEndpoint := factory.NewAPIEndpoint(
  823. &types.APIRequestMetadata{
  824. Verb: types.APIVerbDelete,
  825. Method: types.HTTPVerbDelete,
  826. Path: &types.Path{
  827. Parent: basePath,
  828. RelativePath: relPath + "/roles",
  829. },
  830. Scopes: []types.PermissionScope{
  831. types.UserScope,
  832. types.ProjectScope,
  833. },
  834. },
  835. )
  836. deleteRoleHandler := project.NewRoleDeleteHandler(
  837. config,
  838. factory.GetDecoderValidator(),
  839. factory.GetResultWriter(),
  840. )
  841. routes = append(routes, &router.Route{
  842. Endpoint: deleteRoleEndpoint,
  843. Handler: deleteRoleHandler,
  844. Router: r,
  845. })
  846. // GET /api/projects/{project_id}/registries -> registry.NewRegistryListHandler
  847. listRegistriesEndpoint := factory.NewAPIEndpoint(
  848. &types.APIRequestMetadata{
  849. Verb: types.APIVerbList,
  850. Method: types.HTTPVerbGet,
  851. Path: &types.Path{
  852. Parent: basePath,
  853. RelativePath: relPath + "/registries",
  854. },
  855. Scopes: []types.PermissionScope{
  856. types.UserScope,
  857. types.ProjectScope,
  858. },
  859. },
  860. )
  861. listRegistriesHandler := registry.NewRegistryListHandler(
  862. config,
  863. factory.GetResultWriter(),
  864. )
  865. routes = append(routes, &router.Route{
  866. Endpoint: listRegistriesEndpoint,
  867. Handler: listRegistriesHandler,
  868. Router: r,
  869. })
  870. // POST /api/projects/{project_id}/registries -> registry.NewRegistryCreateHandler
  871. createRegistryEndpoint := factory.NewAPIEndpoint(
  872. &types.APIRequestMetadata{
  873. Verb: types.APIVerbCreate,
  874. Method: types.HTTPVerbPost,
  875. Path: &types.Path{
  876. Parent: basePath,
  877. RelativePath: relPath + "/registries",
  878. },
  879. Scopes: []types.PermissionScope{
  880. types.UserScope,
  881. types.ProjectScope,
  882. },
  883. },
  884. )
  885. createRegistryHandler := registry.NewRegistryCreateHandler(
  886. config,
  887. factory.GetDecoderValidator(),
  888. factory.GetResultWriter(),
  889. )
  890. routes = append(routes, &router.Route{
  891. Endpoint: createRegistryEndpoint,
  892. Handler: createRegistryHandler,
  893. Router: r,
  894. })
  895. // GET /api/projects/{project_id}/registries/ecr/token -> registry.NewRegistryGetECRTokenHandler
  896. getECRTokenEndpoint := factory.NewAPIEndpoint(
  897. &types.APIRequestMetadata{
  898. Verb: types.APIVerbGet,
  899. Method: types.HTTPVerbGet,
  900. Path: &types.Path{
  901. Parent: basePath,
  902. RelativePath: relPath + "/registries/ecr/token",
  903. },
  904. Scopes: []types.PermissionScope{
  905. types.UserScope,
  906. types.ProjectScope,
  907. },
  908. },
  909. )
  910. getECRTokenHandler := registry.NewRegistryGetECRTokenHandler(
  911. config,
  912. factory.GetDecoderValidator(),
  913. factory.GetResultWriter(),
  914. )
  915. routes = append(routes, &router.Route{
  916. Endpoint: getECRTokenEndpoint,
  917. Handler: getECRTokenHandler,
  918. Router: r,
  919. })
  920. // GET /api/projects/{project_id}/registries/docr/token -> registry.NewRegistryGetDOCRTokenHandler
  921. getDOCRTokenEndpoint := factory.NewAPIEndpoint(
  922. &types.APIRequestMetadata{
  923. Verb: types.APIVerbGet,
  924. Method: types.HTTPVerbGet,
  925. Path: &types.Path{
  926. Parent: basePath,
  927. RelativePath: relPath + "/registries/docr/token",
  928. },
  929. Scopes: []types.PermissionScope{
  930. types.UserScope,
  931. types.ProjectScope,
  932. },
  933. },
  934. )
  935. getDOCRTokenHandler := registry.NewRegistryGetDOCRTokenHandler(
  936. config,
  937. factory.GetDecoderValidator(),
  938. factory.GetResultWriter(),
  939. )
  940. routes = append(routes, &router.Route{
  941. Endpoint: getDOCRTokenEndpoint,
  942. Handler: getDOCRTokenHandler,
  943. Router: r,
  944. })
  945. // GET /api/projects/{project_id}/registries/gcr/token -> registry.NewRegistryGetGCRTokenHandler
  946. getGCRTokenEndpoint := factory.NewAPIEndpoint(
  947. &types.APIRequestMetadata{
  948. Verb: types.APIVerbGet,
  949. Method: types.HTTPVerbGet,
  950. Path: &types.Path{
  951. Parent: basePath,
  952. RelativePath: relPath + "/registries/gcr/token",
  953. },
  954. Scopes: []types.PermissionScope{
  955. types.UserScope,
  956. types.ProjectScope,
  957. },
  958. },
  959. )
  960. getGCRTokenHandler := registry.NewRegistryGetGCRTokenHandler(
  961. config,
  962. factory.GetDecoderValidator(),
  963. factory.GetResultWriter(),
  964. )
  965. routes = append(routes, &router.Route{
  966. Endpoint: getGCRTokenEndpoint,
  967. Handler: getGCRTokenHandler,
  968. Router: r,
  969. })
  970. // GET /api/projects/{project_id}/registries/gar/token -> registry.NewRegistryGetGARTokenHandler
  971. getGARTokenEndpoint := factory.NewAPIEndpoint(
  972. &types.APIRequestMetadata{
  973. Verb: types.APIVerbGet,
  974. Method: types.HTTPVerbGet,
  975. Path: &types.Path{
  976. Parent: basePath,
  977. RelativePath: relPath + "/registries/gar/token",
  978. },
  979. Scopes: []types.PermissionScope{
  980. types.UserScope,
  981. types.ProjectScope,
  982. },
  983. },
  984. )
  985. getGARTokenHandler := registry.NewRegistryGetGARTokenHandler(
  986. config,
  987. factory.GetDecoderValidator(),
  988. factory.GetResultWriter(),
  989. )
  990. routes = append(routes, &router.Route{
  991. Endpoint: getGARTokenEndpoint,
  992. Handler: getGARTokenHandler,
  993. Router: r,
  994. })
  995. // GET /api/projects/{project_id}/registries/acr/token -> registry.NewRegistryGetACRTokenHandler
  996. getACRTokenEndpoint := factory.NewAPIEndpoint(
  997. &types.APIRequestMetadata{
  998. Verb: types.APIVerbGet,
  999. Method: types.HTTPVerbGet,
  1000. Path: &types.Path{
  1001. Parent: basePath,
  1002. RelativePath: relPath + "/registries/acr/token",
  1003. },
  1004. Scopes: []types.PermissionScope{
  1005. types.UserScope,
  1006. types.ProjectScope,
  1007. },
  1008. },
  1009. )
  1010. getACRTokenHandler := registry.NewRegistryGetACRTokenHandler(
  1011. config,
  1012. factory.GetDecoderValidator(),
  1013. factory.GetResultWriter(),
  1014. )
  1015. routes = append(routes, &router.Route{
  1016. Endpoint: getACRTokenEndpoint,
  1017. Handler: getACRTokenHandler,
  1018. Router: r,
  1019. })
  1020. // GET /api/projects/{project_id}/registries/dockerhub/token -> registry.NewRegistryGetDockerhubTokenHandler
  1021. getDockerhubTokenEndpoint := factory.NewAPIEndpoint(
  1022. &types.APIRequestMetadata{
  1023. Verb: types.APIVerbGet,
  1024. Method: types.HTTPVerbGet,
  1025. Path: &types.Path{
  1026. Parent: basePath,
  1027. RelativePath: relPath + "/registries/dockerhub/token",
  1028. },
  1029. Scopes: []types.PermissionScope{
  1030. types.UserScope,
  1031. types.ProjectScope,
  1032. },
  1033. },
  1034. )
  1035. getDockerhubTokenHandler := registry.NewRegistryGetDockerhubTokenHandler(
  1036. config,
  1037. factory.GetDecoderValidator(),
  1038. factory.GetResultWriter(),
  1039. )
  1040. routes = append(routes, &router.Route{
  1041. Endpoint: getDockerhubTokenEndpoint,
  1042. Handler: getDockerhubTokenHandler,
  1043. Router: r,
  1044. })
  1045. // POST /api/projects/{project_id}/infras -> infra.NewInfraCreateHandler
  1046. createInfraEndpoint := factory.NewAPIEndpoint(
  1047. &types.APIRequestMetadata{
  1048. Verb: types.APIVerbCreate,
  1049. Method: types.HTTPVerbPost,
  1050. Path: &types.Path{
  1051. Parent: basePath,
  1052. RelativePath: relPath + "/infras",
  1053. },
  1054. Scopes: []types.PermissionScope{
  1055. types.UserScope,
  1056. types.ProjectScope,
  1057. },
  1058. },
  1059. )
  1060. createInfraHandler := infra.NewInfraCreateHandler(
  1061. config,
  1062. factory.GetDecoderValidator(),
  1063. factory.GetResultWriter(),
  1064. )
  1065. routes = append(routes, &router.Route{
  1066. Endpoint: createInfraEndpoint,
  1067. Handler: createInfraHandler,
  1068. Router: r,
  1069. })
  1070. // GET /api/projects/{project_id}/infras/templates -> infra.NewInfraGetHandler
  1071. getTemplatesEndpoint := factory.NewAPIEndpoint(
  1072. &types.APIRequestMetadata{
  1073. Verb: types.APIVerbGet,
  1074. Method: types.HTTPVerbGet,
  1075. Path: &types.Path{
  1076. Parent: basePath,
  1077. RelativePath: relPath + "/infras/templates",
  1078. },
  1079. Scopes: []types.PermissionScope{
  1080. types.UserScope,
  1081. types.ProjectScope,
  1082. },
  1083. },
  1084. )
  1085. getTemplatesHandler := infra.NewInfraListTemplateHandler(
  1086. config,
  1087. factory.GetResultWriter(),
  1088. )
  1089. routes = append(routes, &router.Route{
  1090. Endpoint: getTemplatesEndpoint,
  1091. Handler: getTemplatesHandler,
  1092. Router: r,
  1093. })
  1094. // GET /api/projects/{project_id}/infras/templates -> infra.NewInfraGetHandler
  1095. getTemplateEndpoint := factory.NewAPIEndpoint(
  1096. &types.APIRequestMetadata{
  1097. Verb: types.APIVerbGet,
  1098. Method: types.HTTPVerbGet,
  1099. Path: &types.Path{
  1100. Parent: basePath,
  1101. RelativePath: fmt.Sprintf("%s/infras/templates/{%s}/{%s}", relPath, types.URLParamTemplateName, types.URLParamTemplateVersion),
  1102. },
  1103. Scopes: []types.PermissionScope{
  1104. types.UserScope,
  1105. types.ProjectScope,
  1106. },
  1107. },
  1108. )
  1109. getTemplateHandler := infra.NewInfraGetTemplateHandler(
  1110. config,
  1111. factory.GetResultWriter(),
  1112. )
  1113. routes = append(routes, &router.Route{
  1114. Endpoint: getTemplateEndpoint,
  1115. Handler: getTemplateHandler,
  1116. Router: r,
  1117. })
  1118. // // POST /api/projects/{project_id}/provision/ecr -> provision.NewProvisionECRHandler
  1119. // provisionECREndpoint := factory.NewAPIEndpoint(
  1120. // &types.APIRequestMetadata{
  1121. // Verb: types.APIVerbCreate,
  1122. // Method: types.HTTPVerbPost,
  1123. // Path: &types.Path{
  1124. // Parent: basePath,
  1125. // RelativePath: relPath + "/provision/ecr",
  1126. // },
  1127. // Scopes: []types.PermissionScope{
  1128. // types.UserScope,
  1129. // types.ProjectScope,
  1130. // },
  1131. // },
  1132. // )
  1133. // provisionECRHandler := provision.NewProvisionECRHandler(
  1134. // config,
  1135. // factory.GetDecoderValidator(),
  1136. // factory.GetResultWriter(),
  1137. // )
  1138. // routes = append(routes, &router.Route{
  1139. // Endpoint: provisionECREndpoint,
  1140. // Handler: provisionECRHandler,
  1141. // Router: r,
  1142. // })
  1143. // // POST /api/projects/{project_id}/provision/eks -> provision.NewProvisionEKSHandler
  1144. // provisionEKSEndpoint := factory.NewAPIEndpoint(
  1145. // &types.APIRequestMetadata{
  1146. // Verb: types.APIVerbCreate,
  1147. // Method: types.HTTPVerbPost,
  1148. // Path: &types.Path{
  1149. // Parent: basePath,
  1150. // RelativePath: relPath + "/provision/eks",
  1151. // },
  1152. // Scopes: []types.PermissionScope{
  1153. // types.UserScope,
  1154. // types.ProjectScope,
  1155. // },
  1156. // CheckUsage: true,
  1157. // UsageMetric: types.Clusters,
  1158. // },
  1159. // )
  1160. // provisionEKSHandler := provision.NewProvisionEKSHandler(
  1161. // config,
  1162. // factory.GetDecoderValidator(),
  1163. // factory.GetResultWriter(),
  1164. // )
  1165. // routes = append(routes, &router.Route{
  1166. // Endpoint: provisionEKSEndpoint,
  1167. // Handler: provisionEKSHandler,
  1168. // Router: r,
  1169. // })
  1170. // // POST /api/projects/{project_id}/provision/docr -> provision.NewProvisionDOCRHandler
  1171. // provisionDOCREndpoint := factory.NewAPIEndpoint(
  1172. // &types.APIRequestMetadata{
  1173. // Verb: types.APIVerbCreate,
  1174. // Method: types.HTTPVerbPost,
  1175. // Path: &types.Path{
  1176. // Parent: basePath,
  1177. // RelativePath: relPath + "/provision/docr",
  1178. // },
  1179. // Scopes: []types.PermissionScope{
  1180. // types.UserScope,
  1181. // types.ProjectScope,
  1182. // },
  1183. // },
  1184. // )
  1185. // provisionDOCRHandler := provision.NewProvisionDOCRHandler(
  1186. // config,
  1187. // factory.GetDecoderValidator(),
  1188. // factory.GetResultWriter(),
  1189. // )
  1190. // routes = append(routes, &router.Route{
  1191. // Endpoint: provisionDOCREndpoint,
  1192. // Handler: provisionDOCRHandler,
  1193. // Router: r,
  1194. // })
  1195. // // POST /api/projects/{project_id}/provision/doks -> provision.NewProvisionDOKSHandler
  1196. // provisionDOKSEndpoint := factory.NewAPIEndpoint(
  1197. // &types.APIRequestMetadata{
  1198. // Verb: types.APIVerbCreate,
  1199. // Method: types.HTTPVerbPost,
  1200. // Path: &types.Path{
  1201. // Parent: basePath,
  1202. // RelativePath: relPath + "/provision/doks",
  1203. // },
  1204. // Scopes: []types.PermissionScope{
  1205. // types.UserScope,
  1206. // types.ProjectScope,
  1207. // },
  1208. // CheckUsage: true,
  1209. // UsageMetric: types.Clusters,
  1210. // },
  1211. // )
  1212. // provisionDOKSHandler := provision.NewProvisionDOKSHandler(
  1213. // config,
  1214. // factory.GetDecoderValidator(),
  1215. // factory.GetResultWriter(),
  1216. // )
  1217. // routes = append(routes, &router.Route{
  1218. // Endpoint: provisionDOKSEndpoint,
  1219. // Handler: provisionDOKSHandler,
  1220. // Router: r,
  1221. // })
  1222. // // POST /api/projects/{project_id}/provision/gcr -> provision.NewProvisionGCRHandler
  1223. // provisionGCREndpoint := factory.NewAPIEndpoint(
  1224. // &types.APIRequestMetadata{
  1225. // Verb: types.APIVerbCreate,
  1226. // Method: types.HTTPVerbPost,
  1227. // Path: &types.Path{
  1228. // Parent: basePath,
  1229. // RelativePath: relPath + "/provision/gcr",
  1230. // },
  1231. // Scopes: []types.PermissionScope{
  1232. // types.UserScope,
  1233. // types.ProjectScope,
  1234. // },
  1235. // },
  1236. // )
  1237. // provisionGCRHandler := provision.NewProvisionGCRHandler(
  1238. // config,
  1239. // factory.GetDecoderValidator(),
  1240. // factory.GetResultWriter(),
  1241. // )
  1242. // routes = append(routes, &router.Route{
  1243. // Endpoint: provisionGCREndpoint,
  1244. // Handler: provisionGCRHandler,
  1245. // Router: r,
  1246. // })
  1247. // // POST /api/projects/{project_id}/provision/gke -> provision.NewProvisionGKEHandler
  1248. // provisionGKEEndpoint := factory.NewAPIEndpoint(
  1249. // &types.APIRequestMetadata{
  1250. // Verb: types.APIVerbCreate,
  1251. // Method: types.HTTPVerbPost,
  1252. // Path: &types.Path{
  1253. // Parent: basePath,
  1254. // RelativePath: relPath + "/provision/gke",
  1255. // },
  1256. // Scopes: []types.PermissionScope{
  1257. // types.UserScope,
  1258. // types.ProjectScope,
  1259. // },
  1260. // CheckUsage: true,
  1261. // UsageMetric: types.Clusters,
  1262. // },
  1263. // )
  1264. // provisionGKEHandler := provision.NewProvisionGKEHandler(
  1265. // config,
  1266. // factory.GetDecoderValidator(),
  1267. // factory.GetResultWriter(),
  1268. // )
  1269. // routes = append(routes, &router.Route{
  1270. // Endpoint: provisionGKEEndpoint,
  1271. // Handler: provisionGKEHandler,
  1272. // Router: r,
  1273. // })
  1274. // POST /api/projects/{project_id}/connect -> project.NewProjectConnectHandler
  1275. connectEndpoint := factory.NewAPIEndpoint(
  1276. &types.APIRequestMetadata{
  1277. Verb: types.APIVerbCreate,
  1278. Method: types.HTTPVerbPost,
  1279. Path: &types.Path{
  1280. Parent: basePath,
  1281. RelativePath: relPath + "/connect",
  1282. },
  1283. Scopes: []types.PermissionScope{
  1284. types.UserScope,
  1285. types.ProjectScope,
  1286. types.SettingsScope,
  1287. },
  1288. },
  1289. )
  1290. connectHandler := project.NewConnectHandler(
  1291. config,
  1292. factory.GetDecoderValidator(),
  1293. factory.GetResultWriter(),
  1294. )
  1295. routes = append(routes, &router.Route{
  1296. Endpoint: connectEndpoint,
  1297. Handler: connectHandler,
  1298. Router: r,
  1299. })
  1300. // POST /api/projects/{project_id}/policy -> policy.NewPolicyCreateHandler
  1301. policyCreateEndpoint := factory.NewAPIEndpoint(
  1302. &types.APIRequestMetadata{
  1303. Verb: types.APIVerbCreate,
  1304. Method: types.HTTPVerbPost,
  1305. Path: &types.Path{
  1306. Parent: basePath,
  1307. RelativePath: relPath + "/policy",
  1308. },
  1309. Scopes: []types.PermissionScope{
  1310. types.UserScope,
  1311. types.ProjectScope,
  1312. types.SettingsScope,
  1313. },
  1314. },
  1315. )
  1316. policyCreateHandler := policy.NewPolicyCreateHandler(
  1317. config,
  1318. factory.GetDecoderValidator(),
  1319. factory.GetResultWriter(),
  1320. )
  1321. routes = append(routes, &router.Route{
  1322. Endpoint: policyCreateEndpoint,
  1323. Handler: policyCreateHandler,
  1324. Router: r,
  1325. })
  1326. // GET /api/projects/{project_id}/policies -> policy.NewPolicyListHandler
  1327. policyListEndpoint := factory.NewAPIEndpoint(
  1328. &types.APIRequestMetadata{
  1329. Verb: types.APIVerbList,
  1330. Method: types.HTTPVerbGet,
  1331. Path: &types.Path{
  1332. Parent: basePath,
  1333. RelativePath: relPath + "/policies",
  1334. },
  1335. Scopes: []types.PermissionScope{
  1336. types.UserScope,
  1337. types.ProjectScope,
  1338. types.SettingsScope,
  1339. },
  1340. },
  1341. )
  1342. policyListHandler := policy.NewPolicyListHandler(
  1343. config,
  1344. factory.GetDecoderValidator(),
  1345. factory.GetResultWriter(),
  1346. )
  1347. routes = append(routes, &router.Route{
  1348. Endpoint: policyListEndpoint,
  1349. Handler: policyListHandler,
  1350. Router: r,
  1351. })
  1352. // GET /api/projects/{project_id}/policy/{policy_id} -> policy.NewPolicyGetHandler
  1353. policyGetEndpoint := factory.NewAPIEndpoint(
  1354. &types.APIRequestMetadata{
  1355. Verb: types.APIVerbGet,
  1356. Method: types.HTTPVerbGet,
  1357. Path: &types.Path{
  1358. Parent: basePath,
  1359. RelativePath: fmt.Sprintf("%s/policy/{%s}", relPath, types.URLParamPolicyID),
  1360. },
  1361. Scopes: []types.PermissionScope{
  1362. types.UserScope,
  1363. types.ProjectScope,
  1364. types.SettingsScope,
  1365. },
  1366. },
  1367. )
  1368. policyGetHandler := policy.NewPolicyGetHandler(
  1369. config,
  1370. factory.GetDecoderValidator(),
  1371. factory.GetResultWriter(),
  1372. )
  1373. routes = append(routes, &router.Route{
  1374. Endpoint: policyGetEndpoint,
  1375. Handler: policyGetHandler,
  1376. Router: r,
  1377. })
  1378. // POST /api/projects/{project_id}/api_token -> api_token.NewAPITokenCreateHandler
  1379. apiTokenCreateEndpoint := factory.NewAPIEndpoint(
  1380. &types.APIRequestMetadata{
  1381. Verb: types.APIVerbCreate,
  1382. Method: types.HTTPVerbPost,
  1383. Path: &types.Path{
  1384. Parent: basePath,
  1385. RelativePath: relPath + "/api_token",
  1386. },
  1387. Scopes: []types.PermissionScope{
  1388. types.UserScope,
  1389. types.ProjectScope,
  1390. types.SettingsScope,
  1391. },
  1392. },
  1393. )
  1394. apiTokenCreateHandler := api_token.NewAPITokenCreateHandler(
  1395. config,
  1396. factory.GetDecoderValidator(),
  1397. factory.GetResultWriter(),
  1398. )
  1399. routes = append(routes, &router.Route{
  1400. Endpoint: apiTokenCreateEndpoint,
  1401. Handler: apiTokenCreateHandler,
  1402. Router: r,
  1403. })
  1404. // GET /api/projects/{project_id}/api_token -> api_token.NewAPITokenListHandler
  1405. apiTokenListEndpoint := factory.NewAPIEndpoint(
  1406. &types.APIRequestMetadata{
  1407. Verb: types.APIVerbList,
  1408. Method: types.HTTPVerbGet,
  1409. Path: &types.Path{
  1410. Parent: basePath,
  1411. RelativePath: fmt.Sprintf("%s/api_token", relPath),
  1412. },
  1413. Scopes: []types.PermissionScope{
  1414. types.UserScope,
  1415. types.ProjectScope,
  1416. types.SettingsScope,
  1417. },
  1418. },
  1419. )
  1420. apiTokenListHandler := api_token.NewAPITokenListHandler(
  1421. config,
  1422. factory.GetDecoderValidator(),
  1423. factory.GetResultWriter(),
  1424. )
  1425. routes = append(routes, &router.Route{
  1426. Endpoint: apiTokenListEndpoint,
  1427. Handler: apiTokenListHandler,
  1428. Router: r,
  1429. })
  1430. // GET /api/projects/{project_id}/api_token/{api_token_id} -> api_token.NewAPITokenGetHandler
  1431. apiTokenGetEndpoint := factory.NewAPIEndpoint(
  1432. &types.APIRequestMetadata{
  1433. Verb: types.APIVerbGet,
  1434. Method: types.HTTPVerbGet,
  1435. Path: &types.Path{
  1436. Parent: basePath,
  1437. RelativePath: fmt.Sprintf("%s/api_token/{%s}", relPath, types.URLParamTokenID),
  1438. },
  1439. Scopes: []types.PermissionScope{
  1440. types.UserScope,
  1441. types.ProjectScope,
  1442. types.SettingsScope,
  1443. },
  1444. },
  1445. )
  1446. apiTokenGetHandler := api_token.NewAPITokenGetHandler(
  1447. config,
  1448. factory.GetDecoderValidator(),
  1449. factory.GetResultWriter(),
  1450. )
  1451. routes = append(routes, &router.Route{
  1452. Endpoint: apiTokenGetEndpoint,
  1453. Handler: apiTokenGetHandler,
  1454. Router: r,
  1455. })
  1456. // POST /api/projects/{project_id}/api_token/{api_token_id}/revoke -> api_token.NewAPITokenRevokeHandler
  1457. apiTokenRevokeEndpoint := factory.NewAPIEndpoint(
  1458. &types.APIRequestMetadata{
  1459. Verb: types.APIVerbUpdate,
  1460. Method: types.HTTPVerbPost,
  1461. Path: &types.Path{
  1462. Parent: basePath,
  1463. RelativePath: fmt.Sprintf("%s/api_token/{%s}/revoke", relPath, types.URLParamTokenID),
  1464. },
  1465. Scopes: []types.PermissionScope{
  1466. types.UserScope,
  1467. types.ProjectScope,
  1468. types.SettingsScope,
  1469. },
  1470. },
  1471. )
  1472. apiTokenRevokeHandler := api_token.NewAPITokenRevokeHandler(
  1473. config,
  1474. factory.GetDecoderValidator(),
  1475. factory.GetResultWriter(),
  1476. )
  1477. routes = append(routes, &router.Route{
  1478. Endpoint: apiTokenRevokeEndpoint,
  1479. Handler: apiTokenRevokeHandler,
  1480. Router: r,
  1481. })
  1482. // POST /api/projects/{project_id}/helmrepos -> helmrepo.NewHelmRepoCreateHandler
  1483. hrCreateEndpoint := factory.NewAPIEndpoint(
  1484. &types.APIRequestMetadata{
  1485. Verb: types.APIVerbCreate,
  1486. Method: types.HTTPVerbPost,
  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. hrCreateHandler := helmrepo.NewHelmRepoCreateHandler(
  1498. config,
  1499. factory.GetDecoderValidator(),
  1500. factory.GetResultWriter(),
  1501. )
  1502. routes = append(routes, &router.Route{
  1503. Endpoint: hrCreateEndpoint,
  1504. Handler: hrCreateHandler,
  1505. Router: r,
  1506. })
  1507. // GET /api/projects/{project_id}/helmrepos -> helmrepo.NewHelmRepoListHandler
  1508. hrListEndpoint := factory.NewAPIEndpoint(
  1509. &types.APIRequestMetadata{
  1510. Verb: types.APIVerbList,
  1511. Method: types.HTTPVerbGet,
  1512. Path: &types.Path{
  1513. Parent: basePath,
  1514. RelativePath: relPath + "/helmrepos",
  1515. },
  1516. Scopes: []types.PermissionScope{
  1517. types.UserScope,
  1518. types.ProjectScope,
  1519. },
  1520. },
  1521. )
  1522. hrListHandler := helmrepo.NewHelmRepoListHandler(
  1523. config,
  1524. factory.GetResultWriter(),
  1525. )
  1526. routes = append(routes, &router.Route{
  1527. Endpoint: hrListEndpoint,
  1528. Handler: hrListHandler,
  1529. Router: r,
  1530. })
  1531. // GET /api/projects/{project_id}/tags -> project.NewGetTagsHandler
  1532. getTagsEndpoint := factory.NewAPIEndpoint(
  1533. &types.APIRequestMetadata{
  1534. Verb: types.APIVerbGet,
  1535. Method: types.HTTPVerbGet,
  1536. Path: &types.Path{
  1537. Parent: basePath,
  1538. RelativePath: relPath + "/tags",
  1539. },
  1540. Scopes: []types.PermissionScope{
  1541. types.UserScope,
  1542. types.ProjectScope,
  1543. },
  1544. },
  1545. )
  1546. getTagsHandler := project.NewGetTagsHandler(
  1547. config,
  1548. factory.GetResultWriter(),
  1549. )
  1550. routes = append(routes, &router.Route{
  1551. Endpoint: getTagsEndpoint,
  1552. Handler: getTagsHandler,
  1553. Router: r,
  1554. })
  1555. // POST /api/projects/{project_id}/tags -> project.NewCreateTagHandler
  1556. createTagEndpoint := factory.NewAPIEndpoint(
  1557. &types.APIRequestMetadata{
  1558. Verb: types.APIVerbCreate,
  1559. Method: types.HTTPVerbPost,
  1560. Path: &types.Path{
  1561. Parent: basePath,
  1562. RelativePath: relPath + "/tags",
  1563. },
  1564. Scopes: []types.PermissionScope{
  1565. types.UserScope,
  1566. types.ProjectScope,
  1567. },
  1568. },
  1569. )
  1570. createTagHandler := project.NewCreateTagHandler(
  1571. config,
  1572. factory.GetDecoderValidator(),
  1573. factory.GetResultWriter(),
  1574. )
  1575. routes = append(routes, &router.Route{
  1576. Endpoint: createTagEndpoint,
  1577. Handler: createTagHandler,
  1578. Router: r,
  1579. })
  1580. // POST /api/projects/{project_id}/contract -> apiContract.NewAPIContractUpdateHandler
  1581. updateAPIContractEndpoint := factory.NewAPIEndpoint(
  1582. &types.APIRequestMetadata{
  1583. Verb: types.APIVerbCreate,
  1584. Method: types.HTTPVerbPost,
  1585. Path: &types.Path{
  1586. Parent: basePath,
  1587. RelativePath: relPath + "/contract",
  1588. },
  1589. Scopes: []types.PermissionScope{
  1590. types.UserScope,
  1591. types.ProjectScope,
  1592. },
  1593. },
  1594. )
  1595. updateAPIContractHandler := apiContract.NewAPIContractUpdateHandler(
  1596. config,
  1597. factory.GetDecoderValidator(),
  1598. factory.GetResultWriter(),
  1599. )
  1600. routes = append(routes, &router.Route{
  1601. Endpoint: updateAPIContractEndpoint,
  1602. Handler: updateAPIContractHandler,
  1603. Router: r,
  1604. })
  1605. // GET /api/projects/{project_id}/contracts -> apiContract.NewAPIContractRevisionListHandler
  1606. listAPIContractRevisionsEndpoint := factory.NewAPIEndpoint(
  1607. &types.APIRequestMetadata{
  1608. Verb: types.APIVerbGet,
  1609. Method: types.HTTPVerbGet,
  1610. Path: &types.Path{
  1611. Parent: basePath,
  1612. RelativePath: relPath + "/contracts",
  1613. },
  1614. Scopes: []types.PermissionScope{
  1615. types.UserScope,
  1616. types.ProjectScope,
  1617. },
  1618. },
  1619. )
  1620. listAPIContractRevisionHandler := apiContract.NewAPIContractRevisionListHandler(
  1621. config,
  1622. factory.GetDecoderValidator(),
  1623. factory.GetResultWriter(),
  1624. )
  1625. routes = append(routes, &router.Route{
  1626. Endpoint: listAPIContractRevisionsEndpoint,
  1627. Handler: listAPIContractRevisionHandler,
  1628. Router: r,
  1629. })
  1630. // DELETE /api/projects/{project_id}/contracts/{revision_id} -> apiContract.NewAPIContractUpdateHandler
  1631. deleteAPIContractRevisionsEndpoint := factory.NewAPIEndpoint(
  1632. &types.APIRequestMetadata{
  1633. Verb: types.APIVerbDelete,
  1634. Method: types.HTTPVerbDelete,
  1635. Path: &types.Path{
  1636. Parent: basePath,
  1637. RelativePath: fmt.Sprintf("%s/contracts/{%s}", relPath, types.URLParamAPIContractRevisionID),
  1638. },
  1639. Scopes: []types.PermissionScope{
  1640. types.UserScope,
  1641. types.ProjectScope,
  1642. types.APIContractRevisionScope,
  1643. },
  1644. },
  1645. )
  1646. deleteAPIContractRevisionHandler := apiContract.NewAPIContractRevisionDeleteHandler(
  1647. config,
  1648. factory.GetDecoderValidator(),
  1649. factory.GetResultWriter(),
  1650. )
  1651. routes = append(routes, &router.Route{
  1652. Endpoint: deleteAPIContractRevisionsEndpoint,
  1653. Handler: deleteAPIContractRevisionHandler,
  1654. Router: r,
  1655. })
  1656. // POST /api/projects/{project_id}/contract/preflight -> apiContract.NewPreflightCheckHandler
  1657. preflightCheckEndpoint := factory.NewAPIEndpoint(
  1658. &types.APIRequestMetadata{
  1659. Verb: types.APIVerbCreate,
  1660. Method: types.HTTPVerbPost,
  1661. Path: &types.Path{
  1662. Parent: basePath,
  1663. RelativePath: fmt.Sprintf("%s/contract/preflight", relPath),
  1664. },
  1665. Scopes: []types.PermissionScope{
  1666. types.UserScope,
  1667. types.ProjectScope,
  1668. },
  1669. },
  1670. )
  1671. preflightCheckHandler := apiContract.NewPreflightCheckHandler(
  1672. config,
  1673. factory.GetDecoderValidator(),
  1674. factory.GetResultWriter(),
  1675. )
  1676. routes = append(routes, &router.Route{
  1677. Endpoint: preflightCheckEndpoint,
  1678. Handler: preflightCheckHandler,
  1679. Router: r,
  1680. })
  1681. // GET /api/projects/{project_id}/cloud/machines -> apiContract.NewCloudProviderMachineTypesHandler
  1682. machineTypeEndpoint := factory.NewAPIEndpoint(
  1683. &types.APIRequestMetadata{
  1684. Verb: types.APIVerbGet,
  1685. Method: types.HTTPVerbGet,
  1686. Path: &types.Path{
  1687. Parent: basePath,
  1688. RelativePath: fmt.Sprintf("%s/cloud/machines", relPath),
  1689. },
  1690. Scopes: []types.PermissionScope{
  1691. types.UserScope,
  1692. types.ProjectScope,
  1693. },
  1694. },
  1695. )
  1696. machineTypeHandler := cloud_provider.NewCloudProviderMachineTypesHandler(
  1697. config,
  1698. factory.GetDecoderValidator(),
  1699. factory.GetResultWriter(),
  1700. )
  1701. routes = append(routes, &router.Route{
  1702. Endpoint: machineTypeEndpoint,
  1703. Handler: machineTypeHandler,
  1704. Router: r,
  1705. })
  1706. // POST /api/projects/{project_id}/rename -> cluster.newRenamProject
  1707. renameProjectEndpoint := factory.NewAPIEndpoint(
  1708. &types.APIRequestMetadata{
  1709. Verb: types.APIVerbCreate,
  1710. Method: types.HTTPVerbPost,
  1711. Path: &types.Path{
  1712. Parent: basePath,
  1713. RelativePath: relPath + "/rename",
  1714. },
  1715. Scopes: []types.PermissionScope{
  1716. types.UserScope,
  1717. types.ProjectScope,
  1718. },
  1719. },
  1720. )
  1721. renameProjectHandler := project.NewRenameProjectHandler(
  1722. config,
  1723. factory.GetDecoderValidator(),
  1724. factory.GetResultWriter(),
  1725. )
  1726. routes = append(routes, &router.Route{
  1727. Endpoint: renameProjectEndpoint,
  1728. Handler: renameProjectHandler,
  1729. Router: r,
  1730. })
  1731. // GET /api/projects/{project_id}/images -> project.ImagesHandler
  1732. imagesEndpoint := factory.NewAPIEndpoint(
  1733. &types.APIRequestMetadata{
  1734. Verb: types.APIVerbList,
  1735. Method: types.HTTPVerbGet,
  1736. Path: &types.Path{
  1737. Parent: basePath,
  1738. RelativePath: relPath + "/images",
  1739. },
  1740. Scopes: []types.PermissionScope{
  1741. types.UserScope,
  1742. types.ProjectScope,
  1743. },
  1744. },
  1745. )
  1746. imagesHandler := project.NewImagesHandler(
  1747. config,
  1748. factory.GetResultWriter(),
  1749. )
  1750. routes = append(routes, &router.Route{
  1751. Endpoint: imagesEndpoint,
  1752. Handler: imagesHandler,
  1753. Router: r,
  1754. })
  1755. // GET /api/projects/{project_id}/targets -> deployment_target.ListDeploymentTargetHandler
  1756. listDeploymentTargetEndpoint := factory.NewAPIEndpoint(
  1757. &types.APIRequestMetadata{
  1758. Verb: types.APIVerbGet,
  1759. Method: types.HTTPVerbGet,
  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. listDeploymentTargetHandler := deployment_target.NewListDeploymentTargetsHandler(
  1771. config,
  1772. factory.GetDecoderValidator(),
  1773. factory.GetResultWriter(),
  1774. )
  1775. routes = append(routes, &router.Route{
  1776. Endpoint: listDeploymentTargetEndpoint,
  1777. Handler: listDeploymentTargetHandler,
  1778. Router: r,
  1779. })
  1780. // GET /api/projects/{project_id}/targets -> deployment_target.ListDeploymentTargetHandler
  1781. createDeploymentTargetEndpoint := factory.NewAPIEndpoint(
  1782. &types.APIRequestMetadata{
  1783. Verb: types.APIVerbCreate,
  1784. Method: types.HTTPVerbPost,
  1785. Path: &types.Path{
  1786. Parent: basePath,
  1787. RelativePath: fmt.Sprintf("%s/targets", relPath),
  1788. },
  1789. Scopes: []types.PermissionScope{
  1790. types.UserScope,
  1791. types.ProjectScope,
  1792. },
  1793. },
  1794. )
  1795. createDeploymentTargetHandler := deployment_target.NewCreateDeploymentTargetHandler(
  1796. config,
  1797. factory.GetDecoderValidator(),
  1798. factory.GetResultWriter(),
  1799. )
  1800. routes = append(routes, &router.Route{
  1801. Endpoint: createDeploymentTargetEndpoint,
  1802. Handler: createDeploymentTargetHandler,
  1803. Router: r,
  1804. })
  1805. // GET /api/projects/{project_id}/neon-integrations -> apiContract.NewListNeonIntegrationsHandler
  1806. listNeonIntegrationsEndpoint := factory.NewAPIEndpoint(
  1807. &types.APIRequestMetadata{
  1808. Verb: types.APIVerbGet,
  1809. Method: types.HTTPVerbGet,
  1810. Path: &types.Path{
  1811. Parent: basePath,
  1812. RelativePath: relPath + "/neon-integrations",
  1813. },
  1814. Scopes: []types.PermissionScope{
  1815. types.UserScope,
  1816. types.ProjectScope,
  1817. },
  1818. },
  1819. )
  1820. listNeonIntegrationsHandler := neon_integration.NewListNeonIntegrationsHandler(
  1821. config,
  1822. factory.GetDecoderValidator(),
  1823. factory.GetResultWriter(),
  1824. )
  1825. routes = append(routes, &router.Route{
  1826. Endpoint: listNeonIntegrationsEndpoint,
  1827. Handler: listNeonIntegrationsHandler,
  1828. Router: r,
  1829. })
  1830. // GET /api/projects/{project_id}/upstash-integrations -> apiContract.NewListUpstashIntegrationsHandler
  1831. listUpstashIntegrationsEndpoint := factory.NewAPIEndpoint(
  1832. &types.APIRequestMetadata{
  1833. Verb: types.APIVerbGet,
  1834. Method: types.HTTPVerbGet,
  1835. Path: &types.Path{
  1836. Parent: basePath,
  1837. RelativePath: relPath + "/upstash-integrations",
  1838. },
  1839. Scopes: []types.PermissionScope{
  1840. types.UserScope,
  1841. types.ProjectScope,
  1842. },
  1843. },
  1844. )
  1845. listUpstashIntegrationsHandler := upstash_integration.NewListUpstashIntegrationsHandler(
  1846. config,
  1847. factory.GetDecoderValidator(),
  1848. factory.GetResultWriter(),
  1849. )
  1850. routes = append(routes, &router.Route{
  1851. Endpoint: listUpstashIntegrationsEndpoint,
  1852. Handler: listUpstashIntegrationsHandler,
  1853. Router: r,
  1854. })
  1855. return routes, newPath
  1856. }