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/licenses/get-managed.ts
Views: 687
/*1Get all licenses that the signed in user manages.23See docs in @cocalc/server/licenses/get-managed.ts45Returns [License1, License2, ...] on success or {error:'a message'} on failure.6For the fields in the License objects, see @cocalc/server/licenses/get-managed.ts7*/89import getManagedLicenses, {10License,11} from "@cocalc/server/licenses/get-managed";12import getAccountId from "lib/account/get-account";13import getParams from "lib/api/get-params";1415import { apiRoute, apiRouteOperation } from "lib/api";16import {17GetManagedLicensesInputSchema,18GetManagedLicensesOutputSchema,19} from "lib/api/schema/licenses/get-managed";2021async function handle(req, res) {22try {23res.json(await get(req));24} catch (err) {25res.json({ error: `${err.message}` });26return;27}28}2930async function get(req): Promise<License[]> {31const account_id = await getAccountId(req);32if (account_id == null) {33return [];34}35const { limit, skip } = getParams(req);36return await getManagedLicenses(account_id, limit, skip);37}3839export default apiRoute({40getManaged: apiRouteOperation({41method: "POST",42openApiOperation: {43tags: ["Licenses"],44},45})46.input({47contentType: "application/json",48body: GetManagedLicensesInputSchema,49})50.outputs([51{52status: 200,53contentType: "application/json",54body: GetManagedLicensesOutputSchema,55},56])57.handler(handle),58});596061