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-image-tested.ts
Views: 687
/*1Set whether or not the image a compute server with given id is using has been tested.2This is used by admins when manually doing final integration testing for a new image3on some cloud provider.4*/56import getAccountId from "lib/account/get-account";7import { setImageTested } from "@cocalc/server/compute/control";8import getParams from "lib/api/get-params";9import userIsInGroup from "@cocalc/server/accounts/is-in-group";1011import { apiRoute, apiRouteOperation } from "lib/api";12import { OkStatus } from "lib/api/status";13import {14SetComputeServerImageTestedInputSchema,15SetComputeServerImageTestedOutputSchema,16} from "lib/api/schema/compute/set-image-tested";1718async function handle(req, res) {19try {20res.json(await get(req));21} catch (err) {22res.json({ error: `${err.message}` });23return;24}25}2627async function get(req) {28const account_id = await getAccountId(req);29if (!account_id) {30throw Error("must be signed in");31}32if (!(await userIsInGroup(account_id, "admin"))) {33throw Error("only admin are allowed to image tested status");34}35const { id, tested } = getParams(req);36await setImageTested({ id, account_id, tested });37return OkStatus;38}3940export default apiRoute({41setImageTested: apiRouteOperation({42method: "POST",43openApiOperation: {44tags: ["Compute"],45},46})47.input({48contentType: "application/json",49body: SetComputeServerImageTestedInputSchema,50})51.outputs([52{53status: 200,54contentType: "application/json",55body: SetComputeServerImageTestedOutputSchema,56},57])58.handler(handle),59});606162