api.tsx 90 KB

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