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/get-images-google.ts
Views: 687
/*1Get all google cloud images.2*/34import getAccountId from "lib/account/get-account";5import { getAllImages } from "@cocalc/server/compute/cloud/google-cloud/images";6import getParams from "lib/api/get-params";7import userIsInGroup from "@cocalc/server/accounts/is-in-group";89import { apiRoute, apiRouteOperation } from "lib/api";10import {11GetComputeServerGoogleImagesInputSchema,12GetComputeServerGoogleImagesOutputSchema,13} from "lib/api/schema/compute/get-images-google";1415async function handle(req, res) {16try {17res.json(await get(req));18} catch (err) {19res.json({ error: `${err.message}` });20return;21}22}2324async function get(req) {25const account_id = await getAccountId(req);26if (!account_id) {27throw Error("must be signed in");28}29let { noCache } = getParams(req);30if (noCache) {31// NOTE: only admins can specify noCache32if (!(await userIsInGroup(account_id, "admin"))) {33throw Error("only admin are allowed to specify noCache");34}35}36return await getAllImages({ noCache: !!noCache });37}3839export default apiRoute({40getImagesGoogle: apiRouteOperation({41method: "POST",42openApiOperation: {43tags: ["Compute"],44},45})46.input({47contentType: "application/json",48body: GetComputeServerGoogleImagesInputSchema,49})50.outputs([51{52status: 200,53contentType: "application/json",54body: GetComputeServerGoogleImagesOutputSchema,55},56])57.handler(handle),58});596061