api.tsx 45 KB

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