api.tsx 91 KB

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