api.tsx 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783
  1. import { PolicyDocType } from "./auth/types";
  2. import { baseApi } from "./baseApi";
  3. import { FullActionConfigType, StorageType } from "./types";
  4. /**
  5. * Generic api call format
  6. * @param {string} token - Bearer token.
  7. * @param {Object} params - Body params.
  8. * @param {Object} pathParams - Path params.
  9. * @param {(err: Object, res: Object) => void} callback - Callback function.
  10. */
  11. const checkAuth = baseApi("GET", "/api/users/current");
  12. const connectECRRegistry = baseApi<
  13. {
  14. name: string;
  15. aws_integration_id: string;
  16. },
  17. { id: number }
  18. >("POST", (pathParams) => {
  19. return `/api/projects/${pathParams.id}/registries`;
  20. });
  21. const connectGCRRegistry = baseApi<
  22. {
  23. name: string;
  24. gcp_integration_id: string;
  25. url: string;
  26. },
  27. { id: number }
  28. >("POST", (pathParams) => {
  29. return `/api/projects/${pathParams.id}/registries`;
  30. });
  31. const connectDORegistry = baseApi<
  32. {
  33. name: string;
  34. do_integration_id: string;
  35. url: string;
  36. },
  37. { project_id: number }
  38. >("POST", (pathParams) => {
  39. return `/api/projects/${pathParams.project_id}/registries`;
  40. });
  41. const getAWSIntegration = baseApi<{}, { project_id: number }>(
  42. "GET",
  43. ({ project_id }) => `/api/projects/${project_id}/integrations/aws`
  44. );
  45. const getGCPIntegration = baseApi<{}, { project_id: number }>(
  46. "GET",
  47. ({ project_id }) => `/api/projects/${project_id}/integrations/gcp`
  48. );
  49. const createAWSIntegration = baseApi<
  50. {
  51. aws_region: string;
  52. aws_cluster_id?: string;
  53. aws_access_key_id: string;
  54. aws_secret_access_key: string;
  55. },
  56. { id: number }
  57. >("POST", (pathParams) => {
  58. return `/api/projects/${pathParams.id}/integrations/aws`;
  59. });
  60. const overwriteAWSIntegration = baseApi<
  61. {
  62. aws_integration_id: number;
  63. aws_access_key_id: string;
  64. aws_secret_access_key: string;
  65. cluster_id: number;
  66. },
  67. {
  68. project_id: number;
  69. }
  70. >("POST", (pathParams) => {
  71. return `/api/projects/${pathParams.project_id}/integrations/aws/overwrite`;
  72. });
  73. const createEmailVerification = baseApi<{}, {}>("POST", (pathParams) => {
  74. return `/api/email/verify/initiate`;
  75. });
  76. const createEnvironment = baseApi<
  77. {
  78. name: string;
  79. },
  80. {
  81. project_id: number;
  82. cluster_id: number;
  83. git_installation_id: number;
  84. git_repo_owner: string;
  85. git_repo_name: string;
  86. }
  87. >("POST", (pathParams) => {
  88. let {
  89. project_id,
  90. cluster_id,
  91. git_installation_id,
  92. git_repo_owner,
  93. git_repo_name,
  94. } = pathParams;
  95. return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${git_repo_owner}/${git_repo_name}/clusters/${cluster_id}/environment`;
  96. });
  97. const deleteEnvironment = baseApi<
  98. {
  99. name: string;
  100. },
  101. {
  102. project_id: number;
  103. cluster_id: number;
  104. git_installation_id: number;
  105. git_repo_owner: string;
  106. git_repo_name: string;
  107. }
  108. >("DELETE", (pathParams) => {
  109. let {
  110. project_id,
  111. cluster_id,
  112. git_installation_id,
  113. git_repo_owner,
  114. git_repo_name,
  115. } = pathParams;
  116. return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${git_repo_owner}/${git_repo_name}/clusters/${cluster_id}/environment`;
  117. });
  118. const listEnvironments = baseApi<
  119. {},
  120. {
  121. project_id: number;
  122. cluster_id: number;
  123. }
  124. >("GET", (pathParams) => {
  125. let { project_id, cluster_id } = pathParams;
  126. return `/api/projects/${project_id}/clusters/${cluster_id}/environments`;
  127. });
  128. const createGCPIntegration = baseApi<
  129. {
  130. gcp_key_data: string;
  131. gcp_project_id: string;
  132. },
  133. {
  134. project_id: number;
  135. }
  136. >("POST", (pathParams) => {
  137. return `/api/projects/${pathParams.project_id}/integrations/gcp`;
  138. });
  139. const createInvite = baseApi<
  140. {
  141. email: string;
  142. kind: string;
  143. },
  144. {
  145. id: number;
  146. }
  147. >("POST", (pathParams) => {
  148. return `/api/projects/${pathParams.id}/invites`;
  149. });
  150. const createPasswordReset = baseApi<
  151. {
  152. email: string;
  153. },
  154. {}
  155. >("POST", (pathParams) => {
  156. return `/api/password/reset/initiate`;
  157. });
  158. const createPasswordResetVerify = baseApi<
  159. {
  160. email: string;
  161. token: string;
  162. token_id: number;
  163. },
  164. {}
  165. >("POST", (pathParams) => {
  166. return `/api/password/reset/verify`;
  167. });
  168. const createPasswordResetFinalize = baseApi<
  169. {
  170. email: string;
  171. token: string;
  172. token_id: number;
  173. new_password: string;
  174. },
  175. {}
  176. >("POST", (pathParams) => {
  177. return `/api/password/reset/finalize`;
  178. });
  179. const createProject = baseApi<{ name: string }, {}>("POST", (pathParams) => {
  180. return `/api/projects`;
  181. });
  182. const createSubdomain = baseApi<
  183. {},
  184. {
  185. id: number;
  186. release_name: string;
  187. namespace: string;
  188. cluster_id: number;
  189. }
  190. >("POST", (pathParams) => {
  191. let { cluster_id, id, namespace, release_name } = pathParams;
  192. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/subdomain`;
  193. });
  194. const deleteCluster = baseApi<
  195. {},
  196. {
  197. project_id: number;
  198. cluster_id: number;
  199. }
  200. >("DELETE", (pathParams) => {
  201. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}`;
  202. });
  203. const deleteInvite = baseApi<{}, { id: number; invId: number }>(
  204. "DELETE",
  205. (pathParams) => {
  206. return `/api/projects/${pathParams.id}/invites/${pathParams.invId}`;
  207. }
  208. );
  209. const deletePod = baseApi<
  210. {},
  211. { name: string; namespace: string; id: number; cluster_id: number }
  212. >("DELETE", (pathParams) => {
  213. let { id, name, cluster_id, namespace } = pathParams;
  214. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/pods/${name}`;
  215. });
  216. const getPodEvents = baseApi<
  217. {},
  218. { name: string; namespace: string; id: number; cluster_id: number }
  219. >("GET", (pathParams) => {
  220. let { id, name, cluster_id, namespace } = pathParams;
  221. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/pods/${name}/events`;
  222. });
  223. const deleteProject = baseApi<{}, { id: number }>("DELETE", (pathParams) => {
  224. return `/api/projects/${pathParams.id}`;
  225. });
  226. const deleteRegistryIntegration = baseApi<
  227. {},
  228. {
  229. project_id: number;
  230. registry_id: number;
  231. }
  232. >("DELETE", (pathParams) => {
  233. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}`;
  234. });
  235. const deleteSlackIntegration = baseApi<
  236. {},
  237. {
  238. project_id: number;
  239. slack_integration_id: number;
  240. }
  241. >("DELETE", (pathParams) => {
  242. return `/api/projects/${pathParams.project_id}/slack_integrations/${pathParams.slack_integration_id}`;
  243. });
  244. const updateNotificationConfig = baseApi<
  245. {
  246. payload: any;
  247. },
  248. {
  249. project_id: number;
  250. cluster_id: number;
  251. namespace: string;
  252. name: string;
  253. }
  254. >("POST", (pathParams) => {
  255. let { project_id, cluster_id, namespace, name } = pathParams;
  256. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/notifications`;
  257. });
  258. const getPRDeploymentList = baseApi<
  259. {
  260. status?: string[];
  261. },
  262. {
  263. cluster_id: number;
  264. project_id: number;
  265. }
  266. >("GET", (pathParams) => {
  267. const { cluster_id, project_id } = pathParams;
  268. return `/api/projects/${project_id}/clusters/${cluster_id}/deployments`;
  269. });
  270. const getPRDeploymentByCluster = baseApi<
  271. {
  272. namespace: string;
  273. },
  274. {
  275. cluster_id: number;
  276. project_id: number;
  277. environment_id: number;
  278. }
  279. >("GET", (pathParams) => {
  280. const { cluster_id, project_id, environment_id } = pathParams;
  281. return `/api/projects/${project_id}/clusters/${cluster_id}/${environment_id}/deployment`;
  282. });
  283. const getPRDeployment = baseApi<
  284. {
  285. namespace: string;
  286. },
  287. {
  288. cluster_id: number;
  289. project_id: number;
  290. git_installation_id: number;
  291. git_repo_owner: string;
  292. git_repo_name: string;
  293. }
  294. >("GET", (pathParams) => {
  295. const {
  296. cluster_id,
  297. project_id,
  298. git_installation_id,
  299. git_repo_owner,
  300. git_repo_name,
  301. } = pathParams;
  302. return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${git_repo_owner}/${git_repo_name}/clusters/${cluster_id}/deployment`;
  303. });
  304. const getNotificationConfig = baseApi<
  305. {},
  306. {
  307. project_id: number;
  308. cluster_id: number;
  309. namespace: string;
  310. name: string;
  311. }
  312. >("GET", (pathParams) => {
  313. let { project_id, cluster_id, namespace, name } = pathParams;
  314. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/notifications`;
  315. });
  316. const getGHAWorkflowTemplate = baseApi<
  317. {
  318. release_name: string;
  319. github_action_config: FullActionConfigType;
  320. },
  321. {
  322. cluster_id: number;
  323. project_id: number;
  324. namespace: string;
  325. }
  326. >("POST", (pathParams) => {
  327. const { cluster_id, project_id, namespace } = pathParams;
  328. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/gha_template`;
  329. });
  330. const deployTemplate = baseApi<
  331. {
  332. template_name: string;
  333. template_version: string;
  334. image_url?: string;
  335. values?: any;
  336. name: string;
  337. github_action_config?: FullActionConfigType;
  338. build_config?: any;
  339. },
  340. {
  341. id: number;
  342. cluster_id: number;
  343. namespace: string;
  344. repo_url?: string;
  345. }
  346. >("POST", (pathParams) => {
  347. let { cluster_id, id, namespace, repo_url } = pathParams;
  348. if (repo_url) {
  349. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases?repo_url=${repo_url}`;
  350. }
  351. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases`;
  352. });
  353. const deployAddon = baseApi<
  354. {
  355. template_name: string;
  356. template_version: string;
  357. values?: any;
  358. name: string;
  359. },
  360. {
  361. id: number;
  362. cluster_id: number;
  363. namespace: string;
  364. repo_url?: string;
  365. }
  366. >("POST", (pathParams) => {
  367. let { cluster_id, id, namespace, repo_url } = pathParams;
  368. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/addons?repo_url=${repo_url}`;
  369. });
  370. const detectBuildpack = baseApi<
  371. {},
  372. {
  373. project_id: number;
  374. git_repo_id: number;
  375. kind: string;
  376. owner: string;
  377. name: string;
  378. branch: string;
  379. }
  380. >("GET", (pathParams) => {
  381. return `/api/projects/${pathParams.project_id}/gitrepos/${
  382. pathParams.git_repo_id
  383. }/repos/${pathParams.kind}/${pathParams.owner}/${
  384. pathParams.name
  385. }/${encodeURIComponent(pathParams.branch)}/buildpack/detect`;
  386. });
  387. const getBranchContents = baseApi<
  388. {
  389. dir: string;
  390. },
  391. {
  392. project_id: number;
  393. git_repo_id: number;
  394. kind: string;
  395. owner: string;
  396. name: string;
  397. branch: string;
  398. }
  399. >("GET", (pathParams) => {
  400. return `/api/projects/${pathParams.project_id}/gitrepos/${
  401. pathParams.git_repo_id
  402. }/repos/${pathParams.kind}/${pathParams.owner}/${
  403. pathParams.name
  404. }/${encodeURIComponent(pathParams.branch)}/contents`;
  405. });
  406. const getProcfileContents = baseApi<
  407. {
  408. path: string;
  409. },
  410. {
  411. project_id: number;
  412. git_repo_id: number;
  413. kind: string;
  414. owner: string;
  415. name: string;
  416. branch: string;
  417. }
  418. >("GET", (pathParams) => {
  419. return `/api/projects/${pathParams.project_id}/gitrepos/${
  420. pathParams.git_repo_id
  421. }/repos/${pathParams.kind}/${pathParams.owner}/${
  422. pathParams.name
  423. }/${encodeURIComponent(pathParams.branch)}/procfile`;
  424. });
  425. const getBranches = baseApi<
  426. {},
  427. {
  428. project_id: number;
  429. git_repo_id: number;
  430. kind: string;
  431. owner: string;
  432. name: string;
  433. }
  434. >("GET", (pathParams) => {
  435. return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id}/repos/${pathParams.kind}/${pathParams.owner}/${pathParams.name}/branches`;
  436. });
  437. const getChart = baseApi<
  438. {},
  439. {
  440. id: number;
  441. cluster_id: number;
  442. namespace: string;
  443. name: string;
  444. revision: number;
  445. }
  446. >("GET", (pathParams) => {
  447. let { id, cluster_id, namespace, name, revision } = pathParams;
  448. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}`;
  449. });
  450. const getCharts = baseApi<
  451. {
  452. limit: number;
  453. skip: number;
  454. byDate: boolean;
  455. statusFilter: string[];
  456. },
  457. {
  458. id: number;
  459. cluster_id: number;
  460. namespace: string;
  461. }
  462. >("GET", (pathParams) => {
  463. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/releases`;
  464. });
  465. const getChartComponents = baseApi<
  466. {},
  467. {
  468. id: number;
  469. cluster_id: number;
  470. namespace: string;
  471. name: string;
  472. revision: number;
  473. }
  474. >("GET", (pathParams) => {
  475. let { id, cluster_id, namespace, name, revision } = pathParams;
  476. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}/components`;
  477. });
  478. const getChartControllers = baseApi<
  479. {},
  480. {
  481. id: number;
  482. cluster_id: number;
  483. namespace: string;
  484. name: string;
  485. revision: number;
  486. }
  487. >("GET", (pathParams) => {
  488. let { id, cluster_id, namespace, name, revision } = pathParams;
  489. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}/controllers`;
  490. });
  491. const getClusterIntegrations = baseApi("GET", "/api/integrations/cluster");
  492. const getClusters = baseApi<{}, { id: number }>("GET", (pathParams) => {
  493. return `/api/projects/${pathParams.id}/clusters`;
  494. });
  495. const getCluster = baseApi<
  496. {},
  497. {
  498. project_id: number;
  499. cluster_id: number;
  500. }
  501. >("GET", (pathParams) => {
  502. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}`;
  503. });
  504. const getClusterNodes = baseApi<
  505. {},
  506. {
  507. project_id: number;
  508. cluster_id: number;
  509. }
  510. >("GET", (pathParams) => {
  511. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/nodes`;
  512. });
  513. const getClusterNode = baseApi<
  514. {},
  515. {
  516. project_id: number;
  517. cluster_id: number;
  518. nodeName: string;
  519. }
  520. >(
  521. "GET",
  522. (pathParams) =>
  523. `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/nodes/${pathParams.nodeName}`
  524. );
  525. const getGitRepoList = baseApi<
  526. {},
  527. {
  528. project_id: number;
  529. git_repo_id: number;
  530. }
  531. >("GET", (pathParams) => {
  532. return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id}/repos`;
  533. });
  534. const getGitRepoPermission = baseApi<
  535. {},
  536. {
  537. project_id: number;
  538. git_repo_id: number;
  539. }
  540. >("GET", (pathParams) => {
  541. return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id}/permissions`;
  542. });
  543. const getGitRepos = baseApi<
  544. {},
  545. {
  546. project_id: number;
  547. }
  548. >("GET", (pathParams) => {
  549. return `/api/projects/${pathParams.project_id}/gitrepos`;
  550. });
  551. const getImageRepos = baseApi<
  552. {},
  553. {
  554. project_id: number;
  555. registry_id: number;
  556. }
  557. >("GET", (pathParams) => {
  558. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}/repositories`;
  559. });
  560. const getImageTags = baseApi<
  561. {},
  562. {
  563. project_id: number;
  564. registry_id: number;
  565. repo_name: string;
  566. }
  567. >("GET", (pathParams) => {
  568. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}/repositories/${pathParams.repo_name}`;
  569. });
  570. const getInfra = baseApi<
  571. {
  572. version?: string;
  573. },
  574. {
  575. project_id: number;
  576. }
  577. >("GET", (pathParams) => {
  578. return `/api/projects/${pathParams.project_id}/infra`;
  579. });
  580. const listInfraTemplates = baseApi<
  581. {},
  582. {
  583. project_id: number;
  584. }
  585. >("GET", (pathParams) => {
  586. return `/api/projects/${pathParams.project_id}/infras/templates`;
  587. });
  588. const getInfraTemplate = baseApi<
  589. {},
  590. {
  591. project_id: number;
  592. name: string;
  593. version: string;
  594. }
  595. >("GET", (pathParams) => {
  596. let { project_id, name, version } = pathParams;
  597. return `/api/projects/${project_id}/infras/templates/${name}/${version}`;
  598. });
  599. const provisionInfra = baseApi<
  600. {
  601. kind: string;
  602. values: any;
  603. aws_integration_id?: number;
  604. gcp_integration_id?: number;
  605. do_integration_id?: number;
  606. cluster_id?: number;
  607. },
  608. {
  609. project_id: number;
  610. }
  611. >("POST", ({ project_id }) => {
  612. return `/api/projects/${project_id}/infras`;
  613. });
  614. const updateInfra = baseApi<
  615. {
  616. values?: any;
  617. },
  618. {
  619. project_id: number;
  620. infra_id: number;
  621. }
  622. >("POST", (pathParams) => {
  623. let { project_id, infra_id } = pathParams;
  624. return `/api/projects/${project_id}/infras/${infra_id}/update`;
  625. });
  626. const retryCreateInfra = baseApi<
  627. {
  628. aws_integration_id?: number;
  629. gcp_integration_id?: number;
  630. do_integration_id?: number;
  631. values?: any;
  632. },
  633. {
  634. project_id: number;
  635. infra_id: number;
  636. }
  637. >("POST", (pathParams) => {
  638. let { project_id, infra_id } = pathParams;
  639. return `/api/projects/${project_id}/infras/${infra_id}/retry_create`;
  640. });
  641. const retryDeleteInfra = baseApi<
  642. {
  643. values?: any;
  644. },
  645. {
  646. project_id: number;
  647. infra_id: number;
  648. }
  649. >("POST", (pathParams) => {
  650. let { project_id, infra_id } = pathParams;
  651. return `/api/projects/${project_id}/infras/${infra_id}/retry_delete`;
  652. });
  653. const deleteInfra = baseApi<
  654. {},
  655. {
  656. project_id: number;
  657. infra_id: number;
  658. }
  659. >("DELETE", (pathParams) => {
  660. let { project_id, infra_id } = pathParams;
  661. return `/api/projects/${project_id}/infras/${infra_id}`;
  662. });
  663. const listOperations = baseApi<
  664. {},
  665. {
  666. project_id: number;
  667. infra_id: number;
  668. }
  669. >("GET", (pathParams) => {
  670. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/operations`;
  671. });
  672. const getOperation = baseApi<
  673. {},
  674. {
  675. project_id: number;
  676. infra_id: number;
  677. operation_id: string;
  678. }
  679. >("GET", (pathParams) => {
  680. let { project_id, infra_id, operation_id } = pathParams;
  681. return `/api/projects/${project_id}/infras/${infra_id}/operations/${operation_id}`;
  682. });
  683. const getOperationLogs = baseApi<
  684. {},
  685. {
  686. project_id: number;
  687. infra_id: number;
  688. operation_id: string;
  689. }
  690. >("GET", (pathParams) => {
  691. let { project_id, infra_id, operation_id } = pathParams;
  692. return `/api/projects/${project_id}/infras/${infra_id}/operations/${operation_id}/logs`;
  693. });
  694. const getInfraState = baseApi<
  695. {},
  696. {
  697. project_id: number;
  698. infra_id: number;
  699. }
  700. >("GET", (pathParams) => {
  701. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/state`;
  702. });
  703. const getInfraRawState = baseApi<
  704. {},
  705. {
  706. project_id: number;
  707. infra_id: number;
  708. }
  709. >("GET", (pathParams) => {
  710. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/raw_state`;
  711. });
  712. const getInfraByID = baseApi<
  713. {},
  714. {
  715. project_id: number;
  716. infra_id: number;
  717. }
  718. >("GET", (pathParams) => {
  719. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}`;
  720. });
  721. const getInfraDesired = baseApi<
  722. {},
  723. {
  724. project_id: number;
  725. infra_id: number;
  726. }
  727. >("GET", (pathParams) => {
  728. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/desired`;
  729. });
  730. const getInfraCurrent = baseApi<
  731. {},
  732. {
  733. project_id: number;
  734. infra_id: number;
  735. }
  736. >("GET", (pathParams) => {
  737. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/current`;
  738. });
  739. const getIngress = baseApi<
  740. {},
  741. { namespace: string; cluster_id: number; name: string; id: number }
  742. >("GET", (pathParams) => {
  743. let { id, name, cluster_id, namespace } = pathParams;
  744. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/ingresses/${name}`;
  745. });
  746. const getInvites = baseApi<{}, { id: number }>("GET", (pathParams) => {
  747. return `/api/projects/${pathParams.id}/invites`;
  748. });
  749. const getJobs = baseApi<
  750. {},
  751. { namespace: string; cluster_id: number; release_name: string; id: number }
  752. >("GET", (pathParams) => {
  753. let { id, release_name, cluster_id, namespace } = pathParams;
  754. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/jobs`;
  755. });
  756. const getJobStatus = baseApi<
  757. {},
  758. { namespace: string; cluster_id: number; release_name: string; id: number }
  759. >("GET", (pathParams) => {
  760. let { id, release_name, cluster_id, namespace } = pathParams;
  761. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/jobs/status`;
  762. });
  763. const getJobPods = baseApi<
  764. {},
  765. { name: string; namespace: string; id: number; cluster_id: number }
  766. >("GET", (pathParams) => {
  767. let { id, name, cluster_id, namespace } = pathParams;
  768. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}/pods`;
  769. });
  770. const getPodByName = baseApi<
  771. {},
  772. {
  773. project_id: number;
  774. cluster_id: number;
  775. namespace: string;
  776. name: string;
  777. }
  778. >(
  779. "GET",
  780. ({ project_id, cluster_id, namespace, name }) =>
  781. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/pods/${name}`
  782. );
  783. const getMatchingPods = baseApi<
  784. {
  785. namespace: string;
  786. selectors: string[];
  787. },
  788. { id: number; cluster_id: number }
  789. >("GET", (pathParams) => {
  790. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/pods`;
  791. });
  792. const getMetrics = baseApi<
  793. {
  794. metric: string;
  795. shouldsum: boolean;
  796. pods?: string[];
  797. kind?: string; // the controller kind
  798. name?: string;
  799. percentile?: number;
  800. namespace: string;
  801. startrange: number;
  802. endrange: number;
  803. resolution: string;
  804. },
  805. {
  806. id: number;
  807. cluster_id: number;
  808. }
  809. >("GET", (pathParams) => {
  810. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/metrics`;
  811. });
  812. const getNamespaces = baseApi<
  813. {},
  814. {
  815. id: number;
  816. cluster_id: number;
  817. }
  818. >("GET", (pathParams) => {
  819. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces`;
  820. });
  821. const getNGINXIngresses = baseApi<
  822. {},
  823. {
  824. id: number;
  825. cluster_id: number;
  826. }
  827. >("GET", (pathParams) => {
  828. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/prometheus/ingresses`;
  829. });
  830. const getOAuthIds = baseApi<
  831. {},
  832. {
  833. project_id: number;
  834. }
  835. >("GET", (pathParams) => {
  836. return `/api/projects/${pathParams.project_id}/integrations/oauth`;
  837. });
  838. const getProjectClusters = baseApi<{}, { id: number }>("GET", (pathParams) => {
  839. return `/api/projects/${pathParams.id}/clusters`;
  840. });
  841. const getProjectRegistries = baseApi<{}, { id: number }>(
  842. "GET",
  843. (pathParams) => {
  844. return `/api/projects/${pathParams.id}/registries`;
  845. }
  846. );
  847. const getProjectRepos = baseApi<{}, { id: number }>("GET", (pathParams) => {
  848. return `/api/projects/${pathParams.id}/repos`;
  849. });
  850. const getProjects = baseApi("GET", "/api/projects");
  851. const getPrometheusIsInstalled = baseApi<
  852. {},
  853. {
  854. id: number;
  855. cluster_id: number;
  856. }
  857. >("GET", (pathParams) => {
  858. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/prometheus/detect`;
  859. });
  860. const getRegistryIntegrations = baseApi("GET", "/api/integrations/registry");
  861. const getReleaseToken = baseApi<
  862. {},
  863. { name: string; id: number; namespace: string; cluster_id: number }
  864. >("GET", (pathParams) => {
  865. let { id, cluster_id, namespace, name } = pathParams;
  866. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/webhook`;
  867. });
  868. const getReleaseSteps = baseApi<
  869. {},
  870. { name: string; id: number; namespace: string; cluster_id: number }
  871. >("GET", (pathParams) => {
  872. let { id, cluster_id, namespace, name } = pathParams;
  873. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/steps`;
  874. });
  875. const destroyInfra = baseApi<
  876. {},
  877. {
  878. project_id: number;
  879. infra_id: number;
  880. }
  881. >("DELETE", (pathParams) => {
  882. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}`;
  883. });
  884. const updateDatabaseStatus = baseApi<
  885. {
  886. status: string;
  887. },
  888. {
  889. project_id: number;
  890. infra_id: number;
  891. }
  892. >("POST", (pathParams) => {
  893. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/database`;
  894. });
  895. const getRepoIntegrations = baseApi("GET", "/api/integrations/repo");
  896. const getRepos = baseApi<{}, { id: number }>("GET", (pathParams) => {
  897. return `/api/projects/${pathParams.id}/repos`;
  898. });
  899. const getSlackIntegrations = baseApi<{}, { id: number }>(
  900. "GET",
  901. (pathParams) => {
  902. return `/api/projects/${pathParams.id}/slack_integrations`;
  903. }
  904. );
  905. const getRevisions = baseApi<
  906. {},
  907. { id: number; cluster_id: number; namespace: string; name: string }
  908. >("GET", (pathParams) => {
  909. let { id, cluster_id, namespace, name } = pathParams;
  910. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/history`;
  911. });
  912. const getTemplateInfo = baseApi<
  913. {
  914. repo_url?: string;
  915. },
  916. { name: string; version: string }
  917. >("GET", (pathParams) => {
  918. return `/api/templates/${pathParams.name}/${pathParams.version}`;
  919. });
  920. const getTemplateUpgradeNotes = baseApi<
  921. {
  922. repo_url?: string;
  923. prev_version: string;
  924. },
  925. { name: string; version: string }
  926. >("GET", (pathParams) => {
  927. return `/api/templates/${pathParams.name}/${pathParams.version}/upgrade_notes`;
  928. });
  929. const getTemplates = baseApi<
  930. {
  931. repo_url?: string;
  932. },
  933. {}
  934. >("GET", "/api/templates");
  935. const getHelmRepos = baseApi<
  936. {},
  937. {
  938. project_id: number;
  939. }
  940. >("GET", (pathParams) => {
  941. return `/api/projects/${pathParams.project_id}/helmrepos`;
  942. });
  943. const getChartsFromHelmRepo = baseApi<
  944. {},
  945. {
  946. project_id: number;
  947. helm_repo_id: number;
  948. }
  949. >("GET", (pathParams) => {
  950. return `/api/projects/${pathParams.project_id}/helmrepos/${pathParams.helm_repo_id}/charts`;
  951. });
  952. const getChartInfoFromHelmRepo = baseApi<
  953. {},
  954. { project_id: number; helm_repo_id: number; name: string; version: string }
  955. >("GET", (pathParams) => {
  956. return `/api/projects/${pathParams.project_id}/helmrepos/${pathParams.helm_repo_id}/charts/${pathParams.name}/${pathParams.version}`;
  957. });
  958. const getMetadata = baseApi<{}, {}>("GET", () => {
  959. return `/api/metadata`;
  960. });
  961. const postWelcome = baseApi<{
  962. email: string;
  963. isCompany: boolean;
  964. company: string;
  965. role: string;
  966. }>("POST", () => {
  967. return `/api/welcome`;
  968. });
  969. const linkGithubProject = baseApi<
  970. {},
  971. {
  972. project_id: number;
  973. }
  974. >("GET", (pathParams) => {
  975. return `/api/oauth/projects/${pathParams.project_id}/github`;
  976. });
  977. const getGithubAccounts = baseApi<{}, {}>("GET", () => {
  978. return `/api/integrations/github-app/accounts`;
  979. });
  980. const logInUser = baseApi<{
  981. email: string;
  982. password: string;
  983. }>("POST", "/api/login");
  984. const logOutUser = baseApi("POST", "/api/logout");
  985. const registerUser = baseApi<{
  986. email: string;
  987. password: string;
  988. }>("POST", "/api/users");
  989. const rollbackChart = baseApi<
  990. {
  991. revision: number;
  992. },
  993. {
  994. id: number;
  995. name: string;
  996. namespace: string;
  997. cluster_id: number;
  998. }
  999. >("POST", (pathParams) => {
  1000. let { id, name, cluster_id, namespace } = pathParams;
  1001. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0/rollback`;
  1002. });
  1003. const uninstallTemplate = baseApi<
  1004. {},
  1005. {
  1006. id: number;
  1007. name: string;
  1008. cluster_id: number;
  1009. namespace: string;
  1010. }
  1011. >("DELETE", (pathParams) => {
  1012. let { id, name, cluster_id, namespace } = pathParams;
  1013. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0`;
  1014. });
  1015. const updateUser = baseApi<
  1016. {
  1017. rawKubeConfig?: string;
  1018. allowedContexts?: string[];
  1019. },
  1020. { id: number }
  1021. >("PUT", (pathParams) => {
  1022. return `/api/users/${pathParams.id}`;
  1023. });
  1024. const upgradeChartValues = baseApi<
  1025. {
  1026. values: string;
  1027. version?: string;
  1028. },
  1029. {
  1030. id: number;
  1031. name: string;
  1032. namespace: string;
  1033. cluster_id: number;
  1034. }
  1035. >("POST", (pathParams) => {
  1036. let { id, name, cluster_id, namespace } = pathParams;
  1037. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0/upgrade`;
  1038. });
  1039. const listEnvGroups = baseApi<
  1040. {},
  1041. {
  1042. id: number;
  1043. namespace: string;
  1044. cluster_id: number;
  1045. }
  1046. >("GET", (pathParams) => {
  1047. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/envgroup/list`;
  1048. });
  1049. const listConfigMaps = baseApi<
  1050. {},
  1051. {
  1052. id: number;
  1053. namespace: string;
  1054. cluster_id: number;
  1055. }
  1056. >("GET", (pathParams) => {
  1057. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/list`;
  1058. });
  1059. const getEnvGroup = baseApi<
  1060. {},
  1061. {
  1062. id: number;
  1063. namespace: string;
  1064. cluster_id: number;
  1065. name: string;
  1066. version?: number;
  1067. }
  1068. >("GET", (pathParams) => {
  1069. return `/api/projects/${pathParams.id}/clusters/${
  1070. pathParams.cluster_id
  1071. }/namespaces/${pathParams.namespace}/envgroup?name=${pathParams.name}${
  1072. pathParams.version ? "&version=" + pathParams.version : ""
  1073. }`;
  1074. });
  1075. const getConfigMap = baseApi<
  1076. {
  1077. name: string;
  1078. },
  1079. {
  1080. id: number;
  1081. namespace: string;
  1082. cluster_id: number;
  1083. }
  1084. >("GET", (pathParams) => {
  1085. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap`;
  1086. });
  1087. const createEnvGroup = baseApi<
  1088. {
  1089. name: string;
  1090. variables: Record<string, string>;
  1091. secret_variables?: Record<string, string>;
  1092. },
  1093. {
  1094. id: number;
  1095. cluster_id: number;
  1096. namespace: string;
  1097. }
  1098. >("POST", (pathParams) => {
  1099. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/envgroup/create`;
  1100. });
  1101. const updateEnvGroup = baseApi<
  1102. {
  1103. name: string;
  1104. variables: { [key: string]: string };
  1105. secret_variables?: { [key: string]: string };
  1106. },
  1107. {
  1108. project_id: number;
  1109. cluster_id: number;
  1110. namespace: string;
  1111. }
  1112. >(
  1113. "POST",
  1114. ({ cluster_id, project_id, namespace }) =>
  1115. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/envgroup/create`
  1116. );
  1117. const createConfigMap = baseApi<
  1118. {
  1119. name: string;
  1120. variables: Record<string, string>;
  1121. secret_variables?: Record<string, string>;
  1122. },
  1123. {
  1124. id: number;
  1125. cluster_id: number;
  1126. namespace: string;
  1127. }
  1128. >("POST", (pathParams) => {
  1129. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/create`;
  1130. });
  1131. const updateConfigMap = baseApi<
  1132. {
  1133. name: string;
  1134. variables: Record<string, string>;
  1135. secret_variables?: Record<string, string>;
  1136. },
  1137. {
  1138. id: number;
  1139. cluster_id: number;
  1140. namespace: string;
  1141. }
  1142. >("POST", (pathParams) => {
  1143. let { id, cluster_id } = pathParams;
  1144. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/update`;
  1145. });
  1146. const renameConfigMap = baseApi<
  1147. {
  1148. name: string;
  1149. new_name: string;
  1150. },
  1151. {
  1152. id: number;
  1153. cluster_id: number;
  1154. namespace: string;
  1155. }
  1156. >("POST", (pathParams) => {
  1157. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/rename`;
  1158. });
  1159. const deleteEnvGroup = baseApi<
  1160. {
  1161. name: string;
  1162. },
  1163. {
  1164. id: number;
  1165. namespace: string;
  1166. cluster_id: number;
  1167. }
  1168. >("DELETE", (pathParams) => {
  1169. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/envgroup`;
  1170. });
  1171. const deleteConfigMap = baseApi<
  1172. {
  1173. name: string;
  1174. },
  1175. {
  1176. id: number;
  1177. namespace: string;
  1178. cluster_id: number;
  1179. }
  1180. >("DELETE", (pathParams) => {
  1181. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/delete`;
  1182. });
  1183. const createNamespace = baseApi<
  1184. {
  1185. name: string;
  1186. },
  1187. { id: number; cluster_id: number }
  1188. >("POST", (pathParams) => {
  1189. let { id, cluster_id } = pathParams;
  1190. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/create`;
  1191. });
  1192. const deleteNamespace = baseApi<
  1193. {
  1194. name: string;
  1195. },
  1196. {
  1197. id: number;
  1198. cluster_id: number;
  1199. }
  1200. >("DELETE", (pathParams) => {
  1201. let { id, cluster_id } = pathParams;
  1202. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/delete`;
  1203. });
  1204. const deleteJob = baseApi<
  1205. {},
  1206. { name: string; namespace: string; id: number; cluster_id: number }
  1207. >("DELETE", (pathParams) => {
  1208. let { id, name, cluster_id, namespace } = pathParams;
  1209. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}`;
  1210. });
  1211. const stopJob = baseApi<
  1212. {},
  1213. { name: string; namespace: string; id: number; cluster_id: number }
  1214. >("POST", (pathParams) => {
  1215. let { id, name, namespace, cluster_id } = pathParams;
  1216. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}/stop`;
  1217. });
  1218. const listAPITokens = baseApi<{}, { project_id: number }>(
  1219. "GET",
  1220. ({ project_id }) => `/api/projects/${project_id}/api_token`
  1221. );
  1222. const getAPIToken = baseApi<{}, { project_id: number; token: string }>(
  1223. "GET",
  1224. ({ project_id, token }) => `/api/projects/${project_id}/api_token/${token}`
  1225. );
  1226. const revokeAPIToken = baseApi<{}, { project_id: number; token: string }>(
  1227. "POST",
  1228. ({ project_id, token }) =>
  1229. `/api/projects/${project_id}/api_token/${token}/revoke`
  1230. );
  1231. const createAPIToken = baseApi<
  1232. {
  1233. name: string;
  1234. policy_uid: string;
  1235. expires_at?: string;
  1236. },
  1237. { project_id: number }
  1238. >("POST", ({ project_id }) => `/api/projects/${project_id}/api_token`);
  1239. const createPolicy = baseApi<
  1240. {
  1241. name: string;
  1242. policy: PolicyDocType[];
  1243. },
  1244. { project_id: number }
  1245. >("POST", ({ project_id }) => `/api/projects/${project_id}/policy`);
  1246. const getAvailableRoles = baseApi<{}, { project_id: number }>(
  1247. "GET",
  1248. ({ project_id }) => `/api/projects/${project_id}/roles`
  1249. );
  1250. const updateInvite = baseApi<
  1251. { kind: string },
  1252. { project_id: number; invite_id: number }
  1253. >(
  1254. "POST",
  1255. ({ project_id, invite_id }) =>
  1256. `/api/projects/${project_id}/invites/${invite_id}`
  1257. );
  1258. const getCollaborators = baseApi<{}, { project_id: number }>(
  1259. "GET",
  1260. ({ project_id }) => `/api/projects/${project_id}/collaborators`
  1261. );
  1262. const updateCollaborator = baseApi<
  1263. {
  1264. kind: string;
  1265. user_id: number;
  1266. },
  1267. { project_id: number }
  1268. >("POST", ({ project_id }) => `/api/projects/${project_id}/roles`);
  1269. const removeCollaborator = baseApi<{ user_id: number }, { project_id: number }>(
  1270. "DELETE",
  1271. ({ project_id }) => `/api/projects/${project_id}/roles`
  1272. );
  1273. const getPolicyDocument = baseApi<{}, { project_id: number }>(
  1274. "GET",
  1275. ({ project_id }) => `/api/projects/${project_id}/policy`
  1276. );
  1277. const createWebhookToken = baseApi<
  1278. {},
  1279. {
  1280. project_id: number;
  1281. chart_name: string;
  1282. namespace: string;
  1283. cluster_id: number;
  1284. }
  1285. >(
  1286. "POST",
  1287. ({ project_id, chart_name, namespace, cluster_id }) =>
  1288. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${chart_name}/0/webhook`
  1289. );
  1290. const getUsage = baseApi<{}, { project_id: number }>(
  1291. "GET",
  1292. ({ project_id }) => `/api/projects/${project_id}/usage`
  1293. );
  1294. // Used for billing purposes
  1295. const getCustomerToken = baseApi<{}, { project_id: number }>(
  1296. "GET",
  1297. ({ project_id }) => `/api/projects/${project_id}/billing/token`
  1298. );
  1299. const getHasBilling = baseApi<{}, { project_id: number }>(
  1300. "GET",
  1301. ({ project_id }) => `/api/projects/${project_id}/billing`
  1302. );
  1303. const getOnboardingState = baseApi<{}, { project_id: number }>(
  1304. "GET",
  1305. ({ project_id }) => `/api/projects/${project_id}/onboarding`
  1306. );
  1307. const saveOnboardingState = baseApi<{}, { project_id: number }>(
  1308. "POST",
  1309. ({ project_id }) => `/api/projects/${project_id}/onboarding`
  1310. );
  1311. const getOnboardingInfra = baseApi<
  1312. {},
  1313. { project_id: number; registry_infra_id: number }
  1314. >(
  1315. "GET",
  1316. ({ project_id, registry_infra_id }) =>
  1317. `/api/projects/${project_id}/infras/${registry_infra_id}`
  1318. );
  1319. const getOnboardingRegistry = baseApi<
  1320. {},
  1321. { project_id: number; registry_connection_id: number }
  1322. >(
  1323. "GET",
  1324. ({ project_id, registry_connection_id }) =>
  1325. `/api/projects/${project_id}/registries/${registry_connection_id}`
  1326. );
  1327. const detectPorterAgent = baseApi<
  1328. {},
  1329. { project_id: number; cluster_id: number }
  1330. >(
  1331. "GET",
  1332. ({ project_id, cluster_id }) =>
  1333. `/api/projects/${project_id}/clusters/${cluster_id}/agent/detect`
  1334. );
  1335. const installPorterAgent = baseApi<
  1336. {},
  1337. { project_id: number; cluster_id: number }
  1338. >(
  1339. "POST",
  1340. ({ cluster_id, project_id }) =>
  1341. `/api/projects/${project_id}/clusters/${cluster_id}/agent/install`
  1342. );
  1343. const getKubeEvents = baseApi<
  1344. {
  1345. skip: number;
  1346. resource_type: string;
  1347. owner_type?: string;
  1348. owner_name?: string;
  1349. namespace?: string;
  1350. },
  1351. { project_id: number; cluster_id: number }
  1352. >("GET", ({ project_id, cluster_id }) => {
  1353. return `/api/projects/${project_id}/clusters/${cluster_id}/kube_events`;
  1354. });
  1355. const getKubeEvent = baseApi<
  1356. {},
  1357. { project_id: number; cluster_id: number; kube_event_id: number }
  1358. >(
  1359. "GET",
  1360. ({ project_id, cluster_id, kube_event_id }) =>
  1361. `/api/projects/${project_id}/clusters/${cluster_id}/kube_events/${kube_event_id}`
  1362. );
  1363. const getLogBuckets = baseApi<
  1364. {},
  1365. { project_id: number; cluster_id: number; kube_event_id: number }
  1366. >(
  1367. "GET",
  1368. ({ project_id, cluster_id, kube_event_id }) =>
  1369. `/api/projects/${project_id}/clusters/${cluster_id}/kube_events/${kube_event_id}/log_buckets`
  1370. );
  1371. const getLogBucketLogs = baseApi<
  1372. { timestamp: number },
  1373. { project_id: number; cluster_id: number; kube_event_id: number }
  1374. >(
  1375. "GET",
  1376. ({ project_id, cluster_id, kube_event_id }) =>
  1377. `/api/projects/${project_id}/clusters/${cluster_id}/kube_events/${kube_event_id}/logs`
  1378. );
  1379. const getCanCreateProject = baseApi<{}, {}>(
  1380. "GET",
  1381. () => "/api/can_create_project"
  1382. );
  1383. const addApplicationToEnvGroup = baseApi<
  1384. {
  1385. name: string; // Env Group name
  1386. app_name: string;
  1387. },
  1388. { project_id: number; cluster_id: number; namespace: string }
  1389. >(
  1390. "POST",
  1391. ({ cluster_id, namespace, project_id }) =>
  1392. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/envgroup/add_application`
  1393. );
  1394. const removeApplicationFromEnvGroup = baseApi<
  1395. {
  1396. name: string; // Env Group name
  1397. app_name: string;
  1398. },
  1399. { project_id: number; cluster_id: number; namespace: string }
  1400. >(
  1401. "POST",
  1402. ({ cluster_id, namespace, project_id }) =>
  1403. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/envgroup/remove_application`
  1404. );
  1405. const provisionDatabase = baseApi<
  1406. {
  1407. username: string;
  1408. password: string;
  1409. machine_type: string;
  1410. db_storage_encrypted: boolean;
  1411. db_name: string;
  1412. db_max_allocated_storage: string;
  1413. db_family: string;
  1414. db_engine_version: string;
  1415. db_allocated_storage: string;
  1416. },
  1417. { project_id: number; cluster_id: number; namespace: string }
  1418. >(
  1419. "POST",
  1420. ({ project_id, cluster_id, namespace }) =>
  1421. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/provision/rds`
  1422. );
  1423. const getDatabases = baseApi<
  1424. {},
  1425. {
  1426. project_id: number;
  1427. cluster_id: number;
  1428. }
  1429. >(
  1430. "GET",
  1431. ({ project_id, cluster_id }) =>
  1432. `/api/projects/${project_id}/clusters/${cluster_id}/databases`
  1433. );
  1434. const getPreviousLogsForContainer = baseApi<
  1435. {
  1436. container_name: string;
  1437. },
  1438. {
  1439. project_id: number;
  1440. cluster_id: number;
  1441. namespace: string;
  1442. pod_name: string;
  1443. }
  1444. >(
  1445. "GET",
  1446. ({ cluster_id, namespace, pod_name: name, project_id }) =>
  1447. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/pod/${name}/previous_logs`
  1448. );
  1449. // Bundle export to allow default api import (api.<method> is more readable)
  1450. export default {
  1451. checkAuth,
  1452. connectECRRegistry,
  1453. connectGCRRegistry,
  1454. connectDORegistry,
  1455. getAWSIntegration,
  1456. getGCPIntegration,
  1457. createAWSIntegration,
  1458. overwriteAWSIntegration,
  1459. createEmailVerification,
  1460. createEnvironment,
  1461. deleteEnvironment,
  1462. listEnvironments,
  1463. createGCPIntegration,
  1464. createInvite,
  1465. createNamespace,
  1466. createPasswordReset,
  1467. createPasswordResetVerify,
  1468. createPasswordResetFinalize,
  1469. createProject,
  1470. createConfigMap,
  1471. deleteCluster,
  1472. deleteConfigMap,
  1473. deleteInvite,
  1474. deleteNamespace,
  1475. deletePod,
  1476. deleteProject,
  1477. deleteRegistryIntegration,
  1478. deleteSlackIntegration,
  1479. updateNotificationConfig,
  1480. getNotificationConfig,
  1481. createSubdomain,
  1482. deployTemplate,
  1483. deployAddon,
  1484. destroyInfra,
  1485. updateDatabaseStatus,
  1486. detectBuildpack,
  1487. getBranchContents,
  1488. getBranches,
  1489. getMetadata,
  1490. postWelcome,
  1491. getChart,
  1492. getCharts,
  1493. getChartComponents,
  1494. getChartControllers,
  1495. getClusterIntegrations,
  1496. getClusters,
  1497. getCluster,
  1498. getClusterNodes,
  1499. getClusterNode,
  1500. getConfigMap,
  1501. getPRDeploymentList,
  1502. getPRDeploymentByCluster,
  1503. getPRDeployment,
  1504. getGHAWorkflowTemplate,
  1505. getGitRepoList,
  1506. getGitRepoPermission,
  1507. getGitRepos,
  1508. getImageRepos,
  1509. getImageTags,
  1510. listInfraTemplates,
  1511. getInfraTemplate,
  1512. getInfra,
  1513. provisionInfra,
  1514. deleteInfra,
  1515. updateInfra,
  1516. listOperations,
  1517. getOperation,
  1518. getOperationLogs,
  1519. retryCreateInfra,
  1520. retryDeleteInfra,
  1521. getInfraState,
  1522. getInfraRawState,
  1523. getInfraByID,
  1524. getInfraDesired,
  1525. getInfraCurrent,
  1526. getIngress,
  1527. getInvites,
  1528. getJobs,
  1529. getJobStatus,
  1530. getJobPods,
  1531. getPodByName,
  1532. getMatchingPods,
  1533. getMetrics,
  1534. getNamespaces,
  1535. getNGINXIngresses,
  1536. getOAuthIds,
  1537. getPodEvents,
  1538. getProcfileContents,
  1539. getProjectClusters,
  1540. getProjectRegistries,
  1541. getProjectRepos,
  1542. getProjects,
  1543. getPrometheusIsInstalled,
  1544. getRegistryIntegrations,
  1545. getReleaseToken,
  1546. getReleaseSteps,
  1547. getRepoIntegrations,
  1548. getSlackIntegrations,
  1549. getRepos,
  1550. getRevisions,
  1551. getTemplateInfo,
  1552. getTemplateUpgradeNotes,
  1553. getTemplates,
  1554. getHelmRepos,
  1555. getChartsFromHelmRepo,
  1556. getChartInfoFromHelmRepo,
  1557. linkGithubProject,
  1558. getGithubAccounts,
  1559. listConfigMaps,
  1560. logInUser,
  1561. logOutUser,
  1562. registerUser,
  1563. rollbackChart,
  1564. uninstallTemplate,
  1565. updateUser,
  1566. renameConfigMap,
  1567. updateConfigMap,
  1568. upgradeChartValues,
  1569. deleteJob,
  1570. stopJob,
  1571. updateInvite,
  1572. listAPITokens,
  1573. getAPIToken,
  1574. revokeAPIToken,
  1575. createAPIToken,
  1576. createPolicy,
  1577. getAvailableRoles,
  1578. getCollaborators,
  1579. updateCollaborator,
  1580. removeCollaborator,
  1581. getPolicyDocument,
  1582. createWebhookToken,
  1583. getUsage,
  1584. getCustomerToken,
  1585. getHasBilling,
  1586. getOnboardingState,
  1587. saveOnboardingState,
  1588. getOnboardingInfra,
  1589. getOnboardingRegistry,
  1590. detectPorterAgent,
  1591. installPorterAgent,
  1592. getKubeEvents,
  1593. getKubeEvent,
  1594. getLogBuckets,
  1595. getLogBucketLogs,
  1596. getCanCreateProject,
  1597. createEnvGroup,
  1598. updateEnvGroup,
  1599. listEnvGroups,
  1600. getEnvGroup,
  1601. deleteEnvGroup,
  1602. addApplicationToEnvGroup,
  1603. removeApplicationFromEnvGroup,
  1604. provisionDatabase,
  1605. getDatabases,
  1606. getPreviousLogsForContainer,
  1607. };