api.tsx 43 KB

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