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/edit.ts
Views: 688
1
/*
2
Edit properties of cloud file system
3
*/
4
5
import getAccountId from "lib/account/get-account";
6
import {
7
userEditCloudFilesystem,
8
FIELDS,
9
} from "@cocalc/server/compute/cloud-filesystem/edit";
10
import getParams from "lib/api/get-params";
11
import type { EditCloudFilesystem } from "@cocalc/util/db-schema/cloud-filesystems";
12
13
export default async function handle(req, res) {
14
try {
15
res.json(await get(req));
16
} catch (err) {
17
res.json({ error: `${err.message}` });
18
return;
19
}
20
}
21
22
async function get(req) {
23
const account_id = await getAccountId(req);
24
if (!account_id) {
25
throw Error("must be signed in");
26
}
27
const params = getParams(req);
28
const { id } = params;
29
const opts: Partial<EditCloudFilesystem> = {};
30
for (const field of FIELDS) {
31
const x = params[field];
32
if (x !== undefined) {
33
opts[field] = x;
34
}
35
}
36
37
return await userEditCloudFilesystem({
38
...(opts as EditCloudFilesystem),
39
account_id,
40
id,
41
});
42
}
43
44