api.tsx 41 KB

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