api.tsx 80 KB

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