@jupyterlab/services
Version:
Client APIs for the Jupyter services REST APIs
35 lines • 1.48 kB
JavaScript
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSpecs = void 0;
const serverconnection_1 = require("../serverconnection");
const validate_1 = require("./validate");
const coreutils_1 = require("@jupyterlab/coreutils");
/**
* The url for the kernelspec service.
*/
const KERNELSPEC_SERVICE_URL = 'api/kernelspecs';
/**
* Fetch all of the kernel specs.
*
* @param settings - The optional server settings.
* @param useCache - Whether to use the cache. If false, always request.
*
* @returns A promise that resolves with the kernel specs.
*
* #### Notes
* Uses the [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/kernelspecs).
*/
async function getSpecs(settings = serverconnection_1.ServerConnection.makeSettings()) {
const url = coreutils_1.URLExt.join(settings.baseUrl, KERNELSPEC_SERVICE_URL);
const response = await serverconnection_1.ServerConnection.makeRequest(url, {}, settings);
if (response.status !== 200) {
const err = await serverconnection_1.ServerConnection.ResponseError.create(response);
throw err;
}
const data = await response.json();
return (0, validate_1.validateSpecModels)(data);
}
exports.getSpecs = getSpecs;
//# sourceMappingURL=restapi.js.map
;