api.tsx 27 KB

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