api.tsx 75 KB

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