api.tsx 48 KB

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