api.tsx 58 KB

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