cluster.go 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328
  1. package router
  2. import (
  3. "fmt"
  4. "github.com/go-chi/chi"
  5. "github.com/porter-dev/porter/api/server/handlers/cluster"
  6. "github.com/porter-dev/porter/api/server/handlers/database"
  7. "github.com/porter-dev/porter/api/server/handlers/environment"
  8. "github.com/porter-dev/porter/api/server/shared"
  9. "github.com/porter-dev/porter/api/server/shared/config"
  10. "github.com/porter-dev/porter/api/server/shared/router"
  11. "github.com/porter-dev/porter/api/types"
  12. )
  13. func NewClusterScopedRegisterer(children ...*router.Registerer) *router.Registerer {
  14. return &router.Registerer{
  15. GetRoutes: GetClusterScopedRoutes,
  16. Children: children,
  17. }
  18. }
  19. func GetClusterScopedRoutes(
  20. r chi.Router,
  21. config *config.Config,
  22. basePath *types.Path,
  23. factory shared.APIEndpointFactory,
  24. children ...*router.Registerer,
  25. ) []*router.Route {
  26. routes, projPath := getClusterRoutes(r, config, basePath, factory)
  27. if len(children) > 0 {
  28. r.Route(projPath.RelativePath, func(r chi.Router) {
  29. for _, child := range children {
  30. childRoutes := child.GetRoutes(r, config, basePath, factory, child.Children...)
  31. routes = append(routes, childRoutes...)
  32. }
  33. })
  34. }
  35. return routes
  36. }
  37. func getClusterRoutes(
  38. r chi.Router,
  39. config *config.Config,
  40. basePath *types.Path,
  41. factory shared.APIEndpointFactory,
  42. ) ([]*router.Route, *types.Path) {
  43. relPath := "/clusters/{cluster_id}"
  44. newPath := &types.Path{
  45. Parent: basePath,
  46. RelativePath: relPath,
  47. }
  48. routes := make([]*router.Route, 0)
  49. // POST /api/projects/{project_id}/clusters -> project.NewCreateClusterManualHandler
  50. createEndpoint := factory.NewAPIEndpoint(
  51. &types.APIRequestMetadata{
  52. Verb: types.APIVerbCreate,
  53. Method: types.HTTPVerbPost,
  54. Path: &types.Path{
  55. Parent: basePath,
  56. RelativePath: "/clusters",
  57. },
  58. Scopes: []types.PermissionScope{
  59. types.UserScope,
  60. types.ProjectScope,
  61. },
  62. },
  63. )
  64. createHandler := cluster.NewCreateClusterManualHandler(
  65. config,
  66. factory.GetDecoderValidator(),
  67. factory.GetResultWriter(),
  68. )
  69. routes = append(routes, &router.Route{
  70. Endpoint: createEndpoint,
  71. Handler: createHandler,
  72. Router: r,
  73. })
  74. // POST /api/projects/{project_id}/clusters/candidates -> project.NewCreateClusterCandidateHandler
  75. createCandidateEndpoint := factory.NewAPIEndpoint(
  76. &types.APIRequestMetadata{
  77. Verb: types.APIVerbCreate,
  78. Method: types.HTTPVerbPost,
  79. Path: &types.Path{
  80. Parent: basePath,
  81. RelativePath: "/clusters/candidates",
  82. },
  83. Scopes: []types.PermissionScope{
  84. types.UserScope,
  85. types.ProjectScope,
  86. },
  87. CheckUsage: true,
  88. UsageMetric: types.Clusters,
  89. },
  90. )
  91. createCandidateHandler := cluster.NewCreateClusterCandidateHandler(
  92. config,
  93. factory.GetDecoderValidator(),
  94. factory.GetResultWriter(),
  95. )
  96. routes = append(routes, &router.Route{
  97. Endpoint: createCandidateEndpoint,
  98. Handler: createCandidateHandler,
  99. Router: r,
  100. })
  101. // GET /api/projects/{project_id}/clusters/candidates -> project.NewListClusterCandidatesHandler
  102. listCandidatesEndpoint := factory.NewAPIEndpoint(
  103. &types.APIRequestMetadata{
  104. Verb: types.APIVerbList,
  105. Method: types.HTTPVerbGet,
  106. Path: &types.Path{
  107. Parent: basePath,
  108. RelativePath: "/clusters/candidates",
  109. },
  110. Scopes: []types.PermissionScope{
  111. types.UserScope,
  112. types.ProjectScope,
  113. },
  114. },
  115. )
  116. listCandidatesHandler := cluster.NewListClusterCandidatesHandler(
  117. config,
  118. factory.GetResultWriter(),
  119. )
  120. routes = append(routes, &router.Route{
  121. Endpoint: listCandidatesEndpoint,
  122. Handler: listCandidatesHandler,
  123. Router: r,
  124. })
  125. // POST /api/projects/{project_id}/clusters/candidates/{candidate_id}/resolve -> project.NewResolveClusterCandidateHandler
  126. resolveCandidateEndpoint := factory.NewAPIEndpoint(
  127. &types.APIRequestMetadata{
  128. Verb: types.APIVerbCreate,
  129. Method: types.HTTPVerbPost,
  130. Path: &types.Path{
  131. Parent: basePath,
  132. RelativePath: fmt.Sprintf(
  133. "/clusters/candidates/{%s}/resolve",
  134. types.URLParamCandidateID,
  135. ),
  136. },
  137. Scopes: []types.PermissionScope{
  138. types.UserScope,
  139. types.ProjectScope,
  140. },
  141. CheckUsage: true,
  142. UsageMetric: types.Clusters,
  143. },
  144. )
  145. resolveCandidateHandler := cluster.NewResolveClusterCandidateHandler(
  146. config,
  147. factory.GetDecoderValidator(),
  148. factory.GetResultWriter(),
  149. )
  150. routes = append(routes, &router.Route{
  151. Endpoint: resolveCandidateEndpoint,
  152. Handler: resolveCandidateHandler,
  153. Router: r,
  154. })
  155. // POST /api/projects/{project_id}/clusters/{cluster_id} -> project.NewClusterUpdateHandler
  156. updateClusterEndpoint := factory.NewAPIEndpoint(
  157. &types.APIRequestMetadata{
  158. Verb: types.APIVerbUpdate,
  159. Method: types.HTTPVerbPost,
  160. Path: &types.Path{
  161. Parent: basePath,
  162. RelativePath: relPath,
  163. },
  164. Scopes: []types.PermissionScope{
  165. types.UserScope,
  166. types.ProjectScope,
  167. types.ClusterScope,
  168. },
  169. },
  170. )
  171. updateClusterHandler := cluster.NewClusterUpdateHandler(
  172. config,
  173. factory.GetDecoderValidator(),
  174. factory.GetResultWriter(),
  175. )
  176. routes = append(routes, &router.Route{
  177. Endpoint: updateClusterEndpoint,
  178. Handler: updateClusterHandler,
  179. Router: r,
  180. })
  181. // DELETE /api/projects/{project_id}/clusters/{cluster_id} -> project.NewClusterDeleteHandler
  182. deleteClusterEndpoint := factory.NewAPIEndpoint(
  183. &types.APIRequestMetadata{
  184. Verb: types.APIVerbDelete,
  185. Method: types.HTTPVerbDelete,
  186. Path: &types.Path{
  187. Parent: basePath,
  188. RelativePath: relPath,
  189. },
  190. Scopes: []types.PermissionScope{
  191. types.UserScope,
  192. types.ProjectScope,
  193. types.ClusterScope,
  194. },
  195. },
  196. )
  197. deleteClusterHandler := cluster.NewClusterDeleteHandler(
  198. config,
  199. factory.GetResultWriter(),
  200. )
  201. routes = append(routes, &router.Route{
  202. Endpoint: deleteClusterEndpoint,
  203. Handler: deleteClusterHandler,
  204. Router: r,
  205. })
  206. // GET /api/projects/{project_id}/clusters/{cluster_id} -> project.NewClusterGetHandler
  207. getEndpoint := factory.NewAPIEndpoint(
  208. &types.APIRequestMetadata{
  209. Verb: types.APIVerbGet,
  210. Method: types.HTTPVerbGet,
  211. Path: &types.Path{
  212. Parent: basePath,
  213. RelativePath: relPath,
  214. },
  215. Scopes: []types.PermissionScope{
  216. types.UserScope,
  217. types.ProjectScope,
  218. types.ClusterScope,
  219. },
  220. },
  221. )
  222. getHandler := cluster.NewClusterGetHandler(
  223. config,
  224. factory.GetResultWriter(),
  225. )
  226. routes = append(routes, &router.Route{
  227. Endpoint: getEndpoint,
  228. Handler: getHandler,
  229. Router: r,
  230. })
  231. // GET /api/projects/{project_id}/clusters/{cluster_id}/databases -> database.NewDatabaseListHandler
  232. listDatabaseEndpoint := factory.NewAPIEndpoint(
  233. &types.APIRequestMetadata{
  234. Verb: types.APIVerbList,
  235. Method: types.HTTPVerbGet,
  236. Path: &types.Path{
  237. Parent: basePath,
  238. RelativePath: relPath + "/databases",
  239. },
  240. Scopes: []types.PermissionScope{
  241. types.UserScope,
  242. types.ProjectScope,
  243. types.ClusterScope,
  244. },
  245. },
  246. )
  247. listDatabaseHandler := database.NewDatabaseListHandler(
  248. config,
  249. factory.GetResultWriter(),
  250. )
  251. routes = append(routes, &router.Route{
  252. Endpoint: listDatabaseEndpoint,
  253. Handler: listDatabaseHandler,
  254. Router: r,
  255. })
  256. if config.ServerConf.GithubIncomingWebhookSecret != "" {
  257. // GET /api/projects/{project_id}/clusters/{cluster_id}/environments -> environment.NewListEnvironmentHandler
  258. listEnvEndpoint := factory.NewAPIEndpoint(
  259. &types.APIRequestMetadata{
  260. Verb: types.APIVerbGet,
  261. Method: types.HTTPVerbGet,
  262. Path: &types.Path{
  263. Parent: basePath,
  264. RelativePath: relPath + "/environments",
  265. },
  266. Scopes: []types.PermissionScope{
  267. types.UserScope,
  268. types.ProjectScope,
  269. types.ClusterScope,
  270. },
  271. },
  272. )
  273. listEnvHandler := environment.NewListEnvironmentHandler(
  274. config,
  275. factory.GetResultWriter(),
  276. )
  277. routes = append(routes, &router.Route{
  278. Endpoint: listEnvEndpoint,
  279. Handler: listEnvHandler,
  280. Router: r,
  281. })
  282. // GET /api/projects/{project_id}/clusters/{cluster_id}/environments/{environment_id} -> environment.NewGetEnvironmentHandler
  283. getEnvEndpoint := factory.NewAPIEndpoint(
  284. &types.APIRequestMetadata{
  285. Verb: types.APIVerbGet,
  286. Method: types.HTTPVerbGet,
  287. Path: &types.Path{
  288. Parent: basePath,
  289. RelativePath: relPath + "/environments/{environment_id}",
  290. },
  291. Scopes: []types.PermissionScope{
  292. types.UserScope,
  293. types.ProjectScope,
  294. types.ClusterScope,
  295. },
  296. },
  297. )
  298. getEnvHandler := environment.NewGetEnvironmentHandler(
  299. config,
  300. factory.GetResultWriter(),
  301. )
  302. routes = append(routes, &router.Route{
  303. Endpoint: getEnvEndpoint,
  304. Handler: getEnvHandler,
  305. Router: r,
  306. })
  307. // PATCH /api/projects/{project_id}/clusters/{cluster_id}/environments/{environment_id}/toggle_new_comment -> environment.NewToggleNewCommentHandler
  308. toggleNewCommentEndpoint := factory.NewAPIEndpoint(
  309. &types.APIRequestMetadata{
  310. Verb: types.APIVerbUpdate,
  311. Method: types.HTTPVerbPatch,
  312. Path: &types.Path{
  313. Parent: basePath,
  314. RelativePath: relPath + "/environments/{environment_id}/toggle_new_comment",
  315. },
  316. Scopes: []types.PermissionScope{
  317. types.UserScope,
  318. types.ProjectScope,
  319. types.ClusterScope,
  320. },
  321. },
  322. )
  323. toggleNewCommentHandler := environment.NewToggleNewCommentHandler(
  324. config,
  325. factory.GetDecoderValidator(),
  326. factory.GetResultWriter(),
  327. )
  328. routes = append(routes, &router.Route{
  329. Endpoint: toggleNewCommentEndpoint,
  330. Handler: toggleNewCommentHandler,
  331. Router: r,
  332. })
  333. // GET /api/projects/{project_id}/clusters/{cluster_id}/environments/{environment_id}/validate_porter_yaml -> environment.NewValidatePorterYAMLHandler
  334. validtatePorterYAMLEndpoint := factory.NewAPIEndpoint(
  335. &types.APIRequestMetadata{
  336. Verb: types.APIVerbGet,
  337. Method: types.HTTPVerbGet,
  338. Path: &types.Path{
  339. Parent: basePath,
  340. RelativePath: relPath + "/environments/{environment_id}/validate_porter_yaml",
  341. },
  342. Scopes: []types.PermissionScope{
  343. types.UserScope,
  344. types.ProjectScope,
  345. types.ClusterScope,
  346. },
  347. },
  348. )
  349. validatePorterYAMLHandler := environment.NewValidatePorterYAMLHandler(
  350. config,
  351. factory.GetDecoderValidator(),
  352. factory.GetResultWriter(),
  353. )
  354. routes = append(routes, &router.Route{
  355. Endpoint: validtatePorterYAMLEndpoint,
  356. Handler: validatePorterYAMLHandler,
  357. Router: r,
  358. })
  359. // GET /api/projects/{project_id}/clusters/{cluster_id}/deployments -> environment.NewListDeploymentsByClusterHandler
  360. listDeploymentsEndpoint := factory.NewAPIEndpoint(
  361. &types.APIRequestMetadata{
  362. Verb: types.APIVerbGet,
  363. Method: types.HTTPVerbGet,
  364. Path: &types.Path{
  365. Parent: basePath,
  366. RelativePath: relPath + "/deployments",
  367. },
  368. Scopes: []types.PermissionScope{
  369. types.UserScope,
  370. types.ProjectScope,
  371. types.ClusterScope,
  372. },
  373. },
  374. )
  375. listDeploymentsHandler := environment.NewListDeploymentsByClusterHandler(
  376. config,
  377. factory.GetDecoderValidator(),
  378. factory.GetResultWriter(),
  379. )
  380. routes = append(routes, &router.Route{
  381. Endpoint: listDeploymentsEndpoint,
  382. Handler: listDeploymentsHandler,
  383. Router: r,
  384. })
  385. // GET /api/projects/{project_id}/clusters/{cluster_id}/environments/{environment_id}/deployment -> environment.NewGetDeploymentByClusterHandler
  386. getDeploymentEndpoint := factory.NewAPIEndpoint(
  387. &types.APIRequestMetadata{
  388. Verb: types.APIVerbGet,
  389. Method: types.HTTPVerbGet,
  390. Path: &types.Path{
  391. Parent: basePath,
  392. RelativePath: relPath + "/environments/{environment_id}/deployment",
  393. },
  394. Scopes: []types.PermissionScope{
  395. types.UserScope,
  396. types.ProjectScope,
  397. types.ClusterScope,
  398. },
  399. },
  400. )
  401. getDeploymentHandler := environment.NewGetDeploymentByEnvironmentHandler(
  402. config,
  403. factory.GetDecoderValidator(),
  404. factory.GetResultWriter(),
  405. )
  406. routes = append(routes, &router.Route{
  407. Endpoint: getDeploymentEndpoint,
  408. Handler: getDeploymentHandler,
  409. Router: r,
  410. })
  411. // PATCH /api/projects/{project_id}/clusters/{cluster_id}/deployments/{deployment_id}/reenable -> environment.NewReenableDeploymentHandler
  412. reenableDeploymentEndpoint := factory.NewAPIEndpoint(
  413. &types.APIRequestMetadata{
  414. Verb: types.APIVerbUpdate,
  415. Method: types.HTTPVerbPatch,
  416. Path: &types.Path{
  417. Parent: basePath,
  418. RelativePath: relPath + "/deployments/{deployment_id}/reenable",
  419. },
  420. Scopes: []types.PermissionScope{
  421. types.UserScope,
  422. types.ProjectScope,
  423. types.ClusterScope,
  424. },
  425. },
  426. )
  427. reenableDeploymentHandler := environment.NewReenableDeploymentHandler(
  428. config,
  429. factory.GetDecoderValidator(),
  430. factory.GetResultWriter(),
  431. )
  432. routes = append(routes, &router.Route{
  433. Endpoint: reenableDeploymentEndpoint,
  434. Handler: reenableDeploymentHandler,
  435. Router: r,
  436. })
  437. // POST /api/projects/{project_id}/clusters/{cluster_id}/deployments/{deployment_id}/trigger_workflow -> environment.NewTriggerDeploymentWorkflowHandler
  438. triggerDeploymentWorkflowEndpoint := factory.NewAPIEndpoint(
  439. &types.APIRequestMetadata{
  440. Verb: types.APIVerbCreate,
  441. Method: types.HTTPVerbPost,
  442. Path: &types.Path{
  443. Parent: basePath,
  444. RelativePath: relPath + "/deployments/{deployment_id}/trigger_workflow",
  445. },
  446. Scopes: []types.PermissionScope{
  447. types.UserScope,
  448. types.ProjectScope,
  449. types.ClusterScope,
  450. },
  451. },
  452. )
  453. triggerDeploymentWorkflowHandler := environment.NewTriggerDeploymentWorkflowHandler(
  454. config,
  455. factory.GetDecoderValidator(),
  456. factory.GetResultWriter(),
  457. )
  458. routes = append(routes, &router.Route{
  459. Endpoint: triggerDeploymentWorkflowEndpoint,
  460. Handler: triggerDeploymentWorkflowHandler,
  461. Router: r,
  462. })
  463. // POST /api/projects/{project_id}/clusters/{cluster_id}/deployments/pull_request -> environment.NewEnablePullRequestHandler
  464. enablePullRequestEndpoint := factory.NewAPIEndpoint(
  465. &types.APIRequestMetadata{
  466. Verb: types.APIVerbCreate,
  467. Method: types.HTTPVerbPost,
  468. Path: &types.Path{
  469. Parent: basePath,
  470. RelativePath: relPath + "/deployments/pull_request",
  471. },
  472. Scopes: []types.PermissionScope{
  473. types.UserScope,
  474. types.ProjectScope,
  475. types.ClusterScope,
  476. },
  477. },
  478. )
  479. enablePullRequestHandler := environment.NewEnablePullRequestHandler(
  480. config,
  481. factory.GetDecoderValidator(),
  482. factory.GetResultWriter(),
  483. )
  484. routes = append(routes, &router.Route{
  485. Endpoint: enablePullRequestEndpoint,
  486. Handler: enablePullRequestHandler,
  487. Router: r,
  488. })
  489. // DELETE /api/projects/{project_id}/clusters/{cluster_id}/deployments/{deployment_id} ->
  490. // environment.NewDeleteDeploymentHandler
  491. deleteDeploymentEndpoint := factory.NewAPIEndpoint(
  492. &types.APIRequestMetadata{
  493. Verb: types.APIVerbDelete,
  494. Method: types.HTTPVerbDelete,
  495. Path: &types.Path{
  496. Parent: basePath,
  497. RelativePath: relPath + "/deployments/{deployment_id}",
  498. },
  499. Scopes: []types.PermissionScope{
  500. types.UserScope,
  501. types.ProjectScope,
  502. types.ClusterScope,
  503. },
  504. },
  505. )
  506. deleteDeploymentHandler := environment.NewDeleteDeploymentHandler(
  507. config,
  508. factory.GetDecoderValidator(),
  509. factory.GetResultWriter(),
  510. )
  511. routes = append(routes, &router.Route{
  512. Endpoint: deleteDeploymentEndpoint,
  513. Handler: deleteDeploymentHandler,
  514. Router: r,
  515. })
  516. // PATCH /api/projects/{project_id}/clusters/{cluster_id}/environments/{environment_id}/settings ->
  517. // environment.NewUpdateEnvironmentSettingsHandler
  518. updateEnvironmentSettingsEndpoint := factory.NewAPIEndpoint(
  519. &types.APIRequestMetadata{
  520. Verb: types.APIVerbUpdate,
  521. Method: types.HTTPVerbPatch,
  522. Path: &types.Path{
  523. Parent: basePath,
  524. RelativePath: relPath + "/environments/{environment_id}/settings",
  525. },
  526. Scopes: []types.PermissionScope{
  527. types.UserScope,
  528. types.ProjectScope,
  529. types.ClusterScope,
  530. },
  531. },
  532. )
  533. updateEnvironmentSettingsHandler := environment.NewUpdateEnvironmentSettingsHandler(
  534. config,
  535. factory.GetDecoderValidator(),
  536. factory.GetResultWriter(),
  537. )
  538. routes = append(routes, &router.Route{
  539. Endpoint: updateEnvironmentSettingsEndpoint,
  540. Handler: updateEnvironmentSettingsHandler,
  541. Router: r,
  542. })
  543. }
  544. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces -> cluster.NewClusterListNamespacesHandler
  545. listNamespacesEndpoint := factory.NewAPIEndpoint(
  546. &types.APIRequestMetadata{
  547. Verb: types.APIVerbGet,
  548. Method: types.HTTPVerbGet,
  549. Path: &types.Path{
  550. Parent: basePath,
  551. RelativePath: relPath + "/namespaces",
  552. },
  553. Scopes: []types.PermissionScope{
  554. types.UserScope,
  555. types.ProjectScope,
  556. types.ClusterScope,
  557. },
  558. },
  559. )
  560. listNamespacesHandler := cluster.NewListNamespacesHandler(
  561. config,
  562. factory.GetResultWriter(),
  563. )
  564. routes = append(routes, &router.Route{
  565. Endpoint: listNamespacesEndpoint,
  566. Handler: listNamespacesHandler,
  567. Router: r,
  568. })
  569. // GET /api/projects/{project_id}/clusters/{cluster_id}/nodes -> cluster.NewListNodesHandler
  570. listNodesEndpoint := factory.NewAPIEndpoint(
  571. &types.APIRequestMetadata{
  572. Verb: types.APIVerbGet,
  573. Method: types.HTTPVerbGet,
  574. Path: &types.Path{
  575. Parent: basePath,
  576. RelativePath: relPath + "/nodes",
  577. },
  578. Scopes: []types.PermissionScope{
  579. types.UserScope,
  580. types.ProjectScope,
  581. types.ClusterScope,
  582. },
  583. },
  584. )
  585. listNodesHandler := cluster.NewListNodesHandler(
  586. config,
  587. factory.GetResultWriter(),
  588. )
  589. routes = append(routes, &router.Route{
  590. Endpoint: listNodesEndpoint,
  591. Handler: listNodesHandler,
  592. Router: r,
  593. })
  594. // GET /api/projects/{project_id}/clusters/{cluster_id}/nodes/{node_name} -> cluster.NewGetNodeHandler
  595. getNodeEndpoint := factory.NewAPIEndpoint(
  596. &types.APIRequestMetadata{
  597. Verb: types.APIVerbGet,
  598. Method: types.HTTPVerbGet,
  599. Path: &types.Path{
  600. Parent: basePath,
  601. RelativePath: fmt.Sprintf("%s/nodes/{%s}", relPath, types.URLParamNodeName),
  602. },
  603. Scopes: []types.PermissionScope{
  604. types.UserScope,
  605. types.ProjectScope,
  606. types.ClusterScope,
  607. },
  608. },
  609. )
  610. getNodeHandler := cluster.NewGetNodeHandler(
  611. config,
  612. factory.GetResultWriter(),
  613. )
  614. routes = append(routes, &router.Route{
  615. Endpoint: getNodeEndpoint,
  616. Handler: getNodeHandler,
  617. Router: r,
  618. })
  619. // POST /api/projects/{project_id}/clusters/{cluster_id}/namespaces/create -> cluster.NewCreateNamespaceHandler
  620. createNamespaceEndpoint := factory.NewAPIEndpoint(
  621. &types.APIRequestMetadata{
  622. Verb: types.APIVerbCreate,
  623. Method: types.HTTPVerbPost,
  624. Path: &types.Path{
  625. Parent: basePath,
  626. RelativePath: relPath + "/namespaces/create",
  627. },
  628. Scopes: []types.PermissionScope{
  629. types.UserScope,
  630. types.ProjectScope,
  631. types.ClusterScope,
  632. },
  633. },
  634. )
  635. createNamespaceHandler := cluster.NewCreateNamespaceHandler(
  636. config,
  637. factory.GetDecoderValidator(),
  638. factory.GetResultWriter(),
  639. )
  640. routes = append(routes, &router.Route{
  641. Endpoint: createNamespaceEndpoint,
  642. Handler: createNamespaceHandler,
  643. Router: r,
  644. })
  645. // DELETE /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace} -> cluster.NewDeleteNamespaceHandler
  646. deleteNamespaceEndpoint := factory.NewAPIEndpoint(
  647. &types.APIRequestMetadata{
  648. Verb: types.APIVerbDelete,
  649. Method: types.HTTPVerbDelete,
  650. Path: &types.Path{
  651. Parent: basePath,
  652. RelativePath: fmt.Sprintf("%s/namespaces/{%s}", relPath, types.URLParamNamespace),
  653. },
  654. Scopes: []types.PermissionScope{
  655. types.UserScope,
  656. types.ProjectScope,
  657. types.ClusterScope,
  658. },
  659. },
  660. )
  661. deleteNamespaceHandler := cluster.NewDeleteNamespaceHandler(
  662. config,
  663. factory.GetDecoderValidator(),
  664. )
  665. routes = append(routes, &router.Route{
  666. Endpoint: deleteNamespaceEndpoint,
  667. Handler: deleteNamespaceHandler,
  668. Router: r,
  669. })
  670. // GET /api/projects/{project_id}/clusters/{cluster_id}/kubeconfig -> cluster.NewGetTemporaryKubeconfigHandler
  671. getTemporaryKubeconfigEndpoint := factory.NewAPIEndpoint(
  672. &types.APIRequestMetadata{
  673. Verb: types.APIVerbUpdate, // we do not want users with no-write access to be able to use this
  674. Method: types.HTTPVerbGet,
  675. Path: &types.Path{
  676. Parent: basePath,
  677. RelativePath: relPath + "/kubeconfig",
  678. },
  679. Scopes: []types.PermissionScope{
  680. types.UserScope,
  681. types.ProjectScope,
  682. types.ClusterScope,
  683. },
  684. },
  685. )
  686. getTemporaryKubeconfigHandler := cluster.NewGetTemporaryKubeconfigHandler(
  687. config,
  688. factory.GetResultWriter(),
  689. )
  690. routes = append(routes, &router.Route{
  691. Endpoint: getTemporaryKubeconfigEndpoint,
  692. Handler: getTemporaryKubeconfigHandler,
  693. Router: r,
  694. })
  695. // GET /api/projects/{project_id}/clusters/{cluster_id}/prometheus/detect -> cluster.NewDetectPrometheusInstalledHandler
  696. detectPrometheusInstalledEndpoint := factory.NewAPIEndpoint(
  697. &types.APIRequestMetadata{
  698. Verb: types.APIVerbGet,
  699. Method: types.HTTPVerbGet,
  700. Path: &types.Path{
  701. Parent: basePath,
  702. RelativePath: relPath + "/prometheus/detect",
  703. },
  704. Scopes: []types.PermissionScope{
  705. types.UserScope,
  706. types.ProjectScope,
  707. types.ClusterScope,
  708. },
  709. },
  710. )
  711. detectPrometheusInstalledHandler := cluster.NewDetectPrometheusInstalledHandler(config)
  712. routes = append(routes, &router.Route{
  713. Endpoint: detectPrometheusInstalledEndpoint,
  714. Handler: detectPrometheusInstalledHandler,
  715. Router: r,
  716. })
  717. // GET /api/projects/{project_id}/clusters/{cluster_id}/agent/detect -> cluster.NewDetectAgentInstalledHandler
  718. detectAgentInstalledEndpoint := factory.NewAPIEndpoint(
  719. &types.APIRequestMetadata{
  720. Verb: types.APIVerbGet,
  721. Method: types.HTTPVerbGet,
  722. Path: &types.Path{
  723. Parent: basePath,
  724. RelativePath: relPath + "/agent/detect",
  725. },
  726. Scopes: []types.PermissionScope{
  727. types.UserScope,
  728. types.ProjectScope,
  729. types.ClusterScope,
  730. },
  731. },
  732. )
  733. detectAgentInstalledHandler := cluster.NewDetectAgentInstalledHandler(config, factory.GetResultWriter())
  734. routes = append(routes, &router.Route{
  735. Endpoint: detectAgentInstalledEndpoint,
  736. Handler: detectAgentInstalledHandler,
  737. Router: r,
  738. })
  739. // POST /api/projects/{project_id}/clusters/{cluster_id}/agent/install -> cluster.NewInstallAgentHandler
  740. installAgentEndpoint := factory.NewAPIEndpoint(
  741. &types.APIRequestMetadata{
  742. Verb: types.APIVerbCreate,
  743. Method: types.HTTPVerbPost,
  744. Path: &types.Path{
  745. Parent: basePath,
  746. RelativePath: relPath + "/agent/install",
  747. },
  748. Scopes: []types.PermissionScope{
  749. types.UserScope,
  750. types.ProjectScope,
  751. types.ClusterScope,
  752. },
  753. },
  754. )
  755. installAgentHandler := cluster.NewInstallAgentHandler(
  756. config,
  757. factory.GetDecoderValidator(),
  758. factory.GetResultWriter(),
  759. )
  760. routes = append(routes, &router.Route{
  761. Endpoint: installAgentEndpoint,
  762. Handler: installAgentHandler,
  763. Router: r,
  764. })
  765. // GET /api/projects/{project_id}/clusters/{cluster_id}/agent/status -> cluster.NewGetAgentStatusHandler
  766. getAgentStatusEndpoint := factory.NewAPIEndpoint(
  767. &types.APIRequestMetadata{
  768. Verb: types.APIVerbGet,
  769. Method: types.HTTPVerbGet,
  770. Path: &types.Path{
  771. Parent: basePath,
  772. RelativePath: relPath + "/agent/status",
  773. },
  774. Scopes: []types.PermissionScope{
  775. types.UserScope,
  776. types.ProjectScope,
  777. types.ClusterScope,
  778. },
  779. },
  780. )
  781. getAgentStatusHandler := cluster.NewGetAgentStatusHandler(config, factory.GetResultWriter())
  782. routes = append(routes, &router.Route{
  783. Endpoint: getAgentStatusEndpoint,
  784. Handler: getAgentStatusHandler,
  785. Router: r,
  786. })
  787. // POST /api/projects/{project_id}/clusters/{cluster_id}/agent/upgrade -> cluster.NewInstallAgentHandler
  788. upgradeAgentEndpoint := factory.NewAPIEndpoint(
  789. &types.APIRequestMetadata{
  790. Verb: types.APIVerbCreate,
  791. Method: types.HTTPVerbPost,
  792. Path: &types.Path{
  793. Parent: basePath,
  794. RelativePath: relPath + "/agent/upgrade",
  795. },
  796. Scopes: []types.PermissionScope{
  797. types.UserScope,
  798. types.ProjectScope,
  799. types.ClusterScope,
  800. },
  801. },
  802. )
  803. upgradeAgentHandler := cluster.NewUpgradeAgentHandler(
  804. config,
  805. factory.GetDecoderValidator(),
  806. factory.GetResultWriter(),
  807. )
  808. routes = append(routes, &router.Route{
  809. Endpoint: upgradeAgentEndpoint,
  810. Handler: upgradeAgentHandler,
  811. Router: r,
  812. })
  813. // GET /api/projects/{project_id}/clusters/{cluster_id}/prometheus/ingresses -> cluster.NewListNGINXIngressesHandler
  814. listNGINXIngressesEndpoint := factory.NewAPIEndpoint(
  815. &types.APIRequestMetadata{
  816. Verb: types.APIVerbGet,
  817. Method: types.HTTPVerbGet,
  818. Path: &types.Path{
  819. Parent: basePath,
  820. RelativePath: relPath + "/prometheus/ingresses",
  821. },
  822. Scopes: []types.PermissionScope{
  823. types.UserScope,
  824. types.ProjectScope,
  825. types.ClusterScope,
  826. },
  827. },
  828. )
  829. listNGINXIngressesHandler := cluster.NewListNGINXIngressesHandler(
  830. config,
  831. factory.GetResultWriter(),
  832. )
  833. routes = append(routes, &router.Route{
  834. Endpoint: listNGINXIngressesEndpoint,
  835. Handler: listNGINXIngressesHandler,
  836. Router: r,
  837. })
  838. // GET /api/projects/{project_id}/clusters/{cluster_id}/metrics -> cluster.NewGetPodMetricsHandler
  839. getPodMetricsEndpoint := factory.NewAPIEndpoint(
  840. &types.APIRequestMetadata{
  841. Verb: types.APIVerbGet,
  842. Method: types.HTTPVerbGet,
  843. Path: &types.Path{
  844. Parent: basePath,
  845. RelativePath: relPath + "/metrics",
  846. },
  847. Scopes: []types.PermissionScope{
  848. types.UserScope,
  849. types.ProjectScope,
  850. types.ClusterScope,
  851. },
  852. },
  853. )
  854. getPodMetricsHandler := cluster.NewGetPodMetricsHandler(
  855. config,
  856. factory.GetDecoderValidator(),
  857. factory.GetResultWriter(),
  858. )
  859. routes = append(routes, &router.Route{
  860. Endpoint: getPodMetricsEndpoint,
  861. Handler: getPodMetricsHandler,
  862. Router: r,
  863. })
  864. // GET /api/projects/{project_id}/clusters/{cluster_id}/helm_release -> cluster.NewStreamHelmReleaseHandler
  865. streamHelmReleaseEndpoint := factory.NewAPIEndpoint(
  866. &types.APIRequestMetadata{
  867. Verb: types.APIVerbGet,
  868. Method: types.HTTPVerbGet,
  869. Path: &types.Path{
  870. Parent: basePath,
  871. RelativePath: relPath + "/helm_release",
  872. },
  873. Scopes: []types.PermissionScope{
  874. types.UserScope,
  875. types.ProjectScope,
  876. types.ClusterScope,
  877. },
  878. IsWebsocket: true,
  879. },
  880. )
  881. streamHelmReleaseHandler := cluster.NewStreamHelmReleaseHandler(
  882. config,
  883. factory.GetDecoderValidator(),
  884. factory.GetResultWriter(),
  885. )
  886. routes = append(routes, &router.Route{
  887. Endpoint: streamHelmReleaseEndpoint,
  888. Handler: streamHelmReleaseHandler,
  889. Router: r,
  890. })
  891. // GET /api/projects/{project_id}/clusters/{cluster_id}/{kind}/status -> cluster.NewStreamStatusHandler
  892. streamStatusEndpoint := factory.NewAPIEndpoint(
  893. &types.APIRequestMetadata{
  894. Verb: types.APIVerbGet,
  895. Method: types.HTTPVerbGet,
  896. Path: &types.Path{
  897. Parent: basePath,
  898. RelativePath: fmt.Sprintf(
  899. "%s/{%s}/status",
  900. relPath,
  901. types.URLParamKind,
  902. ),
  903. },
  904. Scopes: []types.PermissionScope{
  905. types.UserScope,
  906. types.ProjectScope,
  907. types.ClusterScope,
  908. },
  909. IsWebsocket: true,
  910. },
  911. )
  912. streamStatusHandler := cluster.NewStreamStatusHandler(
  913. config,
  914. factory.GetDecoderValidator(),
  915. factory.GetResultWriter(),
  916. )
  917. routes = append(routes, &router.Route{
  918. Endpoint: streamStatusEndpoint,
  919. Handler: streamStatusHandler,
  920. Router: r,
  921. })
  922. // GET /api/projects/{project_id}/clusters/{cluster_id}/pods -> cluster.NewGetPodsHandler
  923. getPodsEndpoint := factory.NewAPIEndpoint(
  924. &types.APIRequestMetadata{
  925. Verb: types.APIVerbGet,
  926. Method: types.HTTPVerbGet,
  927. Path: &types.Path{
  928. Parent: basePath,
  929. RelativePath: relPath + "/pods",
  930. },
  931. Scopes: []types.PermissionScope{
  932. types.UserScope,
  933. types.ProjectScope,
  934. types.ClusterScope,
  935. },
  936. },
  937. )
  938. getPodsHandler := cluster.NewGetPodsHandler(
  939. config,
  940. factory.GetDecoderValidator(),
  941. factory.GetResultWriter(),
  942. )
  943. routes = append(routes, &router.Route{
  944. Endpoint: getPodsEndpoint,
  945. Handler: getPodsHandler,
  946. Router: r,
  947. })
  948. // GET /api/projects/{project_id}/clusters/{cluster_id}/incidents -> cluster.NewListIncidentsHandler
  949. listIncidentsEndpoint := factory.NewAPIEndpoint(
  950. &types.APIRequestMetadata{
  951. Verb: types.APIVerbGet,
  952. Method: types.HTTPVerbGet,
  953. Path: &types.Path{
  954. Parent: basePath,
  955. RelativePath: relPath + "/incidents",
  956. },
  957. Scopes: []types.PermissionScope{
  958. types.UserScope,
  959. types.ProjectScope,
  960. types.ClusterScope,
  961. },
  962. },
  963. )
  964. listIncidentsHandler := cluster.NewListIncidentsHandler(
  965. config,
  966. factory.GetDecoderValidator(),
  967. factory.GetResultWriter(),
  968. )
  969. routes = append(routes, &router.Route{
  970. Endpoint: listIncidentsEndpoint,
  971. Handler: listIncidentsHandler,
  972. Router: r,
  973. })
  974. // GET /api/projects/{project_id}/clusters/{cluster_id}/incidents/{incident_id} -> cluster.NewGetIncidentHandler
  975. getIncidentEndpoint := factory.NewAPIEndpoint(
  976. &types.APIRequestMetadata{
  977. Verb: types.APIVerbGet,
  978. Method: types.HTTPVerbGet,
  979. Path: &types.Path{
  980. Parent: basePath,
  981. RelativePath: fmt.Sprintf("%s/incidents/{%s}", relPath, types.URLParamIncidentID),
  982. },
  983. Scopes: []types.PermissionScope{
  984. types.UserScope,
  985. types.ProjectScope,
  986. types.ClusterScope,
  987. },
  988. },
  989. )
  990. getIncidentHandler := cluster.NewGetIncidentHandler(
  991. config,
  992. factory.GetDecoderValidator(),
  993. factory.GetResultWriter(),
  994. )
  995. routes = append(routes, &router.Route{
  996. Endpoint: getIncidentEndpoint,
  997. Handler: getIncidentHandler,
  998. Router: r,
  999. })
  1000. // GET /api/projects/{project_id}/clusters/{cluster_id}/incidents/{incident_id}/events -> cluster.NewListIncidentEventsHandler
  1001. listIncidentEventsEndpoint := factory.NewAPIEndpoint(
  1002. &types.APIRequestMetadata{
  1003. Verb: types.APIVerbGet,
  1004. Method: types.HTTPVerbGet,
  1005. Path: &types.Path{
  1006. Parent: basePath,
  1007. RelativePath: fmt.Sprintf("%s/incidents/{%s}/events", relPath, types.URLParamIncidentID),
  1008. },
  1009. Scopes: []types.PermissionScope{
  1010. types.UserScope,
  1011. types.ProjectScope,
  1012. types.ClusterScope,
  1013. },
  1014. },
  1015. )
  1016. listIncidentEventsHandler := cluster.NewListIncidentEventsHandler(
  1017. config,
  1018. factory.GetDecoderValidator(),
  1019. factory.GetResultWriter(),
  1020. )
  1021. routes = append(routes, &router.Route{
  1022. Endpoint: listIncidentEventsEndpoint,
  1023. Handler: listIncidentEventsHandler,
  1024. Router: r,
  1025. })
  1026. // GET /api/projects/{project_id}/clusters/{cluster_id}/logs -> cluster.NewGetLogsHandler
  1027. getLogsEndpoint := factory.NewAPIEndpoint(
  1028. &types.APIRequestMetadata{
  1029. Verb: types.APIVerbGet,
  1030. Method: types.HTTPVerbGet,
  1031. Path: &types.Path{
  1032. Parent: basePath,
  1033. RelativePath: fmt.Sprintf("%s/logs", relPath),
  1034. },
  1035. Scopes: []types.PermissionScope{
  1036. types.UserScope,
  1037. types.ProjectScope,
  1038. types.ClusterScope,
  1039. },
  1040. },
  1041. )
  1042. getLogsHandler := cluster.NewGetLogsHandler(
  1043. config,
  1044. factory.GetDecoderValidator(),
  1045. factory.GetResultWriter(),
  1046. )
  1047. routes = append(routes, &router.Route{
  1048. Endpoint: getLogsEndpoint,
  1049. Handler: getLogsHandler,
  1050. Router: r,
  1051. })
  1052. // GET /api/projects/{project_id}/clusters/{cluster_id}/logs/pod_values -> cluster.NewGetLogPodValuesHandler
  1053. getLogPodValuesEndpoint := factory.NewAPIEndpoint(
  1054. &types.APIRequestMetadata{
  1055. Verb: types.APIVerbGet,
  1056. Method: types.HTTPVerbGet,
  1057. Path: &types.Path{
  1058. Parent: basePath,
  1059. RelativePath: fmt.Sprintf("%s/logs/pod_values", relPath),
  1060. },
  1061. Scopes: []types.PermissionScope{
  1062. types.UserScope,
  1063. types.ProjectScope,
  1064. types.ClusterScope,
  1065. },
  1066. },
  1067. )
  1068. getLogPodValuesHandler := cluster.NewGetLogPodValuesHandler(
  1069. config,
  1070. factory.GetDecoderValidator(),
  1071. factory.GetResultWriter(),
  1072. )
  1073. routes = append(routes, &router.Route{
  1074. Endpoint: getLogPodValuesEndpoint,
  1075. Handler: getLogPodValuesHandler,
  1076. Router: r,
  1077. })
  1078. // GET /api/projects/{project_id}/clusters/{cluster_id}/logs/revision_values -> cluster.NewGetLogPodValuesHandler
  1079. getLogRevisionValuesEndpoint := factory.NewAPIEndpoint(
  1080. &types.APIRequestMetadata{
  1081. Verb: types.APIVerbGet,
  1082. Method: types.HTTPVerbGet,
  1083. Path: &types.Path{
  1084. Parent: basePath,
  1085. RelativePath: fmt.Sprintf("%s/logs/revision_values", relPath),
  1086. },
  1087. Scopes: []types.PermissionScope{
  1088. types.UserScope,
  1089. types.ProjectScope,
  1090. types.ClusterScope,
  1091. },
  1092. },
  1093. )
  1094. getLogRevisionValuesHandler := cluster.NewGetLogRevisionValuesHandler(
  1095. config,
  1096. factory.GetDecoderValidator(),
  1097. factory.GetResultWriter(),
  1098. )
  1099. routes = append(routes, &router.Route{
  1100. Endpoint: getLogRevisionValuesEndpoint,
  1101. Handler: getLogRevisionValuesHandler,
  1102. Router: r,
  1103. })
  1104. // GET /api/projects/{project_id}/clusters/{cluster_id}/events -> cluster.NewGetEventsHandler
  1105. getEventsEndpoint := factory.NewAPIEndpoint(
  1106. &types.APIRequestMetadata{
  1107. Verb: types.APIVerbGet,
  1108. Method: types.HTTPVerbGet,
  1109. Path: &types.Path{
  1110. Parent: basePath,
  1111. RelativePath: fmt.Sprintf("%s/events", relPath),
  1112. },
  1113. Scopes: []types.PermissionScope{
  1114. types.UserScope,
  1115. types.ProjectScope,
  1116. types.ClusterScope,
  1117. },
  1118. },
  1119. )
  1120. getEventsHandler := cluster.NewGetEventsHandler(
  1121. config,
  1122. factory.GetDecoderValidator(),
  1123. factory.GetResultWriter(),
  1124. )
  1125. routes = append(routes, &router.Route{
  1126. Endpoint: getEventsEndpoint,
  1127. Handler: getEventsHandler,
  1128. Router: r,
  1129. })
  1130. // POST /api/projects/{project_id}/clusters/{cluster_id}/incidents/notify_new -> cluster.NewNotifyNewIncidentHandler
  1131. notifyNewIncidentEndpoint := factory.NewAPIEndpoint(
  1132. &types.APIRequestMetadata{
  1133. Verb: types.APIVerbCreate,
  1134. Method: types.HTTPVerbPost,
  1135. Path: &types.Path{
  1136. Parent: basePath,
  1137. RelativePath: relPath + "/incidents/notify_new",
  1138. },
  1139. Scopes: []types.PermissionScope{
  1140. types.UserScope,
  1141. types.ProjectScope,
  1142. types.ClusterScope,
  1143. },
  1144. },
  1145. )
  1146. notifyNewIncidentHandler := cluster.NewNotifyNewIncidentHandler(
  1147. config,
  1148. factory.GetDecoderValidator(),
  1149. factory.GetResultWriter(),
  1150. )
  1151. routes = append(routes, &router.Route{
  1152. Endpoint: notifyNewIncidentEndpoint,
  1153. Handler: notifyNewIncidentHandler,
  1154. Router: r,
  1155. })
  1156. // POST /api/projects/{project_id}/clusters/{cluster_id}/incidents/notify_resolved -> cluster.NewNotifyResolvedIncidentHandler
  1157. notifyResolvedIncidentEndpoint := factory.NewAPIEndpoint(
  1158. &types.APIRequestMetadata{
  1159. Verb: types.APIVerbCreate,
  1160. Method: types.HTTPVerbPost,
  1161. Path: &types.Path{
  1162. Parent: basePath,
  1163. RelativePath: relPath + "/incidents/notify_resolved",
  1164. },
  1165. Scopes: []types.PermissionScope{
  1166. types.UserScope,
  1167. types.ProjectScope,
  1168. types.ClusterScope,
  1169. },
  1170. },
  1171. )
  1172. notifyResolvedIncidentHandler := cluster.NewNotifyResolvedIncidentHandler(
  1173. config,
  1174. factory.GetDecoderValidator(),
  1175. factory.GetResultWriter(),
  1176. )
  1177. routes = append(routes, &router.Route{
  1178. Endpoint: notifyResolvedIncidentEndpoint,
  1179. Handler: notifyResolvedIncidentHandler,
  1180. Router: r,
  1181. })
  1182. return routes, newPath
  1183. }