namespace.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. package router
  2. import (
  3. "fmt"
  4. "github.com/go-chi/chi"
  5. "github.com/porter-dev/porter/api/server/handlers/job"
  6. "github.com/porter-dev/porter/api/server/handlers/namespace"
  7. "github.com/porter-dev/porter/api/server/handlers/provision"
  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/types"
  11. )
  12. func NewNamespaceScopedRegisterer(children ...*Registerer) *Registerer {
  13. return &Registerer{
  14. GetRoutes: GetNamespaceScopedRoutes,
  15. Children: children,
  16. }
  17. }
  18. func GetNamespaceScopedRoutes(
  19. r chi.Router,
  20. config *config.Config,
  21. basePath *types.Path,
  22. factory shared.APIEndpointFactory,
  23. children ...*Registerer,
  24. ) []*Route {
  25. routes, projPath := getNamespaceRoutes(r, config, basePath, factory)
  26. if len(children) > 0 {
  27. r.Route(projPath.RelativePath, func(r chi.Router) {
  28. for _, child := range children {
  29. childRoutes := child.GetRoutes(r, config, basePath, factory, child.Children...)
  30. routes = append(routes, childRoutes...)
  31. }
  32. })
  33. }
  34. return routes
  35. }
  36. func getNamespaceRoutes(
  37. r chi.Router,
  38. config *config.Config,
  39. basePath *types.Path,
  40. factory shared.APIEndpointFactory,
  41. ) ([]*Route, *types.Path) {
  42. relPath := "/namespaces/{namespace}"
  43. newPath := &types.Path{
  44. Parent: basePath,
  45. RelativePath: relPath,
  46. }
  47. routes := make([]*Route, 0)
  48. // POST /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/provision/rds/ -> provision.NewProvisionRDSHandler
  49. provisionRDSEndpoint := factory.NewAPIEndpoint(
  50. &types.APIRequestMetadata{
  51. Verb: types.APIVerbCreate,
  52. Method: types.HTTPVerbPost,
  53. Path: &types.Path{
  54. Parent: basePath,
  55. RelativePath: relPath + "/provision/rds",
  56. },
  57. Scopes: []types.PermissionScope{
  58. types.UserScope,
  59. types.ProjectScope,
  60. types.ClusterScope,
  61. types.NamespaceScope,
  62. },
  63. },
  64. )
  65. provisionRDSHandler := provision.NewProvisionRDSHandler(
  66. config,
  67. factory.GetDecoderValidator(),
  68. factory.GetResultWriter(),
  69. )
  70. routes = append(routes, &Route{
  71. Endpoint: provisionRDSEndpoint,
  72. Handler: provisionRDSHandler,
  73. Router: r,
  74. })
  75. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/envgroup/list -> namespace.NewListEnvGroupsHandler
  76. listEnvGroupsEndpoint := factory.NewAPIEndpoint(
  77. &types.APIRequestMetadata{
  78. Verb: types.APIVerbGet,
  79. Method: types.HTTPVerbGet,
  80. Path: &types.Path{
  81. Parent: basePath,
  82. RelativePath: relPath + "/envgroup/list",
  83. },
  84. Scopes: []types.PermissionScope{
  85. types.UserScope,
  86. types.ProjectScope,
  87. types.ClusterScope,
  88. types.NamespaceScope,
  89. },
  90. },
  91. )
  92. listEnvGroupsHandler := namespace.NewListEnvGroupsHandler(
  93. config,
  94. factory.GetResultWriter(),
  95. )
  96. routes = append(routes, &Route{
  97. Endpoint: listEnvGroupsEndpoint,
  98. Handler: listEnvGroupsHandler,
  99. Router: r,
  100. })
  101. // POST /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/envgroup/clone -> namespace.NewCloneEnvGroupHandler
  102. cloneEnvGroupEndpoint := factory.NewAPIEndpoint(
  103. &types.APIRequestMetadata{
  104. Verb: types.APIVerbCreate,
  105. Method: types.HTTPVerbPost,
  106. Path: &types.Path{
  107. Parent: basePath,
  108. RelativePath: relPath + "/envgroup/clone",
  109. },
  110. Scopes: []types.PermissionScope{
  111. types.UserScope,
  112. types.ProjectScope,
  113. types.ClusterScope,
  114. types.NamespaceScope,
  115. },
  116. },
  117. )
  118. cloneEnvGroupHandler := namespace.NewCloneEnvGroupHandler(
  119. config,
  120. factory.GetDecoderValidator(),
  121. factory.GetResultWriter(),
  122. )
  123. routes = append(routes, &Route{
  124. Endpoint: cloneEnvGroupEndpoint,
  125. Handler: cloneEnvGroupHandler,
  126. Router: r,
  127. })
  128. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/envgroup -> namespace.NewGetEnvGroupHandler
  129. getEnvGroupEndpoint := factory.NewAPIEndpoint(
  130. &types.APIRequestMetadata{
  131. Verb: types.APIVerbGet,
  132. Method: types.HTTPVerbGet,
  133. Path: &types.Path{
  134. Parent: basePath,
  135. RelativePath: relPath + "/envgroup",
  136. },
  137. Scopes: []types.PermissionScope{
  138. types.UserScope,
  139. types.ProjectScope,
  140. types.ClusterScope,
  141. types.NamespaceScope,
  142. },
  143. },
  144. )
  145. getEnvGroupHandler := namespace.NewGetEnvGroupHandler(
  146. config,
  147. factory.GetDecoderValidator(),
  148. factory.GetResultWriter(),
  149. )
  150. routes = append(routes, &Route{
  151. Endpoint: getEnvGroupEndpoint,
  152. Handler: getEnvGroupHandler,
  153. Router: r,
  154. })
  155. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/envgroup/all_versions -> namespace.NewGetEnvGroupAllVersionsHandler
  156. getEnvGroupAllVersionsEndpoint := factory.NewAPIEndpoint(
  157. &types.APIRequestMetadata{
  158. Verb: types.APIVerbGet,
  159. Method: types.HTTPVerbGet,
  160. Path: &types.Path{
  161. Parent: basePath,
  162. RelativePath: relPath + "/envgroup/all_versions",
  163. },
  164. Scopes: []types.PermissionScope{
  165. types.UserScope,
  166. types.ProjectScope,
  167. types.ClusterScope,
  168. types.NamespaceScope,
  169. },
  170. },
  171. )
  172. getEnvGroupAllVersionsHandler := namespace.NewGetEnvGroupAllVersionsHandler(
  173. config,
  174. factory.GetDecoderValidator(),
  175. factory.GetResultWriter(),
  176. )
  177. routes = append(routes, &Route{
  178. Endpoint: getEnvGroupAllVersionsEndpoint,
  179. Handler: getEnvGroupAllVersionsHandler,
  180. Router: r,
  181. })
  182. // POST /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/envgroup/create -> namespace.NewCreateEnvGroupHandler
  183. createEnvGroupEndpoint := factory.NewAPIEndpoint(
  184. &types.APIRequestMetadata{
  185. Verb: types.APIVerbCreate,
  186. Method: types.HTTPVerbPost,
  187. Path: &types.Path{
  188. Parent: basePath,
  189. RelativePath: relPath + "/envgroup/create",
  190. },
  191. Scopes: []types.PermissionScope{
  192. types.UserScope,
  193. types.ProjectScope,
  194. types.ClusterScope,
  195. types.NamespaceScope,
  196. },
  197. },
  198. )
  199. createEnvGroupHandler := namespace.NewCreateEnvGroupHandler(
  200. config,
  201. factory.GetDecoderValidator(),
  202. factory.GetResultWriter(),
  203. )
  204. routes = append(routes, &Route{
  205. Endpoint: createEnvGroupEndpoint,
  206. Handler: createEnvGroupHandler,
  207. Router: r,
  208. })
  209. // POST /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/envgroup/add_application -> namespace.NewAddEnvGroupAppHandler
  210. updateEnvGroupAppsEndpoint := factory.NewAPIEndpoint(
  211. &types.APIRequestMetadata{
  212. Verb: types.APIVerbUpdate,
  213. Method: types.HTTPVerbPost,
  214. Path: &types.Path{
  215. Parent: basePath,
  216. RelativePath: relPath + "/envgroup/add_application",
  217. },
  218. Scopes: []types.PermissionScope{
  219. types.UserScope,
  220. types.ProjectScope,
  221. types.ClusterScope,
  222. types.NamespaceScope,
  223. },
  224. },
  225. )
  226. updateEnvGroupAppsHandler := namespace.NewAddEnvGroupAppHandler(
  227. config,
  228. factory.GetDecoderValidator(),
  229. factory.GetResultWriter(),
  230. )
  231. routes = append(routes, &Route{
  232. Endpoint: updateEnvGroupAppsEndpoint,
  233. Handler: updateEnvGroupAppsHandler,
  234. Router: r,
  235. })
  236. // POST /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/envgroup/remove_application -> namespace.NewRemoveEnvGroupAppHandler
  237. removeEnvGroupAppEndpoint := factory.NewAPIEndpoint(
  238. &types.APIRequestMetadata{
  239. Verb: types.APIVerbUpdate,
  240. Method: types.HTTPVerbPost,
  241. Path: &types.Path{
  242. Parent: basePath,
  243. RelativePath: relPath + "/envgroup/remove_application",
  244. },
  245. Scopes: []types.PermissionScope{
  246. types.UserScope,
  247. types.ProjectScope,
  248. types.ClusterScope,
  249. types.NamespaceScope,
  250. },
  251. },
  252. )
  253. removeEnvGroupAppHandler := namespace.NewRemoveEnvGroupAppHandler(
  254. config,
  255. factory.GetDecoderValidator(),
  256. factory.GetResultWriter(),
  257. )
  258. routes = append(routes, &Route{
  259. Endpoint: removeEnvGroupAppEndpoint,
  260. Handler: removeEnvGroupAppHandler,
  261. Router: r,
  262. })
  263. // DELETE /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/envgroup -> namespace.NewDeleteEnvGroupHandler
  264. deleteEnvGroupEndpoint := factory.NewAPIEndpoint(
  265. &types.APIRequestMetadata{
  266. Verb: types.APIVerbDelete,
  267. Method: types.HTTPVerbDelete,
  268. Path: &types.Path{
  269. Parent: basePath,
  270. RelativePath: relPath + "/envgroup",
  271. },
  272. Scopes: []types.PermissionScope{
  273. types.UserScope,
  274. types.ProjectScope,
  275. types.ClusterScope,
  276. types.NamespaceScope,
  277. },
  278. },
  279. )
  280. deleteEnvGroupHandler := namespace.NewDeleteEnvGroupHandler(
  281. config,
  282. factory.GetDecoderValidator(),
  283. factory.GetResultWriter(),
  284. )
  285. routes = append(routes, &Route{
  286. Endpoint: deleteEnvGroupEndpoint,
  287. Handler: deleteEnvGroupHandler,
  288. Router: r,
  289. })
  290. // POST /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/configmap/update -> namespace.NewUpdateConfigMapHandler
  291. updateConfigMapEndpoint := factory.NewAPIEndpoint(
  292. &types.APIRequestMetadata{
  293. Verb: types.APIVerbUpdate,
  294. Method: types.HTTPVerbPost,
  295. Path: &types.Path{
  296. Parent: basePath,
  297. RelativePath: relPath + "/configmap/update",
  298. },
  299. Scopes: []types.PermissionScope{
  300. types.UserScope,
  301. types.ProjectScope,
  302. types.ClusterScope,
  303. types.NamespaceScope,
  304. },
  305. },
  306. )
  307. updateConfigMapHandler := namespace.NewUpdateConfigMapHandler(
  308. config,
  309. factory.GetDecoderValidator(),
  310. factory.GetResultWriter(),
  311. )
  312. routes = append(routes, &Route{
  313. Endpoint: updateConfigMapEndpoint,
  314. Handler: updateConfigMapHandler,
  315. Router: r,
  316. })
  317. // DELETE /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/crd -> namespace.NewCRDDeleteHandler
  318. deleteCRDEndpoint := factory.NewAPIEndpoint(
  319. &types.APIRequestMetadata{
  320. Verb: types.APIVerbDelete,
  321. Method: types.HTTPVerbDelete,
  322. Path: &types.Path{
  323. Parent: basePath,
  324. RelativePath: relPath + "/crd",
  325. },
  326. Scopes: []types.PermissionScope{
  327. types.UserScope,
  328. types.ProjectScope,
  329. types.ClusterScope,
  330. },
  331. },
  332. )
  333. deleteCRDHandler := namespace.NewCRDDeleteHandler(
  334. config,
  335. factory.GetDecoderValidator(),
  336. factory.GetResultWriter(),
  337. )
  338. routes = append(routes, &Route{
  339. Endpoint: deleteCRDEndpoint,
  340. Handler: deleteCRDHandler,
  341. Router: r,
  342. })
  343. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases -> namespace.NewListReleasesHandler
  344. listReleasesEndpoint := factory.NewAPIEndpoint(
  345. &types.APIRequestMetadata{
  346. Verb: types.APIVerbGet,
  347. Method: types.HTTPVerbGet,
  348. Path: &types.Path{
  349. Parent: basePath,
  350. RelativePath: relPath + "/releases",
  351. },
  352. Scopes: []types.PermissionScope{
  353. types.UserScope,
  354. types.ProjectScope,
  355. types.ClusterScope,
  356. types.NamespaceScope,
  357. },
  358. },
  359. )
  360. listReleasesHandler := namespace.NewListReleasesHandler(
  361. config,
  362. factory.GetDecoderValidator(),
  363. factory.GetResultWriter(),
  364. )
  365. routes = append(routes, &Route{
  366. Endpoint: listReleasesEndpoint,
  367. Handler: listReleasesHandler,
  368. Router: r,
  369. })
  370. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/pod/{name}/logs -> namespace.NewStreamPodLogsHandler
  371. streamPodLogsEndpoint := factory.NewAPIEndpoint(
  372. &types.APIRequestMetadata{
  373. Verb: types.APIVerbGet,
  374. Method: types.HTTPVerbGet,
  375. Path: &types.Path{
  376. Parent: basePath,
  377. RelativePath: fmt.Sprintf(
  378. "%s/pod/{%s}/logs",
  379. relPath,
  380. types.URLParamPodName,
  381. ),
  382. },
  383. Scopes: []types.PermissionScope{
  384. types.UserScope,
  385. types.ProjectScope,
  386. types.ClusterScope,
  387. types.NamespaceScope,
  388. },
  389. IsWebsocket: true,
  390. },
  391. )
  392. streamPodLogsHandler := namespace.NewStreamPodLogsHandler(
  393. config,
  394. factory.GetDecoderValidator(),
  395. factory.GetResultWriter(),
  396. )
  397. routes = append(routes, &Route{
  398. Endpoint: streamPodLogsEndpoint,
  399. Handler: streamPodLogsHandler,
  400. Router: r,
  401. })
  402. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/pod/{name}/previous_logs
  403. getPreviousLogsEndpoint := factory.NewAPIEndpoint(
  404. &types.APIRequestMetadata{
  405. Verb: types.APIVerbGet,
  406. Method: types.HTTPVerbGet,
  407. Path: &types.Path{
  408. Parent: basePath,
  409. RelativePath: fmt.Sprintf(
  410. "%s/pod/{%s}/previous_logs",
  411. relPath,
  412. types.URLParamPodName,
  413. ),
  414. },
  415. Scopes: []types.PermissionScope{
  416. types.UserScope,
  417. types.ProjectScope,
  418. types.ClusterScope,
  419. types.NamespaceScope,
  420. },
  421. },
  422. )
  423. getPreviousLogsHandler := namespace.NewGetPreviousLogsHandler(
  424. config,
  425. factory.GetDecoderValidator(),
  426. factory.GetResultWriter(),
  427. )
  428. routes = append(routes, &Route{
  429. Endpoint: getPreviousLogsEndpoint,
  430. Handler: getPreviousLogsHandler,
  431. Router: r,
  432. })
  433. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/jobs/{name}/pods -> jobs.NewGetPodsHandler
  434. getJobPodsEndpoint := factory.NewAPIEndpoint(
  435. &types.APIRequestMetadata{
  436. Verb: types.APIVerbList,
  437. Method: types.HTTPVerbGet,
  438. Path: &types.Path{
  439. Parent: basePath,
  440. RelativePath: fmt.Sprintf(
  441. "%s/jobs/{%s}/pods",
  442. relPath,
  443. types.URLParamJobName,
  444. ),
  445. },
  446. Scopes: []types.PermissionScope{
  447. types.UserScope,
  448. types.ProjectScope,
  449. types.ClusterScope,
  450. types.NamespaceScope,
  451. },
  452. },
  453. )
  454. getJobPodsHandler := job.NewGetPodsHandler(
  455. config,
  456. factory.GetResultWriter(),
  457. )
  458. routes = append(routes, &Route{
  459. Endpoint: getJobPodsEndpoint,
  460. Handler: getJobPodsHandler,
  461. Router: r,
  462. })
  463. // DELETE /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/jobs/{name} -> jobs.NewDeleteHandler
  464. deleteJobEndpoint := factory.NewAPIEndpoint(
  465. &types.APIRequestMetadata{
  466. Verb: types.APIVerbDelete,
  467. Method: types.HTTPVerbDelete,
  468. Path: &types.Path{
  469. Parent: basePath,
  470. RelativePath: fmt.Sprintf(
  471. "%s/jobs/{%s}",
  472. relPath,
  473. types.URLParamJobName,
  474. ),
  475. },
  476. Scopes: []types.PermissionScope{
  477. types.UserScope,
  478. types.ProjectScope,
  479. types.ClusterScope,
  480. types.NamespaceScope,
  481. },
  482. },
  483. )
  484. deleteJobHandler := job.NewDeleteHandler(
  485. config,
  486. )
  487. routes = append(routes, &Route{
  488. Endpoint: deleteJobEndpoint,
  489. Handler: deleteJobHandler,
  490. Router: r,
  491. })
  492. // POST /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/jobs/{name}/stop -> jobs.NewStopHandler
  493. stopJobEndpoint := factory.NewAPIEndpoint(
  494. &types.APIRequestMetadata{
  495. Verb: types.APIVerbUpdate,
  496. Method: types.HTTPVerbPost,
  497. Path: &types.Path{
  498. Parent: basePath,
  499. RelativePath: fmt.Sprintf(
  500. "%s/jobs/{%s}/stop",
  501. relPath,
  502. types.URLParamJobName,
  503. ),
  504. },
  505. Scopes: []types.PermissionScope{
  506. types.UserScope,
  507. types.ProjectScope,
  508. types.ClusterScope,
  509. types.NamespaceScope,
  510. },
  511. },
  512. )
  513. stopJobHandler := job.NewStopHandler(
  514. config,
  515. )
  516. routes = append(routes, &Route{
  517. Endpoint: stopJobEndpoint,
  518. Handler: stopJobHandler,
  519. Router: r,
  520. })
  521. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/pods/{name} -> namespace.NewGetPodHandler
  522. getPodEndpoint := factory.NewAPIEndpoint(
  523. &types.APIRequestMetadata{
  524. Verb: types.APIVerbGet,
  525. Method: types.HTTPVerbGet,
  526. Path: &types.Path{
  527. Parent: basePath,
  528. RelativePath: fmt.Sprintf(
  529. "%s/pods/{%s}",
  530. relPath,
  531. types.URLParamPodName,
  532. ),
  533. },
  534. Scopes: []types.PermissionScope{
  535. types.UserScope,
  536. types.ProjectScope,
  537. types.ClusterScope,
  538. types.NamespaceScope,
  539. },
  540. },
  541. )
  542. getPodHandler := namespace.NewGetPodHandler(
  543. config,
  544. factory.GetResultWriter(),
  545. )
  546. routes = append(routes, &Route{
  547. Endpoint: getPodEndpoint,
  548. Handler: getPodHandler,
  549. Router: r,
  550. })
  551. // DELETE /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/pods/{name} -> namespace.NewDeletePodHandler
  552. deletePodEndpoint := factory.NewAPIEndpoint(
  553. &types.APIRequestMetadata{
  554. Verb: types.APIVerbDelete,
  555. Method: types.HTTPVerbDelete,
  556. Path: &types.Path{
  557. Parent: basePath,
  558. RelativePath: fmt.Sprintf(
  559. "%s/pods/{%s}",
  560. relPath,
  561. types.URLParamPodName,
  562. ),
  563. },
  564. Scopes: []types.PermissionScope{
  565. types.UserScope,
  566. types.ProjectScope,
  567. types.ClusterScope,
  568. types.NamespaceScope,
  569. },
  570. },
  571. )
  572. deletePodHandler := namespace.NewDeletePodHandler(
  573. config,
  574. )
  575. routes = append(routes, &Route{
  576. Endpoint: deletePodEndpoint,
  577. Handler: deletePodHandler,
  578. Router: r,
  579. })
  580. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/pods/{name}/events -> namespace.NewGetPodEventsHandler
  581. getPodEventsEndpoint := factory.NewAPIEndpoint(
  582. &types.APIRequestMetadata{
  583. Verb: types.APIVerbList,
  584. Method: types.HTTPVerbGet,
  585. Path: &types.Path{
  586. Parent: basePath,
  587. RelativePath: fmt.Sprintf(
  588. "%s/pods/{%s}/events",
  589. relPath,
  590. types.URLParamPodName,
  591. ),
  592. },
  593. Scopes: []types.PermissionScope{
  594. types.UserScope,
  595. types.ProjectScope,
  596. types.ClusterScope,
  597. types.NamespaceScope,
  598. },
  599. },
  600. )
  601. getPodEventsHandler := namespace.NewGetPodEventsHandler(
  602. config,
  603. factory.GetResultWriter(),
  604. )
  605. routes = append(routes, &Route{
  606. Endpoint: getPodEventsEndpoint,
  607. Handler: getPodEventsHandler,
  608. Router: r,
  609. })
  610. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/ingresses/{name} ->
  611. // release.NewGetJobsHandler
  612. getIngressEndpoint := factory.NewAPIEndpoint(
  613. &types.APIRequestMetadata{
  614. Verb: types.APIVerbGet,
  615. Method: types.HTTPVerbGet,
  616. Path: &types.Path{
  617. Parent: basePath,
  618. RelativePath: relPath + "/ingresses/{name}",
  619. },
  620. Scopes: []types.PermissionScope{
  621. types.UserScope,
  622. types.ProjectScope,
  623. types.ClusterScope,
  624. types.NamespaceScope,
  625. },
  626. },
  627. )
  628. getIngressHandler := namespace.NewGetIngressHandler(
  629. config,
  630. factory.GetResultWriter(),
  631. )
  632. routes = append(routes, &Route{
  633. Endpoint: getIngressEndpoint,
  634. Handler: getIngressHandler,
  635. Router: r,
  636. })
  637. return routes, newPath
  638. }