api.tsx 93 KB

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