api.tsx 61 KB

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