api.tsx 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527
  1. import { PolicyDocType } from "./auth/types";
  2. import { PullRequest } from "main/home/cluster-dashboard/preview-environments/types";
  3. import { baseApi } from "./baseApi";
  4. import { BuildConfig, FullActionConfigType } from "./types";
  5. import {
  6. CreateStackBody,
  7. SourceConfig,
  8. } from "main/home/cluster-dashboard/stacks/types";
  9. /**
  10. * Generic api call format
  11. * @param {string} token - Bearer token.
  12. * @param {Object} params - Body params.
  13. * @param {Object} pathParams - Path params.
  14. * @param {(err: Object, res: Object) => void} callback - Callback function.
  15. */
  16. const checkAuth = baseApi("GET", "/api/users/current");
  17. const connectECRRegistry = baseApi<
  18. {
  19. name: string;
  20. aws_integration_id: string;
  21. },
  22. { id: number }
  23. >("POST", (pathParams) => {
  24. return `/api/projects/${pathParams.id}/registries`;
  25. });
  26. const connectGCRRegistry = baseApi<
  27. {
  28. name: string;
  29. gcp_integration_id: string;
  30. url: string;
  31. },
  32. { id: number }
  33. >("POST", (pathParams) => {
  34. return `/api/projects/${pathParams.id}/registries`;
  35. });
  36. const connectDORegistry = baseApi<
  37. {
  38. name: string;
  39. do_integration_id: string;
  40. url: string;
  41. },
  42. { project_id: number }
  43. >("POST", (pathParams) => {
  44. return `/api/projects/${pathParams.project_id}/registries`;
  45. });
  46. const getAWSIntegration = baseApi<{}, { project_id: number }>(
  47. "GET",
  48. ({ project_id }) => `/api/projects/${project_id}/integrations/aws`
  49. );
  50. const getGCPIntegration = baseApi<{}, { project_id: number }>(
  51. "GET",
  52. ({ project_id }) => `/api/projects/${project_id}/integrations/gcp`
  53. );
  54. const getAzureIntegration = baseApi<{}, { project_id: number }>(
  55. "GET",
  56. ({ project_id }) => `/api/projects/${project_id}/integrations/azure`
  57. );
  58. const getGitlabIntegration = baseApi<{}, { project_id: number }>(
  59. "GET",
  60. ({ project_id }) => `/api/projects/${project_id}/integrations/gitlab`
  61. );
  62. const createAWSIntegration = baseApi<
  63. {
  64. aws_region: string;
  65. aws_cluster_id?: string;
  66. aws_access_key_id: string;
  67. aws_secret_access_key: string;
  68. aws_assume_role_arn?: string;
  69. },
  70. { id: number }
  71. >("POST", (pathParams) => {
  72. return `/api/projects/${pathParams.id}/integrations/aws`;
  73. });
  74. const overwriteAWSIntegration = baseApi<
  75. {
  76. aws_integration_id: number;
  77. aws_access_key_id: string;
  78. aws_secret_access_key: string;
  79. cluster_id: number;
  80. },
  81. {
  82. project_id: number;
  83. }
  84. >("POST", (pathParams) => {
  85. return `/api/projects/${pathParams.project_id}/integrations/aws/overwrite`;
  86. });
  87. const updateCluster = baseApi<
  88. {
  89. name?: string;
  90. aws_cluster_id?: string;
  91. agent_integration_enabled?: boolean;
  92. preview_envs_enabled?: boolean;
  93. },
  94. {
  95. project_id: number;
  96. cluster_id: number;
  97. }
  98. >("POST", (pathParams) => {
  99. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}`;
  100. });
  101. const createAzureIntegration = baseApi<
  102. {
  103. azure_client_id: string;
  104. azure_subscription_id: string;
  105. azure_tenant_id: string;
  106. service_principal_key: string;
  107. },
  108. { id: number }
  109. >("POST", (pathParams) => {
  110. return `/api/projects/${pathParams.id}/integrations/azure`;
  111. });
  112. const createGitlabIntegration = baseApi<
  113. {
  114. instance_url: string;
  115. client_id: string;
  116. client_secret: string;
  117. },
  118. { id: number }
  119. >("POST", (pathParams) => {
  120. return `/api/projects/${pathParams.id}/integrations/gitlab`;
  121. });
  122. const createEmailVerification = baseApi<{}, {}>("POST", (pathParams) => {
  123. return `/api/email/verify/initiate`;
  124. });
  125. const createEnvironment = baseApi<
  126. {
  127. name: string;
  128. mode: "auto" | "manual";
  129. disable_new_comments: boolean;
  130. git_repo_branches: string[];
  131. namespace_labels: Record<string, string>;
  132. },
  133. {
  134. project_id: number;
  135. cluster_id: number;
  136. git_installation_id: number;
  137. git_repo_owner: string;
  138. git_repo_name: string;
  139. }
  140. >("POST", (pathParams) => {
  141. let {
  142. project_id,
  143. cluster_id,
  144. git_installation_id,
  145. git_repo_owner,
  146. git_repo_name,
  147. } = pathParams;
  148. return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${git_repo_owner}/${git_repo_name}/clusters/${cluster_id}/environment`;
  149. });
  150. const updateEnvironment = baseApi<
  151. {
  152. mode: "auto" | "manual";
  153. disable_new_comments: boolean;
  154. git_repo_branches: string[]; // Array with branch names
  155. namespace_labels: Record<string, string>;
  156. },
  157. {
  158. project_id: number;
  159. cluster_id: number;
  160. environment_id: number;
  161. }
  162. >(
  163. "PATCH",
  164. ({ project_id, cluster_id, environment_id }) =>
  165. `/api/projects/${project_id}/clusters/${cluster_id}/environments/${environment_id}/settings`
  166. );
  167. const deleteEnvironment = baseApi<
  168. {
  169. name: string;
  170. },
  171. {
  172. project_id: number;
  173. cluster_id: number;
  174. git_installation_id: number;
  175. git_repo_owner: string;
  176. git_repo_name: string;
  177. }
  178. >("DELETE", (pathParams) => {
  179. let {
  180. project_id,
  181. cluster_id,
  182. git_installation_id,
  183. git_repo_owner,
  184. git_repo_name,
  185. } = pathParams;
  186. return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${git_repo_owner}/${git_repo_name}/clusters/${cluster_id}/environment`;
  187. });
  188. const createPreviewEnvironmentDeployment = baseApi<
  189. PullRequest,
  190. { project_id: number; cluster_id: number }
  191. >(
  192. "POST",
  193. ({ project_id, cluster_id }) =>
  194. `/api/projects/${project_id}/clusters/${cluster_id}/deployments/pull_request`
  195. );
  196. const reenablePreviewEnvironmentDeployment = baseApi<
  197. {},
  198. {
  199. project_id: number;
  200. cluster_id: number;
  201. deployment_id: number;
  202. }
  203. >(
  204. "PATCH",
  205. ({ project_id, cluster_id, deployment_id }) =>
  206. `/api/projects/${project_id}/clusters/${cluster_id}/deployments/${deployment_id}/reenable`
  207. );
  208. const listEnvironments = baseApi<
  209. {},
  210. {
  211. project_id: number;
  212. cluster_id: number;
  213. }
  214. >("GET", (pathParams) => {
  215. let { project_id, cluster_id } = pathParams;
  216. return `/api/projects/${project_id}/clusters/${cluster_id}/environments`;
  217. });
  218. const getEnvironment = baseApi<
  219. {},
  220. {
  221. project_id: number;
  222. cluster_id: number;
  223. environment_id: number;
  224. }
  225. >("GET", (pathParams) => {
  226. let { project_id, cluster_id, environment_id } = pathParams;
  227. return `/api/projects/${project_id}/clusters/${cluster_id}/environments/${environment_id}`;
  228. });
  229. const toggleNewCommentForEnvironment = baseApi<
  230. {
  231. disable: boolean;
  232. },
  233. {
  234. project_id: number;
  235. cluster_id: number;
  236. environment_id: number;
  237. }
  238. >("PATCH", (pathParams) => {
  239. let { project_id, cluster_id, environment_id } = pathParams;
  240. return `/api/projects/${project_id}/clusters/${cluster_id}/environments/${environment_id}/toggle_new_comment`;
  241. });
  242. const validatePorterYAML = baseApi<
  243. {
  244. branch?: string;
  245. },
  246. {
  247. project_id: number;
  248. cluster_id: number;
  249. environment_id: number;
  250. }
  251. >("GET", (pathParams) => {
  252. const { project_id, cluster_id, environment_id } = pathParams;
  253. return `/api/projects/${project_id}/clusters/${cluster_id}/environments/${environment_id}/validate_porter_yaml`;
  254. });
  255. const createGCPIntegration = baseApi<
  256. {
  257. gcp_key_data: string;
  258. gcp_project_id: string;
  259. },
  260. {
  261. project_id: number;
  262. }
  263. >("POST", (pathParams) => {
  264. return `/api/projects/${pathParams.project_id}/integrations/gcp`;
  265. });
  266. const createInvite = baseApi<
  267. {
  268. email: string;
  269. kind: string;
  270. },
  271. {
  272. id: number;
  273. }
  274. >("POST", (pathParams) => {
  275. return `/api/projects/${pathParams.id}/invites`;
  276. });
  277. const createPasswordReset = baseApi<
  278. {
  279. email: string;
  280. },
  281. {}
  282. >("POST", (pathParams) => {
  283. return `/api/password/reset/initiate`;
  284. });
  285. const createPasswordResetVerify = baseApi<
  286. {
  287. email: string;
  288. token: string;
  289. token_id: number;
  290. },
  291. {}
  292. >("POST", (pathParams) => {
  293. return `/api/password/reset/verify`;
  294. });
  295. const createPasswordResetFinalize = baseApi<
  296. {
  297. email: string;
  298. token: string;
  299. token_id: number;
  300. new_password: string;
  301. },
  302. {}
  303. >("POST", (pathParams) => {
  304. return `/api/password/reset/finalize`;
  305. });
  306. const createProject = baseApi<{ name: string }, {}>("POST", (pathParams) => {
  307. return `/api/projects`;
  308. });
  309. const createSubdomain = baseApi<
  310. {},
  311. {
  312. id: number;
  313. release_name: string;
  314. namespace: string;
  315. cluster_id: number;
  316. }
  317. >("POST", (pathParams) => {
  318. let { cluster_id, id, namespace, release_name } = pathParams;
  319. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/subdomain`;
  320. });
  321. const deleteCluster = baseApi<
  322. {},
  323. {
  324. project_id: number;
  325. cluster_id: number;
  326. }
  327. >("DELETE", (pathParams) => {
  328. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}`;
  329. });
  330. const deleteInvite = baseApi<{}, { id: number; invId: number }>(
  331. "DELETE",
  332. (pathParams) => {
  333. return `/api/projects/${pathParams.id}/invites/${pathParams.invId}`;
  334. }
  335. );
  336. const deletePod = baseApi<
  337. {},
  338. { name: string; namespace: string; id: number; cluster_id: number }
  339. >("DELETE", (pathParams) => {
  340. let { id, name, cluster_id, namespace } = pathParams;
  341. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/pods/${name}`;
  342. });
  343. const getPodEvents = baseApi<
  344. {},
  345. { name: string; namespace: string; id: number; cluster_id: number }
  346. >("GET", (pathParams) => {
  347. let { id, name, cluster_id, namespace } = pathParams;
  348. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/pods/${name}/events`;
  349. });
  350. const deleteProject = baseApi<{}, { id: number }>("DELETE", (pathParams) => {
  351. return `/api/projects/${pathParams.id}`;
  352. });
  353. const deleteRegistryIntegration = baseApi<
  354. {},
  355. {
  356. project_id: number;
  357. registry_id: number;
  358. }
  359. >("DELETE", (pathParams) => {
  360. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}`;
  361. });
  362. const deleteSlackIntegration = baseApi<
  363. {},
  364. {
  365. project_id: number;
  366. slack_integration_id: number;
  367. }
  368. >("DELETE", (pathParams) => {
  369. return `/api/projects/${pathParams.project_id}/slack_integrations/${pathParams.slack_integration_id}`;
  370. });
  371. const updateNotificationConfig = baseApi<
  372. {
  373. payload: any;
  374. },
  375. {
  376. project_id: number;
  377. cluster_id: number;
  378. namespace: string;
  379. name: string;
  380. }
  381. >("POST", (pathParams) => {
  382. let { project_id, cluster_id, namespace, name } = pathParams;
  383. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/notifications`;
  384. });
  385. const getPRDeploymentList = baseApi<
  386. {
  387. environment_id?: number;
  388. },
  389. {
  390. cluster_id: number;
  391. project_id: number;
  392. }
  393. >("GET", (pathParams) => {
  394. const { cluster_id, project_id } = pathParams;
  395. return `/api/projects/${project_id}/clusters/${cluster_id}/deployments`;
  396. });
  397. const getPRDeploymentByID = baseApi<
  398. {
  399. id: number;
  400. },
  401. {
  402. cluster_id: number;
  403. project_id: number;
  404. environment_id: number;
  405. }
  406. >("GET", (pathParams) => {
  407. const { cluster_id, project_id, environment_id } = pathParams;
  408. return `/api/projects/${project_id}/clusters/${cluster_id}/environments/${environment_id}/deployment`;
  409. });
  410. // TODO (soham): Check if we are really using this?
  411. // const getPRDeployment = baseApi<
  412. // {
  413. // namespace: string;
  414. // },
  415. // {
  416. // cluster_id: number;
  417. // project_id: number;
  418. // git_installation_id: number;
  419. // git_repo_owner: string;
  420. // git_repo_name: string;
  421. // }
  422. // >("GET", (pathParams) => {
  423. // const {
  424. // cluster_id,
  425. // project_id,
  426. // git_installation_id,
  427. // git_repo_owner,
  428. // git_repo_name,
  429. // } = pathParams;
  430. // return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${git_repo_owner}/${git_repo_name}/clusters/${cluster_id}/deployment`;
  431. // });
  432. const deletePRDeployment = baseApi<
  433. {},
  434. {
  435. cluster_id: number;
  436. project_id: number;
  437. deployment_id: number;
  438. }
  439. >("DELETE", (pathParams) => {
  440. const { cluster_id, project_id, deployment_id } = pathParams;
  441. return `/api/projects/${project_id}/clusters/${cluster_id}/deployments/${deployment_id}`;
  442. });
  443. const getNotificationConfig = baseApi<
  444. {},
  445. {
  446. project_id: number;
  447. cluster_id: number;
  448. namespace: string;
  449. name: string;
  450. }
  451. >("GET", (pathParams) => {
  452. let { project_id, cluster_id, namespace, name } = pathParams;
  453. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/notifications`;
  454. });
  455. const getGHAWorkflowTemplate = baseApi<
  456. {
  457. release_name: string;
  458. github_action_config: FullActionConfigType;
  459. },
  460. {
  461. cluster_id: number;
  462. project_id: number;
  463. namespace: string;
  464. }
  465. >("POST", (pathParams) => {
  466. const { cluster_id, project_id, namespace } = pathParams;
  467. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/gha_template`;
  468. });
  469. const deployTemplate = baseApi<
  470. {
  471. template_name: string;
  472. template_version: string;
  473. image_url?: string;
  474. values?: any;
  475. name: string;
  476. git_action_config?: FullActionConfigType;
  477. build_config?: any;
  478. synced_env_groups?: string[];
  479. },
  480. {
  481. id: number;
  482. cluster_id: number;
  483. namespace: string;
  484. repo_url?: string;
  485. }
  486. >("POST", (pathParams) => {
  487. let { cluster_id, id, namespace, repo_url } = pathParams;
  488. if (repo_url) {
  489. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases?repo_url=${repo_url}`;
  490. }
  491. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases`;
  492. });
  493. const deployAddon = baseApi<
  494. {
  495. template_name: string;
  496. template_version: string;
  497. values?: any;
  498. name: string;
  499. },
  500. {
  501. id: number;
  502. cluster_id: number;
  503. namespace: string;
  504. repo_url?: string;
  505. }
  506. >("POST", (pathParams) => {
  507. let { cluster_id, id, namespace, repo_url } = pathParams;
  508. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/addons?repo_url=${repo_url}`;
  509. });
  510. const detectBuildpack = baseApi<
  511. {},
  512. {
  513. project_id: number;
  514. git_repo_id: number;
  515. kind: string;
  516. owner: string;
  517. name: string;
  518. branch: string;
  519. }
  520. >("GET", (pathParams) => {
  521. return `/api/projects/${pathParams.project_id}/gitrepos/${
  522. pathParams.git_repo_id
  523. }/repos/${pathParams.kind}/${pathParams.owner}/${
  524. pathParams.name
  525. }/${encodeURIComponent(pathParams.branch)}/buildpack/detect`;
  526. });
  527. const detectGitlabBuildpack = baseApi<
  528. { dir: string },
  529. {
  530. project_id: number;
  531. integration_id: number;
  532. repo_owner: string;
  533. repo_name: string;
  534. branch: string;
  535. }
  536. >(
  537. "GET",
  538. ({ project_id, integration_id, repo_name, repo_owner, branch }) =>
  539. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos/${repo_owner}/${repo_name}/${branch}/buildpack/detect`
  540. );
  541. const getBranchContents = baseApi<
  542. {
  543. dir: string;
  544. },
  545. {
  546. project_id: number;
  547. git_repo_id: number;
  548. kind: string;
  549. owner: string;
  550. name: string;
  551. branch: string;
  552. }
  553. >("GET", (pathParams) => {
  554. return `/api/projects/${pathParams.project_id}/gitrepos/${
  555. pathParams.git_repo_id
  556. }/repos/${pathParams.kind}/${pathParams.owner}/${
  557. pathParams.name
  558. }/${encodeURIComponent(pathParams.branch)}/contents`;
  559. });
  560. const getProcfileContents = baseApi<
  561. {
  562. path: string;
  563. },
  564. {
  565. project_id: number;
  566. git_repo_id: number;
  567. kind: string;
  568. owner: string;
  569. name: string;
  570. branch: string;
  571. }
  572. >("GET", (pathParams) => {
  573. return `/api/projects/${pathParams.project_id}/gitrepos/${
  574. pathParams.git_repo_id
  575. }/repos/${pathParams.kind}/${pathParams.owner}/${
  576. pathParams.name
  577. }/${encodeURIComponent(pathParams.branch)}/procfile`;
  578. });
  579. const getGitlabProcfileContents = baseApi<
  580. {
  581. path: string;
  582. },
  583. {
  584. project_id: number;
  585. integration_id: number;
  586. owner: string;
  587. name: string;
  588. branch: string;
  589. }
  590. >(
  591. "GET",
  592. ({ project_id, integration_id, owner, name, branch }) =>
  593. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos/${owner}/${name}/${encodeURIComponent(
  594. branch
  595. )}/procfile`
  596. );
  597. const getBranches = baseApi<
  598. {},
  599. {
  600. project_id: number;
  601. git_repo_id: number;
  602. kind: string;
  603. owner: string;
  604. name: string;
  605. }
  606. >("GET", (pathParams) => {
  607. return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id}/repos/${pathParams.kind}/${pathParams.owner}/${pathParams.name}/branches`;
  608. });
  609. const getChart = baseApi<
  610. {},
  611. {
  612. id: number;
  613. cluster_id: number;
  614. namespace: string;
  615. name: string;
  616. revision: number;
  617. }
  618. >("GET", (pathParams) => {
  619. let { id, cluster_id, namespace, name, revision } = pathParams;
  620. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}`;
  621. });
  622. const getCharts = baseApi<
  623. {
  624. limit: number;
  625. skip: number;
  626. byDate: boolean;
  627. statusFilter: string[];
  628. },
  629. {
  630. id: number;
  631. cluster_id: number;
  632. namespace: string;
  633. }
  634. >("GET", (pathParams) => {
  635. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/releases`;
  636. });
  637. const getChartComponents = baseApi<
  638. {},
  639. {
  640. id: number;
  641. cluster_id: number;
  642. namespace: string;
  643. name: string;
  644. revision: number;
  645. }
  646. >("GET", (pathParams) => {
  647. let { id, cluster_id, namespace, name, revision } = pathParams;
  648. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}/components`;
  649. });
  650. const getChartControllers = baseApi<
  651. {},
  652. {
  653. id: number;
  654. cluster_id: number;
  655. namespace: string;
  656. name: string;
  657. revision: number;
  658. }
  659. >("GET", (pathParams) => {
  660. let { id, cluster_id, namespace, name, revision } = pathParams;
  661. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}/controllers`;
  662. });
  663. const getClusterIntegrations = baseApi("GET", "/api/integrations/cluster");
  664. const getClusters = baseApi<{}, { id: number }>("GET", (pathParams) => {
  665. return `/api/projects/${pathParams.id}/clusters`;
  666. });
  667. const getCluster = baseApi<
  668. {},
  669. {
  670. project_id: number;
  671. cluster_id: number;
  672. }
  673. >("GET", (pathParams) => {
  674. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}`;
  675. });
  676. const getClusterNodes = baseApi<
  677. {},
  678. {
  679. project_id: number;
  680. cluster_id: number;
  681. }
  682. >("GET", (pathParams) => {
  683. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/nodes`;
  684. });
  685. const getClusterNode = baseApi<
  686. {},
  687. {
  688. project_id: number;
  689. cluster_id: number;
  690. nodeName: string;
  691. }
  692. >(
  693. "GET",
  694. (pathParams) =>
  695. `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/nodes/${pathParams.nodeName}`
  696. );
  697. const getGitRepoList = baseApi<
  698. {},
  699. {
  700. project_id: number;
  701. git_repo_id: number;
  702. }
  703. >("GET", (pathParams) => {
  704. return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id}/repos`;
  705. });
  706. const getGitRepoPermission = baseApi<
  707. {},
  708. {
  709. project_id: number;
  710. git_repo_id: number;
  711. }
  712. >("GET", (pathParams) => {
  713. return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id}/permissions`;
  714. });
  715. const getGitRepos = baseApi<
  716. {},
  717. {
  718. project_id: number;
  719. }
  720. >("GET", (pathParams) => {
  721. return `/api/projects/${pathParams.project_id}/gitrepos`;
  722. });
  723. const getImageRepos = baseApi<
  724. {},
  725. {
  726. project_id: number;
  727. registry_id: number;
  728. }
  729. >("GET", (pathParams) => {
  730. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}/repositories`;
  731. });
  732. const getImageTags = baseApi<
  733. {},
  734. {
  735. project_id: number;
  736. registry_id: number;
  737. repo_name: string;
  738. }
  739. >("GET", (pathParams) => {
  740. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}/repositories/${pathParams.repo_name}`;
  741. });
  742. const getInfra = baseApi<
  743. {
  744. version?: string;
  745. },
  746. {
  747. project_id: number;
  748. }
  749. >("GET", (pathParams) => {
  750. return `/api/projects/${pathParams.project_id}/infra`;
  751. });
  752. const listInfraTemplates = baseApi<
  753. {},
  754. {
  755. project_id: number;
  756. }
  757. >("GET", (pathParams) => {
  758. return `/api/projects/${pathParams.project_id}/infras/templates`;
  759. });
  760. const getInfraTemplate = baseApi<
  761. {},
  762. {
  763. project_id: number;
  764. name: string;
  765. version: string;
  766. }
  767. >("GET", (pathParams) => {
  768. let { project_id, name, version } = pathParams;
  769. return `/api/projects/${project_id}/infras/templates/${name}/${version}`;
  770. });
  771. const provisionInfra = baseApi<
  772. {
  773. kind: string;
  774. values: any;
  775. aws_integration_id?: number;
  776. gcp_integration_id?: number;
  777. do_integration_id?: number;
  778. azure_integration_id?: number;
  779. cluster_id?: number;
  780. },
  781. {
  782. project_id: number;
  783. }
  784. >("POST", ({ project_id }) => {
  785. return `/api/projects/${project_id}/infras`;
  786. });
  787. const updateInfra = baseApi<
  788. {
  789. values?: any;
  790. },
  791. {
  792. project_id: number;
  793. infra_id: number;
  794. }
  795. >("POST", (pathParams) => {
  796. let { project_id, infra_id } = pathParams;
  797. return `/api/projects/${project_id}/infras/${infra_id}/update`;
  798. });
  799. const retryCreateInfra = baseApi<
  800. {
  801. aws_integration_id?: number;
  802. gcp_integration_id?: number;
  803. do_integration_id?: number;
  804. values?: any;
  805. },
  806. {
  807. project_id: number;
  808. infra_id: number;
  809. }
  810. >("POST", (pathParams) => {
  811. let { project_id, infra_id } = pathParams;
  812. return `/api/projects/${project_id}/infras/${infra_id}/retry_create`;
  813. });
  814. const retryDeleteInfra = baseApi<
  815. {
  816. values?: any;
  817. },
  818. {
  819. project_id: number;
  820. infra_id: number;
  821. }
  822. >("POST", (pathParams) => {
  823. let { project_id, infra_id } = pathParams;
  824. return `/api/projects/${project_id}/infras/${infra_id}/retry_delete`;
  825. });
  826. const deleteInfra = baseApi<
  827. {},
  828. {
  829. project_id: number;
  830. infra_id: number;
  831. }
  832. >("DELETE", (pathParams) => {
  833. let { project_id, infra_id } = pathParams;
  834. return `/api/projects/${project_id}/infras/${infra_id}`;
  835. });
  836. const listOperations = baseApi<
  837. {},
  838. {
  839. project_id: number;
  840. infra_id: number;
  841. }
  842. >("GET", (pathParams) => {
  843. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/operations`;
  844. });
  845. const getOperation = baseApi<
  846. {},
  847. {
  848. project_id: number;
  849. infra_id: number;
  850. operation_id: string;
  851. }
  852. >("GET", (pathParams) => {
  853. let { project_id, infra_id, operation_id } = pathParams;
  854. return `/api/projects/${project_id}/infras/${infra_id}/operations/${operation_id}`;
  855. });
  856. const getOperationLogs = baseApi<
  857. {},
  858. {
  859. project_id: number;
  860. infra_id: number;
  861. operation_id: string;
  862. }
  863. >("GET", (pathParams) => {
  864. let { project_id, infra_id, operation_id } = pathParams;
  865. return `/api/projects/${project_id}/infras/${infra_id}/operations/${operation_id}/logs`;
  866. });
  867. const getInfraState = baseApi<
  868. {},
  869. {
  870. project_id: number;
  871. infra_id: number;
  872. }
  873. >("GET", (pathParams) => {
  874. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/state`;
  875. });
  876. const getInfraRawState = baseApi<
  877. {},
  878. {
  879. project_id: number;
  880. infra_id: number;
  881. }
  882. >("GET", (pathParams) => {
  883. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/raw_state`;
  884. });
  885. const getInfraByID = baseApi<
  886. {},
  887. {
  888. project_id: number;
  889. infra_id: number;
  890. }
  891. >("GET", (pathParams) => {
  892. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}`;
  893. });
  894. const getInfraDesired = baseApi<
  895. {},
  896. {
  897. project_id: number;
  898. infra_id: number;
  899. }
  900. >("GET", (pathParams) => {
  901. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/desired`;
  902. });
  903. const getInfraCurrent = baseApi<
  904. {},
  905. {
  906. project_id: number;
  907. infra_id: number;
  908. }
  909. >("GET", (pathParams) => {
  910. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/current`;
  911. });
  912. const getIngress = baseApi<
  913. {},
  914. { namespace: string; cluster_id: number; name: string; id: number }
  915. >("GET", (pathParams) => {
  916. let { id, name, cluster_id, namespace } = pathParams;
  917. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/ingresses/${name}`;
  918. });
  919. const getInvites = baseApi<{}, { id: number }>("GET", (pathParams) => {
  920. return `/api/projects/${pathParams.id}/invites`;
  921. });
  922. const getJobs = baseApi<
  923. {},
  924. { namespace: string; cluster_id: number; release_name: string; id: number }
  925. >("GET", (pathParams) => {
  926. let { id, release_name, cluster_id, namespace } = pathParams;
  927. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/jobs`;
  928. });
  929. const getJobStatus = baseApi<
  930. {},
  931. { namespace: string; cluster_id: number; release_name: string; id: number }
  932. >("GET", (pathParams) => {
  933. let { id, release_name, cluster_id, namespace } = pathParams;
  934. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/jobs/status`;
  935. });
  936. const getJobPods = baseApi<
  937. {},
  938. { name: string; namespace: string; id: number; cluster_id: number }
  939. >("GET", (pathParams) => {
  940. let { id, name, cluster_id, namespace } = pathParams;
  941. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}/pods`;
  942. });
  943. const getPodByName = baseApi<
  944. {},
  945. {
  946. project_id: number;
  947. cluster_id: number;
  948. namespace: string;
  949. name: string;
  950. }
  951. >(
  952. "GET",
  953. ({ project_id, cluster_id, namespace, name }) =>
  954. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/pods/${name}`
  955. );
  956. const getMatchingPods = baseApi<
  957. {
  958. namespace: string;
  959. selectors: string[];
  960. },
  961. { id: number; cluster_id: number }
  962. >("GET", (pathParams) => {
  963. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/pods`;
  964. });
  965. const getAllReleasePods = baseApi<
  966. {},
  967. {
  968. id: number;
  969. name: string;
  970. namespace: string;
  971. cluster_id: number;
  972. }
  973. >("GET", (pathParams) => {
  974. const { id, name, cluster_id, namespace } = pathParams;
  975. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0/pods/all`;
  976. });
  977. const getMetrics = baseApi<
  978. {
  979. metric: string;
  980. shouldsum: boolean;
  981. pods?: string[];
  982. kind?: string; // the controller kind
  983. name?: string;
  984. percentile?: number;
  985. namespace: string;
  986. startrange: number;
  987. endrange: number;
  988. resolution: string;
  989. },
  990. {
  991. id: number;
  992. cluster_id: number;
  993. }
  994. >("GET", (pathParams) => {
  995. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/metrics`;
  996. });
  997. const getNamespaces = baseApi<
  998. {},
  999. {
  1000. id: number;
  1001. cluster_id: number;
  1002. }
  1003. >("GET", (pathParams) => {
  1004. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces`;
  1005. });
  1006. const getNGINXIngresses = baseApi<
  1007. {},
  1008. {
  1009. id: number;
  1010. cluster_id: number;
  1011. }
  1012. >("GET", (pathParams) => {
  1013. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/prometheus/ingresses`;
  1014. });
  1015. const getOAuthIds = baseApi<
  1016. {},
  1017. {
  1018. project_id: number;
  1019. }
  1020. >("GET", (pathParams) => {
  1021. return `/api/projects/${pathParams.project_id}/integrations/oauth`;
  1022. });
  1023. const getProjectClusters = baseApi<{}, { id: number }>("GET", (pathParams) => {
  1024. return `/api/projects/${pathParams.id}/clusters`;
  1025. });
  1026. const getProjectRegistries = baseApi<{}, { id: number }>(
  1027. "GET",
  1028. (pathParams) => {
  1029. return `/api/projects/${pathParams.id}/registries`;
  1030. }
  1031. );
  1032. const getProjectRepos = baseApi<{}, { id: number }>("GET", (pathParams) => {
  1033. return `/api/projects/${pathParams.id}/repos`;
  1034. });
  1035. const getProjects = baseApi("GET", "/api/projects");
  1036. const getPrometheusIsInstalled = baseApi<
  1037. {},
  1038. {
  1039. id: number;
  1040. cluster_id: number;
  1041. }
  1042. >("GET", (pathParams) => {
  1043. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/prometheus/detect`;
  1044. });
  1045. const getRegistryIntegrations = baseApi("GET", "/api/integrations/registry");
  1046. const getReleaseToken = baseApi<
  1047. {},
  1048. { name: string; id: number; namespace: string; cluster_id: number }
  1049. >("GET", (pathParams) => {
  1050. let { id, cluster_id, namespace, name } = pathParams;
  1051. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/webhook`;
  1052. });
  1053. const getReleaseSteps = baseApi<
  1054. {},
  1055. { name: string; id: number; namespace: string; cluster_id: number }
  1056. >("GET", (pathParams) => {
  1057. let { id, cluster_id, namespace, name } = pathParams;
  1058. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/steps`;
  1059. });
  1060. const destroyInfra = baseApi<
  1061. {},
  1062. {
  1063. project_id: number;
  1064. infra_id: number;
  1065. }
  1066. >("DELETE", (pathParams) => {
  1067. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}`;
  1068. });
  1069. const updateDatabaseStatus = baseApi<
  1070. {
  1071. status: string;
  1072. },
  1073. {
  1074. project_id: number;
  1075. infra_id: number;
  1076. }
  1077. >("POST", (pathParams) => {
  1078. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/database`;
  1079. });
  1080. const getRepoIntegrations = baseApi("GET", "/api/integrations/repo");
  1081. const getRepos = baseApi<{}, { id: number }>("GET", (pathParams) => {
  1082. return `/api/projects/${pathParams.id}/repos`;
  1083. });
  1084. const getSlackIntegrations = baseApi<{}, { id: number }>(
  1085. "GET",
  1086. (pathParams) => {
  1087. return `/api/projects/${pathParams.id}/slack_integrations`;
  1088. }
  1089. );
  1090. const getRevisions = baseApi<
  1091. {},
  1092. { id: number; cluster_id: number; namespace: string; name: string }
  1093. >("GET", (pathParams) => {
  1094. let { id, cluster_id, namespace, name } = pathParams;
  1095. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/history`;
  1096. });
  1097. const getTemplateInfo = baseApi<
  1098. {
  1099. repo_url?: string;
  1100. },
  1101. { project_id: number; name: string; version: string }
  1102. >("GET", (pathParams) => {
  1103. return `/api/v1/projects/${pathParams.project_id}/templates/${pathParams.name}/versions/${pathParams.version}`;
  1104. });
  1105. const getTemplateUpgradeNotes = baseApi<
  1106. {
  1107. repo_url?: string;
  1108. prev_version: string;
  1109. },
  1110. { project_id: number; name: string; version: string }
  1111. >("GET", (pathParams) => {
  1112. return `/api/v1/projects/${pathParams.project_id}/templates/${pathParams.name}/versions/${pathParams.version}/upgrade_notes`;
  1113. });
  1114. const getTemplates = baseApi<
  1115. {
  1116. repo_url?: string;
  1117. },
  1118. {
  1119. project_id: number;
  1120. }
  1121. >("GET", (pathParams) => {
  1122. return `/api/v1/projects/${pathParams.project_id}/templates`;
  1123. });
  1124. const getHelmRepos = baseApi<
  1125. {},
  1126. {
  1127. project_id: number;
  1128. }
  1129. >("GET", (pathParams) => {
  1130. return `/api/projects/${pathParams.project_id}/helmrepos`;
  1131. });
  1132. const getChartsFromHelmRepo = baseApi<
  1133. {},
  1134. {
  1135. project_id: number;
  1136. helm_repo_id: number;
  1137. }
  1138. >("GET", (pathParams) => {
  1139. return `/api/projects/${pathParams.project_id}/helmrepos/${pathParams.helm_repo_id}/charts`;
  1140. });
  1141. const getChartInfoFromHelmRepo = baseApi<
  1142. {},
  1143. { project_id: number; helm_repo_id: number; name: string; version: string }
  1144. >("GET", (pathParams) => {
  1145. return `/api/projects/${pathParams.project_id}/helmrepos/${pathParams.helm_repo_id}/charts/${pathParams.name}/${pathParams.version}`;
  1146. });
  1147. const getMetadata = baseApi<{}, {}>("GET", () => {
  1148. return `/api/metadata`;
  1149. });
  1150. const postWelcome = baseApi<{
  1151. email: string;
  1152. isCompany: boolean;
  1153. name: string;
  1154. company: string;
  1155. role: string;
  1156. }>("POST", () => {
  1157. return `/api/welcome`;
  1158. });
  1159. const linkGithubProject = baseApi<
  1160. {},
  1161. {
  1162. project_id: number;
  1163. }
  1164. >("GET", (pathParams) => {
  1165. return `/api/oauth/projects/${pathParams.project_id}/github`;
  1166. });
  1167. const getGithubAccounts = baseApi<{}, {}>("GET", () => {
  1168. return `/api/integrations/github-app/accounts`;
  1169. });
  1170. const logInUser = baseApi<{
  1171. email: string;
  1172. password: string;
  1173. }>("POST", "/api/login");
  1174. const logOutUser = baseApi("POST", "/api/logout");
  1175. const registerUser = baseApi<{
  1176. email: string;
  1177. password: string;
  1178. }>("POST", "/api/users");
  1179. const rollbackChart = baseApi<
  1180. {
  1181. revision: number;
  1182. },
  1183. {
  1184. id: number;
  1185. name: string;
  1186. namespace: string;
  1187. cluster_id: number;
  1188. }
  1189. >("POST", (pathParams) => {
  1190. let { id, name, cluster_id, namespace } = pathParams;
  1191. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0/rollback`;
  1192. });
  1193. const uninstallTemplate = baseApi<
  1194. {},
  1195. {
  1196. id: number;
  1197. name: string;
  1198. cluster_id: number;
  1199. namespace: string;
  1200. }
  1201. >("DELETE", (pathParams) => {
  1202. let { id, name, cluster_id, namespace } = pathParams;
  1203. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0`;
  1204. });
  1205. const updateUser = baseApi<
  1206. {
  1207. rawKubeConfig?: string;
  1208. allowedContexts?: string[];
  1209. },
  1210. { id: number }
  1211. >("PUT", (pathParams) => {
  1212. return `/api/users/${pathParams.id}`;
  1213. });
  1214. const upgradeChartValues = baseApi<
  1215. {
  1216. values: string;
  1217. version?: string;
  1218. latest_revision?: number;
  1219. },
  1220. {
  1221. id: number;
  1222. name: string;
  1223. namespace: string;
  1224. cluster_id: number;
  1225. }
  1226. >("POST", (pathParams) => {
  1227. let { id, name, cluster_id, namespace } = pathParams;
  1228. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0/upgrade`;
  1229. });
  1230. const listEnvGroups = baseApi<
  1231. {},
  1232. {
  1233. id: number;
  1234. namespace: string;
  1235. cluster_id: number;
  1236. }
  1237. >("GET", (pathParams) => {
  1238. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/envgroup/list`;
  1239. });
  1240. const listConfigMaps = baseApi<
  1241. {},
  1242. {
  1243. id: number;
  1244. namespace: string;
  1245. cluster_id: number;
  1246. }
  1247. >("GET", (pathParams) => {
  1248. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/list`;
  1249. });
  1250. const getEnvGroup = baseApi<
  1251. {},
  1252. {
  1253. id: number;
  1254. namespace: string;
  1255. cluster_id: number;
  1256. name: string;
  1257. version?: number;
  1258. }
  1259. >("GET", (pathParams) => {
  1260. return `/api/projects/${pathParams.id}/clusters/${
  1261. pathParams.cluster_id
  1262. }/namespaces/${pathParams.namespace}/envgroup?name=${pathParams.name}${
  1263. pathParams.version ? "&version=" + pathParams.version : ""
  1264. }`;
  1265. });
  1266. const getConfigMap = baseApi<
  1267. {
  1268. name: string;
  1269. },
  1270. {
  1271. id: number;
  1272. namespace: string;
  1273. cluster_id: number;
  1274. }
  1275. >("GET", (pathParams) => {
  1276. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap`;
  1277. });
  1278. const createEnvGroup = baseApi<
  1279. {
  1280. name: string;
  1281. variables: Record<string, string>;
  1282. secret_variables?: Record<string, string>;
  1283. },
  1284. {
  1285. id: number;
  1286. cluster_id: number;
  1287. namespace: string;
  1288. }
  1289. >("POST", (pathParams) => {
  1290. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/envgroup/create`;
  1291. });
  1292. const cloneEnvGroup = baseApi<
  1293. {
  1294. name: string;
  1295. namespace: string;
  1296. clone_name: string;
  1297. version: number;
  1298. },
  1299. {
  1300. id: number;
  1301. namespace: string;
  1302. cluster_id: number;
  1303. }
  1304. >("POST", (pathParams) => {
  1305. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/envgroup/clone`;
  1306. });
  1307. const updateEnvGroup = baseApi<
  1308. {
  1309. name: string;
  1310. variables: { [key: string]: string };
  1311. secret_variables?: { [key: string]: string };
  1312. },
  1313. {
  1314. project_id: number;
  1315. cluster_id: number;
  1316. namespace: string;
  1317. }
  1318. >(
  1319. "POST",
  1320. ({ cluster_id, project_id, namespace }) =>
  1321. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/envgroup/create`
  1322. );
  1323. const createConfigMap = baseApi<
  1324. {
  1325. name: string;
  1326. variables: Record<string, string>;
  1327. secret_variables?: Record<string, string>;
  1328. },
  1329. {
  1330. id: number;
  1331. cluster_id: number;
  1332. namespace: string;
  1333. }
  1334. >("POST", (pathParams) => {
  1335. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/create`;
  1336. });
  1337. const updateConfigMap = baseApi<
  1338. {
  1339. name: string;
  1340. variables: Record<string, string>;
  1341. secret_variables?: Record<string, string>;
  1342. },
  1343. {
  1344. id: number;
  1345. cluster_id: number;
  1346. namespace: string;
  1347. }
  1348. >("POST", (pathParams) => {
  1349. let { id, cluster_id } = pathParams;
  1350. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/update`;
  1351. });
  1352. const renameConfigMap = baseApi<
  1353. {
  1354. name: string;
  1355. new_name: string;
  1356. },
  1357. {
  1358. id: number;
  1359. cluster_id: number;
  1360. namespace: string;
  1361. }
  1362. >("POST", (pathParams) => {
  1363. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/rename`;
  1364. });
  1365. const deleteEnvGroup = baseApi<
  1366. {
  1367. name: string;
  1368. },
  1369. {
  1370. id: number;
  1371. namespace: string;
  1372. cluster_id: number;
  1373. }
  1374. >("DELETE", (pathParams) => {
  1375. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/envgroup`;
  1376. });
  1377. const deleteConfigMap = baseApi<
  1378. {
  1379. name: string;
  1380. },
  1381. {
  1382. id: number;
  1383. namespace: string;
  1384. cluster_id: number;
  1385. }
  1386. >("DELETE", (pathParams) => {
  1387. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/delete`;
  1388. });
  1389. const createNamespace = baseApi<
  1390. {
  1391. name: string;
  1392. },
  1393. { id: number; cluster_id: number }
  1394. >("POST", (pathParams) => {
  1395. let { id, cluster_id } = pathParams;
  1396. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/create`;
  1397. });
  1398. const deleteNamespace = baseApi<
  1399. {},
  1400. {
  1401. id: number;
  1402. cluster_id: number;
  1403. namespace: string;
  1404. }
  1405. >("DELETE", (pathParams) => {
  1406. let { id, cluster_id, namespace } = pathParams;
  1407. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}`;
  1408. });
  1409. const deleteJob = baseApi<
  1410. {},
  1411. { name: string; namespace: string; id: number; cluster_id: number }
  1412. >("DELETE", (pathParams) => {
  1413. let { id, name, cluster_id, namespace } = pathParams;
  1414. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}`;
  1415. });
  1416. const stopJob = baseApi<
  1417. {},
  1418. { name: string; namespace: string; id: number; cluster_id: number }
  1419. >("POST", (pathParams) => {
  1420. let { id, name, namespace, cluster_id } = pathParams;
  1421. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}/stop`;
  1422. });
  1423. const listAPITokens = baseApi<{}, { project_id: number }>(
  1424. "GET",
  1425. ({ project_id }) => `/api/projects/${project_id}/api_token`
  1426. );
  1427. const getAPIToken = baseApi<{}, { project_id: number; token: string }>(
  1428. "GET",
  1429. ({ project_id, token }) => `/api/projects/${project_id}/api_token/${token}`
  1430. );
  1431. const revokeAPIToken = baseApi<{}, { project_id: number; token: string }>(
  1432. "POST",
  1433. ({ project_id, token }) =>
  1434. `/api/projects/${project_id}/api_token/${token}/revoke`
  1435. );
  1436. const createAPIToken = baseApi<
  1437. {
  1438. name: string;
  1439. policy_uid: string;
  1440. expires_at?: string;
  1441. },
  1442. { project_id: number }
  1443. >("POST", ({ project_id }) => `/api/projects/${project_id}/api_token`);
  1444. const createPolicy = baseApi<
  1445. {
  1446. name: string;
  1447. policy: PolicyDocType[];
  1448. },
  1449. { project_id: number }
  1450. >("POST", ({ project_id }) => `/api/projects/${project_id}/policy`);
  1451. const getAvailableRoles = baseApi<{}, { project_id: number }>(
  1452. "GET",
  1453. ({ project_id }) => `/api/projects/${project_id}/roles`
  1454. );
  1455. const updateInvite = baseApi<
  1456. { kind: string },
  1457. { project_id: number; invite_id: number }
  1458. >(
  1459. "POST",
  1460. ({ project_id, invite_id }) =>
  1461. `/api/projects/${project_id}/invites/${invite_id}`
  1462. );
  1463. const getCollaborators = baseApi<{}, { project_id: number }>(
  1464. "GET",
  1465. ({ project_id }) => `/api/projects/${project_id}/collaborators`
  1466. );
  1467. const updateCollaborator = baseApi<
  1468. {
  1469. kind: string;
  1470. user_id: number;
  1471. },
  1472. { project_id: number }
  1473. >("POST", ({ project_id }) => `/api/projects/${project_id}/roles`);
  1474. const removeCollaborator = baseApi<{ user_id: number }, { project_id: number }>(
  1475. "DELETE",
  1476. ({ project_id }) => `/api/projects/${project_id}/roles`
  1477. );
  1478. const getPolicyDocument = baseApi<{}, { project_id: number }>(
  1479. "GET",
  1480. ({ project_id }) => `/api/projects/${project_id}/policy`
  1481. );
  1482. const createWebhookToken = baseApi<
  1483. {},
  1484. {
  1485. project_id: number;
  1486. chart_name: string;
  1487. namespace: string;
  1488. cluster_id: number;
  1489. }
  1490. >(
  1491. "POST",
  1492. ({ project_id, chart_name, namespace, cluster_id }) =>
  1493. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${chart_name}/0/webhook`
  1494. );
  1495. const getUsage = baseApi<{}, { project_id: number }>(
  1496. "GET",
  1497. ({ project_id }) => `/api/projects/${project_id}/usage`
  1498. );
  1499. // Used for billing purposes
  1500. const getCustomerToken = baseApi<{}, { project_id: number }>(
  1501. "GET",
  1502. ({ project_id }) => `/api/projects/${project_id}/billing/token`
  1503. );
  1504. const getHasBilling = baseApi<{}, { project_id: number }>(
  1505. "GET",
  1506. ({ project_id }) => `/api/projects/${project_id}/billing`
  1507. );
  1508. const getOnboardingState = baseApi<{}, { project_id: number }>(
  1509. "GET",
  1510. ({ project_id }) => `/api/projects/${project_id}/onboarding`
  1511. );
  1512. const saveOnboardingState = baseApi<{}, { project_id: number }>(
  1513. "POST",
  1514. ({ project_id }) => `/api/projects/${project_id}/onboarding`
  1515. );
  1516. const getOnboardingInfra = baseApi<
  1517. {},
  1518. { project_id: number; registry_infra_id: number }
  1519. >(
  1520. "GET",
  1521. ({ project_id, registry_infra_id }) =>
  1522. `/api/projects/${project_id}/infras/${registry_infra_id}`
  1523. );
  1524. const getOnboardingRegistry = baseApi<
  1525. {},
  1526. { project_id: number; registry_connection_id: number }
  1527. >(
  1528. "GET",
  1529. ({ project_id, registry_connection_id }) =>
  1530. `/api/projects/${project_id}/registries/${registry_connection_id}`
  1531. );
  1532. const detectPorterAgent = baseApi<
  1533. {},
  1534. { project_id: number; cluster_id: number }
  1535. >(
  1536. "GET",
  1537. ({ project_id, cluster_id }) =>
  1538. `/api/projects/${project_id}/clusters/${cluster_id}/agent/detect`
  1539. );
  1540. const installPorterAgent = baseApi<
  1541. {},
  1542. { project_id: number; cluster_id: number }
  1543. >(
  1544. "POST",
  1545. ({ cluster_id, project_id }) =>
  1546. `/api/projects/${project_id}/clusters/${cluster_id}/agent/install`
  1547. );
  1548. const getKubeEvents = baseApi<
  1549. {
  1550. skip: number;
  1551. resource_type: string;
  1552. owner_type?: string;
  1553. owner_name?: string;
  1554. namespace?: string;
  1555. },
  1556. { project_id: number; cluster_id: number }
  1557. >("GET", ({ project_id, cluster_id }) => {
  1558. return `/api/projects/${project_id}/clusters/${cluster_id}/kube_events`;
  1559. });
  1560. const getKubeEvent = baseApi<
  1561. {},
  1562. { project_id: number; cluster_id: number; kube_event_id: number }
  1563. >(
  1564. "GET",
  1565. ({ project_id, cluster_id, kube_event_id }) =>
  1566. `/api/projects/${project_id}/clusters/${cluster_id}/kube_events/${kube_event_id}`
  1567. );
  1568. const getLogBuckets = baseApi<
  1569. {},
  1570. { project_id: number; cluster_id: number; kube_event_id: number }
  1571. >(
  1572. "GET",
  1573. ({ project_id, cluster_id, kube_event_id }) =>
  1574. `/api/projects/${project_id}/clusters/${cluster_id}/kube_events/${kube_event_id}/log_buckets`
  1575. );
  1576. const getLogBucketLogs = baseApi<
  1577. { timestamp: number },
  1578. { project_id: number; cluster_id: number; kube_event_id: number }
  1579. >(
  1580. "GET",
  1581. ({ project_id, cluster_id, kube_event_id }) =>
  1582. `/api/projects/${project_id}/clusters/${cluster_id}/kube_events/${kube_event_id}/logs`
  1583. );
  1584. const getCanCreateProject = baseApi<{}, {}>(
  1585. "GET",
  1586. () => "/api/can_create_project"
  1587. );
  1588. const addApplicationToEnvGroup = baseApi<
  1589. {
  1590. name: string; // Env Group name
  1591. app_name: string;
  1592. },
  1593. { project_id: number; cluster_id: number; namespace: string }
  1594. >(
  1595. "POST",
  1596. ({ cluster_id, namespace, project_id }) =>
  1597. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/envgroup/add_application`
  1598. );
  1599. const removeApplicationFromEnvGroup = baseApi<
  1600. {
  1601. name: string; // Env Group name
  1602. app_name: string;
  1603. },
  1604. { project_id: number; cluster_id: number; namespace: string }
  1605. >(
  1606. "POST",
  1607. ({ cluster_id, namespace, project_id }) =>
  1608. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/envgroup/remove_application`
  1609. );
  1610. const provisionDatabase = baseApi<
  1611. {
  1612. username: string;
  1613. password: string;
  1614. machine_type: string;
  1615. db_storage_encrypted: boolean;
  1616. db_name: string;
  1617. db_max_allocated_storage: string;
  1618. db_family: string;
  1619. db_engine_version: string;
  1620. db_allocated_storage: string;
  1621. },
  1622. { project_id: number; cluster_id: number; namespace: string }
  1623. >(
  1624. "POST",
  1625. ({ project_id, cluster_id, namespace }) =>
  1626. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/provision/rds`
  1627. );
  1628. const getDatabases = baseApi<
  1629. {},
  1630. {
  1631. project_id: number;
  1632. cluster_id: number;
  1633. }
  1634. >(
  1635. "GET",
  1636. ({ project_id, cluster_id }) =>
  1637. `/api/projects/${project_id}/clusters/${cluster_id}/databases`
  1638. );
  1639. const getPreviousLogsForContainer = baseApi<
  1640. {
  1641. container_name: string;
  1642. },
  1643. {
  1644. project_id: number;
  1645. cluster_id: number;
  1646. namespace: string;
  1647. pod_name: string;
  1648. }
  1649. >(
  1650. "GET",
  1651. ({ cluster_id, namespace, pod_name: name, project_id }) =>
  1652. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/pod/${name}/previous_logs`
  1653. );
  1654. const upgradePorterAgent = baseApi<
  1655. {},
  1656. { project_id: number; cluster_id: number }
  1657. >(
  1658. "POST",
  1659. ({ project_id, cluster_id }) =>
  1660. `/api/projects/${project_id}/clusters/${cluster_id}/agent/upgrade`
  1661. );
  1662. const updateBuildConfig = baseApi<
  1663. BuildConfig,
  1664. {
  1665. project_id: number;
  1666. cluster_id: number;
  1667. namespace: string;
  1668. release_name: string;
  1669. }
  1670. >(
  1671. "POST",
  1672. ({ project_id, cluster_id, namespace, release_name }) =>
  1673. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/buildconfig`
  1674. );
  1675. const updateGitActionConfig = baseApi<
  1676. {
  1677. git_action_config: {
  1678. git_branch: string;
  1679. };
  1680. },
  1681. {
  1682. project_id: number;
  1683. cluster_id: number;
  1684. namespace: string;
  1685. release_name: string;
  1686. revision?: 0; // Always update latest
  1687. }
  1688. >(
  1689. "PATCH",
  1690. ({ project_id, cluster_id, namespace, release_name, revision = 0 }) =>
  1691. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/${revision}/git_action_config`
  1692. );
  1693. const reRunGHWorkflow = baseApi<
  1694. {},
  1695. {
  1696. project_id: number;
  1697. cluster_id: number;
  1698. git_installation_id: number;
  1699. owner: string;
  1700. name: string;
  1701. branch?: string;
  1702. filename?: string;
  1703. release_name?: string;
  1704. }
  1705. >(
  1706. "POST",
  1707. ({
  1708. project_id,
  1709. git_installation_id,
  1710. owner,
  1711. name,
  1712. cluster_id,
  1713. filename,
  1714. release_name,
  1715. branch,
  1716. }) => {
  1717. const queryParams = new URLSearchParams();
  1718. if (branch) {
  1719. queryParams.set("branch", branch);
  1720. }
  1721. if (release_name) {
  1722. queryParams.set("release_name", release_name);
  1723. }
  1724. if (filename) {
  1725. queryParams.set("filename", filename);
  1726. }
  1727. return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${owner}/${name}/clusters/${cluster_id}/rerun_workflow?${queryParams.toString()}`;
  1728. }
  1729. );
  1730. const triggerPreviewEnvWorkflow = baseApi<
  1731. {},
  1732. { project_id: number; cluster_id: number; deployment_id: number }
  1733. >(
  1734. "POST",
  1735. ({ project_id, cluster_id, deployment_id }) =>
  1736. `/api/projects/${project_id}/clusters/${cluster_id}/deployments/${deployment_id}/trigger_workflow`
  1737. );
  1738. const getTagsByProjectId = baseApi<{}, { project_id: number }>(
  1739. "GET",
  1740. ({ project_id }) => `/api/projects/${project_id}/tags`
  1741. );
  1742. const createTag = baseApi<
  1743. { name: string; color: string },
  1744. { project_id: number }
  1745. >("POST", ({ project_id }) => `/api/projects/${project_id}/tags`);
  1746. const updateReleaseTags = baseApi<
  1747. {
  1748. tags: string[];
  1749. },
  1750. {
  1751. project_id: number;
  1752. cluster_id: number;
  1753. namespace: string;
  1754. release_name: string;
  1755. }
  1756. >(
  1757. "PATCH",
  1758. ({ project_id, cluster_id, namespace, release_name }) =>
  1759. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/update_tags`
  1760. );
  1761. const updateCanonicalName = baseApi<
  1762. {
  1763. canonical_name: string;
  1764. },
  1765. {
  1766. project_id: number;
  1767. cluster_id: number;
  1768. namespace: string;
  1769. release_name: string;
  1770. }
  1771. >(
  1772. "PATCH",
  1773. ({ project_id, cluster_id, namespace, release_name }) =>
  1774. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/update_canonical_name`
  1775. );
  1776. const getGitProviders = baseApi<{}, { project_id: number }>(
  1777. "GET",
  1778. ({ project_id }) => `/api/projects/${project_id}/integrations/git`
  1779. );
  1780. const getGitlabRepos = baseApi<
  1781. {},
  1782. { project_id: number; integration_id: number }
  1783. >(
  1784. "GET",
  1785. ({ project_id, integration_id }) =>
  1786. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos`
  1787. );
  1788. const getGitlabBranches = baseApi<
  1789. {},
  1790. {
  1791. project_id: number;
  1792. integration_id: number;
  1793. repo_owner: string;
  1794. repo_name: string;
  1795. }
  1796. >(
  1797. "GET",
  1798. ({ project_id, integration_id, repo_owner, repo_name }) =>
  1799. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos/${repo_owner}/${repo_name}/branches`
  1800. );
  1801. const getGitlabFolderContent = baseApi<
  1802. {
  1803. dir: string;
  1804. },
  1805. {
  1806. project_id: number;
  1807. integration_id: number;
  1808. repo_owner: string;
  1809. repo_name: string;
  1810. branch: string;
  1811. }
  1812. >(
  1813. "GET",
  1814. ({ project_id, integration_id, repo_owner, repo_name, branch }) =>
  1815. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos/${repo_owner}/${repo_name}/${branch}/contents`
  1816. );
  1817. const getLogPodValues = baseApi<
  1818. {
  1819. namespace?: string;
  1820. revision?: string;
  1821. match_prefix?: string;
  1822. start_range?: string;
  1823. end_range?: string;
  1824. },
  1825. {
  1826. project_id: number;
  1827. cluster_id: number;
  1828. }
  1829. >(
  1830. "GET",
  1831. ({ project_id, cluster_id }) =>
  1832. `/api/projects/${project_id}/clusters/${cluster_id}/logs/pod_values`
  1833. );
  1834. const getLogs = baseApi<
  1835. {
  1836. limit?: number;
  1837. start_range?: string;
  1838. end_range?: string;
  1839. revision?: string;
  1840. pod_selector: string;
  1841. namespace: string;
  1842. search_param?: string;
  1843. direction?: string;
  1844. },
  1845. {
  1846. project_id: number;
  1847. cluster_id: number;
  1848. }
  1849. >(
  1850. "GET",
  1851. ({ project_id, cluster_id }) =>
  1852. `/api/projects/${project_id}/clusters/${cluster_id}/logs`
  1853. );
  1854. const listPorterEvents = baseApi<
  1855. {
  1856. release_name?: number;
  1857. release_namespace?: string;
  1858. type?: string;
  1859. },
  1860. {
  1861. project_id: number;
  1862. cluster_id: number;
  1863. }
  1864. >(
  1865. "GET",
  1866. ({ project_id, cluster_id }) =>
  1867. `/api/projects/${project_id}/clusters/${cluster_id}/events`
  1868. );
  1869. const listPorterJobEvents = baseApi<
  1870. {
  1871. release_name?: number;
  1872. release_namespace?: string;
  1873. type?: string;
  1874. job_name: string;
  1875. },
  1876. {
  1877. project_id: number;
  1878. cluster_id: number;
  1879. }
  1880. >(
  1881. "GET",
  1882. ({ project_id, cluster_id }) =>
  1883. `/api/projects/${project_id}/clusters/${cluster_id}/events/job`
  1884. );
  1885. const listIncidents = baseApi<
  1886. {
  1887. release_name?: number;
  1888. release_namespace?: string;
  1889. status?: string;
  1890. },
  1891. {
  1892. project_id: number;
  1893. cluster_id: number;
  1894. }
  1895. >(
  1896. "GET",
  1897. ({ project_id, cluster_id }) =>
  1898. `/api/projects/${project_id}/clusters/${cluster_id}/incidents`
  1899. );
  1900. const getIncident = baseApi<
  1901. {},
  1902. {
  1903. project_id: number;
  1904. cluster_id: number;
  1905. incident_id: string;
  1906. }
  1907. >(
  1908. "GET",
  1909. ({ project_id, cluster_id, incident_id }) =>
  1910. `/api/projects/${project_id}/clusters/${cluster_id}/incidents/${incident_id}`
  1911. );
  1912. const getIncidentEvents = baseApi<
  1913. {
  1914. incident_id?: string;
  1915. pod_prefix?: string;
  1916. },
  1917. {
  1918. project_id: number;
  1919. cluster_id: number;
  1920. }
  1921. >(
  1922. "GET",
  1923. ({ project_id, cluster_id }) =>
  1924. `/api/projects/${project_id}/clusters/${cluster_id}/incidents/events`
  1925. );
  1926. // STACKS
  1927. const createStack = baseApi<
  1928. CreateStackBody,
  1929. {
  1930. project_id: number;
  1931. cluster_id: number;
  1932. namespace: string;
  1933. }
  1934. >(
  1935. "POST",
  1936. ({ project_id, cluster_id, namespace }) =>
  1937. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks`
  1938. );
  1939. const updateStack = baseApi<
  1940. {
  1941. name: string;
  1942. },
  1943. {
  1944. project_id: number;
  1945. cluster_id: number;
  1946. namespace: string;
  1947. stack_id: string;
  1948. }
  1949. >(
  1950. "PATCH",
  1951. ({ project_id, cluster_id, namespace, stack_id }) =>
  1952. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}`
  1953. );
  1954. const listStacks = baseApi<
  1955. {},
  1956. { project_id: number; cluster_id: number; namespace: string }
  1957. >(
  1958. "GET",
  1959. ({ project_id, cluster_id, namespace }) =>
  1960. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks`
  1961. );
  1962. const getStack = baseApi<
  1963. {},
  1964. {
  1965. project_id: number;
  1966. cluster_id: number;
  1967. namespace: string;
  1968. stack_id: string;
  1969. }
  1970. >(
  1971. "GET",
  1972. ({ project_id, cluster_id, namespace, stack_id }) =>
  1973. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}`
  1974. );
  1975. const getStackRevision = baseApi<
  1976. {},
  1977. {
  1978. project_id: number;
  1979. cluster_id: number;
  1980. namespace: string;
  1981. stack_id: string;
  1982. revision_id: number;
  1983. }
  1984. >(
  1985. "GET",
  1986. ({ project_id, cluster_id, namespace, stack_id, revision_id }) =>
  1987. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/${revision_id}`
  1988. );
  1989. const rollbackStack = baseApi<
  1990. {
  1991. target_revision: number;
  1992. },
  1993. {
  1994. project_id: number;
  1995. cluster_id: number;
  1996. namespace: string;
  1997. stack_id: string;
  1998. }
  1999. >(
  2000. "POST",
  2001. ({ project_id, cluster_id, namespace, stack_id }) =>
  2002. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/rollback`
  2003. );
  2004. const deleteStack = baseApi<
  2005. {},
  2006. {
  2007. project_id: number;
  2008. cluster_id: number;
  2009. namespace: string;
  2010. stack_id: string;
  2011. }
  2012. >(
  2013. "DELETE",
  2014. ({ project_id, cluster_id, namespace, stack_id }) =>
  2015. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}`
  2016. );
  2017. const updateStackSourceConfig = baseApi<
  2018. {
  2019. source_configs: SourceConfig[];
  2020. },
  2021. {
  2022. project_id: number;
  2023. cluster_id: number;
  2024. namespace: string;
  2025. stack_id: string;
  2026. }
  2027. >(
  2028. "PUT",
  2029. ({ project_id, cluster_id, namespace, stack_id }) =>
  2030. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/source`
  2031. );
  2032. const addStackAppResource = baseApi<
  2033. CreateStackBody["app_resources"][0],
  2034. {
  2035. project_id: number;
  2036. cluster_id: number;
  2037. namespace: string;
  2038. stack_id: string;
  2039. }
  2040. >(
  2041. "PATCH",
  2042. ({ project_id, cluster_id, namespace, stack_id }) =>
  2043. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/add_application`
  2044. );
  2045. const removeStackAppResource = baseApi<
  2046. {},
  2047. {
  2048. project_id: number;
  2049. cluster_id: number;
  2050. namespace: string;
  2051. stack_id: string;
  2052. app_resource_name: string;
  2053. }
  2054. >(
  2055. "DELETE",
  2056. ({ project_id, cluster_id, namespace, stack_id, app_resource_name }) =>
  2057. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/remove_application/${app_resource_name}`
  2058. );
  2059. const addStackEnvGroup = baseApi<
  2060. CreateStackBody["env_groups"][0],
  2061. {
  2062. project_id: number;
  2063. cluster_id: number;
  2064. namespace: string;
  2065. stack_id: string;
  2066. }
  2067. >(
  2068. "PATCH",
  2069. ({ project_id, cluster_id, namespace, stack_id }) =>
  2070. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/add_env_group`
  2071. );
  2072. const removeStackEnvGroup = baseApi<
  2073. {},
  2074. {
  2075. project_id: number;
  2076. cluster_id: number;
  2077. namespace: string;
  2078. stack_id: string;
  2079. env_group_name: string;
  2080. }
  2081. >(
  2082. "DELETE",
  2083. ({ project_id, cluster_id, namespace, stack_id, env_group_name }) =>
  2084. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/remove_env_group/${env_group_name}`
  2085. );
  2086. const getGithubStatus = baseApi<{}, {}>("GET", ({}) => `/api/status/github`);
  2087. // Bundle export to allow default api import (api.<method> is more readable)
  2088. export default {
  2089. checkAuth,
  2090. connectECRRegistry,
  2091. connectGCRRegistry,
  2092. connectDORegistry,
  2093. getAWSIntegration,
  2094. getGCPIntegration,
  2095. getAzureIntegration,
  2096. getGitlabIntegration,
  2097. createAWSIntegration,
  2098. overwriteAWSIntegration,
  2099. updateCluster,
  2100. createAzureIntegration,
  2101. createGitlabIntegration,
  2102. createEmailVerification,
  2103. createEnvironment,
  2104. updateEnvironment,
  2105. deleteEnvironment,
  2106. createPreviewEnvironmentDeployment,
  2107. reenablePreviewEnvironmentDeployment,
  2108. listEnvironments,
  2109. getEnvironment,
  2110. toggleNewCommentForEnvironment,
  2111. validatePorterYAML,
  2112. createGCPIntegration,
  2113. createInvite,
  2114. createNamespace,
  2115. createPasswordReset,
  2116. createPasswordResetVerify,
  2117. createPasswordResetFinalize,
  2118. createProject,
  2119. createConfigMap,
  2120. deleteCluster,
  2121. deleteConfigMap,
  2122. deleteInvite,
  2123. deleteNamespace,
  2124. deletePod,
  2125. deleteProject,
  2126. deleteRegistryIntegration,
  2127. deleteSlackIntegration,
  2128. updateNotificationConfig,
  2129. getNotificationConfig,
  2130. createSubdomain,
  2131. deployTemplate,
  2132. deployAddon,
  2133. destroyInfra,
  2134. updateDatabaseStatus,
  2135. detectBuildpack,
  2136. detectGitlabBuildpack,
  2137. getBranchContents,
  2138. getBranches,
  2139. getMetadata,
  2140. postWelcome,
  2141. getChart,
  2142. getCharts,
  2143. getChartComponents,
  2144. getChartControllers,
  2145. getClusterIntegrations,
  2146. getClusters,
  2147. getCluster,
  2148. getClusterNodes,
  2149. getClusterNode,
  2150. getConfigMap,
  2151. getPRDeploymentList,
  2152. getPRDeploymentByID,
  2153. // getPRDeployment,
  2154. getGHAWorkflowTemplate,
  2155. getGitRepoList,
  2156. getGitRepoPermission,
  2157. getGitRepos,
  2158. getImageRepos,
  2159. getImageTags,
  2160. listInfraTemplates,
  2161. getInfraTemplate,
  2162. getInfra,
  2163. provisionInfra,
  2164. deleteInfra,
  2165. updateInfra,
  2166. listOperations,
  2167. getOperation,
  2168. getOperationLogs,
  2169. retryCreateInfra,
  2170. retryDeleteInfra,
  2171. getInfraState,
  2172. getInfraRawState,
  2173. getInfraByID,
  2174. getInfraDesired,
  2175. getInfraCurrent,
  2176. getIngress,
  2177. getInvites,
  2178. getJobs,
  2179. getJobStatus,
  2180. getJobPods,
  2181. getPodByName,
  2182. getMatchingPods,
  2183. getAllReleasePods,
  2184. getMetrics,
  2185. getNamespaces,
  2186. getNGINXIngresses,
  2187. getOAuthIds,
  2188. getPodEvents,
  2189. getProcfileContents,
  2190. getGitlabProcfileContents,
  2191. getProjectClusters,
  2192. getProjectRegistries,
  2193. getProjectRepos,
  2194. getProjects,
  2195. getPrometheusIsInstalled,
  2196. getRegistryIntegrations,
  2197. getReleaseToken,
  2198. getReleaseSteps,
  2199. getRepoIntegrations,
  2200. getSlackIntegrations,
  2201. getRepos,
  2202. getRevisions,
  2203. getTemplateInfo,
  2204. getTemplateUpgradeNotes,
  2205. getTemplates,
  2206. getHelmRepos,
  2207. getChartsFromHelmRepo,
  2208. getChartInfoFromHelmRepo,
  2209. linkGithubProject,
  2210. getGithubAccounts,
  2211. listConfigMaps,
  2212. logInUser,
  2213. logOutUser,
  2214. registerUser,
  2215. rollbackChart,
  2216. uninstallTemplate,
  2217. updateUser,
  2218. renameConfigMap,
  2219. updateConfigMap,
  2220. upgradeChartValues,
  2221. deleteJob,
  2222. stopJob,
  2223. updateInvite,
  2224. listAPITokens,
  2225. getAPIToken,
  2226. revokeAPIToken,
  2227. createAPIToken,
  2228. createPolicy,
  2229. getAvailableRoles,
  2230. getCollaborators,
  2231. updateCollaborator,
  2232. removeCollaborator,
  2233. getPolicyDocument,
  2234. createWebhookToken,
  2235. getUsage,
  2236. getCustomerToken,
  2237. getHasBilling,
  2238. getOnboardingState,
  2239. saveOnboardingState,
  2240. getOnboardingInfra,
  2241. getOnboardingRegistry,
  2242. detectPorterAgent,
  2243. installPorterAgent,
  2244. getKubeEvents,
  2245. getKubeEvent,
  2246. getLogBuckets,
  2247. getLogBucketLogs,
  2248. getCanCreateProject,
  2249. createEnvGroup,
  2250. cloneEnvGroup,
  2251. updateEnvGroup,
  2252. listEnvGroups,
  2253. getEnvGroup,
  2254. deleteEnvGroup,
  2255. addApplicationToEnvGroup,
  2256. removeApplicationFromEnvGroup,
  2257. provisionDatabase,
  2258. getDatabases,
  2259. getPreviousLogsForContainer,
  2260. upgradePorterAgent,
  2261. deletePRDeployment,
  2262. updateBuildConfig,
  2263. updateGitActionConfig,
  2264. reRunGHWorkflow,
  2265. triggerPreviewEnvWorkflow,
  2266. getTagsByProjectId,
  2267. createTag,
  2268. updateReleaseTags,
  2269. updateCanonicalName,
  2270. getGitProviders,
  2271. getGitlabRepos,
  2272. getGitlabBranches,
  2273. getGitlabFolderContent,
  2274. getLogPodValues,
  2275. getLogs,
  2276. listPorterEvents,
  2277. listPorterJobEvents,
  2278. listIncidents,
  2279. getIncident,
  2280. getIncidentEvents,
  2281. // STACKS
  2282. listStacks,
  2283. getStack,
  2284. getStackRevision,
  2285. createStack,
  2286. updateStack,
  2287. rollbackStack,
  2288. deleteStack,
  2289. updateStackSourceConfig,
  2290. addStackAppResource,
  2291. removeStackAppResource,
  2292. addStackEnvGroup,
  2293. removeStackEnvGroup,
  2294. // STATUS
  2295. getGithubStatus,
  2296. };