api.tsx 57 KB

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