api.tsx 56 KB

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