api.tsx 61 KB

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