api.tsx 93 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069
  1. import {
  2. type Contract,
  3. type PreflightCheckRequest,
  4. type QuotaIncreaseRequest,
  5. } from "@porter-dev/api-contracts";
  6. import { type PullRequest } from "main/home/cluster-dashboard/preview-environments/types";
  7. import {
  8. type CreateStackBody,
  9. type SourceConfig,
  10. } from "main/home/cluster-dashboard/stacks/types";
  11. import { type PolicyDocType } from "./auth/types";
  12. import { baseApi } from "./baseApi";
  13. import {
  14. type AppEventWebhook,
  15. type BuildConfig,
  16. type CreateUpdatePorterAppOptions,
  17. type FullActionConfigType,
  18. } from "./types";
  19. /**
  20. * Generic api call format
  21. * @param {string} token - Bearer token.
  22. * @param {Object} params - Body params.
  23. * @param {Object} pathParams - Path params.
  24. * @param {(err: Object, res: Object) => void} callback - Callback function.
  25. */
  26. const checkAuth = baseApi("GET", "/api/users/current");
  27. const connectECRRegistry = baseApi<
  28. {
  29. name: string;
  30. aws_integration_id: string;
  31. },
  32. { id: number }
  33. >("POST", (pathParams) => {
  34. return `/api/projects/${pathParams.id}/registries`;
  35. });
  36. const connectGCRRegistry = baseApi<
  37. {
  38. name: string;
  39. gcp_integration_id: string;
  40. url: string;
  41. },
  42. { id: number }
  43. >("POST", (pathParams) => {
  44. return `/api/projects/${pathParams.id}/registries`;
  45. });
  46. const connectDORegistry = baseApi<
  47. {
  48. name: string;
  49. do_integration_id: string;
  50. url: string;
  51. },
  52. { project_id: number }
  53. >("POST", (pathParams) => {
  54. return `/api/projects/${pathParams.project_id}/registries`;
  55. });
  56. const getAWSIntegration = baseApi<{}, { project_id: number }>(
  57. "GET",
  58. ({ project_id }) => `/api/projects/${project_id}/integrations/aws`
  59. );
  60. const getGCPIntegration = baseApi<{}, { project_id: number }>(
  61. "GET",
  62. ({ project_id }) => `/api/projects/${project_id}/integrations/gcp`
  63. );
  64. const getAzureIntegration = baseApi<{}, { project_id: number }>(
  65. "GET",
  66. ({ project_id }) => `/api/projects/${project_id}/integrations/azure`
  67. );
  68. const getGitlabIntegration = baseApi<{}, { project_id: number }>(
  69. "GET",
  70. ({ project_id }) => `/api/projects/${project_id}/integrations/gitlab`
  71. );
  72. const legacyPreflightCheck = baseApi<PreflightCheckRequest, { id: number }>(
  73. "POST",
  74. (pathParams) => {
  75. return `/api/projects/${pathParams.id}/integrations/preflightcheck`;
  76. }
  77. );
  78. const requestQuotaIncrease = baseApi<QuotaIncreaseRequest, { id: number }>(
  79. "POST",
  80. (pathParams) => {
  81. return `/api/projects/${pathParams.id}/integrations/quotaincrease`;
  82. }
  83. );
  84. const createAWSIntegration = baseApi<
  85. {
  86. aws_region?: string;
  87. aws_cluster_id?: string;
  88. aws_access_key_id?: string;
  89. aws_secret_access_key?: string;
  90. aws_assume_role_arn?: string;
  91. aws_target_arn?: string;
  92. aws_external_id?: string;
  93. },
  94. { id: number }
  95. >("POST", (pathParams) => {
  96. return `/api/projects/${pathParams.id}/integrations/aws`;
  97. });
  98. const overwriteAWSIntegration = baseApi<
  99. {
  100. aws_integration_id: number;
  101. aws_access_key_id: string;
  102. aws_secret_access_key: string;
  103. cluster_id: number;
  104. },
  105. {
  106. project_id: number;
  107. }
  108. >("POST", (pathParams) => {
  109. return `/api/projects/${pathParams.project_id}/integrations/aws/overwrite`;
  110. });
  111. const updateCluster = baseApi<
  112. {
  113. name?: string;
  114. aws_cluster_id?: string;
  115. agent_integration_enabled?: boolean;
  116. preview_envs_enabled?: boolean;
  117. },
  118. {
  119. project_id: number;
  120. cluster_id: number;
  121. }
  122. >("POST", (pathParams) => {
  123. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}`;
  124. });
  125. const renameProject = baseApi<
  126. {
  127. name: string | undefined;
  128. },
  129. {
  130. project_id: number;
  131. }
  132. >("POST", (pathParams) => {
  133. return `/api/projects/${pathParams.project_id}/rename`;
  134. });
  135. const renameCluster = baseApi<
  136. {
  137. name: string;
  138. },
  139. {
  140. project_id: number;
  141. cluster_id: number;
  142. }
  143. >("POST", (pathParams) => {
  144. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/rename`;
  145. });
  146. const createAzureIntegration = baseApi<
  147. {
  148. azure_client_id: string;
  149. azure_subscription_id: string;
  150. azure_tenant_id: string;
  151. service_principal_key: string;
  152. },
  153. { id: number }
  154. >("POST", (pathParams) => {
  155. return `/api/projects/${pathParams.id}/integrations/azure`;
  156. });
  157. const createGitlabIntegration = baseApi<
  158. {
  159. instance_url: string;
  160. client_id: string;
  161. client_secret: string;
  162. },
  163. { id: number }
  164. >("POST", (pathParams) => {
  165. return `/api/projects/${pathParams.id}/integrations/gitlab`;
  166. });
  167. const createEmailVerification = baseApi<{}, {}>("POST", (pathParams) => {
  168. return `/api/email/verify/initiate`;
  169. });
  170. const getPorterApps = baseApi<
  171. {},
  172. {
  173. project_id: number;
  174. cluster_id: number;
  175. }
  176. >("GET", (pathParams) => {
  177. const { project_id, cluster_id } = pathParams;
  178. return `/api/projects/${project_id}/clusters/${cluster_id}/applications`;
  179. });
  180. const getPorterApp = baseApi<
  181. {},
  182. {
  183. project_id: number;
  184. cluster_id: number;
  185. name: string;
  186. }
  187. >("GET", (pathParams) => {
  188. const { project_id, cluster_id, name } = pathParams;
  189. return `/api/projects/${project_id}/clusters/${cluster_id}/applications/${name}`;
  190. });
  191. const getPorterAppEvent = baseApi<
  192. {},
  193. {
  194. project_id: number;
  195. cluster_id: number;
  196. event_id: string;
  197. porter_app_name: string;
  198. }
  199. >("GET", (pathParams) => {
  200. const { project_id, cluster_id, event_id, porter_app_name } = pathParams;
  201. return `/api/projects/${project_id}/clusters/${cluster_id}/apps/${porter_app_name}/events/${event_id}`;
  202. });
  203. const createPorterApp = baseApi<
  204. CreateUpdatePorterAppOptions,
  205. {
  206. project_id: number;
  207. cluster_id: number;
  208. stack_name: string;
  209. }
  210. >("POST", (pathParams) => {
  211. const { project_id, cluster_id, stack_name } = pathParams;
  212. return `/api/projects/${project_id}/clusters/${cluster_id}/applications/${stack_name}`;
  213. });
  214. const deletePorterApp = baseApi<
  215. {},
  216. {
  217. project_id: number;
  218. cluster_id: number;
  219. name: string;
  220. }
  221. >("DELETE", (pathParams) => {
  222. const { project_id, cluster_id, name } = pathParams;
  223. return `/api/projects/${project_id}/clusters/${cluster_id}/applications/${name}`;
  224. });
  225. const rollbackPorterApp = baseApi<
  226. {
  227. revision: number;
  228. },
  229. {
  230. project_id: number;
  231. cluster_id: number;
  232. stack_name: string;
  233. }
  234. >("POST", (pathParams) => {
  235. const { project_id, cluster_id, stack_name } = pathParams;
  236. return `/api/projects/${project_id}/clusters/${cluster_id}/applications/${stack_name}/rollback`;
  237. });
  238. const getLogsWithinTimeRange = baseApi<
  239. {
  240. chart_name?: string;
  241. limit: number;
  242. start_range?: string;
  243. end_range?: string;
  244. search_param?: string;
  245. namespace?: string;
  246. pod_selector?: string;
  247. direction?: string;
  248. },
  249. {
  250. project_id: number;
  251. cluster_id: number;
  252. }
  253. >(
  254. "GET",
  255. ({ project_id, cluster_id }) =>
  256. `/api/projects/${project_id}/clusters/${cluster_id}/applications/logs`
  257. );
  258. const appLogs = baseApi<
  259. {
  260. service_name: string;
  261. deployment_target_id: string;
  262. limit: number;
  263. start_range: string;
  264. end_range: string;
  265. search_param?: string;
  266. direction?: string;
  267. app_revision_id?: string;
  268. job_run_name?: string;
  269. },
  270. {
  271. project_id: number;
  272. cluster_id: number;
  273. porter_app_name: string;
  274. }
  275. >(
  276. "GET",
  277. ({ project_id, cluster_id, porter_app_name }) =>
  278. `/api/projects/${project_id}/clusters/${cluster_id}/apps/${porter_app_name}/logs`
  279. );
  280. const appHelmValues = baseApi<
  281. {
  282. app_id: number;
  283. deployment_target_id: string;
  284. with_defaults: boolean;
  285. },
  286. {
  287. project_id: number;
  288. cluster_id: number;
  289. porter_app_name: string;
  290. }
  291. >(
  292. "GET",
  293. ({ project_id, cluster_id, porter_app_name }) =>
  294. `/api/projects/${project_id}/clusters/${cluster_id}/apps/${porter_app_name}/helm-values`
  295. );
  296. const appJobs = baseApi<
  297. {
  298. deployment_target_id: string;
  299. job_name: string;
  300. },
  301. {
  302. project_id: number;
  303. cluster_id: number;
  304. porter_app_name: string;
  305. }
  306. >(
  307. "GET",
  308. ({ project_id, cluster_id, porter_app_name }) =>
  309. `/api/projects/${project_id}/clusters/${cluster_id}/apps/${porter_app_name}/jobs`
  310. );
  311. const cancelJob = baseApi<
  312. {
  313. deployment_target_id: string;
  314. },
  315. {
  316. project_id: number;
  317. cluster_id: number;
  318. porter_app_name: string;
  319. job_run_name: string;
  320. }
  321. >("POST", ({ project_id, cluster_id, porter_app_name, job_run_name }) => {
  322. return `/api/projects/${project_id}/clusters/${cluster_id}/apps/${porter_app_name}/jobs/${job_run_name}/cancel`;
  323. });
  324. const appServiceStatus = baseApi<
  325. {
  326. deployment_target_id: string;
  327. service: string;
  328. },
  329. { project_id: number; cluster_id: number; app_name: string }
  330. >("GET", ({ project_id, cluster_id, app_name }) => {
  331. return `/api/projects/${project_id}/clusters/${cluster_id}/apps/${app_name}/service_status`;
  332. });
  333. const appEvents = baseApi<
  334. {
  335. page?: number;
  336. deployment_target_id: string;
  337. },
  338. {
  339. project_id: number;
  340. cluster_id: number;
  341. porter_app_name: string;
  342. }
  343. >("GET", (pathParams) => {
  344. const { project_id, cluster_id, porter_app_name } = pathParams;
  345. return `/api/projects/${project_id}/clusters/${cluster_id}/apps/${porter_app_name}/events`;
  346. });
  347. const getFeedEvents = baseApi<
  348. {},
  349. {
  350. project_id: number;
  351. cluster_id: number;
  352. stack_name: string;
  353. page?: number;
  354. }
  355. >("GET", (pathParams) => {
  356. const { project_id, cluster_id, stack_name, page } = pathParams;
  357. return `/api/projects/${project_id}/clusters/${cluster_id}/applications/${stack_name}/events?page=${
  358. page || 1
  359. }`;
  360. });
  361. const createEnvironment = baseApi<
  362. {
  363. name: string;
  364. mode: "auto" | "manual";
  365. disable_new_comments: boolean;
  366. git_repo_branches: string[];
  367. namespace_labels: Record<string, string>;
  368. git_deploy_branches: string[];
  369. },
  370. {
  371. project_id: number;
  372. cluster_id: number;
  373. git_installation_id: number;
  374. git_repo_owner: string;
  375. git_repo_name: string;
  376. }
  377. >("POST", (pathParams) => {
  378. const {
  379. project_id,
  380. cluster_id,
  381. git_installation_id,
  382. git_repo_owner,
  383. git_repo_name,
  384. } = pathParams;
  385. return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${git_repo_owner}/${git_repo_name}/clusters/${cluster_id}/environment`;
  386. });
  387. const updateEnvironment = baseApi<
  388. {
  389. mode: "auto" | "manual";
  390. disable_new_comments: boolean;
  391. git_repo_branches: string[]; // Array with branch names
  392. namespace_labels: Record<string, string>;
  393. git_deploy_branches: string[];
  394. },
  395. {
  396. project_id: number;
  397. cluster_id: number;
  398. environment_id: number;
  399. }
  400. >(
  401. "PATCH",
  402. ({ project_id, cluster_id, environment_id }) =>
  403. `/api/projects/${project_id}/clusters/${cluster_id}/environments/${environment_id}/settings`
  404. );
  405. const deleteEnvironment = baseApi<
  406. {
  407. name: string;
  408. },
  409. {
  410. project_id: number;
  411. cluster_id: number;
  412. git_installation_id: number;
  413. git_repo_owner: string;
  414. git_repo_name: string;
  415. }
  416. >("DELETE", (pathParams) => {
  417. const {
  418. project_id,
  419. cluster_id,
  420. git_installation_id,
  421. git_repo_owner,
  422. git_repo_name,
  423. } = pathParams;
  424. return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${git_repo_owner}/${git_repo_name}/clusters/${cluster_id}/environment`;
  425. });
  426. const createPreviewEnvironmentDeployment = baseApi<
  427. PullRequest,
  428. { project_id: number; cluster_id: number }
  429. >(
  430. "POST",
  431. ({ project_id, cluster_id }) =>
  432. `/api/projects/${project_id}/clusters/${cluster_id}/deployments/pull_request`
  433. );
  434. const reenablePreviewEnvironmentDeployment = baseApi<
  435. {},
  436. {
  437. project_id: number;
  438. cluster_id: number;
  439. deployment_id: number;
  440. }
  441. >(
  442. "PATCH",
  443. ({ project_id, cluster_id, deployment_id }) =>
  444. `/api/projects/${project_id}/clusters/${cluster_id}/deployments/${deployment_id}/reenable`
  445. );
  446. const listEnvironments = baseApi<
  447. {},
  448. {
  449. project_id: number;
  450. cluster_id: number;
  451. }
  452. >("GET", (pathParams) => {
  453. const { project_id, cluster_id } = pathParams;
  454. return `/api/projects/${project_id}/clusters/${cluster_id}/environments`;
  455. });
  456. const getEnvironment = baseApi<
  457. {},
  458. {
  459. project_id: number;
  460. cluster_id: number;
  461. environment_id: number;
  462. }
  463. >("GET", (pathParams) => {
  464. const { project_id, cluster_id, environment_id } = pathParams;
  465. return `/api/projects/${project_id}/clusters/${cluster_id}/environments/${environment_id}`;
  466. });
  467. const toggleNewCommentForEnvironment = baseApi<
  468. {
  469. disable: boolean;
  470. },
  471. {
  472. project_id: number;
  473. cluster_id: number;
  474. environment_id: number;
  475. }
  476. >("PATCH", (pathParams) => {
  477. const { project_id, cluster_id, environment_id } = pathParams;
  478. return `/api/projects/${project_id}/clusters/${cluster_id}/environments/${environment_id}/toggle_new_comment`;
  479. });
  480. const validatePorterYAML = baseApi<
  481. {
  482. branch?: string;
  483. },
  484. {
  485. project_id: number;
  486. cluster_id: number;
  487. environment_id: number;
  488. }
  489. >("GET", (pathParams) => {
  490. const { project_id, cluster_id, environment_id } = pathParams;
  491. return `/api/projects/${project_id}/clusters/${cluster_id}/environments/${environment_id}/validate_porter_yaml`;
  492. });
  493. const createGCPIntegration = baseApi<
  494. {
  495. gcp_key_data: string;
  496. gcp_project_id: string;
  497. },
  498. {
  499. project_id: number;
  500. }
  501. >("POST", (pathParams) => {
  502. return `/api/projects/${pathParams.project_id}/integrations/gcp`;
  503. });
  504. const createInvite = baseApi<
  505. {
  506. email: string;
  507. kind: string;
  508. },
  509. {
  510. id: number;
  511. }
  512. >("POST", (pathParams) => {
  513. return `/api/projects/${pathParams.id}/invites`;
  514. });
  515. const inviteAdmin = baseApi<{}, { project_id: number }>(
  516. "POST",
  517. (pathParams) => {
  518. return `/api/projects/${pathParams.project_id}/invite_admin`;
  519. }
  520. );
  521. const createPasswordReset = baseApi<
  522. {
  523. email: string;
  524. },
  525. {}
  526. >("POST", (pathParams) => {
  527. return `/api/password/reset/initiate`;
  528. });
  529. const createPasswordResetVerify = baseApi<
  530. {
  531. email: string;
  532. token: string;
  533. token_id: number;
  534. },
  535. {}
  536. >("POST", (pathParams) => {
  537. return `/api/password/reset/verify`;
  538. });
  539. const createPasswordResetFinalize = baseApi<
  540. {
  541. email: string;
  542. token: string;
  543. token_id: number;
  544. new_password: string;
  545. },
  546. {}
  547. >("POST", (pathParams) => {
  548. return `/api/password/reset/finalize`;
  549. });
  550. const createProject = baseApi<{ name: string }, {}>("POST", (pathParams) => {
  551. return `/api/projects`;
  552. });
  553. const connectProjectToCluster = baseApi<
  554. {},
  555. {
  556. id: number;
  557. }
  558. >("POST", (pathParams) => {
  559. const { id } = pathParams;
  560. return `/api/projects/${id}/connect`;
  561. });
  562. const createSubdomain = baseApi<
  563. {},
  564. {
  565. id: number;
  566. release_name: string;
  567. namespace: string;
  568. cluster_id: number;
  569. }
  570. >("POST", (pathParams) => {
  571. const { cluster_id, id, namespace, release_name } = pathParams;
  572. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/subdomain`;
  573. });
  574. const deleteCluster = baseApi<
  575. {},
  576. {
  577. project_id: number;
  578. cluster_id: number;
  579. }
  580. >("DELETE", (pathParams) => {
  581. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}`;
  582. });
  583. const deleteInvite = baseApi<{}, { id: number; invId: number }>(
  584. "DELETE",
  585. (pathParams) => {
  586. return `/api/projects/${pathParams.id}/invites/${pathParams.invId}`;
  587. }
  588. );
  589. const deletePod = baseApi<
  590. {},
  591. { name: string; namespace: string; id: number; cluster_id: number }
  592. >("DELETE", (pathParams) => {
  593. const { id, name, cluster_id, namespace } = pathParams;
  594. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/pods/${name}`;
  595. });
  596. const getPodEvents = baseApi<
  597. {},
  598. { name: string; namespace: string; id: number; cluster_id: number }
  599. >("GET", (pathParams) => {
  600. const { id, name, cluster_id, namespace } = pathParams;
  601. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/pods/${name}/events`;
  602. });
  603. const deleteProject = baseApi<{}, { id: number }>("DELETE", (pathParams) => {
  604. return `/api/projects/${pathParams.id}`;
  605. });
  606. const deleteRegistryIntegration = baseApi<
  607. {},
  608. {
  609. project_id: number;
  610. registry_id: number;
  611. }
  612. >("DELETE", (pathParams) => {
  613. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}`;
  614. });
  615. const deleteSlackIntegration = baseApi<
  616. {},
  617. {
  618. project_id: number;
  619. slack_integration_id: number;
  620. }
  621. >("DELETE", (pathParams) => {
  622. return `/api/projects/${pathParams.project_id}/slack_integrations/${pathParams.slack_integration_id}`;
  623. });
  624. const legacyUpdateNotificationConfig = baseApi<
  625. {
  626. payload: any;
  627. },
  628. {
  629. project_id: number;
  630. cluster_id: number;
  631. namespace: string;
  632. name: string;
  633. }
  634. >("POST", (pathParams) => {
  635. const { project_id, cluster_id, namespace, name } = pathParams;
  636. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/notifications`;
  637. });
  638. const getNotificationConfig = baseApi<
  639. {},
  640. {
  641. project_id: number;
  642. notification_config_id: number;
  643. }
  644. >("GET", (pathParams) => {
  645. const { project_id, notification_config_id } = pathParams;
  646. return `/api/projects/${project_id}/notifications/config/${notification_config_id}`;
  647. });
  648. const updateNotificationConfig = baseApi<
  649. {
  650. slack_integration_id: number;
  651. config: {
  652. mention: string;
  653. statuses: {
  654. successful: boolean;
  655. failed: boolean;
  656. progressing: boolean;
  657. };
  658. types: {
  659. deploy: boolean;
  660. predeploy: boolean;
  661. build: boolean;
  662. alert: boolean;
  663. };
  664. };
  665. },
  666. {
  667. project_id: number;
  668. notification_config_id: number;
  669. }
  670. >("POST", (pathParams) => {
  671. const { project_id, notification_config_id } = pathParams;
  672. return `/api/projects/${project_id}/notifications/config/${notification_config_id}`;
  673. });
  674. const getNotification = baseApi<
  675. {},
  676. {
  677. project_id: number;
  678. notification_id: string;
  679. }
  680. >("GET", (pathParams) => {
  681. const { project_id, notification_id } = pathParams;
  682. return `/api/projects/${project_id}/notifications/${notification_id}`;
  683. });
  684. const getPRDeploymentList = baseApi<
  685. {
  686. environment_id?: number;
  687. },
  688. {
  689. cluster_id: number;
  690. project_id: number;
  691. }
  692. >("GET", (pathParams) => {
  693. const { cluster_id, project_id } = pathParams;
  694. return `/api/projects/${project_id}/clusters/${cluster_id}/deployments`;
  695. });
  696. const getPRDeploymentByID = baseApi<
  697. {
  698. id: number;
  699. },
  700. {
  701. cluster_id: number;
  702. project_id: number;
  703. environment_id: number;
  704. }
  705. >("GET", (pathParams) => {
  706. const { cluster_id, project_id, environment_id } = pathParams;
  707. return `/api/projects/${project_id}/clusters/${cluster_id}/environments/${environment_id}/deployment`;
  708. });
  709. const deletePRDeployment = baseApi<
  710. {},
  711. {
  712. cluster_id: number;
  713. project_id: number;
  714. deployment_id: number;
  715. }
  716. >("DELETE", (pathParams) => {
  717. const { cluster_id, project_id, deployment_id } = pathParams;
  718. return `/api/projects/${project_id}/clusters/${cluster_id}/deployments/${deployment_id}`;
  719. });
  720. const legacyGetNotificationConfig = baseApi<
  721. {},
  722. {
  723. project_id: number;
  724. cluster_id: number;
  725. namespace: string;
  726. name: string;
  727. }
  728. >("GET", (pathParams) => {
  729. const { project_id, cluster_id, namespace, name } = pathParams;
  730. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/notifications`;
  731. });
  732. const getGHAWorkflowTemplate = baseApi<
  733. {
  734. release_name: string;
  735. github_action_config: FullActionConfigType;
  736. },
  737. {
  738. cluster_id: number;
  739. project_id: number;
  740. namespace: string;
  741. }
  742. >("POST", (pathParams) => {
  743. const { cluster_id, project_id, namespace } = pathParams;
  744. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/gha_template`;
  745. });
  746. const deployTemplate = baseApi<
  747. {
  748. template_name: string;
  749. template_version: string;
  750. image_url?: string;
  751. values?: any;
  752. name: string;
  753. git_action_config?: FullActionConfigType;
  754. build_config?: any;
  755. synced_env_groups?: string[];
  756. },
  757. {
  758. id: number;
  759. cluster_id: number;
  760. namespace: string;
  761. repo_url?: string;
  762. }
  763. >("POST", (pathParams) => {
  764. const { cluster_id, id, namespace, repo_url } = pathParams;
  765. if (repo_url) {
  766. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases?repo_url=${repo_url}`;
  767. }
  768. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases`;
  769. });
  770. const deployAddon = baseApi<
  771. {
  772. template_name: string;
  773. template_version: string;
  774. values?: any;
  775. name: string;
  776. },
  777. {
  778. id: number;
  779. cluster_id: number;
  780. namespace: string;
  781. repo_url?: string;
  782. }
  783. >("POST", (pathParams) => {
  784. const { cluster_id, id, namespace, repo_url } = pathParams;
  785. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/addons?repo_url=${repo_url}`;
  786. });
  787. const detectBuildpack = baseApi<
  788. {},
  789. {
  790. project_id: number;
  791. git_repo_id: number;
  792. kind: string;
  793. owner: string;
  794. name: string;
  795. branch: string;
  796. }
  797. >("GET", (pathParams) => {
  798. return `/api/projects/${pathParams.project_id}/gitrepos/${
  799. pathParams.git_repo_id
  800. }/repos/${pathParams.kind}/${pathParams.owner}/${
  801. pathParams.name
  802. }/${encodeURIComponent(pathParams.branch)}/buildpack/detect`;
  803. });
  804. const detectGitlabBuildpack = baseApi<
  805. { dir: string },
  806. {
  807. project_id: number;
  808. integration_id: number;
  809. repo_owner: string;
  810. repo_name: string;
  811. branch: string;
  812. }
  813. >(
  814. "GET",
  815. ({ project_id, integration_id, repo_name, repo_owner, branch }) =>
  816. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos/${repo_owner}/${repo_name}/${branch}/buildpack/detect`
  817. );
  818. const getBranchContents = baseApi<
  819. {
  820. dir: string;
  821. },
  822. {
  823. project_id: number;
  824. git_repo_id: number;
  825. kind: string;
  826. owner: string;
  827. name: string;
  828. branch: string;
  829. }
  830. >("GET", (pathParams) => {
  831. return `/api/projects/${pathParams.project_id}/gitrepos/${
  832. pathParams.git_repo_id
  833. }/repos/${pathParams.kind}/${pathParams.owner}/${
  834. pathParams.name
  835. }/${encodeURIComponent(pathParams.branch)}/contents`;
  836. });
  837. const getProcfileContents = baseApi<
  838. {
  839. path: string;
  840. },
  841. {
  842. project_id: number;
  843. git_repo_id: number;
  844. kind: string;
  845. owner: string;
  846. name: string;
  847. branch: string;
  848. }
  849. >("GET", (pathParams) => {
  850. return `/api/projects/${pathParams.project_id}/gitrepos/${
  851. pathParams.git_repo_id
  852. }/repos/${pathParams.kind}/${pathParams.owner}/${
  853. pathParams.name
  854. }/${encodeURIComponent(pathParams.branch)}/procfile`;
  855. });
  856. const getPorterYamlContents = baseApi<
  857. {
  858. path: string;
  859. },
  860. {
  861. project_id: number;
  862. git_repo_id: number;
  863. kind: string;
  864. owner: string;
  865. name: string;
  866. branch: string;
  867. }
  868. >("GET", (pathParams) => {
  869. return `/api/projects/${pathParams.project_id}/gitrepos/${
  870. pathParams.git_repo_id
  871. }/repos/${pathParams.kind}/${pathParams.owner}/${
  872. pathParams.name
  873. }/${encodeURIComponent(pathParams.branch)}/porteryaml`;
  874. });
  875. const parsePorterYaml = baseApi<
  876. {
  877. b64_yaml: string;
  878. app_name?: string;
  879. },
  880. {
  881. project_id: number;
  882. cluster_id: number;
  883. }
  884. >("POST", (pathParams) => {
  885. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/apps/parse`;
  886. });
  887. const attachEnvGroup = baseApi<
  888. {
  889. env_group_name: string;
  890. app_instance_ids: string[];
  891. },
  892. { project_id: number; cluster_id: number }
  893. >(
  894. "POST",
  895. ({ project_id, cluster_id }) =>
  896. `/api/projects/${project_id}/clusters/${cluster_id}/apps/attach-env-group`
  897. );
  898. const getDefaultDeploymentTarget = baseApi<
  899. {},
  900. {
  901. project_id: number;
  902. cluster_id: number;
  903. }
  904. >("GET", (pathParams) => {
  905. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/default-deployment-target`;
  906. });
  907. const deleteDeploymentTarget = baseApi<
  908. {},
  909. {
  910. project_id: number;
  911. deployment_target_id: string;
  912. }
  913. >("DELETE", ({ project_id, deployment_target_id }) => {
  914. return `/api/projects/${project_id}/targets/${deployment_target_id}`;
  915. });
  916. const getBranchHead = baseApi<
  917. {},
  918. {
  919. project_id: number;
  920. git_repo_id: number;
  921. kind: string;
  922. owner: string;
  923. name: string;
  924. branch: string;
  925. }
  926. >("GET", (pathParams) => {
  927. return `/api/projects/${pathParams.project_id}/gitrepos/${
  928. pathParams.git_repo_id
  929. }/repos/${pathParams.kind}/${pathParams.owner}/${
  930. pathParams.name
  931. }/${encodeURIComponent(pathParams.branch)}/head`;
  932. });
  933. const createApp = baseApi<
  934. | {
  935. name: string;
  936. deployment_target_id: string;
  937. type: "github";
  938. git_repo_id: number;
  939. git_branch: string;
  940. git_repo_name: string;
  941. porter_yaml_path: string;
  942. }
  943. | {
  944. name: string;
  945. deployment_target_id: string;
  946. type: "docker-registry";
  947. image: {
  948. repository: string;
  949. tag: string;
  950. };
  951. },
  952. {
  953. project_id: number;
  954. cluster_id: number;
  955. }
  956. >("POST", (pathParams) => {
  957. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/apps/create`;
  958. });
  959. const createAppTemplate = baseApi<
  960. {
  961. b64_app_proto: string;
  962. variables: Record<string, string>;
  963. secrets: Record<string, string>;
  964. base_deployment_target_id: string;
  965. addons?: Array<{
  966. base64_addon: string;
  967. variables: Record<string, string>;
  968. secrets: Record<string, string>;
  969. }>;
  970. git_overrides?: {
  971. git_branch?: string;
  972. git_repo_id: number;
  973. git_repo_name: string;
  974. };
  975. },
  976. {
  977. project_id: number;
  978. cluster_id: number;
  979. porter_app_name: string;
  980. }
  981. >("POST", ({ project_id, cluster_id, porter_app_name }) => {
  982. return `/api/projects/${project_id}/clusters/${cluster_id}/apps/${porter_app_name}/templates`;
  983. });
  984. const listTemplateEnvironments = baseApi<
  985. Record<string, unknown>,
  986. {
  987. project_id: number;
  988. cluster_id: number;
  989. }
  990. >("GET", (pathParams) => {
  991. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/apps/templates`;
  992. });
  993. const updateApp = baseApi<
  994. {
  995. deployment_target_id: string;
  996. b64_app_proto?: string;
  997. git_source?: {
  998. git_repo_id: number;
  999. git_branch: string;
  1000. git_repo_name: string;
  1001. };
  1002. porter_yaml_path?: string;
  1003. variables?: Record<string, string>;
  1004. secrets?: Record<string, string>;
  1005. is_env_override?: boolean;
  1006. deletions?: {
  1007. service_names: string[];
  1008. predeploy: string[];
  1009. env_variable_names?: string[];
  1010. env_group_names: string[];
  1011. service_deletions: Record<
  1012. string,
  1013. {
  1014. domain_names: string[];
  1015. ingress_annotation_keys: string[];
  1016. }
  1017. >;
  1018. };
  1019. with_predeploy?: boolean;
  1020. },
  1021. {
  1022. project_id: number;
  1023. cluster_id: number;
  1024. }
  1025. >("POST", (pathParams) => {
  1026. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/apps/update`;
  1027. });
  1028. const appRun = baseApi<
  1029. {
  1030. deployment_target_id: string;
  1031. service_name: string;
  1032. },
  1033. {
  1034. project_id: number;
  1035. cluster_id: number;
  1036. porter_app_name: string;
  1037. }
  1038. >("POST", (pathParams) => {
  1039. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/apps/${pathParams.porter_app_name}/run`;
  1040. });
  1041. const updateBuildSettings = baseApi<
  1042. {
  1043. build_settings: {
  1044. method: string;
  1045. context: string;
  1046. dockerfile: string;
  1047. builder: string;
  1048. buildpacks: string[];
  1049. };
  1050. deployment_target_id: string;
  1051. },
  1052. {
  1053. project_id: number;
  1054. cluster_id: number;
  1055. porter_app_name: string;
  1056. }
  1057. >("POST", (pathParams) => {
  1058. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/apps/${pathParams.porter_app_name}/build`;
  1059. });
  1060. const revertApp = baseApi<
  1061. {
  1062. deployment_target_id: string;
  1063. app_revision_id: string;
  1064. },
  1065. {
  1066. project_id: number;
  1067. cluster_id: number;
  1068. porter_app_name: string;
  1069. }
  1070. >("POST", (pathParams) => {
  1071. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/apps/${pathParams.porter_app_name}/rollback`;
  1072. });
  1073. const getAttachedEnvGroups = baseApi<
  1074. {},
  1075. {
  1076. project_id: number;
  1077. cluster_id: number;
  1078. app_name: string;
  1079. revision_id: string;
  1080. }
  1081. >("GET", (pathParams) => {
  1082. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/apps/${pathParams.app_name}/revisions/${pathParams.revision_id}/env`;
  1083. });
  1084. const getLatestRevision = baseApi<
  1085. {
  1086. deployment_target_id: string;
  1087. },
  1088. {
  1089. project_id: number;
  1090. cluster_id: number;
  1091. porter_app_name: string;
  1092. }
  1093. >("GET", ({ project_id, cluster_id, porter_app_name }) => {
  1094. return `/api/projects/${project_id}/clusters/${cluster_id}/apps/${porter_app_name}/latest`;
  1095. });
  1096. const appNotifications = baseApi<
  1097. {
  1098. deployment_target_id: string;
  1099. },
  1100. {
  1101. project_id: number;
  1102. cluster_id: number;
  1103. porter_app_name: string;
  1104. }
  1105. >("GET", ({ project_id, cluster_id, porter_app_name }) => {
  1106. return `/api/projects/${project_id}/clusters/${cluster_id}/apps/${porter_app_name}/notifications`;
  1107. });
  1108. const getRevision = baseApi<
  1109. {},
  1110. {
  1111. project_id: number;
  1112. cluster_id: number;
  1113. porter_app_name: string;
  1114. revision_id: string;
  1115. }
  1116. >("GET", ({ project_id, cluster_id, porter_app_name, revision_id }) => {
  1117. return `/api/projects/${project_id}/clusters/${cluster_id}/apps/${porter_app_name}/revisions/${revision_id}`;
  1118. });
  1119. const porterYamlFromRevision = baseApi<
  1120. {
  1121. should_format_for_export: boolean;
  1122. },
  1123. {
  1124. project_id: number;
  1125. cluster_id: number;
  1126. porter_app_name: string;
  1127. revision_id: string;
  1128. }
  1129. >("GET", ({ project_id, cluster_id, porter_app_name, revision_id }) => {
  1130. return `/api/projects/${project_id}/clusters/${cluster_id}/apps/${porter_app_name}/revisions/${revision_id}/yaml`;
  1131. });
  1132. const listAppRevisions = baseApi<
  1133. {
  1134. deployment_target_id: string;
  1135. },
  1136. {
  1137. project_id: number;
  1138. cluster_id: number;
  1139. porter_app_name: string;
  1140. }
  1141. >("GET", ({ project_id, cluster_id, porter_app_name }) => {
  1142. return `/api/projects/${project_id}/clusters/${cluster_id}/apps/${porter_app_name}/revisions`;
  1143. });
  1144. const getLatestAppRevisions = baseApi<
  1145. {
  1146. deployment_target_id: string | undefined;
  1147. ignore_preview_apps: boolean;
  1148. },
  1149. {
  1150. project_id: number;
  1151. cluster_id: number;
  1152. }
  1153. >("GET", ({ project_id, cluster_id }) => {
  1154. return `/api/projects/${project_id}/clusters/${cluster_id}/apps/revisions`;
  1155. });
  1156. const getAppInstances = baseApi<
  1157. {
  1158. deployment_target_id: string | undefined;
  1159. },
  1160. {
  1161. project_id: number;
  1162. cluster_id: number;
  1163. }
  1164. >("GET", ({ project_id, cluster_id }) => {
  1165. return `/api/projects/${project_id}/clusters/${cluster_id}/apps/instances`;
  1166. });
  1167. const listDeploymentTargets = baseApi<
  1168. {
  1169. preview: boolean;
  1170. },
  1171. {
  1172. project_id: number;
  1173. cluster_id: number;
  1174. }
  1175. >("GET", ({ project_id, cluster_id }) => {
  1176. return `/api/projects/${project_id}/clusters/${cluster_id}/deployment-targets`;
  1177. });
  1178. const createDeploymentTarget = baseApi<
  1179. {
  1180. name: string;
  1181. preview: boolean;
  1182. },
  1183. {
  1184. project_id: number;
  1185. cluster_id: number;
  1186. }
  1187. >("POST", ({ project_id, cluster_id }) => {
  1188. return `/api/projects/${project_id}/clusters/${cluster_id}/deployment-targets`;
  1189. });
  1190. const getDeploymentTarget = baseApi<
  1191. {},
  1192. {
  1193. project_id: number;
  1194. deployment_target_id: string;
  1195. }
  1196. >("GET", ({ project_id, deployment_target_id }) => {
  1197. return `/api/projects/${project_id}/targets/${deployment_target_id}`;
  1198. });
  1199. const getAppTemplate = baseApi<
  1200. {},
  1201. {
  1202. project_id: number;
  1203. cluster_id: number;
  1204. porter_app_name: string;
  1205. }
  1206. >("GET", ({ project_id, cluster_id, porter_app_name }) => {
  1207. return `/api/projects/${project_id}/clusters/${cluster_id}/apps/${porter_app_name}/templates`;
  1208. });
  1209. const listAddons = baseApi<
  1210. {},
  1211. {
  1212. projectId: number;
  1213. deploymentTargetId: string;
  1214. }
  1215. >("GET", ({ projectId, deploymentTargetId }) => {
  1216. return `/api/projects/${projectId}/targets/${deploymentTargetId}/addons`;
  1217. });
  1218. const getAddon = baseApi<
  1219. {},
  1220. {
  1221. projectId: number;
  1222. deploymentTargetId: string;
  1223. addonName: string;
  1224. }
  1225. >("GET", ({ projectId, deploymentTargetId, addonName }) => {
  1226. return `/api/projects/${projectId}/targets/${deploymentTargetId}/addons/${addonName}`;
  1227. });
  1228. const getTailscaleServices = baseApi<
  1229. {},
  1230. {
  1231. projectId: number;
  1232. deploymentTargetId: string;
  1233. }
  1234. >("GET", ({ projectId, deploymentTargetId }) => {
  1235. return `/api/projects/${projectId}/targets/${deploymentTargetId}/addons/tailscale-services`;
  1236. });
  1237. const updateAddon = baseApi<
  1238. {
  1239. b64_addon: string;
  1240. },
  1241. {
  1242. projectId: number;
  1243. deploymentTargetId: string;
  1244. }
  1245. >("POST", ({ projectId, deploymentTargetId }) => {
  1246. return `/api/projects/${projectId}/targets/${deploymentTargetId}/addons/update`;
  1247. });
  1248. const deleteAddon = baseApi<
  1249. {},
  1250. {
  1251. projectId: number;
  1252. deploymentTargetId: string;
  1253. addonName: string;
  1254. }
  1255. >("DELETE", ({ projectId, deploymentTargetId, addonName }) => {
  1256. return `/api/projects/${projectId}/targets/${deploymentTargetId}/addons/${addonName}`;
  1257. });
  1258. const getGitlabProcfileContents = baseApi<
  1259. {
  1260. path: string;
  1261. },
  1262. {
  1263. project_id: number;
  1264. integration_id: number;
  1265. owner: string;
  1266. name: string;
  1267. branch: string;
  1268. }
  1269. >(
  1270. "GET",
  1271. ({ project_id, integration_id, owner, name, branch }) =>
  1272. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos/${owner}/${name}/${encodeURIComponent(
  1273. branch
  1274. )}/procfile`
  1275. );
  1276. const getBranches = baseApi<
  1277. {},
  1278. {
  1279. project_id: number;
  1280. git_repo_id: number;
  1281. kind: string;
  1282. owner: string;
  1283. name: string;
  1284. }
  1285. >("GET", (pathParams) => {
  1286. return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id}/repos/${pathParams.kind}/${pathParams.owner}/${pathParams.name}/branches`;
  1287. });
  1288. const getChart = baseApi<
  1289. {},
  1290. {
  1291. id: number;
  1292. cluster_id: number;
  1293. namespace: string;
  1294. name: string;
  1295. revision: number;
  1296. }
  1297. >("GET", (pathParams) => {
  1298. const { id, cluster_id, namespace, name, revision } = pathParams;
  1299. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}`;
  1300. });
  1301. const getCharts = baseApi<
  1302. {
  1303. limit: number;
  1304. skip: number;
  1305. byDate: boolean;
  1306. statusFilter: string[];
  1307. },
  1308. {
  1309. id: number;
  1310. cluster_id: number;
  1311. namespace: string;
  1312. }
  1313. >("GET", (pathParams) => {
  1314. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/releases`;
  1315. });
  1316. const getChartComponents = baseApi<
  1317. {},
  1318. {
  1319. id: number;
  1320. cluster_id: number;
  1321. namespace: string;
  1322. name: string;
  1323. revision: number;
  1324. }
  1325. >("GET", (pathParams) => {
  1326. const { id, cluster_id, namespace, name, revision } = pathParams;
  1327. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}/components`;
  1328. });
  1329. const getChartControllers = baseApi<
  1330. {},
  1331. {
  1332. id: number;
  1333. cluster_id: number;
  1334. namespace: string;
  1335. name: string;
  1336. revision: number;
  1337. }
  1338. >("GET", (pathParams) => {
  1339. const { id, cluster_id, namespace, name, revision } = pathParams;
  1340. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}/controllers`;
  1341. });
  1342. const getClusterIntegrations = baseApi("GET", "/api/integrations/cluster");
  1343. const getClusters = baseApi<{}, { id: number }>("GET", (pathParams) => {
  1344. return `/api/projects/${pathParams.id}/clusters`;
  1345. });
  1346. const getCluster = baseApi<
  1347. {},
  1348. {
  1349. project_id: number;
  1350. cluster_id: number;
  1351. }
  1352. >("GET", (pathParams) => {
  1353. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}`;
  1354. });
  1355. const getClusterStatus = baseApi<
  1356. {},
  1357. {
  1358. project_id: number;
  1359. cluster_id: number;
  1360. }
  1361. >("GET", (pathParams) => {
  1362. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/status`;
  1363. });
  1364. const getClusterNodes = baseApi<
  1365. {},
  1366. {
  1367. project_id: number;
  1368. cluster_id: number;
  1369. }
  1370. >("GET", (pathParams) => {
  1371. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/nodes`;
  1372. });
  1373. const getClusterNode = baseApi<
  1374. {},
  1375. {
  1376. project_id: number;
  1377. cluster_id: number;
  1378. nodeName: string;
  1379. }
  1380. >(
  1381. "GET",
  1382. (pathParams) =>
  1383. `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/nodes/${pathParams.nodeName}`
  1384. );
  1385. const getGitRepoList = baseApi<
  1386. {},
  1387. {
  1388. project_id: number;
  1389. git_repo_id: number;
  1390. }
  1391. >("GET", (pathParams) => {
  1392. return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id}/repos`;
  1393. });
  1394. const getGitRepoPermission = baseApi<
  1395. {},
  1396. {
  1397. project_id: number;
  1398. git_repo_id: number;
  1399. }
  1400. >("GET", (pathParams) => {
  1401. return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id}/permissions`;
  1402. });
  1403. const getGitRepos = baseApi<
  1404. {},
  1405. {
  1406. project_id: number;
  1407. }
  1408. >("GET", (pathParams) => {
  1409. return `/api/projects/${pathParams.project_id}/gitrepos`;
  1410. });
  1411. const getImageRepos = baseApi<
  1412. {},
  1413. {
  1414. project_id: number;
  1415. registry_id: number;
  1416. }
  1417. >("GET", (pathParams) => {
  1418. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}/repositories`;
  1419. });
  1420. const getImageTags = baseApi<
  1421. {},
  1422. {
  1423. project_id: number;
  1424. registry_id: number;
  1425. repo_name: string;
  1426. }
  1427. >("GET", (pathParams) => {
  1428. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}/repositories/${pathParams.repo_name}`;
  1429. });
  1430. const images = baseApi<
  1431. {},
  1432. {
  1433. project_id: number;
  1434. }
  1435. >("GET", (pathParams) => {
  1436. return `/api/projects/${pathParams.project_id}/images`;
  1437. });
  1438. const getInfra = baseApi<
  1439. {
  1440. version?: string;
  1441. },
  1442. {
  1443. project_id: number;
  1444. }
  1445. >("GET", (pathParams) => {
  1446. return `/api/projects/${pathParams.project_id}/infra`;
  1447. });
  1448. const listInfraTemplates = baseApi<
  1449. {},
  1450. {
  1451. project_id: number;
  1452. }
  1453. >("GET", (pathParams) => {
  1454. return `/api/projects/${pathParams.project_id}/infras/templates`;
  1455. });
  1456. const getInfraTemplate = baseApi<
  1457. {},
  1458. {
  1459. project_id: number;
  1460. name: string;
  1461. version: string;
  1462. }
  1463. >("GET", (pathParams) => {
  1464. const { project_id, name, version } = pathParams;
  1465. return `/api/projects/${project_id}/infras/templates/${name}/${version}`;
  1466. });
  1467. const provisionCluster = baseApi<
  1468. {
  1469. project_id: number;
  1470. cluster_id?: number;
  1471. cloud_provider: string;
  1472. cloud_provider_credentials_id: string;
  1473. cluster_settings: {
  1474. cluster_name: string;
  1475. cluster_version: string;
  1476. cidr_range: string;
  1477. region: string;
  1478. node_groups: [
  1479. {
  1480. instance_type: string;
  1481. min_instances: number;
  1482. max_instances: number;
  1483. node_group_type: number;
  1484. },
  1485. {
  1486. instance_type: string;
  1487. min_instances: number;
  1488. max_instances: number;
  1489. node_group_type: number;
  1490. },
  1491. ];
  1492. };
  1493. },
  1494. {
  1495. project_id: number;
  1496. }
  1497. >("POST", ({ project_id }) => {
  1498. return `/api/projects/${project_id}/provision/cluster`;
  1499. });
  1500. const createContract = baseApi<Contract, { project_id: number }>(
  1501. "POST",
  1502. ({ project_id }) => {
  1503. return `/api/projects/${project_id}/contract`;
  1504. }
  1505. );
  1506. const cloudContractPreflightCheck = baseApi<Contract, { project_id: number }>(
  1507. "POST",
  1508. ({ project_id }) => {
  1509. return `/api/projects/${project_id}/contract/preflight`;
  1510. }
  1511. );
  1512. const cloudProviderMachineTypes = baseApi<
  1513. {
  1514. cloud_provider: string;
  1515. cloud_provider_credential_identifier: string;
  1516. region: string;
  1517. },
  1518. { project_id: number }
  1519. >("GET", ({ project_id }) => {
  1520. return `/api/projects/${project_id}/cloud/machines`;
  1521. });
  1522. const getContracts = baseApi<
  1523. { cluster_id?: number; latest?: boolean },
  1524. { project_id: number }
  1525. >("GET", ({ project_id }) => {
  1526. return `/api/projects/${project_id}/contracts`;
  1527. });
  1528. const deleteContract = baseApi<{}, { project_id: number; revision_id: string }>(
  1529. "DELETE",
  1530. ({ project_id, revision_id }) => {
  1531. return `/api/projects/${project_id}/contracts/${revision_id}`;
  1532. }
  1533. );
  1534. const getClusterState = baseApi<{}, { project_id: number; cluster_id: number }>(
  1535. "GET",
  1536. ({ project_id, cluster_id }) => {
  1537. return `/api/projects/${project_id}/clusters/${cluster_id}/state`;
  1538. }
  1539. );
  1540. const getComplianceChecks = baseApi<
  1541. { vendor: "vanta" | "oneleet"; profile: "soc2" | "hipaa" },
  1542. { projectId: number; clusterId: number }
  1543. >("GET", ({ projectId, clusterId }) => {
  1544. return `/api/projects/${projectId}/clusters/${clusterId}/compliance/checks`;
  1545. });
  1546. const provisionInfra = baseApi<
  1547. {
  1548. kind: string;
  1549. values: any;
  1550. aws_integration_id?: number;
  1551. gcp_integration_id?: number;
  1552. do_integration_id?: number;
  1553. azure_integration_id?: number;
  1554. cluster_id?: number;
  1555. },
  1556. {
  1557. project_id: number;
  1558. }
  1559. >("POST", ({ project_id }) => {
  1560. return `/api/projects/${project_id}/infras`;
  1561. });
  1562. const updateInfra = baseApi<
  1563. { values?: any },
  1564. {
  1565. project_id: number;
  1566. infra_id: number;
  1567. }
  1568. >("POST", (pathParams) => {
  1569. const { project_id, infra_id } = pathParams;
  1570. return `/api/projects/${project_id}/infras/${infra_id}/update`;
  1571. });
  1572. const retryCreateInfra = baseApi<
  1573. {
  1574. aws_integration_id?: number;
  1575. gcp_integration_id?: number;
  1576. do_integration_id?: number;
  1577. values?: any;
  1578. },
  1579. {
  1580. project_id: number;
  1581. infra_id: number;
  1582. }
  1583. >("POST", (pathParams) => {
  1584. const { project_id, infra_id } = pathParams;
  1585. return `/api/projects/${project_id}/infras/${infra_id}/retry_create`;
  1586. });
  1587. const retryDeleteInfra = baseApi<
  1588. { values?: any },
  1589. {
  1590. project_id: number;
  1591. infra_id: number;
  1592. }
  1593. >("POST", (pathParams) => {
  1594. const { project_id, infra_id } = pathParams;
  1595. return `/api/projects/${project_id}/infras/${infra_id}/retry_delete`;
  1596. });
  1597. const deleteInfra = baseApi<
  1598. {},
  1599. {
  1600. project_id: number;
  1601. infra_id: number;
  1602. }
  1603. >("DELETE", (pathParams) => {
  1604. const { project_id, infra_id } = pathParams;
  1605. return `/api/projects/${project_id}/infras/${infra_id}`;
  1606. });
  1607. const listOperations = baseApi<
  1608. {},
  1609. {
  1610. project_id: number;
  1611. infra_id: number;
  1612. }
  1613. >("GET", (pathParams) => {
  1614. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/operations`;
  1615. });
  1616. const getOperation = baseApi<
  1617. {},
  1618. {
  1619. project_id: number;
  1620. infra_id: number;
  1621. operation_id: string;
  1622. }
  1623. >("GET", (pathParams) => {
  1624. const { project_id, infra_id, operation_id } = pathParams;
  1625. return `/api/projects/${project_id}/infras/${infra_id}/operations/${operation_id}`;
  1626. });
  1627. const getOperationLogs = baseApi<
  1628. {},
  1629. {
  1630. project_id: number;
  1631. infra_id: number;
  1632. operation_id: string;
  1633. }
  1634. >("GET", (pathParams) => {
  1635. const { project_id, infra_id, operation_id } = pathParams;
  1636. return `/api/projects/${project_id}/infras/${infra_id}/operations/${operation_id}/logs`;
  1637. });
  1638. const getInfraState = baseApi<
  1639. {},
  1640. {
  1641. project_id: number;
  1642. infra_id: number;
  1643. }
  1644. >("GET", (pathParams) => {
  1645. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/state`;
  1646. });
  1647. const getInfraRawState = baseApi<
  1648. {},
  1649. {
  1650. project_id: number;
  1651. infra_id: number;
  1652. }
  1653. >("GET", (pathParams) => {
  1654. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/raw_state`;
  1655. });
  1656. const getInfraByID = baseApi<
  1657. {},
  1658. {
  1659. project_id: number;
  1660. infra_id: number;
  1661. }
  1662. >("GET", (pathParams) => {
  1663. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}`;
  1664. });
  1665. const getInfraDesired = baseApi<
  1666. {},
  1667. {
  1668. project_id: number;
  1669. infra_id: number;
  1670. }
  1671. >("GET", (pathParams) => {
  1672. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/desired`;
  1673. });
  1674. const getInfraCurrent = baseApi<
  1675. {},
  1676. {
  1677. project_id: number;
  1678. infra_id: number;
  1679. }
  1680. >("GET", (pathParams) => {
  1681. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/current`;
  1682. });
  1683. const getIngress = baseApi<
  1684. {},
  1685. { namespace: string; cluster_id: number; name: string; id: number }
  1686. >("GET", (pathParams) => {
  1687. const { id, name, cluster_id, namespace } = pathParams;
  1688. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/ingresses/${name}`;
  1689. });
  1690. const getInvites = baseApi<{}, { id: number }>("GET", (pathParams) => {
  1691. return `/api/projects/${pathParams.id}/invites`;
  1692. });
  1693. const getJobs = baseApi<
  1694. {},
  1695. { namespace: string; cluster_id: number; release_name: string; id: number }
  1696. >("GET", (pathParams) => {
  1697. const { id, release_name, cluster_id, namespace } = pathParams;
  1698. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/jobs`;
  1699. });
  1700. const getJobStatus = baseApi<
  1701. {},
  1702. { namespace: string; cluster_id: number; release_name: string; id: number }
  1703. >("GET", (pathParams) => {
  1704. const { id, release_name, cluster_id, namespace } = pathParams;
  1705. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/jobs/status`;
  1706. });
  1707. const getJobPods = baseApi<
  1708. {},
  1709. { name: string; namespace: string; id: number; cluster_id: number }
  1710. >("GET", (pathParams) => {
  1711. const { id, name, cluster_id, namespace } = pathParams;
  1712. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}/pods`;
  1713. });
  1714. const getPodByName = baseApi<
  1715. {},
  1716. {
  1717. project_id: number;
  1718. cluster_id: number;
  1719. namespace: string;
  1720. name: string;
  1721. }
  1722. >(
  1723. "GET",
  1724. ({ project_id, cluster_id, namespace, name }) =>
  1725. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/pods/${name}`
  1726. );
  1727. const getMatchingPods = baseApi<
  1728. {
  1729. namespace: string;
  1730. selectors: string[];
  1731. },
  1732. { id: number; cluster_id: number }
  1733. >("GET", (pathParams) => {
  1734. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/pods`;
  1735. });
  1736. const getAllReleasePods = baseApi<
  1737. {},
  1738. {
  1739. id: number;
  1740. name: string;
  1741. namespace: string;
  1742. cluster_id: number;
  1743. }
  1744. >("GET", (pathParams) => {
  1745. const { id, name, cluster_id, namespace } = pathParams;
  1746. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0/pods/all`;
  1747. });
  1748. const getMetrics = baseApi<
  1749. {
  1750. metric: string;
  1751. shouldsum: boolean;
  1752. pods?: string[];
  1753. kind?: string; // the controller kind
  1754. name?: string;
  1755. percentile?: number;
  1756. namespace: string;
  1757. startrange: number;
  1758. endrange: number;
  1759. resolution: string;
  1760. },
  1761. {
  1762. id: number;
  1763. cluster_id: number;
  1764. }
  1765. >("GET", (pathParams) => {
  1766. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/metrics`;
  1767. });
  1768. const appMetrics = baseApi<
  1769. {
  1770. metric: string;
  1771. shouldsum: boolean;
  1772. pods?: string[];
  1773. kind?: string; // the controller kind
  1774. name?: string;
  1775. percentile?: number;
  1776. deployment_target_id: string;
  1777. startrange: number;
  1778. endrange: number;
  1779. resolution: string;
  1780. },
  1781. {
  1782. id: number;
  1783. cluster_id: number;
  1784. }
  1785. >("GET", (pathParams) => {
  1786. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/apps/metrics`;
  1787. });
  1788. const getNamespaces = baseApi<
  1789. {},
  1790. {
  1791. id: number;
  1792. cluster_id: number;
  1793. }
  1794. >("GET", (pathParams) => {
  1795. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces`;
  1796. });
  1797. const getNGINXIngresses = baseApi<
  1798. {},
  1799. {
  1800. id: number;
  1801. cluster_id: number;
  1802. }
  1803. >("GET", (pathParams) => {
  1804. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/prometheus/ingresses`;
  1805. });
  1806. const getOAuthIds = baseApi<
  1807. {},
  1808. {
  1809. project_id: number;
  1810. }
  1811. >("GET", (pathParams) => {
  1812. return `/api/projects/${pathParams.project_id}/integrations/oauth`;
  1813. });
  1814. const getProjectClusters = baseApi<{}, { id: number }>("GET", (pathParams) => {
  1815. return `/api/projects/${pathParams.id}/clusters`;
  1816. });
  1817. const getProjectRegistries = baseApi<{}, { id: number }>(
  1818. "GET",
  1819. (pathParams) => {
  1820. return `/api/projects/${pathParams.id}/registries`;
  1821. }
  1822. );
  1823. const getProjectRepos = baseApi<{}, { id: number }>("GET", (pathParams) => {
  1824. return `/api/projects/${pathParams.id}/repos`;
  1825. });
  1826. const getProjects = baseApi("GET", "/api/projects");
  1827. const getProject = baseApi<{}, { id: number }>("GET", (pathParams) => {
  1828. return `/api/projects/${pathParams.id}`;
  1829. });
  1830. const getPrometheusIsInstalled = baseApi<
  1831. {},
  1832. {
  1833. id: number;
  1834. cluster_id: number;
  1835. }
  1836. >("GET", (pathParams) => {
  1837. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/prometheus/detect`;
  1838. });
  1839. const getRegistryIntegrations = baseApi("GET", "/api/integrations/registry");
  1840. const getReleaseToken = baseApi<
  1841. {},
  1842. { name: string; id: number; namespace: string; cluster_id: number }
  1843. >("GET", (pathParams) => {
  1844. const { id, cluster_id, namespace, name } = pathParams;
  1845. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/webhook`;
  1846. });
  1847. const getReleaseSteps = baseApi<
  1848. {},
  1849. { name: string; id: number; namespace: string; cluster_id: number }
  1850. >("GET", (pathParams) => {
  1851. const { id, cluster_id, namespace, name } = pathParams;
  1852. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/steps`;
  1853. });
  1854. const destroyInfra = baseApi<
  1855. {},
  1856. {
  1857. project_id: number;
  1858. infra_id: number;
  1859. }
  1860. >("DELETE", (pathParams) => {
  1861. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}`;
  1862. });
  1863. const updateDatabaseStatus = baseApi<
  1864. {
  1865. status: string;
  1866. },
  1867. {
  1868. project_id: number;
  1869. infra_id: number;
  1870. }
  1871. >("POST", (pathParams) => {
  1872. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/database`;
  1873. });
  1874. const getRepoIntegrations = baseApi("GET", "/api/integrations/repo");
  1875. const getRepos = baseApi<{}, { id: number }>("GET", (pathParams) => {
  1876. return `/api/projects/${pathParams.id}/repos`;
  1877. });
  1878. const getSlackIntegrations = baseApi<{}, { id: number }>(
  1879. "GET",
  1880. (pathParams) => {
  1881. return `/api/projects/${pathParams.id}/slack_integrations`;
  1882. }
  1883. );
  1884. const getNeonIntegrations = baseApi<{}, { projectId: number }>(
  1885. "GET",
  1886. ({ projectId }) => {
  1887. return `/api/projects/${projectId}/neon-integrations`;
  1888. }
  1889. );
  1890. const getUpstashIntegrations = baseApi<{}, { projectId: number }>(
  1891. "GET",
  1892. ({ projectId }) => {
  1893. return `/api/projects/${projectId}/upstash-integrations`;
  1894. }
  1895. );
  1896. const getRevisions = baseApi<
  1897. {},
  1898. { id: number; cluster_id: number; namespace: string; name: string }
  1899. >("GET", (pathParams) => {
  1900. const { id, cluster_id, namespace, name } = pathParams;
  1901. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/history`;
  1902. });
  1903. const getTemplateInfo = baseApi<
  1904. {
  1905. repo_url?: string;
  1906. },
  1907. { project_id: number; name: string; version: string }
  1908. >("GET", (pathParams) => {
  1909. return `/api/v1/projects/${pathParams.project_id}/templates/${pathParams.name}/versions/${pathParams.version}`;
  1910. });
  1911. const getTemplateUpgradeNotes = baseApi<
  1912. {
  1913. repo_url?: string;
  1914. prev_version: string;
  1915. },
  1916. { project_id: number; name: string; version: string }
  1917. >("GET", (pathParams) => {
  1918. return `/api/v1/projects/${pathParams.project_id}/templates/${pathParams.name}/versions/${pathParams.version}/upgrade_notes`;
  1919. });
  1920. const getTemplates = baseApi<
  1921. {
  1922. repo_url?: string;
  1923. },
  1924. {
  1925. project_id: number;
  1926. }
  1927. >("GET", (pathParams) => {
  1928. return `/api/v1/projects/${pathParams.project_id}/templates`;
  1929. });
  1930. const getHelmRepos = baseApi<
  1931. {},
  1932. {
  1933. project_id: number;
  1934. }
  1935. >("GET", (pathParams) => {
  1936. return `/api/projects/${pathParams.project_id}/helmrepos`;
  1937. });
  1938. const getChartsFromHelmRepo = baseApi<
  1939. {},
  1940. {
  1941. project_id: number;
  1942. helm_repo_id: number;
  1943. }
  1944. >("GET", (pathParams) => {
  1945. return `/api/projects/${pathParams.project_id}/helmrepos/${pathParams.helm_repo_id}/charts`;
  1946. });
  1947. const getChartInfoFromHelmRepo = baseApi<
  1948. {},
  1949. { project_id: number; helm_repo_id: number; name: string; version: string }
  1950. >("GET", (pathParams) => {
  1951. return `/api/projects/${pathParams.project_id}/helmrepos/${pathParams.helm_repo_id}/charts/${pathParams.name}/${pathParams.version}`;
  1952. });
  1953. const getMetadata = baseApi<{}, {}>("GET", () => {
  1954. return `/api/metadata`;
  1955. });
  1956. const postWelcome = baseApi<{
  1957. email: string;
  1958. isCompany: boolean;
  1959. name: string;
  1960. company: string;
  1961. role: string;
  1962. }>("POST", () => {
  1963. return `/api/welcome`;
  1964. });
  1965. const linkGithubProject = baseApi<
  1966. {},
  1967. {
  1968. project_id: number;
  1969. }
  1970. >("GET", (pathParams) => {
  1971. return `/api/oauth/projects/${pathParams.project_id}/github`;
  1972. });
  1973. const getGithubAccounts = baseApi<{}, {}>("GET", () => {
  1974. return `/api/integrations/github-app/accounts`;
  1975. });
  1976. const logInUser = baseApi<{
  1977. email: string;
  1978. password: string;
  1979. }>("POST", "/api/login");
  1980. const logOutUser = baseApi("POST", "/api/logout");
  1981. const registerUser = baseApi<{
  1982. email: string;
  1983. password: string;
  1984. first_name: string;
  1985. last_name: string;
  1986. company_name: string;
  1987. referral_method?: string;
  1988. referred_by_code?: string;
  1989. }>("POST", "/api/users");
  1990. const rollbackChart = baseApi<
  1991. {
  1992. revision: number;
  1993. },
  1994. {
  1995. id: number;
  1996. name: string;
  1997. namespace: string;
  1998. cluster_id: number;
  1999. }
  2000. >("POST", (pathParams) => {
  2001. const { id, name, cluster_id, namespace } = pathParams;
  2002. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0/rollback`;
  2003. });
  2004. const uninstallTemplate = baseApi<
  2005. {},
  2006. {
  2007. id: number;
  2008. name: string;
  2009. cluster_id: number;
  2010. namespace: string;
  2011. }
  2012. >("DELETE", (pathParams) => {
  2013. const { id, name, cluster_id, namespace } = pathParams;
  2014. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0`;
  2015. });
  2016. const updateUserInfo = baseApi<
  2017. {
  2018. first_name: string;
  2019. last_name: string;
  2020. company_name: string;
  2021. },
  2022. {}
  2023. >("POST", (pathParams) => {
  2024. return `/api/users/update/info`;
  2025. });
  2026. const updateUser = baseApi<
  2027. {
  2028. rawKubeConfig?: string;
  2029. allowedContexts?: string[];
  2030. },
  2031. { id: number }
  2032. >("PUT", (pathParams) => {
  2033. return `/api/users/${pathParams.id}`;
  2034. });
  2035. const upgradeChartValues = baseApi<
  2036. {
  2037. values: string;
  2038. version?: string;
  2039. latest_revision?: number;
  2040. },
  2041. {
  2042. id: number;
  2043. name: string;
  2044. namespace: string;
  2045. cluster_id: number;
  2046. }
  2047. >("POST", (pathParams) => {
  2048. const { id, name, cluster_id, namespace } = pathParams;
  2049. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0/upgrade`;
  2050. });
  2051. const getAllEnvGroups = baseApi<
  2052. {
  2053. type?: string;
  2054. },
  2055. {
  2056. id: number;
  2057. cluster_id: number;
  2058. }
  2059. >("GET", (pathParams) => {
  2060. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/environment-groups`;
  2061. });
  2062. const updateAppsLinkedToEnvironmentGroup = baseApi<
  2063. {
  2064. name: string;
  2065. },
  2066. {
  2067. id: number;
  2068. cluster_id: number;
  2069. }
  2070. >("POST", (pathParams) => {
  2071. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/environment-groups/update-linked-apps`;
  2072. });
  2073. const updateEnvironmentGroupV2 = baseApi<
  2074. {
  2075. deployment_target_id: string;
  2076. variables: Record<string, string>;
  2077. secrets: Record<string, string>;
  2078. b64_app_proto: string;
  2079. remove_missing?: boolean;
  2080. },
  2081. {
  2082. id: number;
  2083. cluster_id: number;
  2084. app_name: string;
  2085. }
  2086. >("POST", (pathParams) => {
  2087. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/apps/${pathParams.app_name}/update-environment `;
  2088. });
  2089. const listEnvGroups = baseApi<
  2090. {},
  2091. {
  2092. id: number;
  2093. namespace: string;
  2094. cluster_id: number;
  2095. }
  2096. >("GET", (pathParams) => {
  2097. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/envgroup/list`;
  2098. });
  2099. const listConfigMaps = baseApi<
  2100. {},
  2101. {
  2102. id: number;
  2103. namespace: string;
  2104. cluster_id: number;
  2105. }
  2106. >("GET", (pathParams) => {
  2107. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/list`;
  2108. });
  2109. const getEnvGroup = baseApi<
  2110. {},
  2111. {
  2112. id: number;
  2113. namespace: string;
  2114. cluster_id: number;
  2115. name: string;
  2116. version?: number;
  2117. }
  2118. >("GET", (pathParams) => {
  2119. return `/api/projects/${pathParams.id}/clusters/${
  2120. pathParams.cluster_id
  2121. }/namespaces/${pathParams.namespace}/envgroup?name=${pathParams.name}${
  2122. pathParams.version ? "&version=" + pathParams.version : ""
  2123. }`;
  2124. });
  2125. const getConfigMap = baseApi<
  2126. {
  2127. name: string;
  2128. },
  2129. {
  2130. id: number;
  2131. namespace: string;
  2132. cluster_id: number;
  2133. }
  2134. >("GET", (pathParams) => {
  2135. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap`;
  2136. });
  2137. const createEnvGroup = baseApi<
  2138. {
  2139. name: string;
  2140. variables: Record<string, string>;
  2141. secret_variables?: Record<string, string>;
  2142. },
  2143. {
  2144. id: number;
  2145. cluster_id: number;
  2146. namespace: string;
  2147. }
  2148. >("POST", (pathParams) => {
  2149. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/envgroup/create`;
  2150. });
  2151. const createEnvironmentGroups = baseApi<
  2152. {
  2153. name: string;
  2154. variables?: Record<string, string>;
  2155. secret_variables?: Record<string, string>;
  2156. files?: Array<{
  2157. name: string;
  2158. contents: string;
  2159. }>;
  2160. type?: string;
  2161. auth_token?: string;
  2162. is_env_override?: boolean;
  2163. infisical_env?: {
  2164. slug: string;
  2165. path: string;
  2166. };
  2167. },
  2168. {
  2169. id: number;
  2170. cluster_id: number;
  2171. }
  2172. >("POST", (pathParams) => {
  2173. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/environment-groups`;
  2174. });
  2175. const enableExternalEnvGroupProviders = baseApi<
  2176. {},
  2177. {
  2178. id: number;
  2179. cluster_id: number;
  2180. }
  2181. >("POST", (pathParams) => {
  2182. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/environment-groups/enable-external-providers`;
  2183. });
  2184. const areExternalEnvGroupProvidersEnabled = baseApi<
  2185. {},
  2186. {
  2187. id: number;
  2188. cluster_id: number;
  2189. }
  2190. >("GET", (pathParams) => {
  2191. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/environment-groups/are-external-providers-enabled`;
  2192. });
  2193. const cloneEnvGroup = baseApi<
  2194. {
  2195. name: string;
  2196. namespace: string;
  2197. clone_name: string;
  2198. version: number;
  2199. },
  2200. {
  2201. id: number;
  2202. namespace: string;
  2203. cluster_id: number;
  2204. }
  2205. >("POST", (pathParams) => {
  2206. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/envgroup/clone`;
  2207. });
  2208. const updateEnvGroup = baseApi<
  2209. {
  2210. name: string;
  2211. variables: Record<string, string>;
  2212. secret_variables?: Record<string, string>;
  2213. },
  2214. {
  2215. project_id: number;
  2216. cluster_id: number;
  2217. namespace: string;
  2218. }
  2219. >(
  2220. "POST",
  2221. ({ cluster_id, project_id, namespace }) =>
  2222. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/envgroup/create`
  2223. );
  2224. const updateStacksEnvGroup = baseApi<
  2225. {
  2226. name: string;
  2227. variables: Record<string, string>;
  2228. secret_variables?: Record<string, string>;
  2229. apps?: string[];
  2230. },
  2231. {
  2232. project_id: number;
  2233. cluster_id: number;
  2234. namespace: string;
  2235. }
  2236. >(
  2237. "POST",
  2238. ({ cluster_id, project_id, namespace }) =>
  2239. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/envgroup/create`
  2240. );
  2241. const createConfigMap = baseApi<
  2242. {
  2243. name: string;
  2244. variables: Record<string, string>;
  2245. secret_variables?: Record<string, string>;
  2246. },
  2247. {
  2248. id: number;
  2249. cluster_id: number;
  2250. namespace: string;
  2251. }
  2252. >("POST", (pathParams) => {
  2253. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/create`;
  2254. });
  2255. const updateConfigMap = baseApi<
  2256. {
  2257. name: string;
  2258. variables: Record<string, string>;
  2259. secret_variables?: Record<string, string>;
  2260. },
  2261. {
  2262. id: number;
  2263. cluster_id: number;
  2264. namespace: string;
  2265. }
  2266. >("POST", (pathParams) => {
  2267. const { id, cluster_id } = pathParams;
  2268. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/update`;
  2269. });
  2270. const renameConfigMap = baseApi<
  2271. {
  2272. name: string;
  2273. new_name: string;
  2274. },
  2275. {
  2276. id: number;
  2277. cluster_id: number;
  2278. namespace: string;
  2279. }
  2280. >("POST", (pathParams) => {
  2281. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/rename`;
  2282. });
  2283. const deleteEnvGroup = baseApi<
  2284. {
  2285. name: string;
  2286. },
  2287. {
  2288. id: number;
  2289. namespace: string;
  2290. cluster_id: number;
  2291. }
  2292. >("DELETE", (pathParams) => {
  2293. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/envgroup`;
  2294. });
  2295. const deleteNewEnvGroup = baseApi<
  2296. {
  2297. name: string;
  2298. type?: string;
  2299. },
  2300. {
  2301. id: number;
  2302. cluster_id: number;
  2303. }
  2304. >("DELETE", (pathParams) => {
  2305. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/environment-groups`;
  2306. });
  2307. const deleteConfigMap = baseApi<
  2308. {
  2309. name: string;
  2310. },
  2311. {
  2312. id: number;
  2313. namespace: string;
  2314. cluster_id: number;
  2315. }
  2316. >("DELETE", (pathParams) => {
  2317. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/delete`;
  2318. });
  2319. const createNamespace = baseApi<
  2320. {
  2321. name: string;
  2322. },
  2323. { id: number; cluster_id: number }
  2324. >("POST", (pathParams) => {
  2325. const { id, cluster_id } = pathParams;
  2326. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/create`;
  2327. });
  2328. const deleteNamespace = baseApi<
  2329. {},
  2330. {
  2331. id: number;
  2332. cluster_id: number;
  2333. namespace: string;
  2334. }
  2335. >("DELETE", (pathParams) => {
  2336. const { id, cluster_id, namespace } = pathParams;
  2337. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}`;
  2338. });
  2339. const deleteJob = baseApi<
  2340. {},
  2341. { name: string; namespace: string; id: number; cluster_id: number }
  2342. >("DELETE", (pathParams) => {
  2343. const { id, name, cluster_id, namespace } = pathParams;
  2344. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}`;
  2345. });
  2346. const stopJob = baseApi<
  2347. {},
  2348. { name: string; namespace: string; id: number; cluster_id: number }
  2349. >("POST", (pathParams) => {
  2350. const { id, name, namespace, cluster_id } = pathParams;
  2351. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}/stop`;
  2352. });
  2353. const listAPITokens = baseApi<{}, { project_id: number }>(
  2354. "GET",
  2355. ({ project_id }) => `/api/projects/${project_id}/api_token`
  2356. );
  2357. const getAPIToken = baseApi<{}, { project_id: number; token: string }>(
  2358. "GET",
  2359. ({ project_id, token }) => `/api/projects/${project_id}/api_token/${token}`
  2360. );
  2361. const revokeAPIToken = baseApi<{}, { project_id: number; token: string }>(
  2362. "POST",
  2363. ({ project_id, token }) =>
  2364. `/api/projects/${project_id}/api_token/${token}/revoke`
  2365. );
  2366. const createAPIToken = baseApi<
  2367. {
  2368. name: string;
  2369. policy_uid: string;
  2370. expires_at?: string;
  2371. },
  2372. { project_id: number }
  2373. >("POST", ({ project_id }) => `/api/projects/${project_id}/api_token`);
  2374. const createPolicy = baseApi<
  2375. {
  2376. name: string;
  2377. policy: PolicyDocType[];
  2378. },
  2379. { project_id: number }
  2380. >("POST", ({ project_id }) => `/api/projects/${project_id}/policy`);
  2381. const getAvailableRoles = baseApi<{}, { project_id: number }>(
  2382. "GET",
  2383. ({ project_id }) => `/api/projects/${project_id}/roles`
  2384. );
  2385. const updateInvite = baseApi<
  2386. { kind: string },
  2387. { project_id: number; invite_id: number }
  2388. >(
  2389. "POST",
  2390. ({ project_id, invite_id }) =>
  2391. `/api/projects/${project_id}/invites/${invite_id}`
  2392. );
  2393. const getCollaborators = baseApi<{}, { project_id: number }>(
  2394. "GET",
  2395. ({ project_id }) => `/api/projects/${project_id}/collaborators`
  2396. );
  2397. const updateCollaborator = baseApi<
  2398. {
  2399. kind: string;
  2400. user_id: number;
  2401. },
  2402. { project_id: number }
  2403. >("POST", ({ project_id }) => `/api/projects/${project_id}/roles`);
  2404. const removeCollaborator = baseApi<{ user_id: number }, { project_id: number }>(
  2405. "DELETE",
  2406. ({ project_id }) => `/api/projects/${project_id}/roles`
  2407. );
  2408. const getPolicyDocument = baseApi<{}, { project_id: number }>(
  2409. "GET",
  2410. ({ project_id }) => `/api/projects/${project_id}/policy`
  2411. );
  2412. const createWebhookToken = baseApi<
  2413. {},
  2414. {
  2415. project_id: number;
  2416. chart_name: string;
  2417. namespace: string;
  2418. cluster_id: number;
  2419. }
  2420. >(
  2421. "POST",
  2422. ({ project_id, chart_name, namespace, cluster_id }) =>
  2423. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${chart_name}/0/webhook`
  2424. );
  2425. const getUsage = baseApi<{}, { project_id: number }>(
  2426. "GET",
  2427. ({ project_id }) => `/api/projects/${project_id}/usage`
  2428. );
  2429. const getOnboardingState = baseApi<{}, { project_id: number }>(
  2430. "GET",
  2431. ({ project_id }) => `/api/projects/${project_id}/onboarding`
  2432. );
  2433. const saveOnboardingState = baseApi<{}, { project_id: number }>(
  2434. "POST",
  2435. ({ project_id }) => `/api/projects/${project_id}/onboarding`
  2436. );
  2437. const getOnboardingInfra = baseApi<
  2438. {},
  2439. { project_id: number; registry_infra_id: number }
  2440. >(
  2441. "GET",
  2442. ({ project_id, registry_infra_id }) =>
  2443. `/api/projects/${project_id}/infras/${registry_infra_id}`
  2444. );
  2445. const getOnboardingRegistry = baseApi<
  2446. {},
  2447. { project_id: number; registry_connection_id: number }
  2448. >(
  2449. "GET",
  2450. ({ project_id, registry_connection_id }) =>
  2451. `/api/projects/${project_id}/registries/${registry_connection_id}`
  2452. );
  2453. const detectPorterAgent = baseApi<
  2454. {},
  2455. { project_id: number; cluster_id: number }
  2456. >(
  2457. "GET",
  2458. ({ project_id, cluster_id }) =>
  2459. `/api/projects/${project_id}/clusters/${cluster_id}/agent/detect`
  2460. );
  2461. const installPorterAgent = baseApi<
  2462. {},
  2463. { project_id: number; cluster_id: number }
  2464. >(
  2465. "POST",
  2466. ({ cluster_id, project_id }) =>
  2467. `/api/projects/${project_id}/clusters/${cluster_id}/agent/install`
  2468. );
  2469. const getKubeEvents = baseApi<
  2470. {
  2471. skip: number;
  2472. resource_type: string;
  2473. owner_type?: string;
  2474. owner_name?: string;
  2475. namespace?: string;
  2476. },
  2477. { project_id: number; cluster_id: number }
  2478. >("GET", ({ project_id, cluster_id }) => {
  2479. return `/api/projects/${project_id}/clusters/${cluster_id}/kube_events`;
  2480. });
  2481. const getKubeEvent = baseApi<
  2482. {},
  2483. { project_id: number; cluster_id: number; kube_event_id: number }
  2484. >(
  2485. "GET",
  2486. ({ project_id, cluster_id, kube_event_id }) =>
  2487. `/api/projects/${project_id}/clusters/${cluster_id}/kube_events/${kube_event_id}`
  2488. );
  2489. const getLogBuckets = baseApi<
  2490. {},
  2491. { project_id: number; cluster_id: number; kube_event_id: number }
  2492. >(
  2493. "GET",
  2494. ({ project_id, cluster_id, kube_event_id }) =>
  2495. `/api/projects/${project_id}/clusters/${cluster_id}/kube_events/${kube_event_id}/log_buckets`
  2496. );
  2497. const getLogBucketLogs = baseApi<
  2498. { timestamp: number },
  2499. { project_id: number; cluster_id: number; kube_event_id: number }
  2500. >(
  2501. "GET",
  2502. ({ project_id, cluster_id, kube_event_id }) =>
  2503. `/api/projects/${project_id}/clusters/${cluster_id}/kube_events/${kube_event_id}/logs`
  2504. );
  2505. const getCanCreateProject = baseApi<{}, {}>(
  2506. "GET",
  2507. () => "/api/can_create_project"
  2508. );
  2509. const addApplicationToEnvGroup = baseApi<
  2510. {
  2511. name: string; // Env Group name
  2512. app_name: string;
  2513. },
  2514. { project_id: number; cluster_id: number; namespace: string }
  2515. >(
  2516. "POST",
  2517. ({ cluster_id, namespace, project_id }) =>
  2518. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/envgroup/add_application`
  2519. );
  2520. const removeApplicationFromEnvGroup = baseApi<
  2521. {
  2522. name: string; // Env Group name
  2523. app_name: string;
  2524. },
  2525. { project_id: number; cluster_id: number; namespace: string }
  2526. >(
  2527. "POST",
  2528. ({ cluster_id, namespace, project_id }) =>
  2529. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/envgroup/remove_application`
  2530. );
  2531. const provisionDatabase = baseApi<
  2532. {
  2533. username: string;
  2534. password: string;
  2535. machine_type: string;
  2536. db_storage_encrypted: boolean;
  2537. db_name: string;
  2538. db_max_allocated_storage: string;
  2539. db_family: string;
  2540. db_engine_version: string;
  2541. db_allocated_storage: string;
  2542. },
  2543. { project_id: number; cluster_id: number; namespace: string }
  2544. >(
  2545. "POST",
  2546. ({ project_id, cluster_id, namespace }) =>
  2547. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/provision/rds`
  2548. );
  2549. const getAwsCloudProviders = baseApi<
  2550. {},
  2551. {
  2552. project_id: number;
  2553. }
  2554. >("GET", ({ project_id }) => {
  2555. return `/api/projects/${project_id}/cloud-providers/aws`;
  2556. });
  2557. const getDatabases = baseApi<
  2558. {},
  2559. {
  2560. project_id: number;
  2561. cluster_id: number;
  2562. }
  2563. >(
  2564. "GET",
  2565. ({ project_id, cluster_id }) =>
  2566. `/api/projects/${project_id}/clusters/${cluster_id}/databases`
  2567. );
  2568. const getDatastores = baseApi<
  2569. {},
  2570. {
  2571. project_id: number;
  2572. cloud_provider_name: string;
  2573. cloud_provider_id: string;
  2574. datastore_name?: string;
  2575. datastore_type?: string;
  2576. include_env_group?: boolean;
  2577. include_metadata?: boolean;
  2578. }
  2579. >(
  2580. "GET",
  2581. ({
  2582. project_id,
  2583. cloud_provider_name,
  2584. cloud_provider_id,
  2585. datastore_name,
  2586. datastore_type,
  2587. include_env_group,
  2588. include_metadata,
  2589. }) => {
  2590. const queryParams = new URLSearchParams();
  2591. if (datastore_name) {
  2592. queryParams.set("name", datastore_name);
  2593. }
  2594. if (datastore_type) {
  2595. queryParams.set("type", datastore_type);
  2596. }
  2597. if (include_env_group) {
  2598. queryParams.set("include_env_group", "true");
  2599. }
  2600. if (include_metadata) {
  2601. queryParams.set("include_metadata", "true");
  2602. }
  2603. return `/api/projects/${project_id}/cloud-providers/${cloud_provider_name}/${cloud_provider_id}/datastores?${queryParams.toString()}`;
  2604. }
  2605. );
  2606. const listDatastores = baseApi<
  2607. {},
  2608. {
  2609. project_id: number;
  2610. }
  2611. >("GET", ({ project_id }) => {
  2612. return `/api/projects/${project_id}/datastores`;
  2613. });
  2614. const getDatastore = baseApi<
  2615. {},
  2616. {
  2617. project_id: number;
  2618. datastore_name: string;
  2619. }
  2620. >("GET", ({ project_id, datastore_name }) => {
  2621. return `/api/projects/${project_id}/datastores/${datastore_name}`;
  2622. });
  2623. const getDatastoreCredential = baseApi<
  2624. {},
  2625. {
  2626. project_id: number;
  2627. datastore_name: string;
  2628. }
  2629. >("GET", ({ project_id, datastore_name }) => {
  2630. return `/api/projects/${project_id}/datastores/${datastore_name}/credential`;
  2631. });
  2632. const updateDatastore = baseApi<
  2633. {
  2634. name: string;
  2635. type:
  2636. | "RDS"
  2637. | "ELASTICACHE"
  2638. | "MANAGED-POSTGRES"
  2639. | "MANAGED-REDIS"
  2640. | "NEON"
  2641. | "UPSTASH";
  2642. engine: "POSTGRES" | "AURORA-POSTGRES" | "REDIS";
  2643. values: any;
  2644. },
  2645. { project_id: number; cluster_id: number }
  2646. >(
  2647. "POST",
  2648. ({ project_id, cluster_id }) =>
  2649. `/api/projects/${project_id}/clusters/${cluster_id}/datastores`
  2650. );
  2651. const deleteDatastore = baseApi<
  2652. {},
  2653. {
  2654. project_id: number;
  2655. datastore_name: string;
  2656. }
  2657. >(
  2658. "DELETE",
  2659. ({ project_id, datastore_name }) =>
  2660. `/api/projects/${project_id}/datastores/${datastore_name}`
  2661. );
  2662. const getPreviousLogsForContainer = baseApi<
  2663. {
  2664. container_name: string;
  2665. },
  2666. {
  2667. project_id: number;
  2668. cluster_id: number;
  2669. namespace: string;
  2670. pod_name: string;
  2671. }
  2672. >(
  2673. "GET",
  2674. ({ cluster_id, namespace, pod_name: name, project_id }) =>
  2675. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/pod/${name}/previous_logs`
  2676. );
  2677. const upgradePorterAgent = baseApi<
  2678. {},
  2679. { project_id: number; cluster_id: number }
  2680. >(
  2681. "POST",
  2682. ({ project_id, cluster_id }) =>
  2683. `/api/projects/${project_id}/clusters/${cluster_id}/agent/upgrade`
  2684. );
  2685. const updateBuildConfig = baseApi<
  2686. BuildConfig,
  2687. {
  2688. project_id: number;
  2689. cluster_id: number;
  2690. namespace: string;
  2691. release_name: string;
  2692. }
  2693. >(
  2694. "POST",
  2695. ({ project_id, cluster_id, namespace, release_name }) =>
  2696. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/buildconfig`
  2697. );
  2698. const updateGitActionConfig = baseApi<
  2699. {
  2700. git_action_config: {
  2701. git_branch: string;
  2702. };
  2703. },
  2704. {
  2705. project_id: number;
  2706. cluster_id: number;
  2707. namespace: string;
  2708. release_name: string;
  2709. revision?: 0; // Always update latest
  2710. }
  2711. >(
  2712. "PATCH",
  2713. ({ project_id, cluster_id, namespace, release_name, revision = 0 }) =>
  2714. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/${revision}/git_action_config`
  2715. );
  2716. const reRunGHWorkflow = baseApi<
  2717. {},
  2718. {
  2719. project_id: number;
  2720. cluster_id: number;
  2721. git_installation_id: number;
  2722. owner: string;
  2723. name: string;
  2724. branch?: string;
  2725. filename?: string;
  2726. release_name?: string;
  2727. }
  2728. >(
  2729. "POST",
  2730. ({
  2731. project_id,
  2732. git_installation_id,
  2733. owner,
  2734. name,
  2735. cluster_id,
  2736. filename,
  2737. release_name,
  2738. branch,
  2739. }) => {
  2740. const queryParams = new URLSearchParams();
  2741. if (branch) {
  2742. queryParams.set("branch", branch);
  2743. }
  2744. if (release_name) {
  2745. queryParams.set("release_name", release_name);
  2746. }
  2747. if (filename) {
  2748. queryParams.set("filename", filename);
  2749. }
  2750. return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${owner}/${name}/clusters/${cluster_id}/rerun_workflow?${queryParams.toString()}`;
  2751. }
  2752. );
  2753. const getGHWorkflowLogs = baseApi<
  2754. {},
  2755. {
  2756. project_id: number;
  2757. cluster_id: number;
  2758. git_installation_id: number;
  2759. owner: string;
  2760. name: string;
  2761. filename?: string;
  2762. release_name?: string;
  2763. }
  2764. >(
  2765. "GET",
  2766. ({
  2767. project_id,
  2768. git_installation_id,
  2769. owner,
  2770. name,
  2771. cluster_id,
  2772. filename,
  2773. release_name,
  2774. }) => {
  2775. const queryParams = new URLSearchParams();
  2776. if (release_name) {
  2777. queryParams.set("release_name", release_name);
  2778. }
  2779. if (filename) {
  2780. queryParams.set("filename", filename);
  2781. }
  2782. return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${owner}/${name}/clusters/${cluster_id}/get_logs_workflow?${queryParams.toString()}`;
  2783. }
  2784. );
  2785. const getGHWorkflowLogById = baseApi<
  2786. {},
  2787. {
  2788. project_id: number;
  2789. cluster_id: number;
  2790. git_installation_id: number;
  2791. owner: string;
  2792. name: string;
  2793. filename?: string;
  2794. run_id: string;
  2795. release_name?: string;
  2796. }
  2797. >(
  2798. "GET",
  2799. ({
  2800. project_id,
  2801. git_installation_id,
  2802. owner,
  2803. name,
  2804. cluster_id,
  2805. filename,
  2806. run_id,
  2807. release_name,
  2808. }) => {
  2809. const queryParams = new URLSearchParams();
  2810. if (release_name) {
  2811. queryParams.set("release_name", release_name);
  2812. }
  2813. if (filename) {
  2814. queryParams.set("filename", filename);
  2815. }
  2816. if (run_id) {
  2817. queryParams.set("run_id", run_id);
  2818. }
  2819. return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${owner}/${name}/clusters/${cluster_id}/workflow_run_id?${queryParams.toString()}`;
  2820. }
  2821. );
  2822. const triggerPreviewEnvWorkflow = baseApi<
  2823. {},
  2824. { project_id: number; cluster_id: number; deployment_id: number }
  2825. >(
  2826. "POST",
  2827. ({ project_id, cluster_id, deployment_id }) =>
  2828. `/api/projects/${project_id}/clusters/${cluster_id}/deployments/${deployment_id}/trigger_workflow`
  2829. );
  2830. const getTagsByProjectId = baseApi<{}, { project_id: number }>(
  2831. "GET",
  2832. ({ project_id }) => `/api/projects/${project_id}/tags`
  2833. );
  2834. const createTag = baseApi<
  2835. { name: string; color: string },
  2836. { project_id: number }
  2837. >("POST", ({ project_id }) => `/api/projects/${project_id}/tags`);
  2838. const updateReleaseTags = baseApi<
  2839. {
  2840. tags: string[];
  2841. },
  2842. {
  2843. project_id: number;
  2844. cluster_id: number;
  2845. namespace: string;
  2846. release_name: string;
  2847. }
  2848. >(
  2849. "PATCH",
  2850. ({ project_id, cluster_id, namespace, release_name }) =>
  2851. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/update_tags`
  2852. );
  2853. const updateCanonicalName = baseApi<
  2854. {
  2855. canonical_name: string;
  2856. },
  2857. {
  2858. project_id: number;
  2859. cluster_id: number;
  2860. namespace: string;
  2861. release_name: string;
  2862. }
  2863. >(
  2864. "PATCH",
  2865. ({ project_id, cluster_id, namespace, release_name }) =>
  2866. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/update_canonical_name`
  2867. );
  2868. const getGitProviders = baseApi<{}, { project_id: number }>(
  2869. "GET",
  2870. ({ project_id }) => `/api/projects/${project_id}/integrations/git`
  2871. );
  2872. const getGitlabRepos = baseApi<
  2873. {},
  2874. { project_id: number; integration_id: number }
  2875. >(
  2876. "GET",
  2877. ({ project_id, integration_id }) =>
  2878. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos`
  2879. );
  2880. const getGitlabBranches = baseApi<
  2881. {},
  2882. {
  2883. project_id: number;
  2884. integration_id: number;
  2885. repo_owner: string;
  2886. repo_name: string;
  2887. }
  2888. >(
  2889. "GET",
  2890. ({ project_id, integration_id, repo_owner, repo_name }) =>
  2891. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos/${repo_owner}/${repo_name}/branches`
  2892. );
  2893. const getGitlabFolderContent = baseApi<
  2894. {
  2895. dir: string;
  2896. },
  2897. {
  2898. project_id: number;
  2899. integration_id: number;
  2900. repo_owner: string;
  2901. repo_name: string;
  2902. branch: string;
  2903. }
  2904. >(
  2905. "GET",
  2906. ({ project_id, integration_id, repo_owner, repo_name, branch }) =>
  2907. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos/${repo_owner}/${repo_name}/${branch}/contents`
  2908. );
  2909. const getLogPodValues = baseApi<
  2910. {
  2911. namespace?: string;
  2912. revision?: string;
  2913. match_prefix?: string;
  2914. start_range?: string;
  2915. end_range?: string;
  2916. },
  2917. {
  2918. project_id: number;
  2919. cluster_id: number;
  2920. }
  2921. >(
  2922. "GET",
  2923. ({ project_id, cluster_id }) =>
  2924. `/api/projects/${project_id}/clusters/${cluster_id}/logs/pod_values`
  2925. );
  2926. const getLogs = baseApi<
  2927. {
  2928. limit?: number;
  2929. start_range?: string;
  2930. end_range?: string;
  2931. revision?: string;
  2932. pod_selector: string;
  2933. namespace?: string;
  2934. search_param?: string;
  2935. direction?: string;
  2936. },
  2937. {
  2938. project_id: number;
  2939. cluster_id: number;
  2940. }
  2941. >(
  2942. "GET",
  2943. ({ project_id, cluster_id }) =>
  2944. `/api/projects/${project_id}/clusters/${cluster_id}/logs`
  2945. );
  2946. const listPorterEvents = baseApi<
  2947. {
  2948. release_name?: number;
  2949. release_namespace?: string;
  2950. type?: string;
  2951. },
  2952. {
  2953. project_id: number;
  2954. cluster_id: number;
  2955. }
  2956. >(
  2957. "GET",
  2958. ({ project_id, cluster_id }) =>
  2959. `/api/projects/${project_id}/clusters/${cluster_id}/events`
  2960. );
  2961. const listPorterJobEvents = baseApi<
  2962. {
  2963. release_name?: number;
  2964. release_namespace?: string;
  2965. type?: string;
  2966. job_name: string;
  2967. },
  2968. {
  2969. project_id: number;
  2970. cluster_id: number;
  2971. }
  2972. >(
  2973. "GET",
  2974. ({ project_id, cluster_id }) =>
  2975. `/api/projects/${project_id}/clusters/${cluster_id}/events/job`
  2976. );
  2977. const listIncidents = baseApi<
  2978. {
  2979. release_name?: number;
  2980. release_namespace?: string;
  2981. status?: string;
  2982. },
  2983. {
  2984. project_id: number;
  2985. cluster_id: number;
  2986. }
  2987. >(
  2988. "GET",
  2989. ({ project_id, cluster_id }) =>
  2990. `/api/projects/${project_id}/clusters/${cluster_id}/incidents`
  2991. );
  2992. const getIncident = baseApi<
  2993. {},
  2994. {
  2995. project_id: number;
  2996. cluster_id: number;
  2997. incident_id: string;
  2998. }
  2999. >(
  3000. "GET",
  3001. ({ project_id, cluster_id, incident_id }) =>
  3002. `/api/projects/${project_id}/clusters/${cluster_id}/incidents/${incident_id}`
  3003. );
  3004. const getIncidentEvents = baseApi<
  3005. {
  3006. incident_id?: string;
  3007. pod_prefix?: string;
  3008. },
  3009. {
  3010. project_id: number;
  3011. cluster_id: number;
  3012. }
  3013. >(
  3014. "GET",
  3015. ({ project_id, cluster_id }) =>
  3016. `/api/projects/${project_id}/clusters/${cluster_id}/incidents/events`
  3017. );
  3018. // TRACKING
  3019. const updateOnboardingStep = baseApi<
  3020. {
  3021. step: string;
  3022. provider?: string;
  3023. cloud_provider_credential_identifier?: string;
  3024. account_id?: string;
  3025. cloudformation_url?: string;
  3026. error_message?: string;
  3027. login_url?: string;
  3028. external_id?: string;
  3029. region?: string;
  3030. cluster_name?: string;
  3031. },
  3032. {
  3033. project_id: number;
  3034. }
  3035. >("POST", ({ project_id }) => {
  3036. return `/api/projects/${project_id}/onboarding_step`;
  3037. });
  3038. const updateStackStep = baseApi<
  3039. {
  3040. step: string;
  3041. stack_name?: string;
  3042. error_message?: string;
  3043. delete_workflow_file?: boolean;
  3044. error_stack_trace?: string;
  3045. },
  3046. {
  3047. project_id: number;
  3048. cluster_id: number;
  3049. }
  3050. >("POST", (pathParams) => {
  3051. const { project_id, cluster_id } = pathParams;
  3052. return `/api/projects/${project_id}/clusters/${cluster_id}/applications/analytics`;
  3053. });
  3054. // STACKS
  3055. const createStack = baseApi<
  3056. CreateStackBody,
  3057. {
  3058. project_id: number;
  3059. cluster_id: number;
  3060. namespace: string;
  3061. }
  3062. >(
  3063. "POST",
  3064. ({ project_id, cluster_id, namespace }) =>
  3065. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks`
  3066. );
  3067. const updateStack = baseApi<
  3068. {
  3069. name: string;
  3070. },
  3071. {
  3072. project_id: number;
  3073. cluster_id: number;
  3074. namespace: string;
  3075. stack_id: string;
  3076. }
  3077. >(
  3078. "PATCH",
  3079. ({ project_id, cluster_id, namespace, stack_id }) =>
  3080. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}`
  3081. );
  3082. const listStacks = baseApi<
  3083. {},
  3084. { project_id: number; cluster_id: number; namespace: string }
  3085. >(
  3086. "GET",
  3087. ({ project_id, cluster_id, namespace }) =>
  3088. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks`
  3089. );
  3090. const getStack = baseApi<
  3091. {},
  3092. {
  3093. project_id: number;
  3094. cluster_id: number;
  3095. namespace: string;
  3096. stack_id: string;
  3097. }
  3098. >(
  3099. "GET",
  3100. ({ project_id, cluster_id, namespace, stack_id }) =>
  3101. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}`
  3102. );
  3103. const getStackRevision = baseApi<
  3104. {},
  3105. {
  3106. project_id: number;
  3107. cluster_id: number;
  3108. namespace: string;
  3109. stack_id: string;
  3110. revision_id: number;
  3111. }
  3112. >(
  3113. "GET",
  3114. ({ project_id, cluster_id, namespace, stack_id, revision_id }) =>
  3115. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/${revision_id}`
  3116. );
  3117. const rollbackStack = baseApi<
  3118. {
  3119. target_revision: number;
  3120. },
  3121. {
  3122. project_id: number;
  3123. cluster_id: number;
  3124. namespace: string;
  3125. stack_id: string;
  3126. }
  3127. >(
  3128. "POST",
  3129. ({ project_id, cluster_id, namespace, stack_id }) =>
  3130. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/rollback`
  3131. );
  3132. const deleteStack = baseApi<
  3133. {},
  3134. {
  3135. project_id: number;
  3136. cluster_id: number;
  3137. namespace: string;
  3138. stack_id: string;
  3139. }
  3140. >(
  3141. "DELETE",
  3142. ({ project_id, cluster_id, namespace, stack_id }) =>
  3143. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}`
  3144. );
  3145. const updateStackSourceConfig = baseApi<
  3146. {
  3147. source_configs: SourceConfig[];
  3148. },
  3149. {
  3150. project_id: number;
  3151. cluster_id: number;
  3152. namespace: string;
  3153. stack_id: string;
  3154. }
  3155. >(
  3156. "PUT",
  3157. ({ project_id, cluster_id, namespace, stack_id }) =>
  3158. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/source`
  3159. );
  3160. const addStackAppResource = baseApi<
  3161. CreateStackBody["app_resources"][0],
  3162. {
  3163. project_id: number;
  3164. cluster_id: number;
  3165. namespace: string;
  3166. stack_id: string;
  3167. }
  3168. >(
  3169. "PATCH",
  3170. ({ project_id, cluster_id, namespace, stack_id }) =>
  3171. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/add_application`
  3172. );
  3173. const removeStackAppResource = baseApi<
  3174. {},
  3175. {
  3176. project_id: number;
  3177. cluster_id: number;
  3178. namespace: string;
  3179. stack_id: string;
  3180. app_resource_name: string;
  3181. }
  3182. >(
  3183. "DELETE",
  3184. ({ project_id, cluster_id, namespace, stack_id, app_resource_name }) =>
  3185. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/remove_application/${app_resource_name}`
  3186. );
  3187. const addStackEnvGroup = baseApi<
  3188. CreateStackBody["env_groups"][0],
  3189. {
  3190. project_id: number;
  3191. cluster_id: number;
  3192. namespace: string;
  3193. stack_id: string;
  3194. }
  3195. >(
  3196. "PATCH",
  3197. ({ project_id, cluster_id, namespace, stack_id }) =>
  3198. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/add_env_group`
  3199. );
  3200. const removeStackEnvGroup = baseApi<
  3201. {},
  3202. {
  3203. project_id: number;
  3204. cluster_id: number;
  3205. namespace: string;
  3206. stack_id: string;
  3207. env_group_name: string;
  3208. }
  3209. >(
  3210. "DELETE",
  3211. ({ project_id, cluster_id, namespace, stack_id, env_group_name }) =>
  3212. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/remove_env_group/${env_group_name}`
  3213. );
  3214. // Billing
  3215. const getPublishableKey = baseApi<
  3216. {},
  3217. {
  3218. project_id?: number;
  3219. }
  3220. >(
  3221. "GET",
  3222. ({ project_id }) => `/api/projects/${project_id}/billing/publishable_key`
  3223. );
  3224. const getCustomerUsage = baseApi<
  3225. {
  3226. previous_periods?: number;
  3227. current_period?: boolean;
  3228. },
  3229. {
  3230. project_id?: number;
  3231. }
  3232. >("POST", ({ project_id }) => `/api/projects/${project_id}/billing/usage`);
  3233. const getCustomerCosts = baseApi<
  3234. {},
  3235. {
  3236. project_id?: number;
  3237. starting_on: string;
  3238. ending_before: string;
  3239. limit: number;
  3240. }
  3241. >(
  3242. "GET",
  3243. ({ project_id, starting_on, ending_before, limit }) =>
  3244. `/api/projects/${project_id}/billing/costs?starting_on=${starting_on}&ending_before=${ending_before}&limit=${limit}`
  3245. );
  3246. const getCustomerInvoices = baseApi<
  3247. {},
  3248. {
  3249. project_id?: number;
  3250. }
  3251. >("GET", ({ project_id }) => `/api/projects/${project_id}/billing/invoices`);
  3252. const getCustomerPlan = baseApi<
  3253. {},
  3254. {
  3255. project_id?: number;
  3256. }
  3257. >("GET", ({ project_id }) => `/api/projects/${project_id}/billing/plan`);
  3258. const getPorterCredits = baseApi<
  3259. {},
  3260. {
  3261. project_id?: number;
  3262. }
  3263. >("GET", ({ project_id }) => `/api/projects/${project_id}/billing/credits`);
  3264. const getHasBilling = baseApi<{}, { project_id: number }>(
  3265. "GET",
  3266. ({ project_id }) => `/api/projects/${project_id}/billing`
  3267. );
  3268. const listPaymentMethod = baseApi<
  3269. {},
  3270. {
  3271. project_id?: number;
  3272. }
  3273. >(
  3274. "GET",
  3275. ({ project_id }) => `/api/projects/${project_id}/billing/payment_method`
  3276. );
  3277. const addPaymentMethod = baseApi<
  3278. {},
  3279. {
  3280. project_id?: number;
  3281. }
  3282. >(
  3283. "POST",
  3284. ({ project_id }) => `/api/projects/${project_id}/billing/payment_method`
  3285. );
  3286. const setDefaultPaymentMethod = baseApi<
  3287. {},
  3288. {
  3289. project_id?: number;
  3290. payment_method_id: string;
  3291. }
  3292. >(
  3293. "PUT",
  3294. ({ project_id, payment_method_id }) =>
  3295. `/api/projects/${project_id}/billing/payment_method/${payment_method_id}/default`
  3296. );
  3297. const deletePaymentMethod = baseApi<
  3298. {},
  3299. {
  3300. project_id?: number;
  3301. payment_method_id: string;
  3302. }
  3303. >(
  3304. "DELETE",
  3305. ({ project_id, payment_method_id }) =>
  3306. `/api/projects/${project_id}/billing/payment_method/${payment_method_id}`
  3307. );
  3308. const getReferralDetails = baseApi<
  3309. {},
  3310. {
  3311. project_id?: number;
  3312. }
  3313. >("GET", ({ project_id }) => `/api/projects/${project_id}/referrals/details`);
  3314. const getGithubStatus = baseApi<{}, {}>("GET", ({}) => `/api/status/github`);
  3315. const createSecretAndOpenGitHubPullRequest = baseApi<
  3316. {
  3317. github_app_installation_id: number;
  3318. github_repo_owner: string;
  3319. github_repo_name: string;
  3320. branch: string;
  3321. open_pr?: boolean;
  3322. porter_yaml_path?: string;
  3323. delete_workflow_filename?: string;
  3324. previews_workflow_filename?: string;
  3325. deployment_target_id?: string;
  3326. },
  3327. {
  3328. project_id: number;
  3329. cluster_id: number;
  3330. stack_name: string;
  3331. }
  3332. >(
  3333. "POST",
  3334. ({ project_id, cluster_id, stack_name }) =>
  3335. `/api/projects/${project_id}/clusters/${cluster_id}/applications/${stack_name}/pr`
  3336. );
  3337. const getCloudProviderPermissionsStatus = baseApi<
  3338. {
  3339. cloud_provider: string;
  3340. cloud_provider_credential_identifier: string;
  3341. },
  3342. { project_id: number }
  3343. >(
  3344. "GET",
  3345. ({ project_id }) =>
  3346. `/api/projects/${project_id}/integrations/cloud-permissions`
  3347. );
  3348. const getCloudSqlSecret = baseApi<
  3349. {},
  3350. { project_id: number; deployment_target_id: string; app_name: string }
  3351. >(
  3352. "GET",
  3353. ({ project_id, deployment_target_id, app_name }) =>
  3354. `/api/projects/${project_id}/targets/${deployment_target_id}/apps/${app_name}/cloudsql`
  3355. );
  3356. const createCloudSqlSecret = baseApi<
  3357. {
  3358. b64_service_account_json: string;
  3359. },
  3360. { project_id: number; deployment_target_id: string; app_name: string }
  3361. >(
  3362. "POST",
  3363. ({ project_id, deployment_target_id, app_name }) =>
  3364. `/api/projects/${project_id}/targets/${deployment_target_id}/apps/${app_name}/cloudsql`
  3365. );
  3366. const appEventWebhooks = baseApi<
  3367. {},
  3368. {
  3369. projectId: number;
  3370. deploymentTargetId: string;
  3371. appName: string;
  3372. }
  3373. >("GET", (pathParams) => {
  3374. return `/api/projects/${pathParams.projectId}/targets/${pathParams.deploymentTargetId}/apps/${pathParams.appName}/app-event-webhooks`;
  3375. });
  3376. const updateAppEventWebhooks = baseApi<
  3377. {
  3378. app_event_webhooks: AppEventWebhook[];
  3379. },
  3380. {
  3381. projectId: number;
  3382. deploymentTargetId: string;
  3383. appName: string;
  3384. }
  3385. >("POST", (pathParams) => {
  3386. return `/api/projects/${pathParams.projectId}/targets/${pathParams.deploymentTargetId}/apps/${pathParams.appName}/update-app-event-webhooks`;
  3387. });
  3388. const systemStatusHistory = baseApi<
  3389. {},
  3390. {
  3391. projectId: number;
  3392. clusterId: number;
  3393. }
  3394. >("GET", (pathParams) => {
  3395. return `/api/projects/${pathParams.projectId}/clusters/${pathParams.clusterId}/system-status-history`;
  3396. });
  3397. // Bundle export to allow default api import (api.<method> is more readable)
  3398. export default {
  3399. checkAuth,
  3400. connectECRRegistry,
  3401. connectGCRRegistry,
  3402. connectDORegistry,
  3403. getAWSIntegration,
  3404. getGCPIntegration,
  3405. getAzureIntegration,
  3406. getGitlabIntegration,
  3407. createAWSIntegration,
  3408. overwriteAWSIntegration,
  3409. updateCluster,
  3410. renameCluster,
  3411. renameProject,
  3412. createAzureIntegration,
  3413. createGitlabIntegration,
  3414. createEmailVerification,
  3415. createEnvironment,
  3416. createEnvironmentGroups,
  3417. enableExternalEnvGroupProviders,
  3418. areExternalEnvGroupProvidersEnabled,
  3419. updateEnvironment,
  3420. deleteEnvironment,
  3421. createPreviewEnvironmentDeployment,
  3422. reenablePreviewEnvironmentDeployment,
  3423. listEnvironments,
  3424. getEnvironment,
  3425. toggleNewCommentForEnvironment,
  3426. validatePorterYAML,
  3427. createGCPIntegration,
  3428. createInvite,
  3429. createNamespace,
  3430. createPasswordReset,
  3431. createPasswordResetVerify,
  3432. createPasswordResetFinalize,
  3433. createProject,
  3434. connectProjectToCluster,
  3435. // ------------ PORTER APP -----------
  3436. getPorterApps,
  3437. getPorterApp,
  3438. getPorterAppEvent,
  3439. createPorterApp,
  3440. deletePorterApp,
  3441. rollbackPorterApp,
  3442. createSecretAndOpenGitHubPullRequest,
  3443. getLogsWithinTimeRange,
  3444. appLogs,
  3445. appJobs,
  3446. cancelJob,
  3447. appEvents,
  3448. appServiceStatus,
  3449. getFeedEvents,
  3450. updateStackStep,
  3451. porterYamlFromRevision,
  3452. // -----------------------------------
  3453. createConfigMap,
  3454. deleteCluster,
  3455. deleteConfigMap,
  3456. deleteInvite,
  3457. deleteNamespace,
  3458. deletePod,
  3459. deleteProject,
  3460. deleteRegistryIntegration,
  3461. deleteSlackIntegration,
  3462. legacyUpdateNotificationConfig,
  3463. updateNotificationConfig,
  3464. legacyGetNotificationConfig,
  3465. getNotificationConfig,
  3466. getNotification,
  3467. createSubdomain,
  3468. deployTemplate,
  3469. deployAddon,
  3470. destroyInfra,
  3471. updateDatabaseStatus,
  3472. detectBuildpack,
  3473. detectGitlabBuildpack,
  3474. getBranchContents,
  3475. getBranches,
  3476. getMetadata,
  3477. postWelcome,
  3478. getChart,
  3479. getCharts,
  3480. getChartComponents,
  3481. getChartControllers,
  3482. getClusterIntegrations,
  3483. getClusters,
  3484. getCluster,
  3485. getClusterNodes,
  3486. getClusterNode,
  3487. getClusterStatus,
  3488. getConfigMap,
  3489. getPRDeploymentList,
  3490. getPRDeploymentByID,
  3491. getGHAWorkflowTemplate,
  3492. getGitRepoList,
  3493. getGitRepoPermission,
  3494. getGitRepos,
  3495. getImageRepos,
  3496. getImageTags,
  3497. images,
  3498. listInfraTemplates,
  3499. getInfraTemplate,
  3500. getInfra,
  3501. provisionCluster,
  3502. provisionInfra,
  3503. deleteInfra,
  3504. updateInfra,
  3505. listOperations,
  3506. getOperation,
  3507. getOperationLogs,
  3508. retryCreateInfra,
  3509. retryDeleteInfra,
  3510. getInfraState,
  3511. getInfraRawState,
  3512. getInfraByID,
  3513. getInfraDesired,
  3514. getInfraCurrent,
  3515. getIngress,
  3516. getInvites,
  3517. getJobs,
  3518. getJobStatus,
  3519. getJobPods,
  3520. getPodByName,
  3521. getMatchingPods,
  3522. getAllReleasePods,
  3523. getClusterState,
  3524. getComplianceChecks,
  3525. getMetrics,
  3526. appMetrics,
  3527. appHelmValues,
  3528. getNamespaces,
  3529. getNGINXIngresses,
  3530. getOAuthIds,
  3531. getPodEvents,
  3532. getProcfileContents,
  3533. getPorterYamlContents,
  3534. parsePorterYaml,
  3535. attachEnvGroup,
  3536. getDefaultDeploymentTarget,
  3537. deleteDeploymentTarget,
  3538. getBranchHead,
  3539. createApp,
  3540. createAppTemplate,
  3541. listTemplateEnvironments,
  3542. updateApp,
  3543. appRun,
  3544. updateBuildSettings,
  3545. revertApp,
  3546. getAttachedEnvGroups,
  3547. getLatestRevision,
  3548. appNotifications,
  3549. getRevision,
  3550. listAppRevisions,
  3551. getLatestAppRevisions,
  3552. getAppInstances,
  3553. listDeploymentTargets,
  3554. createDeploymentTarget,
  3555. getDeploymentTarget,
  3556. getAppTemplate,
  3557. listAddons,
  3558. getAddon,
  3559. getTailscaleServices,
  3560. updateAddon,
  3561. deleteAddon,
  3562. getGitlabProcfileContents,
  3563. getProjectClusters,
  3564. getProjectRegistries,
  3565. getProjectRepos,
  3566. getProjects,
  3567. getProject,
  3568. getPrometheusIsInstalled,
  3569. getRegistryIntegrations,
  3570. getReleaseToken,
  3571. getReleaseSteps,
  3572. getRepoIntegrations,
  3573. getSlackIntegrations,
  3574. getNeonIntegrations,
  3575. getUpstashIntegrations,
  3576. getRepos,
  3577. getRevisions,
  3578. getTemplateInfo,
  3579. getTemplateUpgradeNotes,
  3580. getTemplates,
  3581. getHelmRepos,
  3582. getChartsFromHelmRepo,
  3583. getChartInfoFromHelmRepo,
  3584. linkGithubProject,
  3585. inviteAdmin,
  3586. getGithubAccounts,
  3587. listConfigMaps,
  3588. logInUser,
  3589. logOutUser,
  3590. registerUser,
  3591. rollbackChart,
  3592. uninstallTemplate,
  3593. updateUserInfo,
  3594. updateUser,
  3595. renameConfigMap,
  3596. updateConfigMap,
  3597. upgradeChartValues,
  3598. deleteJob,
  3599. stopJob,
  3600. updateInvite,
  3601. listAPITokens,
  3602. getAPIToken,
  3603. revokeAPIToken,
  3604. createAPIToken,
  3605. createPolicy,
  3606. getAvailableRoles,
  3607. getCollaborators,
  3608. updateCollaborator,
  3609. removeCollaborator,
  3610. getPolicyDocument,
  3611. createWebhookToken,
  3612. getUsage,
  3613. getHasBilling,
  3614. getOnboardingState,
  3615. saveOnboardingState,
  3616. getOnboardingInfra,
  3617. getOnboardingRegistry,
  3618. detectPorterAgent,
  3619. installPorterAgent,
  3620. getKubeEvents,
  3621. getKubeEvent,
  3622. getLogBuckets,
  3623. getLogBucketLogs,
  3624. getCanCreateProject,
  3625. createEnvGroup,
  3626. cloneEnvGroup,
  3627. updateEnvGroup,
  3628. updateStacksEnvGroup,
  3629. listEnvGroups,
  3630. getAllEnvGroups,
  3631. updateEnvironmentGroupV2,
  3632. updateAppsLinkedToEnvironmentGroup,
  3633. getEnvGroup,
  3634. deleteEnvGroup,
  3635. deleteNewEnvGroup,
  3636. addApplicationToEnvGroup,
  3637. removeApplicationFromEnvGroup,
  3638. provisionDatabase,
  3639. legacyPreflightCheck,
  3640. requestQuotaIncrease,
  3641. getAwsCloudProviders,
  3642. getDatabases,
  3643. getDatastores,
  3644. listDatastores,
  3645. getDatastore,
  3646. getDatastoreCredential,
  3647. updateDatastore,
  3648. deleteDatastore,
  3649. getPreviousLogsForContainer,
  3650. upgradePorterAgent,
  3651. deletePRDeployment,
  3652. updateBuildConfig,
  3653. updateGitActionConfig,
  3654. reRunGHWorkflow,
  3655. getGHWorkflowLogs,
  3656. getGHWorkflowLogById,
  3657. triggerPreviewEnvWorkflow,
  3658. getTagsByProjectId,
  3659. createTag,
  3660. updateReleaseTags,
  3661. updateCanonicalName,
  3662. getGitProviders,
  3663. getGitlabRepos,
  3664. getGitlabBranches,
  3665. getGitlabFolderContent,
  3666. getLogPodValues,
  3667. getLogs,
  3668. listPorterEvents,
  3669. listPorterJobEvents,
  3670. listIncidents,
  3671. getIncident,
  3672. getIncidentEvents,
  3673. createContract,
  3674. getContracts,
  3675. cloudContractPreflightCheck,
  3676. deleteContract,
  3677. // TRACKING
  3678. updateOnboardingStep,
  3679. // STACKS
  3680. listStacks,
  3681. getStack,
  3682. getStackRevision,
  3683. createStack,
  3684. updateStack,
  3685. rollbackStack,
  3686. deleteStack,
  3687. updateStackSourceConfig,
  3688. addStackAppResource,
  3689. removeStackAppResource,
  3690. addStackEnvGroup,
  3691. removeStackEnvGroup,
  3692. // BILLING
  3693. getPublishableKey,
  3694. getPorterCredits,
  3695. getCustomerPlan,
  3696. getCustomerUsage,
  3697. getCustomerCosts,
  3698. getCustomerInvoices,
  3699. listPaymentMethod,
  3700. addPaymentMethod,
  3701. setDefaultPaymentMethod,
  3702. deletePaymentMethod,
  3703. getReferralDetails,
  3704. // STATUS
  3705. getGithubStatus,
  3706. getCloudProviderPermissionsStatus,
  3707. getCloudSqlSecret,
  3708. createCloudSqlSecret,
  3709. cloudProviderMachineTypes,
  3710. // Webhooks
  3711. appEventWebhooks,
  3712. updateAppEventWebhooks,
  3713. // system status
  3714. systemStatusHistory,
  3715. };