namespace.go 17 KB

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