api.tsx 54 KB

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