api.tsx 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453
  1. import { PolicyDocType } from "./auth/types";
  2. import { PullRequest } from "main/home/cluster-dashboard/preview-environments/types";
  3. import { baseApi } from "./baseApi";
  4. import { BuildConfig, FullActionConfigType } from "./types";
  5. import {
  6. CreateStackBody,
  7. SourceConfig,
  8. } from "main/home/cluster-dashboard/stacks/types";
  9. /**
  10. * Generic api call format
  11. * @param {string} token - Bearer token.
  12. * @param {Object} params - Body params.
  13. * @param {Object} pathParams - Path params.
  14. * @param {(err: Object, res: Object) => void} callback - Callback function.
  15. */
  16. const checkAuth = baseApi("GET", "/api/users/current");
  17. const connectECRRegistry = baseApi<
  18. {
  19. name: string;
  20. aws_integration_id: string;
  21. },
  22. { id: number }
  23. >("POST", (pathParams) => {
  24. return `/api/projects/${pathParams.id}/registries`;
  25. });
  26. const connectGCRRegistry = baseApi<
  27. {
  28. name: string;
  29. gcp_integration_id: string;
  30. url: string;
  31. },
  32. { id: number }
  33. >("POST", (pathParams) => {
  34. return `/api/projects/${pathParams.id}/registries`;
  35. });
  36. const connectDORegistry = baseApi<
  37. {
  38. name: string;
  39. do_integration_id: string;
  40. url: string;
  41. },
  42. { project_id: number }
  43. >("POST", (pathParams) => {
  44. return `/api/projects/${pathParams.project_id}/registries`;
  45. });
  46. const getAWSIntegration = baseApi<{}, { project_id: number }>(
  47. "GET",
  48. ({ project_id }) => `/api/projects/${project_id}/integrations/aws`
  49. );
  50. const getGCPIntegration = baseApi<{}, { project_id: number }>(
  51. "GET",
  52. ({ project_id }) => `/api/projects/${project_id}/integrations/gcp`
  53. );
  54. const getAzureIntegration = baseApi<{}, { project_id: number }>(
  55. "GET",
  56. ({ project_id }) => `/api/projects/${project_id}/integrations/azure`
  57. );
  58. const getGitlabIntegration = baseApi<{}, { project_id: number }>(
  59. "GET",
  60. ({ project_id }) => `/api/projects/${project_id}/integrations/gitlab`
  61. );
  62. const createAWSIntegration = baseApi<
  63. {
  64. aws_region: string;
  65. aws_cluster_id?: string;
  66. aws_access_key_id: string;
  67. aws_secret_access_key: string;
  68. aws_assume_role_arn?: string;
  69. },
  70. { id: number }
  71. >("POST", (pathParams) => {
  72. return `/api/projects/${pathParams.id}/integrations/aws`;
  73. });
  74. const overwriteAWSIntegration = baseApi<
  75. {
  76. aws_integration_id: number;
  77. aws_access_key_id: string;
  78. aws_secret_access_key: string;
  79. cluster_id: number;
  80. },
  81. {
  82. project_id: number;
  83. }
  84. >("POST", (pathParams) => {
  85. return `/api/projects/${pathParams.project_id}/integrations/aws/overwrite`;
  86. });
  87. const updateCluster = baseApi<
  88. {
  89. name?: string;
  90. aws_cluster_id?: string;
  91. agent_integration_enabled?: boolean;
  92. preview_envs_enabled?: boolean;
  93. },
  94. {
  95. project_id: number;
  96. cluster_id: number;
  97. }
  98. >("POST", (pathParams) => {
  99. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}`;
  100. });
  101. const createAzureIntegration = baseApi<
  102. {
  103. azure_client_id: string;
  104. azure_subscription_id: string;
  105. azure_tenant_id: string;
  106. service_principal_key: string;
  107. },
  108. { id: number }
  109. >("POST", (pathParams) => {
  110. return `/api/projects/${pathParams.id}/integrations/azure`;
  111. });
  112. const createGitlabIntegration = baseApi<
  113. {
  114. instance_url: string;
  115. client_id: string;
  116. client_secret: string;
  117. },
  118. { id: number }
  119. >("POST", (pathParams) => {
  120. return `/api/projects/${pathParams.id}/integrations/gitlab`;
  121. });
  122. const createEmailVerification = baseApi<{}, {}>("POST", (pathParams) => {
  123. return `/api/email/verify/initiate`;
  124. });
  125. const createEnvironment = baseApi<
  126. {
  127. name: string;
  128. mode: "auto" | "manual";
  129. },
  130. {
  131. project_id: number;
  132. cluster_id: number;
  133. git_installation_id: number;
  134. git_repo_owner: string;
  135. git_repo_name: string;
  136. }
  137. >("POST", (pathParams) => {
  138. let {
  139. project_id,
  140. cluster_id,
  141. git_installation_id,
  142. git_repo_owner,
  143. git_repo_name,
  144. } = pathParams;
  145. return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${git_repo_owner}/${git_repo_name}/clusters/${cluster_id}/environment`;
  146. });
  147. const deleteEnvironment = baseApi<
  148. {
  149. name: string;
  150. },
  151. {
  152. project_id: number;
  153. cluster_id: number;
  154. git_installation_id: number;
  155. git_repo_owner: string;
  156. git_repo_name: string;
  157. }
  158. >("DELETE", (pathParams) => {
  159. let {
  160. project_id,
  161. cluster_id,
  162. git_installation_id,
  163. git_repo_owner,
  164. git_repo_name,
  165. } = pathParams;
  166. return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${git_repo_owner}/${git_repo_name}/clusters/${cluster_id}/environment`;
  167. });
  168. const createPreviewEnvironmentDeployment = baseApi<
  169. PullRequest,
  170. { project_id: number; cluster_id: number }
  171. >(
  172. "POST",
  173. ({ project_id, cluster_id }) =>
  174. `/api/projects/${project_id}/clusters/${cluster_id}/deployments/pull_request`
  175. );
  176. const reenablePreviewEnvironmentDeployment = baseApi<
  177. {},
  178. {
  179. project_id: number;
  180. cluster_id: number;
  181. deployment_id: number;
  182. }
  183. >(
  184. "PATCH",
  185. ({ project_id, cluster_id, deployment_id }) =>
  186. `/api/projects/${project_id}/clusters/${cluster_id}/deployments/${deployment_id}/reenable`
  187. );
  188. const listEnvironments = baseApi<
  189. {},
  190. {
  191. project_id: number;
  192. cluster_id: number;
  193. }
  194. >("GET", (pathParams) => {
  195. let { project_id, cluster_id } = pathParams;
  196. return `/api/projects/${project_id}/clusters/${cluster_id}/environments`;
  197. });
  198. const getEnvironment = baseApi<
  199. {},
  200. {
  201. project_id: number;
  202. cluster_id: number;
  203. environment_id: number;
  204. }
  205. >("GET", (pathParams) => {
  206. let { project_id, cluster_id, environment_id } = pathParams;
  207. return `/api/projects/${project_id}/clusters/${cluster_id}/environments/${environment_id}`;
  208. });
  209. const toggleNewCommentForEnvironment = baseApi<
  210. {
  211. disable: boolean;
  212. },
  213. {
  214. project_id: number;
  215. cluster_id: number;
  216. environment_id: number;
  217. }
  218. >("PATCH", (pathParams) => {
  219. let { project_id, cluster_id, environment_id } = pathParams;
  220. return `/api/projects/${project_id}/clusters/${cluster_id}/environments/${environment_id}/toggle_new_comment`;
  221. });
  222. const createGCPIntegration = baseApi<
  223. {
  224. gcp_key_data: string;
  225. gcp_project_id: string;
  226. },
  227. {
  228. project_id: number;
  229. }
  230. >("POST", (pathParams) => {
  231. return `/api/projects/${pathParams.project_id}/integrations/gcp`;
  232. });
  233. const createInvite = baseApi<
  234. {
  235. email: string;
  236. kind: string;
  237. },
  238. {
  239. id: number;
  240. }
  241. >("POST", (pathParams) => {
  242. return `/api/projects/${pathParams.id}/invites`;
  243. });
  244. const createPasswordReset = baseApi<
  245. {
  246. email: string;
  247. },
  248. {}
  249. >("POST", (pathParams) => {
  250. return `/api/password/reset/initiate`;
  251. });
  252. const createPasswordResetVerify = baseApi<
  253. {
  254. email: string;
  255. token: string;
  256. token_id: number;
  257. },
  258. {}
  259. >("POST", (pathParams) => {
  260. return `/api/password/reset/verify`;
  261. });
  262. const createPasswordResetFinalize = baseApi<
  263. {
  264. email: string;
  265. token: string;
  266. token_id: number;
  267. new_password: string;
  268. },
  269. {}
  270. >("POST", (pathParams) => {
  271. return `/api/password/reset/finalize`;
  272. });
  273. const createProject = baseApi<{ name: string }, {}>("POST", (pathParams) => {
  274. return `/api/projects`;
  275. });
  276. const createSubdomain = baseApi<
  277. {},
  278. {
  279. id: number;
  280. release_name: string;
  281. namespace: string;
  282. cluster_id: number;
  283. }
  284. >("POST", (pathParams) => {
  285. let { cluster_id, id, namespace, release_name } = pathParams;
  286. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/subdomain`;
  287. });
  288. const deleteCluster = baseApi<
  289. {},
  290. {
  291. project_id: number;
  292. cluster_id: number;
  293. }
  294. >("DELETE", (pathParams) => {
  295. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}`;
  296. });
  297. const deleteInvite = baseApi<{}, { id: number; invId: number }>(
  298. "DELETE",
  299. (pathParams) => {
  300. return `/api/projects/${pathParams.id}/invites/${pathParams.invId}`;
  301. }
  302. );
  303. const deletePod = baseApi<
  304. {},
  305. { name: string; namespace: string; id: number; cluster_id: number }
  306. >("DELETE", (pathParams) => {
  307. let { id, name, cluster_id, namespace } = pathParams;
  308. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/pods/${name}`;
  309. });
  310. const getPodEvents = baseApi<
  311. {},
  312. { name: string; namespace: string; id: number; cluster_id: number }
  313. >("GET", (pathParams) => {
  314. let { id, name, cluster_id, namespace } = pathParams;
  315. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/pods/${name}/events`;
  316. });
  317. const deleteProject = baseApi<{}, { id: number }>("DELETE", (pathParams) => {
  318. return `/api/projects/${pathParams.id}`;
  319. });
  320. const deleteRegistryIntegration = baseApi<
  321. {},
  322. {
  323. project_id: number;
  324. registry_id: number;
  325. }
  326. >("DELETE", (pathParams) => {
  327. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}`;
  328. });
  329. const deleteSlackIntegration = baseApi<
  330. {},
  331. {
  332. project_id: number;
  333. slack_integration_id: number;
  334. }
  335. >("DELETE", (pathParams) => {
  336. return `/api/projects/${pathParams.project_id}/slack_integrations/${pathParams.slack_integration_id}`;
  337. });
  338. const updateNotificationConfig = baseApi<
  339. {
  340. payload: any;
  341. },
  342. {
  343. project_id: number;
  344. cluster_id: number;
  345. namespace: string;
  346. name: string;
  347. }
  348. >("POST", (pathParams) => {
  349. let { project_id, cluster_id, namespace, name } = pathParams;
  350. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/notifications`;
  351. });
  352. const getPRDeploymentList = baseApi<
  353. {
  354. environment_id?: number;
  355. },
  356. {
  357. cluster_id: number;
  358. project_id: number;
  359. }
  360. >("GET", (pathParams) => {
  361. const { cluster_id, project_id } = pathParams;
  362. return `/api/projects/${project_id}/clusters/${cluster_id}/deployments`;
  363. });
  364. const getPRDeploymentByEnvironment = baseApi<
  365. {
  366. namespace: string;
  367. },
  368. {
  369. cluster_id: number;
  370. project_id: number;
  371. environment_id: number;
  372. }
  373. >("GET", (pathParams) => {
  374. const { cluster_id, project_id, environment_id } = pathParams;
  375. return `/api/projects/${project_id}/clusters/${cluster_id}/environments/${environment_id}/deployment`;
  376. });
  377. const getPRDeployment = baseApi<
  378. {
  379. namespace: string;
  380. },
  381. {
  382. cluster_id: number;
  383. project_id: number;
  384. git_installation_id: number;
  385. git_repo_owner: string;
  386. git_repo_name: string;
  387. }
  388. >("GET", (pathParams) => {
  389. const {
  390. cluster_id,
  391. project_id,
  392. git_installation_id,
  393. git_repo_owner,
  394. git_repo_name,
  395. } = pathParams;
  396. return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${git_repo_owner}/${git_repo_name}/clusters/${cluster_id}/deployment`;
  397. });
  398. const deletePRDeployment = baseApi<
  399. {},
  400. {
  401. cluster_id: number;
  402. project_id: number;
  403. deployment_id: number;
  404. }
  405. >("DELETE", (pathParams) => {
  406. const { cluster_id, project_id, deployment_id } = pathParams;
  407. return `/api/projects/${project_id}/clusters/${cluster_id}/deployments/${deployment_id}`;
  408. });
  409. const getNotificationConfig = baseApi<
  410. {},
  411. {
  412. project_id: number;
  413. cluster_id: number;
  414. namespace: string;
  415. name: string;
  416. }
  417. >("GET", (pathParams) => {
  418. let { project_id, cluster_id, namespace, name } = pathParams;
  419. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/notifications`;
  420. });
  421. const getGHAWorkflowTemplate = baseApi<
  422. {
  423. release_name: string;
  424. github_action_config: FullActionConfigType;
  425. },
  426. {
  427. cluster_id: number;
  428. project_id: number;
  429. namespace: string;
  430. }
  431. >("POST", (pathParams) => {
  432. const { cluster_id, project_id, namespace } = pathParams;
  433. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/gha_template`;
  434. });
  435. const deployTemplate = baseApi<
  436. {
  437. template_name: string;
  438. template_version: string;
  439. image_url?: string;
  440. values?: any;
  441. name: string;
  442. git_action_config?: FullActionConfigType;
  443. build_config?: any;
  444. synced_env_groups?: string[];
  445. },
  446. {
  447. id: number;
  448. cluster_id: number;
  449. namespace: string;
  450. repo_url?: string;
  451. }
  452. >("POST", (pathParams) => {
  453. let { cluster_id, id, namespace, repo_url } = pathParams;
  454. if (repo_url) {
  455. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases?repo_url=${repo_url}`;
  456. }
  457. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases`;
  458. });
  459. const deployAddon = baseApi<
  460. {
  461. template_name: string;
  462. template_version: string;
  463. values?: any;
  464. name: string;
  465. },
  466. {
  467. id: number;
  468. cluster_id: number;
  469. namespace: string;
  470. repo_url?: string;
  471. }
  472. >("POST", (pathParams) => {
  473. let { cluster_id, id, namespace, repo_url } = pathParams;
  474. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/addons?repo_url=${repo_url}`;
  475. });
  476. const detectBuildpack = baseApi<
  477. {},
  478. {
  479. project_id: number;
  480. git_repo_id: number;
  481. kind: string;
  482. owner: string;
  483. name: string;
  484. branch: string;
  485. }
  486. >("GET", (pathParams) => {
  487. return `/api/projects/${pathParams.project_id}/gitrepos/${
  488. pathParams.git_repo_id
  489. }/repos/${pathParams.kind}/${pathParams.owner}/${
  490. pathParams.name
  491. }/${encodeURIComponent(pathParams.branch)}/buildpack/detect`;
  492. });
  493. const detectGitlabBuildpack = baseApi<
  494. { dir: string },
  495. {
  496. project_id: number;
  497. integration_id: number;
  498. repo_owner: string;
  499. repo_name: string;
  500. branch: string;
  501. }
  502. >(
  503. "GET",
  504. ({ project_id, integration_id, repo_name, repo_owner, branch }) =>
  505. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos/${repo_owner}/${repo_name}/${branch}/buildpack/detect`
  506. );
  507. const getBranchContents = baseApi<
  508. {
  509. dir: string;
  510. },
  511. {
  512. project_id: number;
  513. git_repo_id: number;
  514. kind: string;
  515. owner: string;
  516. name: string;
  517. branch: string;
  518. }
  519. >("GET", (pathParams) => {
  520. return `/api/projects/${pathParams.project_id}/gitrepos/${
  521. pathParams.git_repo_id
  522. }/repos/${pathParams.kind}/${pathParams.owner}/${
  523. pathParams.name
  524. }/${encodeURIComponent(pathParams.branch)}/contents`;
  525. });
  526. const getProcfileContents = baseApi<
  527. {
  528. path: string;
  529. },
  530. {
  531. project_id: number;
  532. git_repo_id: number;
  533. kind: string;
  534. owner: string;
  535. name: string;
  536. branch: string;
  537. }
  538. >("GET", (pathParams) => {
  539. return `/api/projects/${pathParams.project_id}/gitrepos/${
  540. pathParams.git_repo_id
  541. }/repos/${pathParams.kind}/${pathParams.owner}/${
  542. pathParams.name
  543. }/${encodeURIComponent(pathParams.branch)}/procfile`;
  544. });
  545. const getGitlabProcfileContents = baseApi<
  546. {
  547. path: string;
  548. },
  549. {
  550. project_id: number;
  551. integration_id: number;
  552. owner: string;
  553. name: string;
  554. branch: string;
  555. }
  556. >(
  557. "GET",
  558. ({ project_id, integration_id, owner, name, branch }) =>
  559. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos/${owner}/${name}/${encodeURIComponent(
  560. branch
  561. )}/procfile`
  562. );
  563. const getBranches = baseApi<
  564. {},
  565. {
  566. project_id: number;
  567. git_repo_id: number;
  568. kind: string;
  569. owner: string;
  570. name: string;
  571. }
  572. >("GET", (pathParams) => {
  573. return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id}/repos/${pathParams.kind}/${pathParams.owner}/${pathParams.name}/branches`;
  574. });
  575. const getChart = baseApi<
  576. {},
  577. {
  578. id: number;
  579. cluster_id: number;
  580. namespace: string;
  581. name: string;
  582. revision: number;
  583. }
  584. >("GET", (pathParams) => {
  585. let { id, cluster_id, namespace, name, revision } = pathParams;
  586. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}`;
  587. });
  588. const getCharts = baseApi<
  589. {
  590. limit: number;
  591. skip: number;
  592. byDate: boolean;
  593. statusFilter: string[];
  594. },
  595. {
  596. id: number;
  597. cluster_id: number;
  598. namespace: string;
  599. }
  600. >("GET", (pathParams) => {
  601. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/releases`;
  602. });
  603. const getChartComponents = baseApi<
  604. {},
  605. {
  606. id: number;
  607. cluster_id: number;
  608. namespace: string;
  609. name: string;
  610. revision: number;
  611. }
  612. >("GET", (pathParams) => {
  613. let { id, cluster_id, namespace, name, revision } = pathParams;
  614. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}/components`;
  615. });
  616. const getChartControllers = baseApi<
  617. {},
  618. {
  619. id: number;
  620. cluster_id: number;
  621. namespace: string;
  622. name: string;
  623. revision: number;
  624. }
  625. >("GET", (pathParams) => {
  626. let { id, cluster_id, namespace, name, revision } = pathParams;
  627. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}/controllers`;
  628. });
  629. const getClusterIntegrations = baseApi("GET", "/api/integrations/cluster");
  630. const getClusters = baseApi<{}, { id: number }>("GET", (pathParams) => {
  631. return `/api/projects/${pathParams.id}/clusters`;
  632. });
  633. const getCluster = baseApi<
  634. {},
  635. {
  636. project_id: number;
  637. cluster_id: number;
  638. }
  639. >("GET", (pathParams) => {
  640. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}`;
  641. });
  642. const getClusterNodes = baseApi<
  643. {},
  644. {
  645. project_id: number;
  646. cluster_id: number;
  647. }
  648. >("GET", (pathParams) => {
  649. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/nodes`;
  650. });
  651. const getClusterNode = baseApi<
  652. {},
  653. {
  654. project_id: number;
  655. cluster_id: number;
  656. nodeName: string;
  657. }
  658. >(
  659. "GET",
  660. (pathParams) =>
  661. `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/nodes/${pathParams.nodeName}`
  662. );
  663. const getGitRepoList = baseApi<
  664. {},
  665. {
  666. project_id: number;
  667. git_repo_id: number;
  668. }
  669. >("GET", (pathParams) => {
  670. return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id}/repos`;
  671. });
  672. const getGitRepoPermission = baseApi<
  673. {},
  674. {
  675. project_id: number;
  676. git_repo_id: number;
  677. }
  678. >("GET", (pathParams) => {
  679. return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id}/permissions`;
  680. });
  681. const getGitRepos = baseApi<
  682. {},
  683. {
  684. project_id: number;
  685. }
  686. >("GET", (pathParams) => {
  687. return `/api/projects/${pathParams.project_id}/gitrepos`;
  688. });
  689. const getImageRepos = baseApi<
  690. {},
  691. {
  692. project_id: number;
  693. registry_id: number;
  694. }
  695. >("GET", (pathParams) => {
  696. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}/repositories`;
  697. });
  698. const getImageTags = baseApi<
  699. {},
  700. {
  701. project_id: number;
  702. registry_id: number;
  703. repo_name: string;
  704. }
  705. >("GET", (pathParams) => {
  706. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}/repositories/${pathParams.repo_name}`;
  707. });
  708. const getInfra = baseApi<
  709. {
  710. version?: string;
  711. },
  712. {
  713. project_id: number;
  714. }
  715. >("GET", (pathParams) => {
  716. return `/api/projects/${pathParams.project_id}/infra`;
  717. });
  718. const listInfraTemplates = baseApi<
  719. {},
  720. {
  721. project_id: number;
  722. }
  723. >("GET", (pathParams) => {
  724. return `/api/projects/${pathParams.project_id}/infras/templates`;
  725. });
  726. const getInfraTemplate = baseApi<
  727. {},
  728. {
  729. project_id: number;
  730. name: string;
  731. version: string;
  732. }
  733. >("GET", (pathParams) => {
  734. let { project_id, name, version } = pathParams;
  735. return `/api/projects/${project_id}/infras/templates/${name}/${version}`;
  736. });
  737. const provisionInfra = baseApi<
  738. {
  739. kind: string;
  740. values: any;
  741. aws_integration_id?: number;
  742. gcp_integration_id?: number;
  743. do_integration_id?: number;
  744. azure_integration_id?: number;
  745. cluster_id?: number;
  746. },
  747. {
  748. project_id: number;
  749. }
  750. >("POST", ({ project_id }) => {
  751. return `/api/projects/${project_id}/infras`;
  752. });
  753. const updateInfra = baseApi<
  754. {
  755. values?: any;
  756. },
  757. {
  758. project_id: number;
  759. infra_id: number;
  760. }
  761. >("POST", (pathParams) => {
  762. let { project_id, infra_id } = pathParams;
  763. return `/api/projects/${project_id}/infras/${infra_id}/update`;
  764. });
  765. const retryCreateInfra = baseApi<
  766. {
  767. aws_integration_id?: number;
  768. gcp_integration_id?: number;
  769. do_integration_id?: number;
  770. values?: any;
  771. },
  772. {
  773. project_id: number;
  774. infra_id: number;
  775. }
  776. >("POST", (pathParams) => {
  777. let { project_id, infra_id } = pathParams;
  778. return `/api/projects/${project_id}/infras/${infra_id}/retry_create`;
  779. });
  780. const retryDeleteInfra = baseApi<
  781. {
  782. values?: any;
  783. },
  784. {
  785. project_id: number;
  786. infra_id: number;
  787. }
  788. >("POST", (pathParams) => {
  789. let { project_id, infra_id } = pathParams;
  790. return `/api/projects/${project_id}/infras/${infra_id}/retry_delete`;
  791. });
  792. const deleteInfra = baseApi<
  793. {},
  794. {
  795. project_id: number;
  796. infra_id: number;
  797. }
  798. >("DELETE", (pathParams) => {
  799. let { project_id, infra_id } = pathParams;
  800. return `/api/projects/${project_id}/infras/${infra_id}`;
  801. });
  802. const listOperations = baseApi<
  803. {},
  804. {
  805. project_id: number;
  806. infra_id: number;
  807. }
  808. >("GET", (pathParams) => {
  809. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/operations`;
  810. });
  811. const getOperation = baseApi<
  812. {},
  813. {
  814. project_id: number;
  815. infra_id: number;
  816. operation_id: string;
  817. }
  818. >("GET", (pathParams) => {
  819. let { project_id, infra_id, operation_id } = pathParams;
  820. return `/api/projects/${project_id}/infras/${infra_id}/operations/${operation_id}`;
  821. });
  822. const getOperationLogs = baseApi<
  823. {},
  824. {
  825. project_id: number;
  826. infra_id: number;
  827. operation_id: string;
  828. }
  829. >("GET", (pathParams) => {
  830. let { project_id, infra_id, operation_id } = pathParams;
  831. return `/api/projects/${project_id}/infras/${infra_id}/operations/${operation_id}/logs`;
  832. });
  833. const getInfraState = baseApi<
  834. {},
  835. {
  836. project_id: number;
  837. infra_id: number;
  838. }
  839. >("GET", (pathParams) => {
  840. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/state`;
  841. });
  842. const getInfraRawState = baseApi<
  843. {},
  844. {
  845. project_id: number;
  846. infra_id: number;
  847. }
  848. >("GET", (pathParams) => {
  849. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/raw_state`;
  850. });
  851. const getInfraByID = baseApi<
  852. {},
  853. {
  854. project_id: number;
  855. infra_id: number;
  856. }
  857. >("GET", (pathParams) => {
  858. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}`;
  859. });
  860. const getInfraDesired = baseApi<
  861. {},
  862. {
  863. project_id: number;
  864. infra_id: number;
  865. }
  866. >("GET", (pathParams) => {
  867. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/desired`;
  868. });
  869. const getInfraCurrent = baseApi<
  870. {},
  871. {
  872. project_id: number;
  873. infra_id: number;
  874. }
  875. >("GET", (pathParams) => {
  876. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/current`;
  877. });
  878. const getIngress = baseApi<
  879. {},
  880. { namespace: string; cluster_id: number; name: string; id: number }
  881. >("GET", (pathParams) => {
  882. let { id, name, cluster_id, namespace } = pathParams;
  883. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/ingresses/${name}`;
  884. });
  885. const getInvites = baseApi<{}, { id: number }>("GET", (pathParams) => {
  886. return `/api/projects/${pathParams.id}/invites`;
  887. });
  888. const getJobs = baseApi<
  889. {},
  890. { namespace: string; cluster_id: number; release_name: string; id: number }
  891. >("GET", (pathParams) => {
  892. let { id, release_name, cluster_id, namespace } = pathParams;
  893. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/jobs`;
  894. });
  895. const getJobStatus = baseApi<
  896. {},
  897. { namespace: string; cluster_id: number; release_name: string; id: number }
  898. >("GET", (pathParams) => {
  899. let { id, release_name, cluster_id, namespace } = pathParams;
  900. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/jobs/status`;
  901. });
  902. const getJobPods = baseApi<
  903. {},
  904. { name: string; namespace: string; id: number; cluster_id: number }
  905. >("GET", (pathParams) => {
  906. let { id, name, cluster_id, namespace } = pathParams;
  907. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}/pods`;
  908. });
  909. const getPodByName = baseApi<
  910. {},
  911. {
  912. project_id: number;
  913. cluster_id: number;
  914. namespace: string;
  915. name: string;
  916. }
  917. >(
  918. "GET",
  919. ({ project_id, cluster_id, namespace, name }) =>
  920. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/pods/${name}`
  921. );
  922. const getMatchingPods = baseApi<
  923. {
  924. namespace: string;
  925. selectors: string[];
  926. },
  927. { id: number; cluster_id: number }
  928. >("GET", (pathParams) => {
  929. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/pods`;
  930. });
  931. const getMetrics = baseApi<
  932. {
  933. metric: string;
  934. shouldsum: boolean;
  935. pods?: string[];
  936. kind?: string; // the controller kind
  937. name?: string;
  938. percentile?: number;
  939. namespace: string;
  940. startrange: number;
  941. endrange: number;
  942. resolution: string;
  943. },
  944. {
  945. id: number;
  946. cluster_id: number;
  947. }
  948. >("GET", (pathParams) => {
  949. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/metrics`;
  950. });
  951. const getNamespaces = baseApi<
  952. {},
  953. {
  954. id: number;
  955. cluster_id: number;
  956. }
  957. >("GET", (pathParams) => {
  958. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces`;
  959. });
  960. const getNGINXIngresses = baseApi<
  961. {},
  962. {
  963. id: number;
  964. cluster_id: number;
  965. }
  966. >("GET", (pathParams) => {
  967. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/prometheus/ingresses`;
  968. });
  969. const getOAuthIds = baseApi<
  970. {},
  971. {
  972. project_id: number;
  973. }
  974. >("GET", (pathParams) => {
  975. return `/api/projects/${pathParams.project_id}/integrations/oauth`;
  976. });
  977. const getProjectClusters = baseApi<{}, { id: number }>("GET", (pathParams) => {
  978. return `/api/projects/${pathParams.id}/clusters`;
  979. });
  980. const getProjectRegistries = baseApi<{}, { id: number }>(
  981. "GET",
  982. (pathParams) => {
  983. return `/api/projects/${pathParams.id}/registries`;
  984. }
  985. );
  986. const getProjectRepos = baseApi<{}, { id: number }>("GET", (pathParams) => {
  987. return `/api/projects/${pathParams.id}/repos`;
  988. });
  989. const getProjects = baseApi("GET", "/api/projects");
  990. const getPrometheusIsInstalled = baseApi<
  991. {},
  992. {
  993. id: number;
  994. cluster_id: number;
  995. }
  996. >("GET", (pathParams) => {
  997. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/prometheus/detect`;
  998. });
  999. const getRegistryIntegrations = baseApi("GET", "/api/integrations/registry");
  1000. const getReleaseToken = baseApi<
  1001. {},
  1002. { name: string; id: number; namespace: string; cluster_id: number }
  1003. >("GET", (pathParams) => {
  1004. let { id, cluster_id, namespace, name } = pathParams;
  1005. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/webhook`;
  1006. });
  1007. const getReleaseSteps = baseApi<
  1008. {},
  1009. { name: string; id: number; namespace: string; cluster_id: number }
  1010. >("GET", (pathParams) => {
  1011. let { id, cluster_id, namespace, name } = pathParams;
  1012. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/steps`;
  1013. });
  1014. const destroyInfra = baseApi<
  1015. {},
  1016. {
  1017. project_id: number;
  1018. infra_id: number;
  1019. }
  1020. >("DELETE", (pathParams) => {
  1021. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}`;
  1022. });
  1023. const updateDatabaseStatus = baseApi<
  1024. {
  1025. status: string;
  1026. },
  1027. {
  1028. project_id: number;
  1029. infra_id: number;
  1030. }
  1031. >("POST", (pathParams) => {
  1032. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/database`;
  1033. });
  1034. const getRepoIntegrations = baseApi("GET", "/api/integrations/repo");
  1035. const getRepos = baseApi<{}, { id: number }>("GET", (pathParams) => {
  1036. return `/api/projects/${pathParams.id}/repos`;
  1037. });
  1038. const getSlackIntegrations = baseApi<{}, { id: number }>(
  1039. "GET",
  1040. (pathParams) => {
  1041. return `/api/projects/${pathParams.id}/slack_integrations`;
  1042. }
  1043. );
  1044. const getRevisions = baseApi<
  1045. {},
  1046. { id: number; cluster_id: number; namespace: string; name: string }
  1047. >("GET", (pathParams) => {
  1048. let { id, cluster_id, namespace, name } = pathParams;
  1049. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/history`;
  1050. });
  1051. const getTemplateInfo = baseApi<
  1052. {
  1053. repo_url?: string;
  1054. },
  1055. { name: string; version: string }
  1056. >("GET", (pathParams) => {
  1057. return `/api/templates/${pathParams.name}/${pathParams.version}`;
  1058. });
  1059. const getTemplateUpgradeNotes = baseApi<
  1060. {
  1061. repo_url?: string;
  1062. prev_version: string;
  1063. },
  1064. { name: string; version: string }
  1065. >("GET", (pathParams) => {
  1066. return `/api/templates/${pathParams.name}/${pathParams.version}/upgrade_notes`;
  1067. });
  1068. const getTemplates = baseApi<
  1069. {
  1070. repo_url?: string;
  1071. },
  1072. {}
  1073. >("GET", "/api/templates");
  1074. const getHelmRepos = baseApi<
  1075. {},
  1076. {
  1077. project_id: number;
  1078. }
  1079. >("GET", (pathParams) => {
  1080. return `/api/projects/${pathParams.project_id}/helmrepos`;
  1081. });
  1082. const getChartsFromHelmRepo = baseApi<
  1083. {},
  1084. {
  1085. project_id: number;
  1086. helm_repo_id: number;
  1087. }
  1088. >("GET", (pathParams) => {
  1089. return `/api/projects/${pathParams.project_id}/helmrepos/${pathParams.helm_repo_id}/charts`;
  1090. });
  1091. const getChartInfoFromHelmRepo = baseApi<
  1092. {},
  1093. { project_id: number; helm_repo_id: number; name: string; version: string }
  1094. >("GET", (pathParams) => {
  1095. return `/api/projects/${pathParams.project_id}/helmrepos/${pathParams.helm_repo_id}/charts/${pathParams.name}/${pathParams.version}`;
  1096. });
  1097. const getMetadata = baseApi<{}, {}>("GET", () => {
  1098. return `/api/metadata`;
  1099. });
  1100. const postWelcome = baseApi<{
  1101. email: string;
  1102. isCompany: boolean;
  1103. name: string;
  1104. company: string;
  1105. role: string;
  1106. }>("POST", () => {
  1107. return `/api/welcome`;
  1108. });
  1109. const linkGithubProject = baseApi<
  1110. {},
  1111. {
  1112. project_id: number;
  1113. }
  1114. >("GET", (pathParams) => {
  1115. return `/api/oauth/projects/${pathParams.project_id}/github`;
  1116. });
  1117. const getGithubAccounts = baseApi<{}, {}>("GET", () => {
  1118. return `/api/integrations/github-app/accounts`;
  1119. });
  1120. const logInUser = baseApi<{
  1121. email: string;
  1122. password: string;
  1123. }>("POST", "/api/login");
  1124. const logOutUser = baseApi("POST", "/api/logout");
  1125. const registerUser = baseApi<{
  1126. email: string;
  1127. password: string;
  1128. }>("POST", "/api/users");
  1129. const rollbackChart = baseApi<
  1130. {
  1131. revision: number;
  1132. },
  1133. {
  1134. id: number;
  1135. name: string;
  1136. namespace: string;
  1137. cluster_id: number;
  1138. }
  1139. >("POST", (pathParams) => {
  1140. let { id, name, cluster_id, namespace } = pathParams;
  1141. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0/rollback`;
  1142. });
  1143. const uninstallTemplate = baseApi<
  1144. {},
  1145. {
  1146. id: number;
  1147. name: string;
  1148. cluster_id: number;
  1149. namespace: string;
  1150. }
  1151. >("DELETE", (pathParams) => {
  1152. let { id, name, cluster_id, namespace } = pathParams;
  1153. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0`;
  1154. });
  1155. const updateUser = baseApi<
  1156. {
  1157. rawKubeConfig?: string;
  1158. allowedContexts?: string[];
  1159. },
  1160. { id: number }
  1161. >("PUT", (pathParams) => {
  1162. return `/api/users/${pathParams.id}`;
  1163. });
  1164. const upgradeChartValues = baseApi<
  1165. {
  1166. values: string;
  1167. version?: string;
  1168. latest_revision?: number;
  1169. },
  1170. {
  1171. id: number;
  1172. name: string;
  1173. namespace: string;
  1174. cluster_id: number;
  1175. }
  1176. >("POST", (pathParams) => {
  1177. let { id, name, cluster_id, namespace } = pathParams;
  1178. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0/upgrade`;
  1179. });
  1180. const listEnvGroups = baseApi<
  1181. {},
  1182. {
  1183. id: number;
  1184. namespace: string;
  1185. cluster_id: number;
  1186. }
  1187. >("GET", (pathParams) => {
  1188. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/envgroup/list`;
  1189. });
  1190. const listConfigMaps = baseApi<
  1191. {},
  1192. {
  1193. id: number;
  1194. namespace: string;
  1195. cluster_id: number;
  1196. }
  1197. >("GET", (pathParams) => {
  1198. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/list`;
  1199. });
  1200. const getEnvGroup = baseApi<
  1201. {},
  1202. {
  1203. id: number;
  1204. namespace: string;
  1205. cluster_id: number;
  1206. name: string;
  1207. version?: number;
  1208. }
  1209. >("GET", (pathParams) => {
  1210. return `/api/projects/${pathParams.id}/clusters/${
  1211. pathParams.cluster_id
  1212. }/namespaces/${pathParams.namespace}/envgroup?name=${pathParams.name}${
  1213. pathParams.version ? "&version=" + pathParams.version : ""
  1214. }`;
  1215. });
  1216. const getConfigMap = baseApi<
  1217. {
  1218. name: string;
  1219. },
  1220. {
  1221. id: number;
  1222. namespace: string;
  1223. cluster_id: number;
  1224. }
  1225. >("GET", (pathParams) => {
  1226. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap`;
  1227. });
  1228. const createEnvGroup = baseApi<
  1229. {
  1230. name: string;
  1231. variables: Record<string, string>;
  1232. secret_variables?: Record<string, string>;
  1233. },
  1234. {
  1235. id: number;
  1236. cluster_id: number;
  1237. namespace: string;
  1238. }
  1239. >("POST", (pathParams) => {
  1240. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/envgroup/create`;
  1241. });
  1242. const cloneEnvGroup = baseApi<
  1243. {
  1244. name: string;
  1245. namespace: string;
  1246. clone_name: string;
  1247. version: number;
  1248. },
  1249. {
  1250. id: number;
  1251. namespace: string;
  1252. cluster_id: number;
  1253. }
  1254. >("POST", (pathParams) => {
  1255. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/envgroup/clone`;
  1256. });
  1257. const updateEnvGroup = baseApi<
  1258. {
  1259. name: string;
  1260. variables: { [key: string]: string };
  1261. secret_variables?: { [key: string]: string };
  1262. },
  1263. {
  1264. project_id: number;
  1265. cluster_id: number;
  1266. namespace: string;
  1267. }
  1268. >(
  1269. "POST",
  1270. ({ cluster_id, project_id, namespace }) =>
  1271. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/envgroup/create`
  1272. );
  1273. const createConfigMap = baseApi<
  1274. {
  1275. name: string;
  1276. variables: Record<string, string>;
  1277. secret_variables?: Record<string, string>;
  1278. },
  1279. {
  1280. id: number;
  1281. cluster_id: number;
  1282. namespace: string;
  1283. }
  1284. >("POST", (pathParams) => {
  1285. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/create`;
  1286. });
  1287. const updateConfigMap = baseApi<
  1288. {
  1289. name: string;
  1290. variables: Record<string, string>;
  1291. secret_variables?: Record<string, string>;
  1292. },
  1293. {
  1294. id: number;
  1295. cluster_id: number;
  1296. namespace: string;
  1297. }
  1298. >("POST", (pathParams) => {
  1299. let { id, cluster_id } = pathParams;
  1300. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/update`;
  1301. });
  1302. const renameConfigMap = baseApi<
  1303. {
  1304. name: string;
  1305. new_name: string;
  1306. },
  1307. {
  1308. id: number;
  1309. cluster_id: number;
  1310. namespace: string;
  1311. }
  1312. >("POST", (pathParams) => {
  1313. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/rename`;
  1314. });
  1315. const deleteEnvGroup = baseApi<
  1316. {
  1317. name: string;
  1318. },
  1319. {
  1320. id: number;
  1321. namespace: string;
  1322. cluster_id: number;
  1323. }
  1324. >("DELETE", (pathParams) => {
  1325. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/envgroup`;
  1326. });
  1327. const deleteConfigMap = baseApi<
  1328. {
  1329. name: string;
  1330. },
  1331. {
  1332. id: number;
  1333. namespace: string;
  1334. cluster_id: number;
  1335. }
  1336. >("DELETE", (pathParams) => {
  1337. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/delete`;
  1338. });
  1339. const createNamespace = baseApi<
  1340. {
  1341. name: string;
  1342. },
  1343. { id: number; cluster_id: number }
  1344. >("POST", (pathParams) => {
  1345. let { id, cluster_id } = pathParams;
  1346. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/create`;
  1347. });
  1348. const deleteNamespace = baseApi<
  1349. {},
  1350. {
  1351. id: number;
  1352. cluster_id: number;
  1353. namespace: string;
  1354. }
  1355. >("DELETE", (pathParams) => {
  1356. let { id, cluster_id, namespace } = pathParams;
  1357. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}`;
  1358. });
  1359. const deleteJob = baseApi<
  1360. {},
  1361. { name: string; namespace: string; id: number; cluster_id: number }
  1362. >("DELETE", (pathParams) => {
  1363. let { id, name, cluster_id, namespace } = pathParams;
  1364. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}`;
  1365. });
  1366. const stopJob = baseApi<
  1367. {},
  1368. { name: string; namespace: string; id: number; cluster_id: number }
  1369. >("POST", (pathParams) => {
  1370. let { id, name, namespace, cluster_id } = pathParams;
  1371. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}/stop`;
  1372. });
  1373. const listAPITokens = baseApi<{}, { project_id: number }>(
  1374. "GET",
  1375. ({ project_id }) => `/api/projects/${project_id}/api_token`
  1376. );
  1377. const getAPIToken = baseApi<{}, { project_id: number; token: string }>(
  1378. "GET",
  1379. ({ project_id, token }) => `/api/projects/${project_id}/api_token/${token}`
  1380. );
  1381. const revokeAPIToken = baseApi<{}, { project_id: number; token: string }>(
  1382. "POST",
  1383. ({ project_id, token }) =>
  1384. `/api/projects/${project_id}/api_token/${token}/revoke`
  1385. );
  1386. const createAPIToken = baseApi<
  1387. {
  1388. name: string;
  1389. policy_uid: string;
  1390. expires_at?: string;
  1391. },
  1392. { project_id: number }
  1393. >("POST", ({ project_id }) => `/api/projects/${project_id}/api_token`);
  1394. const createPolicy = baseApi<
  1395. {
  1396. name: string;
  1397. policy: PolicyDocType[];
  1398. },
  1399. { project_id: number }
  1400. >("POST", ({ project_id }) => `/api/projects/${project_id}/policy`);
  1401. const getAvailableRoles = baseApi<{}, { project_id: number }>(
  1402. "GET",
  1403. ({ project_id }) => `/api/projects/${project_id}/roles`
  1404. );
  1405. const updateInvite = baseApi<
  1406. { kind: string },
  1407. { project_id: number; invite_id: number }
  1408. >(
  1409. "POST",
  1410. ({ project_id, invite_id }) =>
  1411. `/api/projects/${project_id}/invites/${invite_id}`
  1412. );
  1413. const getCollaborators = baseApi<{}, { project_id: number }>(
  1414. "GET",
  1415. ({ project_id }) => `/api/projects/${project_id}/collaborators`
  1416. );
  1417. const updateCollaborator = baseApi<
  1418. {
  1419. kind: string;
  1420. user_id: number;
  1421. },
  1422. { project_id: number }
  1423. >("POST", ({ project_id }) => `/api/projects/${project_id}/roles`);
  1424. const removeCollaborator = baseApi<{ user_id: number }, { project_id: number }>(
  1425. "DELETE",
  1426. ({ project_id }) => `/api/projects/${project_id}/roles`
  1427. );
  1428. const getPolicyDocument = baseApi<{}, { project_id: number }>(
  1429. "GET",
  1430. ({ project_id }) => `/api/projects/${project_id}/policy`
  1431. );
  1432. const createWebhookToken = baseApi<
  1433. {},
  1434. {
  1435. project_id: number;
  1436. chart_name: string;
  1437. namespace: string;
  1438. cluster_id: number;
  1439. }
  1440. >(
  1441. "POST",
  1442. ({ project_id, chart_name, namespace, cluster_id }) =>
  1443. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${chart_name}/0/webhook`
  1444. );
  1445. const getUsage = baseApi<{}, { project_id: number }>(
  1446. "GET",
  1447. ({ project_id }) => `/api/projects/${project_id}/usage`
  1448. );
  1449. // Used for billing purposes
  1450. const getCustomerToken = baseApi<{}, { project_id: number }>(
  1451. "GET",
  1452. ({ project_id }) => `/api/projects/${project_id}/billing/token`
  1453. );
  1454. const getHasBilling = baseApi<{}, { project_id: number }>(
  1455. "GET",
  1456. ({ project_id }) => `/api/projects/${project_id}/billing`
  1457. );
  1458. const getOnboardingState = baseApi<{}, { project_id: number }>(
  1459. "GET",
  1460. ({ project_id }) => `/api/projects/${project_id}/onboarding`
  1461. );
  1462. const saveOnboardingState = baseApi<{}, { project_id: number }>(
  1463. "POST",
  1464. ({ project_id }) => `/api/projects/${project_id}/onboarding`
  1465. );
  1466. const getOnboardingInfra = baseApi<
  1467. {},
  1468. { project_id: number; registry_infra_id: number }
  1469. >(
  1470. "GET",
  1471. ({ project_id, registry_infra_id }) =>
  1472. `/api/projects/${project_id}/infras/${registry_infra_id}`
  1473. );
  1474. const getOnboardingRegistry = baseApi<
  1475. {},
  1476. { project_id: number; registry_connection_id: number }
  1477. >(
  1478. "GET",
  1479. ({ project_id, registry_connection_id }) =>
  1480. `/api/projects/${project_id}/registries/${registry_connection_id}`
  1481. );
  1482. const detectPorterAgent = baseApi<
  1483. {},
  1484. { project_id: number; cluster_id: number }
  1485. >(
  1486. "GET",
  1487. ({ project_id, cluster_id }) =>
  1488. `/api/projects/${project_id}/clusters/${cluster_id}/agent/detect`
  1489. );
  1490. const installPorterAgent = baseApi<
  1491. {},
  1492. { project_id: number; cluster_id: number }
  1493. >(
  1494. "POST",
  1495. ({ cluster_id, project_id }) =>
  1496. `/api/projects/${project_id}/clusters/${cluster_id}/agent/install`
  1497. );
  1498. const getKubeEvents = baseApi<
  1499. {
  1500. skip: number;
  1501. resource_type: string;
  1502. owner_type?: string;
  1503. owner_name?: string;
  1504. namespace?: string;
  1505. },
  1506. { project_id: number; cluster_id: number }
  1507. >("GET", ({ project_id, cluster_id }) => {
  1508. return `/api/projects/${project_id}/clusters/${cluster_id}/kube_events`;
  1509. });
  1510. const getKubeEvent = baseApi<
  1511. {},
  1512. { project_id: number; cluster_id: number; kube_event_id: number }
  1513. >(
  1514. "GET",
  1515. ({ project_id, cluster_id, kube_event_id }) =>
  1516. `/api/projects/${project_id}/clusters/${cluster_id}/kube_events/${kube_event_id}`
  1517. );
  1518. const getLogBuckets = baseApi<
  1519. {},
  1520. { project_id: number; cluster_id: number; kube_event_id: number }
  1521. >(
  1522. "GET",
  1523. ({ project_id, cluster_id, kube_event_id }) =>
  1524. `/api/projects/${project_id}/clusters/${cluster_id}/kube_events/${kube_event_id}/log_buckets`
  1525. );
  1526. const getLogBucketLogs = baseApi<
  1527. { timestamp: number },
  1528. { project_id: number; cluster_id: number; kube_event_id: number }
  1529. >(
  1530. "GET",
  1531. ({ project_id, cluster_id, kube_event_id }) =>
  1532. `/api/projects/${project_id}/clusters/${cluster_id}/kube_events/${kube_event_id}/logs`
  1533. );
  1534. const getCanCreateProject = baseApi<{}, {}>(
  1535. "GET",
  1536. () => "/api/can_create_project"
  1537. );
  1538. const addApplicationToEnvGroup = baseApi<
  1539. {
  1540. name: string; // Env Group name
  1541. app_name: string;
  1542. },
  1543. { project_id: number; cluster_id: number; namespace: string }
  1544. >(
  1545. "POST",
  1546. ({ cluster_id, namespace, project_id }) =>
  1547. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/envgroup/add_application`
  1548. );
  1549. const removeApplicationFromEnvGroup = baseApi<
  1550. {
  1551. name: string; // Env Group name
  1552. app_name: string;
  1553. },
  1554. { project_id: number; cluster_id: number; namespace: string }
  1555. >(
  1556. "POST",
  1557. ({ cluster_id, namespace, project_id }) =>
  1558. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/envgroup/remove_application`
  1559. );
  1560. const provisionDatabase = baseApi<
  1561. {
  1562. username: string;
  1563. password: string;
  1564. machine_type: string;
  1565. db_storage_encrypted: boolean;
  1566. db_name: string;
  1567. db_max_allocated_storage: string;
  1568. db_family: string;
  1569. db_engine_version: string;
  1570. db_allocated_storage: string;
  1571. },
  1572. { project_id: number; cluster_id: number; namespace: string }
  1573. >(
  1574. "POST",
  1575. ({ project_id, cluster_id, namespace }) =>
  1576. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/provision/rds`
  1577. );
  1578. const getDatabases = baseApi<
  1579. {},
  1580. {
  1581. project_id: number;
  1582. cluster_id: number;
  1583. }
  1584. >(
  1585. "GET",
  1586. ({ project_id, cluster_id }) =>
  1587. `/api/projects/${project_id}/clusters/${cluster_id}/databases`
  1588. );
  1589. const getPreviousLogsForContainer = baseApi<
  1590. {
  1591. container_name: string;
  1592. },
  1593. {
  1594. project_id: number;
  1595. cluster_id: number;
  1596. namespace: string;
  1597. pod_name: string;
  1598. }
  1599. >(
  1600. "GET",
  1601. ({ cluster_id, namespace, pod_name: name, project_id }) =>
  1602. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/pod/${name}/previous_logs`
  1603. );
  1604. const upgradePorterAgent = baseApi<
  1605. {},
  1606. { project_id: number; cluster_id: number }
  1607. >(
  1608. "POST",
  1609. ({ project_id, cluster_id }) =>
  1610. `/api/projects/${project_id}/clusters/${cluster_id}/agent/upgrade`
  1611. );
  1612. const updateBuildConfig = baseApi<
  1613. BuildConfig,
  1614. {
  1615. project_id: number;
  1616. cluster_id: number;
  1617. namespace: string;
  1618. release_name: string;
  1619. }
  1620. >(
  1621. "POST",
  1622. ({ project_id, cluster_id, namespace, release_name }) =>
  1623. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/buildconfig`
  1624. );
  1625. const updateGitActionConfig = baseApi<
  1626. {
  1627. git_action_config: {
  1628. git_branch: string;
  1629. };
  1630. },
  1631. {
  1632. project_id: number;
  1633. cluster_id: number;
  1634. namespace: string;
  1635. release_name: string;
  1636. revision?: 0; // Always update latest
  1637. }
  1638. >(
  1639. "PATCH",
  1640. ({ project_id, cluster_id, namespace, release_name, revision = 0 }) =>
  1641. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/${revision}/git_action_config`
  1642. );
  1643. const reRunGHWorkflow = baseApi<
  1644. {},
  1645. {
  1646. project_id: number;
  1647. cluster_id: number;
  1648. git_installation_id: number;
  1649. owner: string;
  1650. name: string;
  1651. branch?: string;
  1652. filename?: string;
  1653. release_name?: string;
  1654. }
  1655. >(
  1656. "POST",
  1657. ({
  1658. project_id,
  1659. git_installation_id,
  1660. owner,
  1661. name,
  1662. cluster_id,
  1663. filename,
  1664. release_name,
  1665. branch,
  1666. }) => {
  1667. const queryParams = new URLSearchParams();
  1668. if (branch) {
  1669. queryParams.set("branch", branch);
  1670. }
  1671. if (release_name) {
  1672. queryParams.set("release_name", release_name);
  1673. }
  1674. if (filename) {
  1675. queryParams.set("filename", filename);
  1676. }
  1677. return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${owner}/${name}/clusters/${cluster_id}/rerun_workflow?${queryParams.toString()}`;
  1678. }
  1679. );
  1680. const triggerPreviewEnvWorkflow = baseApi<
  1681. {},
  1682. { project_id: number; cluster_id: number; deployment_id: number }
  1683. >(
  1684. "POST",
  1685. ({ project_id, cluster_id, deployment_id }) =>
  1686. `/api/projects/${project_id}/clusters/${cluster_id}/deployments/${deployment_id}/trigger_workflow`
  1687. );
  1688. const getTagsByProjectId = baseApi<{}, { project_id: number }>(
  1689. "GET",
  1690. ({ project_id }) => `/api/projects/${project_id}/tags`
  1691. );
  1692. const createTag = baseApi<
  1693. { name: string; color: string },
  1694. { project_id: number }
  1695. >("POST", ({ project_id }) => `/api/projects/${project_id}/tags`);
  1696. const updateReleaseTags = baseApi<
  1697. {
  1698. tags: string[];
  1699. },
  1700. {
  1701. project_id: number;
  1702. cluster_id: number;
  1703. namespace: string;
  1704. release_name: string;
  1705. }
  1706. >(
  1707. "PATCH",
  1708. ({ project_id, cluster_id, namespace, release_name }) =>
  1709. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/update_tags`
  1710. );
  1711. const getGitProviders = baseApi<{}, { project_id: number }>(
  1712. "GET",
  1713. ({ project_id }) => `/api/projects/${project_id}/integrations/git`
  1714. );
  1715. const getGitlabRepos = baseApi<
  1716. {},
  1717. { project_id: number; integration_id: number }
  1718. >(
  1719. "GET",
  1720. ({ project_id, integration_id }) =>
  1721. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos`
  1722. );
  1723. const getGitlabBranches = baseApi<
  1724. {},
  1725. {
  1726. project_id: number;
  1727. integration_id: number;
  1728. repo_owner: string;
  1729. repo_name: string;
  1730. }
  1731. >(
  1732. "GET",
  1733. ({ project_id, integration_id, repo_owner, repo_name }) =>
  1734. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos/${repo_owner}/${repo_name}/branches`
  1735. );
  1736. const getGitlabFolderContent = baseApi<
  1737. {
  1738. dir: string;
  1739. },
  1740. {
  1741. project_id: number;
  1742. integration_id: number;
  1743. repo_owner: string;
  1744. repo_name: string;
  1745. branch: string;
  1746. }
  1747. >(
  1748. "GET",
  1749. ({ project_id, integration_id, repo_owner, repo_name, branch }) =>
  1750. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos/${repo_owner}/${repo_name}/${branch}/contents`
  1751. );
  1752. const getLogPodValues = baseApi<
  1753. {
  1754. namespace?: string;
  1755. revision?: string;
  1756. match_prefix?: string;
  1757. start_range?: string;
  1758. end_range?: string;
  1759. },
  1760. {
  1761. project_id: number;
  1762. cluster_id: number;
  1763. }
  1764. >(
  1765. "GET",
  1766. ({ project_id, cluster_id }) =>
  1767. `/api/projects/${project_id}/clusters/${cluster_id}/logs/pod_values`
  1768. );
  1769. const getLogs = baseApi<
  1770. {
  1771. limit?: number;
  1772. start_range?: string;
  1773. end_range?: string;
  1774. revision?: string;
  1775. pod_selector: string;
  1776. namespace: string;
  1777. search_param?: string;
  1778. direction?: string;
  1779. },
  1780. {
  1781. project_id: number;
  1782. cluster_id: number;
  1783. }
  1784. >(
  1785. "GET",
  1786. ({ project_id, cluster_id }) =>
  1787. `/api/projects/${project_id}/clusters/${cluster_id}/logs`
  1788. );
  1789. const listPorterEvents = baseApi<
  1790. {
  1791. release_name?: number;
  1792. release_namespace?: string;
  1793. type?: string;
  1794. },
  1795. {
  1796. project_id: number;
  1797. cluster_id: number;
  1798. }
  1799. >(
  1800. "GET",
  1801. ({ project_id, cluster_id }) =>
  1802. `/api/projects/${project_id}/clusters/${cluster_id}/events`
  1803. );
  1804. const listPorterJobEvents = baseApi<
  1805. {
  1806. release_name?: number;
  1807. release_namespace?: string;
  1808. type?: string;
  1809. job_name: string;
  1810. },
  1811. {
  1812. project_id: number;
  1813. cluster_id: number;
  1814. }
  1815. >(
  1816. "GET",
  1817. ({ project_id, cluster_id }) =>
  1818. `/api/projects/${project_id}/clusters/${cluster_id}/events/job`
  1819. );
  1820. const listIncidents = baseApi<
  1821. {
  1822. release_name?: number;
  1823. release_namespace?: string;
  1824. status?: string;
  1825. },
  1826. {
  1827. project_id: number;
  1828. cluster_id: number;
  1829. }
  1830. >(
  1831. "GET",
  1832. ({ project_id, cluster_id }) =>
  1833. `/api/projects/${project_id}/clusters/${cluster_id}/incidents`
  1834. );
  1835. const getIncident = baseApi<
  1836. {},
  1837. {
  1838. project_id: number;
  1839. cluster_id: number;
  1840. incident_id: string;
  1841. }
  1842. >(
  1843. "GET",
  1844. ({ project_id, cluster_id, incident_id }) =>
  1845. `/api/projects/${project_id}/clusters/${cluster_id}/incidents/${incident_id}`
  1846. );
  1847. const getIncidentEvents = baseApi<
  1848. {
  1849. incident_id?: string;
  1850. pod_prefix?: string;
  1851. },
  1852. {
  1853. project_id: number;
  1854. cluster_id: number;
  1855. }
  1856. >(
  1857. "GET",
  1858. ({ project_id, cluster_id }) =>
  1859. `/api/projects/${project_id}/clusters/${cluster_id}/incidents/events`
  1860. );
  1861. // STACKS
  1862. const createStack = baseApi<
  1863. CreateStackBody,
  1864. {
  1865. project_id: number;
  1866. cluster_id: number;
  1867. namespace: string;
  1868. }
  1869. >(
  1870. "POST",
  1871. ({ project_id, cluster_id, namespace }) =>
  1872. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks`
  1873. );
  1874. const updateStack = baseApi<
  1875. {
  1876. name: string;
  1877. },
  1878. {
  1879. project_id: number;
  1880. cluster_id: number;
  1881. namespace: string;
  1882. stack_id: string;
  1883. }
  1884. >(
  1885. "PATCH",
  1886. ({ project_id, cluster_id, namespace, stack_id }) =>
  1887. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}`
  1888. );
  1889. const listStacks = baseApi<
  1890. {},
  1891. { project_id: number; cluster_id: number; namespace: string }
  1892. >(
  1893. "GET",
  1894. ({ project_id, cluster_id, namespace }) =>
  1895. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks`
  1896. );
  1897. const getStack = baseApi<
  1898. {},
  1899. {
  1900. project_id: number;
  1901. cluster_id: number;
  1902. namespace: string;
  1903. stack_id: string;
  1904. }
  1905. >(
  1906. "GET",
  1907. ({ project_id, cluster_id, namespace, stack_id }) =>
  1908. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}`
  1909. );
  1910. const getStackRevision = baseApi<
  1911. {},
  1912. {
  1913. project_id: number;
  1914. cluster_id: number;
  1915. namespace: string;
  1916. stack_id: string;
  1917. revision_id: number;
  1918. }
  1919. >(
  1920. "GET",
  1921. ({ project_id, cluster_id, namespace, stack_id, revision_id }) =>
  1922. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/${revision_id}`
  1923. );
  1924. const rollbackStack = baseApi<
  1925. {
  1926. target_revision: number;
  1927. },
  1928. {
  1929. project_id: number;
  1930. cluster_id: number;
  1931. namespace: string;
  1932. stack_id: string;
  1933. }
  1934. >(
  1935. "POST",
  1936. ({ project_id, cluster_id, namespace, stack_id }) =>
  1937. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/rollback`
  1938. );
  1939. const deleteStack = baseApi<
  1940. {},
  1941. {
  1942. project_id: number;
  1943. cluster_id: number;
  1944. namespace: string;
  1945. stack_id: string;
  1946. }
  1947. >(
  1948. "DELETE",
  1949. ({ project_id, cluster_id, namespace, stack_id }) =>
  1950. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}`
  1951. );
  1952. const updateStackSourceConfig = baseApi<
  1953. {
  1954. source_configs: SourceConfig[];
  1955. },
  1956. {
  1957. project_id: number;
  1958. cluster_id: number;
  1959. namespace: string;
  1960. stack_id: string;
  1961. }
  1962. >(
  1963. "PUT",
  1964. ({ project_id, cluster_id, namespace, stack_id }) =>
  1965. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/source`
  1966. );
  1967. const addStackAppResource = baseApi<
  1968. CreateStackBody["app_resources"][0],
  1969. {
  1970. project_id: number;
  1971. cluster_id: number;
  1972. namespace: string;
  1973. stack_id: string;
  1974. }
  1975. >(
  1976. "PATCH",
  1977. ({ project_id, cluster_id, namespace, stack_id }) =>
  1978. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/add_application`
  1979. );
  1980. const removeStackAppResource = baseApi<
  1981. {},
  1982. {
  1983. project_id: number;
  1984. cluster_id: number;
  1985. namespace: string;
  1986. stack_id: string;
  1987. app_resource_name: string;
  1988. }
  1989. >(
  1990. "DELETE",
  1991. ({ project_id, cluster_id, namespace, stack_id, app_resource_name }) =>
  1992. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/remove_application/${app_resource_name}`
  1993. );
  1994. const addStackEnvGroup = baseApi<
  1995. CreateStackBody["env_groups"][0],
  1996. {
  1997. project_id: number;
  1998. cluster_id: number;
  1999. namespace: string;
  2000. stack_id: string;
  2001. }
  2002. >(
  2003. "PATCH",
  2004. ({ project_id, cluster_id, namespace, stack_id }) =>
  2005. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/add_env_group`
  2006. );
  2007. const removeStackEnvGroup = baseApi<
  2008. {},
  2009. {
  2010. project_id: number;
  2011. cluster_id: number;
  2012. namespace: string;
  2013. stack_id: string;
  2014. env_group_name: string;
  2015. }
  2016. >(
  2017. "DELETE",
  2018. ({ project_id, cluster_id, namespace, stack_id, env_group_name }) =>
  2019. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/remove_env_group/${env_group_name}`
  2020. );
  2021. const getGithubStatus = baseApi<{}, {}>("GET", ({}) => `/api/status/github`);
  2022. // Bundle export to allow default api import (api.<method> is more readable)
  2023. export default {
  2024. checkAuth,
  2025. connectECRRegistry,
  2026. connectGCRRegistry,
  2027. connectDORegistry,
  2028. getAWSIntegration,
  2029. getGCPIntegration,
  2030. getAzureIntegration,
  2031. getGitlabIntegration,
  2032. createAWSIntegration,
  2033. overwriteAWSIntegration,
  2034. updateCluster,
  2035. createAzureIntegration,
  2036. createGitlabIntegration,
  2037. createEmailVerification,
  2038. createEnvironment,
  2039. deleteEnvironment,
  2040. createPreviewEnvironmentDeployment,
  2041. reenablePreviewEnvironmentDeployment,
  2042. listEnvironments,
  2043. getEnvironment,
  2044. toggleNewCommentForEnvironment,
  2045. createGCPIntegration,
  2046. createInvite,
  2047. createNamespace,
  2048. createPasswordReset,
  2049. createPasswordResetVerify,
  2050. createPasswordResetFinalize,
  2051. createProject,
  2052. createConfigMap,
  2053. deleteCluster,
  2054. deleteConfigMap,
  2055. deleteInvite,
  2056. deleteNamespace,
  2057. deletePod,
  2058. deleteProject,
  2059. deleteRegistryIntegration,
  2060. deleteSlackIntegration,
  2061. updateNotificationConfig,
  2062. getNotificationConfig,
  2063. createSubdomain,
  2064. deployTemplate,
  2065. deployAddon,
  2066. destroyInfra,
  2067. updateDatabaseStatus,
  2068. detectBuildpack,
  2069. detectGitlabBuildpack,
  2070. getBranchContents,
  2071. getBranches,
  2072. getMetadata,
  2073. postWelcome,
  2074. getChart,
  2075. getCharts,
  2076. getChartComponents,
  2077. getChartControllers,
  2078. getClusterIntegrations,
  2079. getClusters,
  2080. getCluster,
  2081. getClusterNodes,
  2082. getClusterNode,
  2083. getConfigMap,
  2084. getPRDeploymentList,
  2085. getPRDeploymentByEnvironment,
  2086. getPRDeployment,
  2087. getGHAWorkflowTemplate,
  2088. getGitRepoList,
  2089. getGitRepoPermission,
  2090. getGitRepos,
  2091. getImageRepos,
  2092. getImageTags,
  2093. listInfraTemplates,
  2094. getInfraTemplate,
  2095. getInfra,
  2096. provisionInfra,
  2097. deleteInfra,
  2098. updateInfra,
  2099. listOperations,
  2100. getOperation,
  2101. getOperationLogs,
  2102. retryCreateInfra,
  2103. retryDeleteInfra,
  2104. getInfraState,
  2105. getInfraRawState,
  2106. getInfraByID,
  2107. getInfraDesired,
  2108. getInfraCurrent,
  2109. getIngress,
  2110. getInvites,
  2111. getJobs,
  2112. getJobStatus,
  2113. getJobPods,
  2114. getPodByName,
  2115. getMatchingPods,
  2116. getMetrics,
  2117. getNamespaces,
  2118. getNGINXIngresses,
  2119. getOAuthIds,
  2120. getPodEvents,
  2121. getProcfileContents,
  2122. getGitlabProcfileContents,
  2123. getProjectClusters,
  2124. getProjectRegistries,
  2125. getProjectRepos,
  2126. getProjects,
  2127. getPrometheusIsInstalled,
  2128. getRegistryIntegrations,
  2129. getReleaseToken,
  2130. getReleaseSteps,
  2131. getRepoIntegrations,
  2132. getSlackIntegrations,
  2133. getRepos,
  2134. getRevisions,
  2135. getTemplateInfo,
  2136. getTemplateUpgradeNotes,
  2137. getTemplates,
  2138. getHelmRepos,
  2139. getChartsFromHelmRepo,
  2140. getChartInfoFromHelmRepo,
  2141. linkGithubProject,
  2142. getGithubAccounts,
  2143. listConfigMaps,
  2144. logInUser,
  2145. logOutUser,
  2146. registerUser,
  2147. rollbackChart,
  2148. uninstallTemplate,
  2149. updateUser,
  2150. renameConfigMap,
  2151. updateConfigMap,
  2152. upgradeChartValues,
  2153. deleteJob,
  2154. stopJob,
  2155. updateInvite,
  2156. listAPITokens,
  2157. getAPIToken,
  2158. revokeAPIToken,
  2159. createAPIToken,
  2160. createPolicy,
  2161. getAvailableRoles,
  2162. getCollaborators,
  2163. updateCollaborator,
  2164. removeCollaborator,
  2165. getPolicyDocument,
  2166. createWebhookToken,
  2167. getUsage,
  2168. getCustomerToken,
  2169. getHasBilling,
  2170. getOnboardingState,
  2171. saveOnboardingState,
  2172. getOnboardingInfra,
  2173. getOnboardingRegistry,
  2174. detectPorterAgent,
  2175. installPorterAgent,
  2176. getKubeEvents,
  2177. getKubeEvent,
  2178. getLogBuckets,
  2179. getLogBucketLogs,
  2180. getCanCreateProject,
  2181. createEnvGroup,
  2182. cloneEnvGroup,
  2183. updateEnvGroup,
  2184. listEnvGroups,
  2185. getEnvGroup,
  2186. deleteEnvGroup,
  2187. addApplicationToEnvGroup,
  2188. removeApplicationFromEnvGroup,
  2189. provisionDatabase,
  2190. getDatabases,
  2191. getPreviousLogsForContainer,
  2192. upgradePorterAgent,
  2193. deletePRDeployment,
  2194. updateBuildConfig,
  2195. updateGitActionConfig,
  2196. reRunGHWorkflow,
  2197. triggerPreviewEnvWorkflow,
  2198. getTagsByProjectId,
  2199. createTag,
  2200. updateReleaseTags,
  2201. getGitProviders,
  2202. getGitlabRepos,
  2203. getGitlabBranches,
  2204. getGitlabFolderContent,
  2205. getLogPodValues,
  2206. getLogs,
  2207. listPorterEvents,
  2208. listPorterJobEvents,
  2209. listIncidents,
  2210. getIncident,
  2211. getIncidentEvents,
  2212. // STACKS
  2213. listStacks,
  2214. getStack,
  2215. getStackRevision,
  2216. createStack,
  2217. updateStack,
  2218. rollbackStack,
  2219. deleteStack,
  2220. updateStackSourceConfig,
  2221. addStackAppResource,
  2222. removeStackAppResource,
  2223. addStackEnvGroup,
  2224. removeStackEnvGroup,
  2225. // STATUS
  2226. getGithubStatus,
  2227. };