api.tsx 55 KB

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