project.go 49 KB

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