Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/next/pages/api/v2/compute/set-server-cloud.ts
Views: 687
/*1Set the cloud of a compute server. The owner is the only one allowed2to do this. Changing the cloud clears the configuration, since it is3not meaningful between clouds.4*/56import getAccountId from "lib/account/get-account";7import setServerCloud from "@cocalc/server/compute/set-server-cloud";8import getParams from "lib/api/get-params";910import { apiRoute, apiRouteOperation } from "lib/api";11import { OkStatus } from "lib/api/status";12import {13SetComputeServerCloudInputSchema,14SetComputeServerCloudOutputSchema,15} from "lib/api/schema/compute/set-server-cloud";1617async function handle(req, res) {18try {19res.json(await get(req));20} catch (err) {21res.json({ error: `${err.message}` });22return;23}24}2526async function get(req) {27const account_id = await getAccountId(req);28if (!account_id) {29throw Error("must be signed in");30}31const { id, cloud } = getParams(req);32await setServerCloud({33account_id,34id,35cloud,36});37return OkStatus;38}3940export default apiRoute({41setServerCloud: apiRouteOperation({42method: "POST",43openApiOperation: {44tags: ["Compute"],45},46})47.input({48contentType: "application/json",49body: SetComputeServerCloudInputSchema,50})51.outputs([52{53status: 200,54contentType: "application/json",55body: SetComputeServerCloudOutputSchema,56},57])58.handler(handle),59});606162