api.tsx 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289
  1. import { baseApi } from "./baseApi";
  2. import { FullActionConfigType, StorageType } from "./types";
  3. /**
  4. * Generic api call format
  5. * @param {string} token - Bearer token.
  6. * @param {Object} params - Body params.
  7. * @param {Object} pathParams - Path params.
  8. * @param {(err: Object, res: Object) => void} callback - Callback function.
  9. */
  10. const checkAuth = baseApi("GET", "/api/users/current");
  11. const connectECRRegistry = baseApi<
  12. {
  13. name: string;
  14. aws_integration_id: string;
  15. },
  16. { id: number }
  17. >("POST", (pathParams) => {
  18. return `/api/projects/${pathParams.id}/registries`;
  19. });
  20. const connectGCRRegistry = baseApi<
  21. {
  22. name: string;
  23. gcp_integration_id: string;
  24. url: string;
  25. },
  26. { id: number }
  27. >("POST", (pathParams) => {
  28. return `/api/projects/${pathParams.id}/registries`;
  29. });
  30. const connectDORegistry = baseApi<
  31. {
  32. name: string;
  33. do_integration_id: string;
  34. url: string;
  35. },
  36. { project_id: number }
  37. >("POST", (pathParams) => {
  38. return `/api/projects/${pathParams.project_id}/registries`;
  39. });
  40. const getAWSIntegration = baseApi<{}, { project_id: number }>(
  41. "GET",
  42. ({ project_id }) => `/api/projects/${project_id}/integrations/aws`
  43. );
  44. const getGCPIntegration = baseApi<{}, { project_id: number }>(
  45. "GET",
  46. ({ project_id }) => `/api/projects/${project_id}/integrations/gcp`
  47. );
  48. const createAWSIntegration = baseApi<
  49. {
  50. aws_region: string;
  51. aws_cluster_id?: string;
  52. aws_access_key_id: string;
  53. aws_secret_access_key: string;
  54. },
  55. { id: number }
  56. >("POST", (pathParams) => {
  57. return `/api/projects/${pathParams.id}/integrations/aws`;
  58. });
  59. const overwriteAWSIntegration = baseApi<
  60. {
  61. aws_integration_id: number;
  62. aws_access_key_id: string;
  63. aws_secret_access_key: string;
  64. cluster_id: number;
  65. },
  66. {
  67. project_id: number;
  68. }
  69. >("POST", (pathParams) => {
  70. return `/api/projects/${pathParams.project_id}/integrations/aws/overwrite`;
  71. });
  72. const createDOCR = baseApi<
  73. {
  74. do_integration_id: number;
  75. docr_name: string;
  76. docr_subscription_tier: string;
  77. },
  78. {
  79. project_id: number;
  80. }
  81. >("POST", (pathParams) => {
  82. return `/api/projects/${pathParams.project_id}/provision/docr`;
  83. });
  84. const createDOKS = baseApi<
  85. {
  86. do_integration_id: number;
  87. doks_name: string;
  88. do_region: string;
  89. issuer_email: string;
  90. },
  91. {
  92. project_id: number;
  93. }
  94. >("POST", (pathParams) => {
  95. return `/api/projects/${pathParams.project_id}/provision/doks`;
  96. });
  97. const createEmailVerification = baseApi<{}, {}>("POST", (pathParams) => {
  98. return `/api/email/verify/initiate`;
  99. });
  100. const createGCPIntegration = baseApi<
  101. {
  102. gcp_key_data: string;
  103. gcp_project_id: string;
  104. },
  105. {
  106. project_id: number;
  107. }
  108. >("POST", (pathParams) => {
  109. return `/api/projects/${pathParams.project_id}/integrations/gcp`;
  110. });
  111. const createGCR = baseApi<
  112. {
  113. gcp_integration_id: number;
  114. },
  115. {
  116. project_id: number;
  117. }
  118. >("POST", (pathParams) => {
  119. return `/api/projects/${pathParams.project_id}/provision/gcr`;
  120. });
  121. const createGKE = baseApi<
  122. {
  123. gcp_region: string;
  124. gcp_integration_id: number;
  125. gke_name: string;
  126. issuer_email: string;
  127. },
  128. {
  129. project_id: number;
  130. }
  131. >("POST", (pathParams) => {
  132. return `/api/projects/${pathParams.project_id}/provision/gke`;
  133. });
  134. const createInvite = baseApi<
  135. {
  136. email: string;
  137. kind: string;
  138. },
  139. {
  140. id: number;
  141. }
  142. >("POST", (pathParams) => {
  143. return `/api/projects/${pathParams.id}/invites`;
  144. });
  145. const createPasswordReset = baseApi<
  146. {
  147. email: string;
  148. },
  149. {}
  150. >("POST", (pathParams) => {
  151. return `/api/password/reset/initiate`;
  152. });
  153. const createPasswordResetVerify = baseApi<
  154. {
  155. email: string;
  156. token: string;
  157. token_id: number;
  158. },
  159. {}
  160. >("POST", (pathParams) => {
  161. return `/api/password/reset/verify`;
  162. });
  163. const createPasswordResetFinalize = baseApi<
  164. {
  165. email: string;
  166. token: string;
  167. token_id: number;
  168. new_password: string;
  169. },
  170. {}
  171. >("POST", (pathParams) => {
  172. return `/api/password/reset/finalize`;
  173. });
  174. const createProject = baseApi<{ name: string }, {}>("POST", (pathParams) => {
  175. return `/api/projects`;
  176. });
  177. const createSubdomain = baseApi<
  178. {},
  179. {
  180. id: number;
  181. release_name: string;
  182. namespace: string;
  183. cluster_id: number;
  184. }
  185. >("POST", (pathParams) => {
  186. let { cluster_id, id, namespace, release_name } = pathParams;
  187. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/subdomain`;
  188. });
  189. const deleteCluster = baseApi<
  190. {},
  191. {
  192. project_id: number;
  193. cluster_id: number;
  194. }
  195. >("DELETE", (pathParams) => {
  196. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}`;
  197. });
  198. const deleteInvite = baseApi<{}, { id: number; invId: number }>(
  199. "DELETE",
  200. (pathParams) => {
  201. return `/api/projects/${pathParams.id}/invites/${pathParams.invId}`;
  202. }
  203. );
  204. const deletePod = baseApi<
  205. {},
  206. { name: string; namespace: string; id: number; cluster_id: number }
  207. >("DELETE", (pathParams) => {
  208. let { id, name, cluster_id, namespace } = pathParams;
  209. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/pods/${name}`;
  210. });
  211. const getPodEvents = baseApi<
  212. {},
  213. { name: string; namespace: string; id: number; cluster_id: number }
  214. >("GET", (pathParams) => {
  215. let { id, name, cluster_id, namespace } = pathParams;
  216. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/pods/${name}/events`;
  217. });
  218. const deleteProject = baseApi<{}, { id: number }>("DELETE", (pathParams) => {
  219. return `/api/projects/${pathParams.id}`;
  220. });
  221. const deleteRegistryIntegration = baseApi<
  222. {},
  223. {
  224. project_id: number;
  225. registry_id: number;
  226. }
  227. >("DELETE", (pathParams) => {
  228. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}`;
  229. });
  230. const deleteSlackIntegration = baseApi<
  231. {},
  232. {
  233. project_id: number;
  234. slack_integration_id: number;
  235. }
  236. >("DELETE", (pathParams) => {
  237. return `/api/projects/${pathParams.project_id}/slack_integrations/${pathParams.slack_integration_id}`;
  238. });
  239. const updateNotificationConfig = baseApi<
  240. {
  241. payload: any;
  242. },
  243. {
  244. project_id: number;
  245. cluster_id: number;
  246. namespace: string;
  247. name: string;
  248. }
  249. >("POST", (pathParams) => {
  250. let { project_id, cluster_id, namespace, name } = pathParams;
  251. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/notifications`;
  252. });
  253. const getNotificationConfig = baseApi<
  254. {},
  255. {
  256. project_id: number;
  257. cluster_id: number;
  258. namespace: string;
  259. name: string;
  260. }
  261. >("GET", (pathParams) => {
  262. let { project_id, cluster_id, namespace, name } = pathParams;
  263. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/notifications`;
  264. });
  265. const getGHAWorkflowTemplate = baseApi<
  266. {
  267. release_name: string;
  268. github_action_config: FullActionConfigType;
  269. },
  270. {
  271. cluster_id: number;
  272. project_id: number;
  273. namespace: string;
  274. }
  275. >("POST", (pathParams) => {
  276. const { cluster_id, project_id, namespace } = pathParams;
  277. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/gha_template`;
  278. });
  279. const deployTemplate = baseApi<
  280. {
  281. template_name: string;
  282. template_version: string;
  283. image_url?: string;
  284. values?: any;
  285. name: string;
  286. github_action_config?: FullActionConfigType;
  287. },
  288. {
  289. id: number;
  290. cluster_id: number;
  291. namespace: string;
  292. repo_url?: string;
  293. }
  294. >("POST", (pathParams) => {
  295. let { cluster_id, id, namespace, repo_url } = pathParams;
  296. if (repo_url) {
  297. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases?repo_url=${repo_url}`;
  298. }
  299. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases`;
  300. });
  301. const deployAddon = baseApi<
  302. {
  303. template_name: string;
  304. template_version: string;
  305. values?: any;
  306. name: string;
  307. },
  308. {
  309. id: number;
  310. cluster_id: number;
  311. namespace: string;
  312. repo_url?: string;
  313. }
  314. >("POST", (pathParams) => {
  315. let { cluster_id, id, namespace, repo_url } = pathParams;
  316. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/addons?repo_url=${repo_url}`;
  317. });
  318. const detectBuildpack = baseApi<
  319. {},
  320. {
  321. project_id: number;
  322. git_repo_id: number;
  323. kind: string;
  324. owner: string;
  325. name: string;
  326. branch: string;
  327. }
  328. >("GET", (pathParams) => {
  329. return `/api/projects/${pathParams.project_id}/gitrepos/${
  330. pathParams.git_repo_id
  331. }/repos/${pathParams.kind}/${pathParams.owner}/${
  332. pathParams.name
  333. }/${encodeURIComponent(pathParams.branch)}/buildpack/detect`;
  334. });
  335. const getBranchContents = baseApi<
  336. {
  337. dir: string;
  338. },
  339. {
  340. project_id: number;
  341. git_repo_id: number;
  342. kind: string;
  343. owner: string;
  344. name: string;
  345. branch: string;
  346. }
  347. >("GET", (pathParams) => {
  348. return `/api/projects/${pathParams.project_id}/gitrepos/${
  349. pathParams.git_repo_id
  350. }/repos/${pathParams.kind}/${pathParams.owner}/${
  351. pathParams.name
  352. }/${encodeURIComponent(pathParams.branch)}/contents`;
  353. });
  354. const getProcfileContents = baseApi<
  355. {
  356. path: string;
  357. },
  358. {
  359. project_id: number;
  360. git_repo_id: number;
  361. kind: string;
  362. owner: string;
  363. name: string;
  364. branch: string;
  365. }
  366. >("GET", (pathParams) => {
  367. return `/api/projects/${pathParams.project_id}/gitrepos/${
  368. pathParams.git_repo_id
  369. }/repos/${pathParams.kind}/${pathParams.owner}/${
  370. pathParams.name
  371. }/${encodeURIComponent(pathParams.branch)}/procfile`;
  372. });
  373. const getBranches = baseApi<
  374. {},
  375. {
  376. project_id: number;
  377. git_repo_id: number;
  378. kind: string;
  379. owner: string;
  380. name: string;
  381. }
  382. >("GET", (pathParams) => {
  383. return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id}/repos/${pathParams.kind}/${pathParams.owner}/${pathParams.name}/branches`;
  384. });
  385. const getChart = baseApi<
  386. {},
  387. {
  388. id: number;
  389. cluster_id: number;
  390. namespace: string;
  391. name: string;
  392. revision: number;
  393. }
  394. >("GET", (pathParams) => {
  395. let { id, cluster_id, namespace, name, revision } = pathParams;
  396. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}`;
  397. });
  398. const getCharts = baseApi<
  399. {
  400. limit: number;
  401. skip: number;
  402. byDate: boolean;
  403. statusFilter: string[];
  404. },
  405. {
  406. id: number;
  407. cluster_id: number;
  408. namespace: string;
  409. }
  410. >("GET", (pathParams) => {
  411. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/releases`;
  412. });
  413. const getChartComponents = baseApi<
  414. {},
  415. {
  416. id: number;
  417. cluster_id: number;
  418. namespace: string;
  419. name: string;
  420. revision: number;
  421. }
  422. >("GET", (pathParams) => {
  423. let { id, cluster_id, namespace, name, revision } = pathParams;
  424. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}/components`;
  425. });
  426. const getChartControllers = baseApi<
  427. {},
  428. {
  429. id: number;
  430. cluster_id: number;
  431. namespace: string;
  432. name: string;
  433. revision: number;
  434. }
  435. >("GET", (pathParams) => {
  436. let { id, cluster_id, namespace, name, revision } = pathParams;
  437. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}/controllers`;
  438. });
  439. const getClusterIntegrations = baseApi("GET", "/api/integrations/cluster");
  440. const getClusters = baseApi<{}, { id: number }>("GET", (pathParams) => {
  441. return `/api/projects/${pathParams.id}/clusters`;
  442. });
  443. const getCluster = baseApi<
  444. {},
  445. {
  446. project_id: number;
  447. cluster_id: number;
  448. }
  449. >("GET", (pathParams) => {
  450. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}`;
  451. });
  452. const getClusterNodes = baseApi<
  453. {},
  454. {
  455. project_id: number;
  456. cluster_id: number;
  457. }
  458. >("GET", (pathParams) => {
  459. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/nodes`;
  460. });
  461. const getClusterNode = baseApi<
  462. {},
  463. {
  464. project_id: number;
  465. cluster_id: number;
  466. nodeName: string;
  467. }
  468. >(
  469. "GET",
  470. (pathParams) =>
  471. `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/nodes/${pathParams.nodeName}`
  472. );
  473. const getGitRepoList = baseApi<
  474. {},
  475. {
  476. project_id: number;
  477. git_repo_id: number;
  478. }
  479. >("GET", (pathParams) => {
  480. return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id}/repos`;
  481. });
  482. const getGitRepos = baseApi<
  483. {},
  484. {
  485. project_id: number;
  486. }
  487. >("GET", (pathParams) => {
  488. return `/api/projects/${pathParams.project_id}/gitrepos`;
  489. });
  490. const getImageRepos = baseApi<
  491. {},
  492. {
  493. project_id: number;
  494. registry_id: number;
  495. }
  496. >("GET", (pathParams) => {
  497. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}/repositories`;
  498. });
  499. const getImageTags = baseApi<
  500. {},
  501. {
  502. project_id: number;
  503. registry_id: number;
  504. repo_name: string;
  505. }
  506. >("GET", (pathParams) => {
  507. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}/repositories/${pathParams.repo_name}`;
  508. });
  509. const getInfra = baseApi<
  510. {},
  511. {
  512. project_id: number;
  513. }
  514. >("GET", (pathParams) => {
  515. return `/api/projects/${pathParams.project_id}/infra`;
  516. });
  517. const getInfraDesired = baseApi<
  518. {},
  519. {
  520. project_id: number;
  521. infra_id: number;
  522. }
  523. >("GET", (pathParams) => {
  524. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/desired`;
  525. });
  526. const getInfraCurrent = baseApi<
  527. {},
  528. {
  529. project_id: number;
  530. infra_id: number;
  531. }
  532. >("GET", (pathParams) => {
  533. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/current`;
  534. });
  535. const getIngress = baseApi<
  536. {},
  537. { namespace: string; cluster_id: number; name: string; id: number }
  538. >("GET", (pathParams) => {
  539. let { id, name, cluster_id, namespace } = pathParams;
  540. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/ingresses/${name}`;
  541. });
  542. const getInvites = baseApi<{}, { id: number }>("GET", (pathParams) => {
  543. return `/api/projects/${pathParams.id}/invites`;
  544. });
  545. const getJobs = baseApi<
  546. {},
  547. { namespace: string; cluster_id: number; release_name: string; id: number }
  548. >("GET", (pathParams) => {
  549. let { id, release_name, cluster_id, namespace } = pathParams;
  550. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/jobs`;
  551. });
  552. const getJobStatus = baseApi<
  553. {},
  554. { namespace: string; cluster_id: number; release_name: string; id: number }
  555. >("GET", (pathParams) => {
  556. let { id, release_name, cluster_id, namespace } = pathParams;
  557. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/jobs/status`;
  558. });
  559. const getJobPods = baseApi<
  560. {},
  561. { name: string; namespace: string; id: number; cluster_id: number }
  562. >("GET", (pathParams) => {
  563. let { id, name, cluster_id, namespace } = pathParams;
  564. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}/pods`;
  565. });
  566. const getMatchingPods = baseApi<
  567. {
  568. namespace: string;
  569. selectors: string[];
  570. },
  571. { id: number; cluster_id: number }
  572. >("GET", (pathParams) => {
  573. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/pods`;
  574. });
  575. const getMetrics = baseApi<
  576. {
  577. metric: string;
  578. shouldsum: boolean;
  579. pods?: string[];
  580. kind?: string; // the controller kind
  581. name?: string;
  582. percentile?: number;
  583. namespace: string;
  584. startrange: number;
  585. endrange: number;
  586. resolution: string;
  587. },
  588. {
  589. id: number;
  590. cluster_id: number;
  591. }
  592. >("GET", (pathParams) => {
  593. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/metrics`;
  594. });
  595. const getNamespaces = baseApi<
  596. {},
  597. {
  598. id: number;
  599. cluster_id: number;
  600. }
  601. >("GET", (pathParams) => {
  602. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces`;
  603. });
  604. const getNGINXIngresses = baseApi<
  605. {},
  606. {
  607. id: number;
  608. cluster_id: number;
  609. }
  610. >("GET", (pathParams) => {
  611. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/prometheus/ingresses`;
  612. });
  613. const getOAuthIds = baseApi<
  614. {},
  615. {
  616. project_id: number;
  617. }
  618. >("GET", (pathParams) => {
  619. return `/api/projects/${pathParams.project_id}/integrations/oauth`;
  620. });
  621. const getProjectClusters = baseApi<{}, { id: number }>("GET", (pathParams) => {
  622. return `/api/projects/${pathParams.id}/clusters`;
  623. });
  624. const getProjectRegistries = baseApi<{}, { id: number }>(
  625. "GET",
  626. (pathParams) => {
  627. return `/api/projects/${pathParams.id}/registries`;
  628. }
  629. );
  630. const getProjectRepos = baseApi<{}, { id: number }>("GET", (pathParams) => {
  631. return `/api/projects/${pathParams.id}/repos`;
  632. });
  633. const getProjects = baseApi("GET", "/api/projects");
  634. const getPrometheusIsInstalled = baseApi<
  635. {},
  636. {
  637. id: number;
  638. cluster_id: number;
  639. }
  640. >("GET", (pathParams) => {
  641. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/prometheus/detect`;
  642. });
  643. const getRegistryIntegrations = baseApi("GET", "/api/integrations/registry");
  644. const getReleaseToken = baseApi<
  645. {},
  646. { name: string; id: number; namespace: string; cluster_id: number }
  647. >("GET", (pathParams) => {
  648. let { id, cluster_id, namespace, name } = pathParams;
  649. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/webhook`;
  650. });
  651. const getReleaseSteps = baseApi<
  652. {},
  653. { name: string; id: number; namespace: string; cluster_id: number }
  654. >("GET", (pathParams) => {
  655. let { id, cluster_id, namespace, name } = pathParams;
  656. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/steps`;
  657. });
  658. const destroyInfra = baseApi<
  659. {
  660. name: string;
  661. },
  662. {
  663. project_id: number;
  664. infra_id: number;
  665. }
  666. >("DELETE", (pathParams) => {
  667. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}`;
  668. });
  669. const getRepoIntegrations = baseApi("GET", "/api/integrations/repo");
  670. const getRepos = baseApi<{}, { id: number }>("GET", (pathParams) => {
  671. return `/api/projects/${pathParams.id}/repos`;
  672. });
  673. const getSlackIntegrations = baseApi<{}, { id: number }>(
  674. "GET",
  675. (pathParams) => {
  676. return `/api/projects/${pathParams.id}/slack_integrations`;
  677. }
  678. );
  679. const getRevisions = baseApi<
  680. {},
  681. { id: number; cluster_id: number; namespace: string; name: string }
  682. >("GET", (pathParams) => {
  683. let { id, cluster_id, namespace, name } = pathParams;
  684. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/history`;
  685. });
  686. const getTemplateInfo = baseApi<
  687. {
  688. repo_url?: string;
  689. },
  690. { name: string; version: string }
  691. >("GET", (pathParams) => {
  692. return `/api/templates/${pathParams.name}/${pathParams.version}`;
  693. });
  694. const getTemplateUpgradeNotes = baseApi<
  695. {
  696. repo_url?: string;
  697. prev_version: string;
  698. },
  699. { name: string; version: string }
  700. >("GET", (pathParams) => {
  701. return `/api/templates/${pathParams.name}/${pathParams.version}/upgrade_notes`;
  702. });
  703. const getTemplates = baseApi<
  704. {
  705. repo_url?: string;
  706. },
  707. {}
  708. >("GET", "/api/templates");
  709. const getMetadata = baseApi<{}, {}>("GET", () => {
  710. return `/api/metadata`;
  711. });
  712. const postWelcome = baseApi<{
  713. email: string;
  714. isCompany: boolean;
  715. company: string;
  716. role: string;
  717. }>("POST", () => {
  718. return `/api/welcome`;
  719. });
  720. const linkGithubProject = baseApi<
  721. {},
  722. {
  723. project_id: number;
  724. }
  725. >("GET", (pathParams) => {
  726. return `/api/oauth/projects/${pathParams.project_id}/github`;
  727. });
  728. const getGithubAccounts = baseApi<{}, {}>("GET", () => {
  729. return `/api/integrations/github-app/accounts`;
  730. });
  731. const logInUser = baseApi<{
  732. email: string;
  733. password: string;
  734. }>("POST", "/api/login");
  735. const logOutUser = baseApi("POST", "/api/logout");
  736. const provisionECR = baseApi<
  737. {
  738. ecr_name: string;
  739. aws_integration_id: number;
  740. },
  741. { id: number }
  742. >("POST", (pathParams) => {
  743. return `/api/projects/${pathParams.id}/provision/ecr`;
  744. });
  745. const provisionEKS = baseApi<
  746. {
  747. eks_name: string;
  748. aws_integration_id: number;
  749. machine_type: string;
  750. issuer_email: string;
  751. },
  752. { id: number }
  753. >("POST", (pathParams) => {
  754. return `/api/projects/${pathParams.id}/provision/eks`;
  755. });
  756. const registerUser = baseApi<{
  757. email: string;
  758. password: string;
  759. }>("POST", "/api/users");
  760. const rollbackChart = baseApi<
  761. {
  762. revision: number;
  763. },
  764. {
  765. id: number;
  766. name: string;
  767. namespace: string;
  768. cluster_id: number;
  769. }
  770. >("POST", (pathParams) => {
  771. let { id, name, cluster_id, namespace } = pathParams;
  772. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0/rollback`;
  773. });
  774. const uninstallTemplate = baseApi<
  775. {},
  776. {
  777. id: number;
  778. name: string;
  779. cluster_id: number;
  780. namespace: string;
  781. }
  782. >("DELETE", (pathParams) => {
  783. let { id, name, cluster_id, namespace } = pathParams;
  784. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0`;
  785. });
  786. const updateUser = baseApi<
  787. {
  788. rawKubeConfig?: string;
  789. allowedContexts?: string[];
  790. },
  791. { id: number }
  792. >("PUT", (pathParams) => {
  793. return `/api/users/${pathParams.id}`;
  794. });
  795. const upgradeChartValues = baseApi<
  796. {
  797. values: string;
  798. version?: string;
  799. },
  800. {
  801. id: number;
  802. name: string;
  803. namespace: string;
  804. cluster_id: number;
  805. }
  806. >("POST", (pathParams) => {
  807. let { id, name, cluster_id, namespace } = pathParams;
  808. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0/upgrade`;
  809. });
  810. const listConfigMaps = baseApi<
  811. {},
  812. {
  813. id: number;
  814. namespace: string;
  815. cluster_id: number;
  816. }
  817. >("GET", (pathParams) => {
  818. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/list`;
  819. });
  820. const getConfigMap = baseApi<
  821. {
  822. name: string;
  823. },
  824. {
  825. id: number;
  826. namespace: string;
  827. cluster_id: number;
  828. }
  829. >("GET", (pathParams) => {
  830. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap`;
  831. });
  832. const createConfigMap = baseApi<
  833. {
  834. name: string;
  835. variables: Record<string, string>;
  836. secret_variables?: Record<string, string>;
  837. },
  838. {
  839. id: number;
  840. cluster_id: number;
  841. namespace: string;
  842. }
  843. >("POST", (pathParams) => {
  844. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/create`;
  845. });
  846. const updateConfigMap = baseApi<
  847. {
  848. name: string;
  849. variables: Record<string, string>;
  850. secret_variables?: Record<string, string>;
  851. },
  852. {
  853. id: number;
  854. cluster_id: number;
  855. namespace: string;
  856. }
  857. >("POST", (pathParams) => {
  858. let { id, cluster_id } = pathParams;
  859. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/update`;
  860. });
  861. const renameConfigMap = baseApi<
  862. {
  863. name: string;
  864. new_name: string;
  865. },
  866. {
  867. id: number;
  868. cluster_id: number;
  869. namespace: string;
  870. }
  871. >("POST", (pathParams) => {
  872. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/rename`;
  873. });
  874. const deleteConfigMap = baseApi<
  875. {
  876. name: string;
  877. },
  878. {
  879. id: number;
  880. namespace: string;
  881. cluster_id: number;
  882. }
  883. >("DELETE", (pathParams) => {
  884. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/delete`;
  885. });
  886. const createNamespace = baseApi<
  887. {
  888. name: string;
  889. },
  890. { id: number; cluster_id: number }
  891. >("POST", (pathParams) => {
  892. let { id, cluster_id } = pathParams;
  893. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/create`;
  894. });
  895. const deleteNamespace = baseApi<
  896. {
  897. name: string;
  898. },
  899. {
  900. id: number;
  901. cluster_id: number;
  902. }
  903. >("DELETE", (pathParams) => {
  904. let { id, cluster_id } = pathParams;
  905. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/delete`;
  906. });
  907. const deleteJob = baseApi<
  908. {},
  909. { name: string; namespace: string; id: number; cluster_id: number }
  910. >("DELETE", (pathParams) => {
  911. let { id, name, cluster_id, namespace } = pathParams;
  912. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}`;
  913. });
  914. const stopJob = baseApi<
  915. {},
  916. { name: string; namespace: string; id: number; cluster_id: number }
  917. >("POST", (pathParams) => {
  918. let { id, name, namespace, cluster_id } = pathParams;
  919. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}/stop`;
  920. });
  921. const getAvailableRoles = baseApi<{}, { project_id: number }>(
  922. "GET",
  923. ({ project_id }) => `/api/projects/${project_id}/roles`
  924. );
  925. const updateInvite = baseApi<
  926. { kind: string },
  927. { project_id: number; invite_id: number }
  928. >(
  929. "POST",
  930. ({ project_id, invite_id }) =>
  931. `/api/projects/${project_id}/invites/${invite_id}`
  932. );
  933. const getCollaborators = baseApi<{}, { project_id: number }>(
  934. "GET",
  935. ({ project_id }) => `/api/projects/${project_id}/collaborators`
  936. );
  937. const updateCollaborator = baseApi<
  938. {
  939. kind: string;
  940. user_id: number;
  941. },
  942. { project_id: number }
  943. >("POST", ({ project_id }) => `/api/projects/${project_id}/roles`);
  944. const removeCollaborator = baseApi<{ user_id: number }, { project_id: number }>(
  945. "DELETE",
  946. ({ project_id }) => `/api/projects/${project_id}/roles`
  947. );
  948. const getPolicyDocument = baseApi<{}, { project_id: number }>(
  949. "GET",
  950. ({ project_id }) => `/api/projects/${project_id}/policy`
  951. );
  952. const createWebhookToken = baseApi<
  953. {},
  954. {
  955. project_id: number;
  956. chart_name: string;
  957. namespace: string;
  958. cluster_id: number;
  959. }
  960. >(
  961. "POST",
  962. ({ project_id, chart_name, namespace, cluster_id }) =>
  963. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${chart_name}/0/webhook`
  964. );
  965. const getUsage = baseApi<{}, { project_id: number }>(
  966. "GET",
  967. ({ project_id }) => `/api/projects/${project_id}/usage`
  968. );
  969. // Used for billing purposes
  970. const getCustomerToken = baseApi<{}, { project_id: number }>(
  971. "GET",
  972. ({ project_id }) => `/api/projects/${project_id}/billing/token`
  973. );
  974. const getHasBilling = baseApi<{}, { project_id: number }>(
  975. "GET",
  976. ({ project_id }) => `/api/projects/${project_id}/billing`
  977. );
  978. const getOnboardingState = baseApi<{}, { project_id: number }>(
  979. "GET",
  980. ({ project_id }) => `/api/projects/${project_id}/onboarding`
  981. );
  982. const saveOnboardingState = baseApi<{}, { project_id: number }>(
  983. "POST",
  984. ({ project_id }) => `/api/projects/${project_id}/onboarding`
  985. );
  986. const getOnboardingInfra = baseApi<
  987. {},
  988. { project_id: number; registry_infra_id: number }
  989. >(
  990. "GET",
  991. ({ project_id, registry_infra_id }) =>
  992. `/api/projects/${project_id}/infras/${registry_infra_id}`
  993. );
  994. const getOnboardingRegistry = baseApi<
  995. {},
  996. { project_id: number; registry_connection_id: number }
  997. >(
  998. "GET",
  999. ({ project_id, registry_connection_id }) =>
  1000. `/api/projects/${project_id}/registries/${registry_connection_id}`
  1001. );
  1002. const detectPorterAgent = baseApi<
  1003. {},
  1004. { project_id: number; cluster_id: number }
  1005. >(
  1006. "GET",
  1007. ({ project_id, cluster_id }) =>
  1008. `/api/projects/${project_id}/clusters/${cluster_id}/agent/detect`
  1009. );
  1010. const installPorterAgent = baseApi<
  1011. {},
  1012. { project_id: number; cluster_id: number }
  1013. >(
  1014. "POST",
  1015. ({ cluster_id, project_id }) =>
  1016. `/api/projects/${project_id}/clusters/${cluster_id}/agent/install`
  1017. );
  1018. const getKubeEvents = baseApi<{}, { project_id: number; cluster_id: number }>(
  1019. "GET",
  1020. ({ project_id, cluster_id }) =>
  1021. `/api/projects/${project_id}/clusters/${cluster_id}/kube_events`
  1022. );
  1023. const getKubeEvent = baseApi<
  1024. {},
  1025. { project_id: number; cluster_id: number; kube_event_id: number }
  1026. >(
  1027. "GET",
  1028. ({ project_id, cluster_id, kube_event_id }) =>
  1029. `/api/projects/${project_id}/clusters/${cluster_id}/kube_events/${kube_event_id}`
  1030. );
  1031. // Bundle export to allow default api import (api.<method> is more readable)
  1032. export default {
  1033. checkAuth,
  1034. connectECRRegistry,
  1035. connectGCRRegistry,
  1036. connectDORegistry,
  1037. getAWSIntegration,
  1038. getGCPIntegration,
  1039. createAWSIntegration,
  1040. overwriteAWSIntegration,
  1041. createDOCR,
  1042. createDOKS,
  1043. createEmailVerification,
  1044. createGCPIntegration,
  1045. createGCR,
  1046. createGKE,
  1047. createInvite,
  1048. createNamespace,
  1049. createPasswordReset,
  1050. createPasswordResetVerify,
  1051. createPasswordResetFinalize,
  1052. createProject,
  1053. createConfigMap,
  1054. deleteCluster,
  1055. deleteConfigMap,
  1056. deleteInvite,
  1057. deleteNamespace,
  1058. deletePod,
  1059. deleteProject,
  1060. deleteRegistryIntegration,
  1061. deleteSlackIntegration,
  1062. updateNotificationConfig,
  1063. getNotificationConfig,
  1064. createSubdomain,
  1065. deployTemplate,
  1066. deployAddon,
  1067. destroyInfra,
  1068. detectBuildpack,
  1069. getBranchContents,
  1070. getBranches,
  1071. getMetadata,
  1072. postWelcome,
  1073. getChart,
  1074. getCharts,
  1075. getChartComponents,
  1076. getChartControllers,
  1077. getClusterIntegrations,
  1078. getClusters,
  1079. getCluster,
  1080. getClusterNodes,
  1081. getClusterNode,
  1082. getConfigMap,
  1083. getGHAWorkflowTemplate,
  1084. getGitRepoList,
  1085. getGitRepos,
  1086. getImageRepos,
  1087. getImageTags,
  1088. getInfra,
  1089. getInfraDesired,
  1090. getInfraCurrent,
  1091. getIngress,
  1092. getInvites,
  1093. getJobs,
  1094. getJobStatus,
  1095. getJobPods,
  1096. getMatchingPods,
  1097. getMetrics,
  1098. getNamespaces,
  1099. getNGINXIngresses,
  1100. getOAuthIds,
  1101. getPodEvents,
  1102. getProcfileContents,
  1103. getProjectClusters,
  1104. getProjectRegistries,
  1105. getProjectRepos,
  1106. getProjects,
  1107. getPrometheusIsInstalled,
  1108. getRegistryIntegrations,
  1109. getReleaseToken,
  1110. getReleaseSteps,
  1111. getRepoIntegrations,
  1112. getSlackIntegrations,
  1113. getRepos,
  1114. getRevisions,
  1115. getTemplateInfo,
  1116. getTemplateUpgradeNotes,
  1117. getTemplates,
  1118. linkGithubProject,
  1119. getGithubAccounts,
  1120. listConfigMaps,
  1121. logInUser,
  1122. logOutUser,
  1123. provisionECR,
  1124. provisionEKS,
  1125. registerUser,
  1126. rollbackChart,
  1127. uninstallTemplate,
  1128. updateUser,
  1129. renameConfigMap,
  1130. updateConfigMap,
  1131. upgradeChartValues,
  1132. deleteJob,
  1133. stopJob,
  1134. updateInvite,
  1135. getAvailableRoles,
  1136. getCollaborators,
  1137. updateCollaborator,
  1138. removeCollaborator,
  1139. getPolicyDocument,
  1140. createWebhookToken,
  1141. getUsage,
  1142. getCustomerToken,
  1143. getHasBilling,
  1144. getOnboardingState,
  1145. saveOnboardingState,
  1146. getOnboardingInfra,
  1147. getOnboardingRegistry,
  1148. detectPorterAgent,
  1149. installPorterAgent,
  1150. getKubeEvents,
  1151. getKubeEvent,
  1152. };