api.tsx 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152
  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. // Bundle export to allow default api import (api.<method> is more readable)
  927. export default {
  928. checkAuth,
  929. connectECRRegistry,
  930. connectGCRRegistry,
  931. createAWSIntegration,
  932. overwriteAWSIntegration,
  933. createDOCR,
  934. createDOKS,
  935. createEmailVerification,
  936. createGCPIntegration,
  937. createGCR,
  938. createGKE,
  939. createInvite,
  940. createNamespace,
  941. createPasswordReset,
  942. createPasswordResetVerify,
  943. createPasswordResetFinalize,
  944. createProject,
  945. createConfigMap,
  946. deleteCluster,
  947. deleteConfigMap,
  948. deleteInvite,
  949. deleteNamespace,
  950. deletePod,
  951. deleteProject,
  952. deleteRegistryIntegration,
  953. deleteSlackIntegration,
  954. updateNotificationConfig,
  955. getNotificationConfig,
  956. createSubdomain,
  957. deployTemplate,
  958. deployAddon,
  959. destroyInfra,
  960. detectBuildpack,
  961. getBranchContents,
  962. getBranches,
  963. getMetadata,
  964. postWelcome,
  965. getChart,
  966. getCharts,
  967. getChartComponents,
  968. getChartControllers,
  969. getClusterIntegrations,
  970. getClusters,
  971. getCluster,
  972. getClusterNodes,
  973. getClusterNode,
  974. getConfigMap,
  975. getGHAWorkflowTemplate,
  976. getGitRepoList,
  977. getGitRepos,
  978. getImageRepos,
  979. getImageTags,
  980. getInfra,
  981. getIngress,
  982. getInvites,
  983. getJobs,
  984. getJobStatus,
  985. getJobPods,
  986. getMatchingPods,
  987. getMetrics,
  988. getNamespaces,
  989. getNGINXIngresses,
  990. getOAuthIds,
  991. getPodEvents,
  992. getProcfileContents,
  993. getProjectClusters,
  994. getProjectRegistries,
  995. getProjectRepos,
  996. getProjects,
  997. getPrometheusIsInstalled,
  998. getRegistryIntegrations,
  999. getReleaseToken,
  1000. getReleaseSteps,
  1001. getRepoIntegrations,
  1002. getSlackIntegrations,
  1003. getRepos,
  1004. getRevisions,
  1005. getTemplateInfo,
  1006. getTemplateUpgradeNotes,
  1007. getTemplates,
  1008. linkGithubProject,
  1009. getGithubAccounts,
  1010. listConfigMaps,
  1011. logInUser,
  1012. logOutUser,
  1013. provisionECR,
  1014. provisionEKS,
  1015. registerUser,
  1016. rollbackChart,
  1017. uninstallTemplate,
  1018. updateUser,
  1019. renameConfigMap,
  1020. updateConfigMap,
  1021. upgradeChartValues,
  1022. deleteJob,
  1023. stopJob,
  1024. updateInvite,
  1025. getAvailableRoles,
  1026. getCollaborators,
  1027. updateCollaborator,
  1028. removeCollaborator,
  1029. getPolicyDocument,
  1030. createWebhookToken,
  1031. };