api.tsx 88 KB

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