@jupyterlab/services
Version:
Client APIs for the Jupyter services REST APIs
120 lines (119 loc) • 4.82 kB
TypeScript
import { ServerConnection } from '../serverconnection';
import { Session } from '.';
import { ISessionAPIClient } from './session';
export type DeepPartial<T> = {
[P in keyof T]?: DeepPartial<T[P]>;
};
/**
* The url for the session service.
*/
export declare const SESSION_SERVICE_URL = "api/sessions";
/**
* List the running sessions.
*/
export declare function listRunning(settings?: ServerConnection.ISettings): Promise<Session.IModel[]>;
/**
* Get a session url.
*/
export declare function getSessionUrl(baseUrl: string, id: string): string;
/**
* Shut down a session by id.
*/
export declare function shutdownSession(id: string, settings?: ServerConnection.ISettings): Promise<void>;
/**
* Get a full session model from the server by session id string.
*/
export declare function getSessionModel(id: string, settings?: ServerConnection.ISettings): Promise<Session.IModel>;
/**
* Create a new session, or return an existing session if the session path
* already exists.
*/
export declare function startSession(options: Session.ISessionOptions, settings?: ServerConnection.ISettings): Promise<Session.IModel>;
/**
* Send a PATCH to the server, updating the session path or the kernel.
*/
export declare function updateSession(model: Pick<Session.IModel, 'id'> & DeepPartial<Omit<Session.IModel, 'id'>>, settings?: ServerConnection.ISettings): Promise<Session.IModel>;
/**
* The session API client.
*
* #### Notes
* Use this class to interact with the Jupyter Server Session API.
* This class adheres to the Jupyter Server API endpoints.
*/
export declare class SessionAPIClient implements ISessionAPIClient {
/**
* Create a new session API client.
*
* @param options - The options used to create the client.
*/
constructor(options: {
serverSettings?: ServerConnection.ISettings;
});
/**
* The server settings used by the client.
*/
readonly serverSettings: ServerConnection.ISettings;
/**
* List the running sessions.
*
* @returns A promise that resolves with the list of running session models.
*
* #### 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#!/sessions) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
listRunning(): Promise<Session.IModel[]>;
/**
* Get a session model.
*
* @param id - The id of the session of interest.
*
* @returns A promise that resolves with the session model.
*
* #### 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#!/sessions) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
getModel(id: string): Promise<Session.IModel>;
/**
* Create a new session.
*
* @param options - The options used to create the session.
*
* @returns A promise that resolves with the session model.
*
* #### 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#!/sessions) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
startNew(options: Session.ISessionOptions): Promise<Session.IModel>;
/**
* Shut down a session by id.
*
* @param id - The id of the session to shut down.
*
* @returns A promise that resolves when the session is shut down.
*
* #### 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#!/sessions) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
shutdown(id: string): Promise<void>;
/**
* Update a session by id.
*
* @param model - The session model to update.
*
* @returns A promise that resolves with the updated session model.
*
* #### 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#!/sessions) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
update(model: Pick<Session.IModel, 'id'> & DeepPartial<Omit<Session.IModel, 'id'>>): Promise<Session.IModel>;
}