api.tsx 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237
  1. import { baseApi } from "./baseApi";
  2. import { FullActionConfigType, StorageType } from "./types";
  3. /**
  4. * Generic api call format
  5. * @param {string} token - Bearer token.
  6. * @param {Object} params - Body params.
  7. * @param {Object} pathParams - Path params.
  8. * @param {(err: Object, res: Object) => void} callback - Callback function.
  9. */
  10. const checkAuth = baseApi("GET", "/api/users/current");
  11. const connectECRRegistry = baseApi<
  12. {
  13. name: string;
  14. aws_integration_id: string;
  15. },
  16. { id: number }
  17. >("POST", (pathParams) => {
  18. return `/api/projects/${pathParams.id}/registries`;
  19. });
  20. const connectGCRRegistry = baseApi<
  21. {
  22. name: string;
  23. gcp_integration_id: string;
  24. url: string;
  25. },
  26. { id: number }
  27. >("POST", (pathParams) => {
  28. return `/api/projects/${pathParams.id}/registries`;
  29. });
  30. const connectDORegistry = baseApi<
  31. {
  32. name: string;
  33. do_integration_id: string;
  34. url: string;
  35. },
  36. { project_id: number }
  37. >("POST", (pathParams) => {
  38. return `/api/projects/${pathParams.project_id}/registries`;
  39. });
  40. const createAWSIntegration = baseApi<
  41. {
  42. aws_region: string;
  43. aws_cluster_id?: string;
  44. aws_access_key_id: string;
  45. aws_secret_access_key: string;
  46. },
  47. { id: number }
  48. >("POST", (pathParams) => {
  49. return `/api/projects/${pathParams.id}/integrations/aws`;
  50. });
  51. const overwriteAWSIntegration = baseApi<
  52. {
  53. aws_integration_id: number;
  54. aws_access_key_id: string;
  55. aws_secret_access_key: string;
  56. cluster_id: number;
  57. },
  58. {
  59. project_id: number;
  60. }
  61. >("POST", (pathParams) => {
  62. return `/api/projects/${pathParams.project_id}/integrations/aws/overwrite`;
  63. });
  64. const createDOCR = baseApi<
  65. {
  66. do_integration_id: number;
  67. docr_name: string;
  68. docr_subscription_tier: string;
  69. },
  70. {
  71. project_id: number;
  72. }
  73. >("POST", (pathParams) => {
  74. return `/api/projects/${pathParams.project_id}/provision/docr`;
  75. });
  76. const createDOKS = baseApi<
  77. {
  78. do_integration_id: number;
  79. doks_name: string;
  80. do_region: string;
  81. },
  82. {
  83. project_id: number;
  84. }
  85. >("POST", (pathParams) => {
  86. return `/api/projects/${pathParams.project_id}/provision/doks`;
  87. });
  88. const createEmailVerification = baseApi<{}, {}>("POST", (pathParams) => {
  89. return `/api/email/verify/initiate`;
  90. });
  91. const createGCPIntegration = baseApi<
  92. {
  93. gcp_region: string;
  94. gcp_key_data: string;
  95. gcp_project_id: string;
  96. },
  97. {
  98. project_id: number;
  99. }
  100. >("POST", (pathParams) => {
  101. return `/api/projects/${pathParams.project_id}/integrations/gcp`;
  102. });
  103. const createGCR = baseApi<
  104. {
  105. gcp_integration_id: number;
  106. },
  107. {
  108. project_id: number;
  109. }
  110. >("POST", (pathParams) => {
  111. return `/api/projects/${pathParams.project_id}/provision/gcr`;
  112. });
  113. const createGKE = baseApi<
  114. {
  115. gcp_integration_id: number;
  116. gke_name: string;
  117. },
  118. {
  119. project_id: number;
  120. }
  121. >("POST", (pathParams) => {
  122. return `/api/projects/${pathParams.project_id}/provision/gke`;
  123. });
  124. const createInvite = baseApi<
  125. {
  126. email: string;
  127. kind: string;
  128. },
  129. {
  130. id: number;
  131. }
  132. >("POST", (pathParams) => {
  133. return `/api/projects/${pathParams.id}/invites`;
  134. });
  135. const createPasswordReset = baseApi<
  136. {
  137. email: string;
  138. },
  139. {}
  140. >("POST", (pathParams) => {
  141. return `/api/password/reset/initiate`;
  142. });
  143. const createPasswordResetVerify = baseApi<
  144. {
  145. email: string;
  146. token: string;
  147. token_id: number;
  148. },
  149. {}
  150. >("POST", (pathParams) => {
  151. return `/api/password/reset/verify`;
  152. });
  153. const createPasswordResetFinalize = baseApi<
  154. {
  155. email: string;
  156. token: string;
  157. token_id: number;
  158. new_password: string;
  159. },
  160. {}
  161. >("POST", (pathParams) => {
  162. return `/api/password/reset/finalize`;
  163. });
  164. const createProject = baseApi<{ name: string }, {}>("POST", (pathParams) => {
  165. return `/api/projects`;
  166. });
  167. const createSubdomain = baseApi<
  168. {},
  169. {
  170. id: number;
  171. release_name: string;
  172. namespace: string;
  173. cluster_id: number;
  174. }
  175. >("POST", (pathParams) => {
  176. let { cluster_id, id, namespace, release_name } = pathParams;
  177. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/subdomain`;
  178. });
  179. const deleteCluster = baseApi<
  180. {},
  181. {
  182. project_id: number;
  183. cluster_id: number;
  184. }
  185. >("DELETE", (pathParams) => {
  186. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}`;
  187. });
  188. const deleteInvite = baseApi<{}, { id: number; invId: number }>(
  189. "DELETE",
  190. (pathParams) => {
  191. return `/api/projects/${pathParams.id}/invites/${pathParams.invId}`;
  192. }
  193. );
  194. const deletePod = baseApi<
  195. {},
  196. { name: string; namespace: string; id: number; cluster_id: number }
  197. >("DELETE", (pathParams) => {
  198. let { id, name, cluster_id, namespace } = pathParams;
  199. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/pods/${name}`;
  200. });
  201. const getPodEvents = baseApi<
  202. {},
  203. { name: string; namespace: string; id: number; cluster_id: number }
  204. >("GET", (pathParams) => {
  205. let { id, name, cluster_id, namespace } = pathParams;
  206. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/pods/${name}/events`;
  207. });
  208. const deleteProject = baseApi<{}, { id: number }>("DELETE", (pathParams) => {
  209. return `/api/projects/${pathParams.id}`;
  210. });
  211. const deleteRegistryIntegration = baseApi<
  212. {},
  213. {
  214. project_id: number;
  215. registry_id: number;
  216. }
  217. >("DELETE", (pathParams) => {
  218. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}`;
  219. });
  220. const deleteSlackIntegration = baseApi<
  221. {},
  222. {
  223. project_id: number;
  224. slack_integration_id: number;
  225. }
  226. >("DELETE", (pathParams) => {
  227. return `/api/projects/${pathParams.project_id}/slack_integrations/${pathParams.slack_integration_id}`;
  228. });
  229. const updateNotificationConfig = baseApi<
  230. {
  231. payload: any;
  232. },
  233. {
  234. project_id: number;
  235. cluster_id: number;
  236. namespace: string;
  237. name: string;
  238. }
  239. >("POST", (pathParams) => {
  240. let { project_id, cluster_id, namespace, name } = pathParams;
  241. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/notifications`;
  242. });
  243. const getNotificationConfig = baseApi<
  244. {},
  245. {
  246. project_id: number;
  247. cluster_id: number;
  248. namespace: string;
  249. name: string;
  250. }
  251. >("GET", (pathParams) => {
  252. let { project_id, cluster_id, namespace, name } = pathParams;
  253. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/notifications`;
  254. });
  255. const getGHAWorkflowTemplate = baseApi<
  256. {
  257. release_name: string;
  258. github_action_config: FullActionConfigType;
  259. },
  260. {
  261. cluster_id: number;
  262. project_id: number;
  263. namespace: string;
  264. }
  265. >("POST", (pathParams) => {
  266. const { cluster_id, project_id, namespace } = pathParams;
  267. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/gha_template`;
  268. });
  269. const deployTemplate = baseApi<
  270. {
  271. template_name: string;
  272. template_version: string;
  273. image_url?: string;
  274. values?: any;
  275. name: string;
  276. github_action_config?: FullActionConfigType;
  277. },
  278. {
  279. id: number;
  280. cluster_id: number;
  281. namespace: string;
  282. repo_url?: string;
  283. }
  284. >("POST", (pathParams) => {
  285. let { cluster_id, id, namespace, repo_url } = pathParams;
  286. if (repo_url) {
  287. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases?repo_url=${repo_url}`;
  288. }
  289. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases`;
  290. });
  291. const deployAddon = baseApi<
  292. {
  293. template_name: string;
  294. template_version: string;
  295. values?: any;
  296. name: string;
  297. },
  298. {
  299. id: number;
  300. cluster_id: number;
  301. namespace: string;
  302. repo_url?: string;
  303. }
  304. >("POST", (pathParams) => {
  305. let { cluster_id, id, namespace, repo_url } = pathParams;
  306. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/addons?repo_url=${repo_url}`;
  307. });
  308. const detectBuildpack = baseApi<
  309. {},
  310. {
  311. project_id: number;
  312. git_repo_id: number;
  313. kind: string;
  314. owner: string;
  315. name: string;
  316. branch: string;
  317. }
  318. >("GET", (pathParams) => {
  319. return `/api/projects/${pathParams.project_id}/gitrepos/${
  320. pathParams.git_repo_id
  321. }/repos/${pathParams.kind}/${pathParams.owner}/${
  322. pathParams.name
  323. }/${encodeURIComponent(pathParams.branch)}/buildpack/detect`;
  324. });
  325. const getBranchContents = baseApi<
  326. {
  327. dir: string;
  328. },
  329. {
  330. project_id: number;
  331. git_repo_id: number;
  332. kind: string;
  333. owner: string;
  334. name: string;
  335. branch: string;
  336. }
  337. >("GET", (pathParams) => {
  338. return `/api/projects/${pathParams.project_id}/gitrepos/${
  339. pathParams.git_repo_id
  340. }/repos/${pathParams.kind}/${pathParams.owner}/${
  341. pathParams.name
  342. }/${encodeURIComponent(pathParams.branch)}/contents`;
  343. });
  344. const getProcfileContents = baseApi<
  345. {
  346. path: string;
  347. },
  348. {
  349. project_id: number;
  350. git_repo_id: number;
  351. kind: string;
  352. owner: string;
  353. name: string;
  354. branch: string;
  355. }
  356. >("GET", (pathParams) => {
  357. return `/api/projects/${pathParams.project_id}/gitrepos/${
  358. pathParams.git_repo_id
  359. }/repos/${pathParams.kind}/${pathParams.owner}/${
  360. pathParams.name
  361. }/${encodeURIComponent(pathParams.branch)}/procfile`;
  362. });
  363. const getBranches = baseApi<
  364. {},
  365. {
  366. project_id: number;
  367. git_repo_id: number;
  368. kind: string;
  369. owner: string;
  370. name: string;
  371. }
  372. >("GET", (pathParams) => {
  373. return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id}/repos/${pathParams.kind}/${pathParams.owner}/${pathParams.name}/branches`;
  374. });
  375. const getChart = baseApi<
  376. {},
  377. {
  378. id: number;
  379. cluster_id: number;
  380. namespace: string;
  381. name: string;
  382. revision: number;
  383. }
  384. >("GET", (pathParams) => {
  385. let { id, cluster_id, namespace, name, revision } = pathParams;
  386. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}`;
  387. });
  388. const getCharts = baseApi<
  389. {
  390. limit: number;
  391. skip: number;
  392. byDate: boolean;
  393. statusFilter: string[];
  394. },
  395. {
  396. id: number;
  397. cluster_id: number;
  398. namespace: string;
  399. }
  400. >("GET", (pathParams) => {
  401. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/releases`;
  402. });
  403. const getChartComponents = baseApi<
  404. {},
  405. {
  406. id: number;
  407. cluster_id: number;
  408. namespace: string;
  409. name: string;
  410. revision: number;
  411. }
  412. >("GET", (pathParams) => {
  413. let { id, cluster_id, namespace, name, revision } = pathParams;
  414. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}/components`;
  415. });
  416. const getChartControllers = baseApi<
  417. {},
  418. {
  419. id: number;
  420. cluster_id: number;
  421. namespace: string;
  422. name: string;
  423. revision: number;
  424. }
  425. >("GET", (pathParams) => {
  426. let { id, cluster_id, namespace, name, revision } = pathParams;
  427. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}/controllers`;
  428. });
  429. const getClusterIntegrations = baseApi("GET", "/api/integrations/cluster");
  430. const getClusters = baseApi<{}, { id: number }>("GET", (pathParams) => {
  431. return `/api/projects/${pathParams.id}/clusters`;
  432. });
  433. const getCluster = baseApi<
  434. {},
  435. {
  436. project_id: number;
  437. cluster_id: number;
  438. }
  439. >("GET", (pathParams) => {
  440. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}`;
  441. });
  442. const getClusterNodes = baseApi<
  443. {},
  444. {
  445. project_id: number;
  446. cluster_id: number;
  447. }
  448. >("GET", (pathParams) => {
  449. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/nodes`;
  450. });
  451. const getClusterNode = baseApi<
  452. {},
  453. {
  454. project_id: number;
  455. cluster_id: number;
  456. nodeName: string;
  457. }
  458. >(
  459. "GET",
  460. (pathParams) =>
  461. `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/nodes/${pathParams.nodeName}`
  462. );
  463. const getGitRepoList = baseApi<
  464. {},
  465. {
  466. project_id: number;
  467. git_repo_id: number;
  468. }
  469. >("GET", (pathParams) => {
  470. return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id}/repos`;
  471. });
  472. const getGitRepos = baseApi<
  473. {},
  474. {
  475. project_id: number;
  476. }
  477. >("GET", (pathParams) => {
  478. return `/api/projects/${pathParams.project_id}/gitrepos`;
  479. });
  480. const getImageRepos = baseApi<
  481. {},
  482. {
  483. project_id: number;
  484. registry_id: number;
  485. }
  486. >("GET", (pathParams) => {
  487. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}/repositories`;
  488. });
  489. const getImageTags = baseApi<
  490. {},
  491. {
  492. project_id: number;
  493. registry_id: number;
  494. repo_name: string;
  495. }
  496. >("GET", (pathParams) => {
  497. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}/repositories/${pathParams.repo_name}`;
  498. });
  499. const getInfra = baseApi<
  500. {},
  501. {
  502. project_id: number;
  503. }
  504. >("GET", (pathParams) => {
  505. return `/api/projects/${pathParams.project_id}/infra`;
  506. });
  507. const getInfraDesired = baseApi<
  508. {},
  509. {
  510. project_id: number;
  511. infra_id: number;
  512. }
  513. >("GET", (pathParams) => {
  514. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/desired`;
  515. });
  516. const getInfraCurrent = baseApi<
  517. {},
  518. {
  519. project_id: number;
  520. infra_id: number;
  521. }
  522. >("GET", (pathParams) => {
  523. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/current`;
  524. });
  525. const getIngress = baseApi<
  526. {},
  527. { namespace: string; cluster_id: number; name: string; id: number }
  528. >("GET", (pathParams) => {
  529. let { id, name, cluster_id, namespace } = pathParams;
  530. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/ingresses/${name}`;
  531. });
  532. const getInvites = baseApi<{}, { id: number }>("GET", (pathParams) => {
  533. return `/api/projects/${pathParams.id}/invites`;
  534. });
  535. const getJobs = baseApi<
  536. {},
  537. { namespace: string; cluster_id: number; release_name: string; id: number }
  538. >("GET", (pathParams) => {
  539. let { id, release_name, cluster_id, namespace } = pathParams;
  540. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/jobs`;
  541. });
  542. const getJobStatus = baseApi<
  543. {},
  544. { namespace: string; cluster_id: number; release_name: string; id: number }
  545. >("GET", (pathParams) => {
  546. let { id, release_name, cluster_id, namespace } = pathParams;
  547. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/jobs/status`;
  548. });
  549. const getJobPods = baseApi<
  550. {},
  551. { name: string; namespace: string; id: number; cluster_id: number }
  552. >("GET", (pathParams) => {
  553. let { id, name, cluster_id, namespace } = pathParams;
  554. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}/pods`;
  555. });
  556. const getMatchingPods = baseApi<
  557. {
  558. namespace: string;
  559. selectors: string[];
  560. },
  561. { id: number; cluster_id: number }
  562. >("GET", (pathParams) => {
  563. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/pods`;
  564. });
  565. const getMetrics = baseApi<
  566. {
  567. metric: string;
  568. shouldsum: boolean;
  569. pods?: string[];
  570. kind?: string; // the controller kind
  571. name?: string;
  572. percentile?: number;
  573. namespace: string;
  574. startrange: number;
  575. endrange: number;
  576. resolution: string;
  577. },
  578. {
  579. id: number;
  580. cluster_id: number;
  581. }
  582. >("GET", (pathParams) => {
  583. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/metrics`;
  584. });
  585. const getNamespaces = baseApi<
  586. {},
  587. {
  588. id: number;
  589. cluster_id: number;
  590. }
  591. >("GET", (pathParams) => {
  592. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces`;
  593. });
  594. const getNGINXIngresses = baseApi<
  595. {},
  596. {
  597. id: number;
  598. cluster_id: number;
  599. }
  600. >("GET", (pathParams) => {
  601. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/prometheus/ingresses`;
  602. });
  603. const getOAuthIds = baseApi<
  604. {},
  605. {
  606. project_id: number;
  607. }
  608. >("GET", (pathParams) => {
  609. return `/api/projects/${pathParams.project_id}/integrations/oauth`;
  610. });
  611. const getProjectClusters = baseApi<{}, { id: number }>("GET", (pathParams) => {
  612. return `/api/projects/${pathParams.id}/clusters`;
  613. });
  614. const getProjectRegistries = baseApi<{}, { id: number }>(
  615. "GET",
  616. (pathParams) => {
  617. return `/api/projects/${pathParams.id}/registries`;
  618. }
  619. );
  620. const getProjectRepos = baseApi<{}, { id: number }>("GET", (pathParams) => {
  621. return `/api/projects/${pathParams.id}/repos`;
  622. });
  623. const getProjects = baseApi("GET", "/api/projects");
  624. const getPrometheusIsInstalled = baseApi<
  625. {},
  626. {
  627. id: number;
  628. cluster_id: number;
  629. }
  630. >("GET", (pathParams) => {
  631. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/prometheus/detect`;
  632. });
  633. const getRegistryIntegrations = baseApi("GET", "/api/integrations/registry");
  634. const getReleaseToken = baseApi<
  635. {},
  636. { name: string; id: number; namespace: string; cluster_id: number }
  637. >("GET", (pathParams) => {
  638. let { id, cluster_id, namespace, name } = pathParams;
  639. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/webhook`;
  640. });
  641. const getReleaseSteps = baseApi<
  642. {},
  643. { name: string; id: number; namespace: string; cluster_id: number }
  644. >("GET", (pathParams) => {
  645. let { id, cluster_id, namespace, name } = pathParams;
  646. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/steps`;
  647. });
  648. const destroyInfra = baseApi<
  649. {
  650. name: string;
  651. },
  652. {
  653. project_id: number;
  654. infra_id: number;
  655. }
  656. >("DELETE", (pathParams) => {
  657. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}`;
  658. });
  659. const getRepoIntegrations = baseApi("GET", "/api/integrations/repo");
  660. const getRepos = baseApi<{}, { id: number }>("GET", (pathParams) => {
  661. return `/api/projects/${pathParams.id}/repos`;
  662. });
  663. const getSlackIntegrations = baseApi<{}, { id: number }>(
  664. "GET",
  665. (pathParams) => {
  666. return `/api/projects/${pathParams.id}/slack_integrations`;
  667. }
  668. );
  669. const getRevisions = baseApi<
  670. {},
  671. { id: number; cluster_id: number; namespace: string; name: string }
  672. >("GET", (pathParams) => {
  673. let { id, cluster_id, namespace, name } = pathParams;
  674. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/history`;
  675. });
  676. const getTemplateInfo = baseApi<
  677. {
  678. repo_url?: string;
  679. },
  680. { name: string; version: string }
  681. >("GET", (pathParams) => {
  682. return `/api/templates/${pathParams.name}/${pathParams.version}`;
  683. });
  684. const getTemplateUpgradeNotes = baseApi<
  685. {
  686. repo_url?: string;
  687. prev_version: string;
  688. },
  689. { name: string; version: string }
  690. >("GET", (pathParams) => {
  691. return `/api/templates/${pathParams.name}/${pathParams.version}/upgrade_notes`;
  692. });
  693. const getTemplates = baseApi<
  694. {
  695. repo_url?: string;
  696. },
  697. {}
  698. >("GET", "/api/templates");
  699. const getMetadata = baseApi<{}, {}>("GET", () => {
  700. return `/api/metadata`;
  701. });
  702. const postWelcome = baseApi<{
  703. email: string;
  704. isCompany: boolean;
  705. company: string;
  706. role: string;
  707. }>("POST", () => {
  708. return `/api/welcome`;
  709. });
  710. const linkGithubProject = baseApi<
  711. {},
  712. {
  713. project_id: number;
  714. }
  715. >("GET", (pathParams) => {
  716. return `/api/oauth/projects/${pathParams.project_id}/github`;
  717. });
  718. const getGithubAccounts = baseApi<{}, {}>("GET", () => {
  719. return `/api/integrations/github-app/accounts`;
  720. });
  721. const logInUser = baseApi<{
  722. email: string;
  723. password: string;
  724. }>("POST", "/api/login");
  725. const logOutUser = baseApi("POST", "/api/logout");
  726. const provisionECR = baseApi<
  727. {
  728. ecr_name: string;
  729. aws_integration_id: string;
  730. },
  731. { id: number }
  732. >("POST", (pathParams) => {
  733. return `/api/projects/${pathParams.id}/provision/ecr`;
  734. });
  735. const provisionEKS = baseApi<
  736. {
  737. eks_name: string;
  738. aws_integration_id: string;
  739. machine_type: string;
  740. },
  741. { id: number }
  742. >("POST", (pathParams) => {
  743. return `/api/projects/${pathParams.id}/provision/eks`;
  744. });
  745. const registerUser = baseApi<{
  746. email: string;
  747. password: string;
  748. }>("POST", "/api/users");
  749. const rollbackChart = baseApi<
  750. {
  751. revision: number;
  752. },
  753. {
  754. id: number;
  755. name: string;
  756. namespace: string;
  757. cluster_id: number;
  758. }
  759. >("POST", (pathParams) => {
  760. let { id, name, cluster_id, namespace } = pathParams;
  761. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0/rollback`;
  762. });
  763. const uninstallTemplate = baseApi<
  764. {},
  765. {
  766. id: number;
  767. name: string;
  768. cluster_id: number;
  769. namespace: string;
  770. }
  771. >("DELETE", (pathParams) => {
  772. let { id, name, cluster_id, namespace } = pathParams;
  773. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0`;
  774. });
  775. const updateUser = baseApi<
  776. {
  777. rawKubeConfig?: string;
  778. allowedContexts?: string[];
  779. },
  780. { id: number }
  781. >("PUT", (pathParams) => {
  782. return `/api/users/${pathParams.id}`;
  783. });
  784. const upgradeChartValues = baseApi<
  785. {
  786. values: string;
  787. version?: string;
  788. },
  789. {
  790. id: number;
  791. name: string;
  792. namespace: string;
  793. cluster_id: number;
  794. }
  795. >("POST", (pathParams) => {
  796. let { id, name, cluster_id, namespace } = pathParams;
  797. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0/upgrade`;
  798. });
  799. const listConfigMaps = baseApi<
  800. {},
  801. {
  802. id: number;
  803. namespace: string;
  804. cluster_id: number;
  805. }
  806. >("GET", (pathParams) => {
  807. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/list`;
  808. });
  809. const getConfigMap = baseApi<
  810. {
  811. name: string;
  812. },
  813. {
  814. id: number;
  815. namespace: string;
  816. cluster_id: number;
  817. }
  818. >("GET", (pathParams) => {
  819. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap`;
  820. });
  821. const createConfigMap = baseApi<
  822. {
  823. name: string;
  824. variables: Record<string, string>;
  825. secret_variables?: Record<string, string>;
  826. },
  827. {
  828. id: number;
  829. cluster_id: number;
  830. namespace: string;
  831. }
  832. >("POST", (pathParams) => {
  833. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/create`;
  834. });
  835. const updateConfigMap = baseApi<
  836. {
  837. name: string;
  838. variables: Record<string, string>;
  839. secret_variables?: Record<string, string>;
  840. },
  841. {
  842. id: number;
  843. cluster_id: number;
  844. namespace: string;
  845. }
  846. >("POST", (pathParams) => {
  847. let { id, cluster_id } = pathParams;
  848. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/update`;
  849. });
  850. const renameConfigMap = baseApi<
  851. {
  852. name: string;
  853. new_name: string;
  854. },
  855. {
  856. id: number;
  857. cluster_id: number;
  858. namespace: string;
  859. }
  860. >("POST", (pathParams) => {
  861. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/rename`;
  862. });
  863. const deleteConfigMap = baseApi<
  864. {
  865. name: string;
  866. },
  867. {
  868. id: number;
  869. namespace: string;
  870. cluster_id: number;
  871. }
  872. >("DELETE", (pathParams) => {
  873. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/delete`;
  874. });
  875. const createNamespace = baseApi<
  876. {
  877. name: string;
  878. },
  879. { id: number; cluster_id: number }
  880. >("POST", (pathParams) => {
  881. let { id, cluster_id } = pathParams;
  882. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/create`;
  883. });
  884. const deleteNamespace = baseApi<
  885. {
  886. name: string;
  887. },
  888. {
  889. id: number;
  890. cluster_id: number;
  891. }
  892. >("DELETE", (pathParams) => {
  893. let { id, cluster_id } = pathParams;
  894. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/delete`;
  895. });
  896. const deleteJob = baseApi<
  897. {},
  898. { name: string; namespace: string; id: number; cluster_id: number }
  899. >("DELETE", (pathParams) => {
  900. let { id, name, cluster_id, namespace } = pathParams;
  901. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}`;
  902. });
  903. const stopJob = baseApi<
  904. {},
  905. { name: string; namespace: string; id: number; cluster_id: number }
  906. >("POST", (pathParams) => {
  907. let { id, name, namespace, cluster_id } = pathParams;
  908. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}/stop`;
  909. });
  910. const getAvailableRoles = baseApi<{}, { project_id: number }>(
  911. "GET",
  912. ({ project_id }) => `/api/projects/${project_id}/roles`
  913. );
  914. const updateInvite = baseApi<
  915. { kind: string },
  916. { project_id: number; invite_id: number }
  917. >(
  918. "POST",
  919. ({ project_id, invite_id }) =>
  920. `/api/projects/${project_id}/invites/${invite_id}`
  921. );
  922. const getCollaborators = baseApi<{}, { project_id: number }>(
  923. "GET",
  924. ({ project_id }) => `/api/projects/${project_id}/collaborators`
  925. );
  926. const updateCollaborator = baseApi<
  927. {
  928. kind: string;
  929. user_id: number;
  930. },
  931. { project_id: number }
  932. >("POST", ({ project_id }) => `/api/projects/${project_id}/roles`);
  933. const removeCollaborator = baseApi<{ user_id: number }, { project_id: number }>(
  934. "DELETE",
  935. ({ project_id }) => `/api/projects/${project_id}/roles`
  936. );
  937. const getPolicyDocument = baseApi<{}, { project_id: number }>(
  938. "GET",
  939. ({ project_id }) => `/api/projects/${project_id}/policy`
  940. );
  941. const createWebhookToken = baseApi<
  942. {},
  943. {
  944. project_id: number;
  945. chart_name: string;
  946. namespace: string;
  947. cluster_id: number;
  948. }
  949. >(
  950. "POST",
  951. ({ project_id, chart_name, namespace, cluster_id }) =>
  952. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${chart_name}/0/webhook`
  953. );
  954. const getUsage = baseApi<{}, { project_id: number }>(
  955. "GET",
  956. ({ project_id }) => `/api/projects/${project_id}/usage`
  957. );
  958. // Used for billing purposes
  959. const getCustomerToken = baseApi<{}, { project_id: number }>(
  960. "GET",
  961. ({ project_id }) => `/api/projects/${project_id}/billing/token`
  962. );
  963. const getHasBilling = baseApi<{}, { project_id: number }>(
  964. "GET",
  965. ({ project_id }) => `/api/projects/${project_id}/billing`
  966. );
  967. const getOnboardingState = baseApi<{}, { project_id: number }>(
  968. "GET",
  969. ({ project_id }) => `/api/projects/${project_id}/onboarding`
  970. );
  971. const saveOnboardingState = baseApi<{}, { project_id: number }>(
  972. "POST",
  973. ({ project_id }) => `/api/projects/${project_id}/onboarding`
  974. );
  975. const getOnboardingInfra = baseApi<
  976. {},
  977. { project_id: number; registry_infra_id: number }
  978. >(
  979. "GET",
  980. ({ project_id, registry_infra_id }) =>
  981. `/api/projects/${project_id}/infras/${registry_infra_id}`
  982. );
  983. const getOnboardingRegistry = baseApi<
  984. {},
  985. { project_id: number; registry_connection_id: number }
  986. >(
  987. "GET",
  988. ({ project_id, registry_connection_id }) =>
  989. `/api/projects/${project_id}/registries/${registry_connection_id}`
  990. );
  991. // Bundle export to allow default api import (api.<method> is more readable)
  992. export default {
  993. checkAuth,
  994. connectECRRegistry,
  995. connectGCRRegistry,
  996. connectDORegistry,
  997. createAWSIntegration,
  998. overwriteAWSIntegration,
  999. createDOCR,
  1000. createDOKS,
  1001. createEmailVerification,
  1002. createGCPIntegration,
  1003. createGCR,
  1004. createGKE,
  1005. createInvite,
  1006. createNamespace,
  1007. createPasswordReset,
  1008. createPasswordResetVerify,
  1009. createPasswordResetFinalize,
  1010. createProject,
  1011. createConfigMap,
  1012. deleteCluster,
  1013. deleteConfigMap,
  1014. deleteInvite,
  1015. deleteNamespace,
  1016. deletePod,
  1017. deleteProject,
  1018. deleteRegistryIntegration,
  1019. deleteSlackIntegration,
  1020. updateNotificationConfig,
  1021. getNotificationConfig,
  1022. createSubdomain,
  1023. deployTemplate,
  1024. deployAddon,
  1025. destroyInfra,
  1026. detectBuildpack,
  1027. getBranchContents,
  1028. getBranches,
  1029. getMetadata,
  1030. postWelcome,
  1031. getChart,
  1032. getCharts,
  1033. getChartComponents,
  1034. getChartControllers,
  1035. getClusterIntegrations,
  1036. getClusters,
  1037. getCluster,
  1038. getClusterNodes,
  1039. getClusterNode,
  1040. getConfigMap,
  1041. getGHAWorkflowTemplate,
  1042. getGitRepoList,
  1043. getGitRepos,
  1044. getImageRepos,
  1045. getImageTags,
  1046. getInfra,
  1047. getInfraDesired,
  1048. getInfraCurrent,
  1049. getIngress,
  1050. getInvites,
  1051. getJobs,
  1052. getJobStatus,
  1053. getJobPods,
  1054. getMatchingPods,
  1055. getMetrics,
  1056. getNamespaces,
  1057. getNGINXIngresses,
  1058. getOAuthIds,
  1059. getPodEvents,
  1060. getProcfileContents,
  1061. getProjectClusters,
  1062. getProjectRegistries,
  1063. getProjectRepos,
  1064. getProjects,
  1065. getPrometheusIsInstalled,
  1066. getRegistryIntegrations,
  1067. getReleaseToken,
  1068. getReleaseSteps,
  1069. getRepoIntegrations,
  1070. getSlackIntegrations,
  1071. getRepos,
  1072. getRevisions,
  1073. getTemplateInfo,
  1074. getTemplateUpgradeNotes,
  1075. getTemplates,
  1076. linkGithubProject,
  1077. getGithubAccounts,
  1078. listConfigMaps,
  1079. logInUser,
  1080. logOutUser,
  1081. provisionECR,
  1082. provisionEKS,
  1083. registerUser,
  1084. rollbackChart,
  1085. uninstallTemplate,
  1086. updateUser,
  1087. renameConfigMap,
  1088. updateConfigMap,
  1089. upgradeChartValues,
  1090. deleteJob,
  1091. stopJob,
  1092. updateInvite,
  1093. getAvailableRoles,
  1094. getCollaborators,
  1095. updateCollaborator,
  1096. removeCollaborator,
  1097. getPolicyDocument,
  1098. createWebhookToken,
  1099. getUsage,
  1100. getCustomerToken,
  1101. getHasBilling,
  1102. getOnboardingState,
  1103. saveOnboardingState,
  1104. getOnboardingInfra,
  1105. getOnboardingRegistry,
  1106. };