api.tsx 73 KB

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