api.tsx 92 KB

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