api.tsx 59 KB

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