CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/pages/api/v2/compute/cloud-filesystem/get-metrics.ts
Views: 688
1
/*
2
Get metrics for a cloud file system.
3
*/
4
5
import getProjectOrAccountId from "lib/account/get-account";
6
import getMetrics from "@cocalc/server/compute/cloud-filesystem/get-metrics";
7
import getParams from "lib/api/get-params";
8
9
export default async function handle(req, res) {
10
try {
11
res.json(await get(req));
12
} catch (err) {
13
res.json({ error: `${err.message}` });
14
return;
15
}
16
}
17
18
async function get(req) {
19
const account_id = await getProjectOrAccountId(req);
20
if (!account_id) {
21
throw Error("invalid auth");
22
}
23
const { cloud_filesystem_id, limit, offset } = getParams(req);
24
25
return await getMetrics({
26
account_id,
27
cloud_filesystem_id,
28
limit,
29
offset,
30
});
31
}
32
33