api.tsx 42 KB

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