api.tsx 54 KB

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