import { ISignal } from 'phosphor/lib/core/signaling'; import { IKernel, Kernel, KernelMessage } from '../kernel'; import { IAjaxSettings } from '../utils'; import { ISession, Session } from './session'; /** * Session object for accessing the session REST api. The session * should be used to start kernels and then shut them down -- for * all other operations, the kernel object should be used. */ export declare class DefaultSession implements ISession { /** * Construct a new session. */ constructor(options: Session.IOptions, id: string, kernel: IKernel); /** * A signal emitted when the session dies. */ sessionDied: ISignal; /** * A signal emitted when the kernel changes. */ kernelChanged: ISignal; /** * A signal emitted when the kernel status changes. */ statusChanged: ISignal; /** * A signal emitted for a kernel messages. */ iopubMessage: ISignal; /** * A signal emitted for an unhandled kernel message. */ unhandledMessage: ISignal; /** * A signal emitted when the session path changes. */ pathChanged: ISignal; /** * Get the session id. */ readonly id: string; /** * Get the session kernel object. * * #### Notes * This is a read-only property, and can be altered by [changeKernel]. * Use the [statusChanged] and [unhandledMessage] signals on the session * instead of the ones on the kernel. */ readonly kernel: IKernel; /** * Get the session path. */ readonly path: string; /** * Get the model associated with the session. */ readonly model: Session.IModel; /** * The current status of the session. * * #### Notes * This is a delegate to the kernel status. */ readonly status: Kernel.Status; /** * Get a copy of the default ajax settings for the session. */ /** * Set the default ajax settings for the session. */ ajaxSettings: IAjaxSettings; /** * Test whether the session has been disposed. */ readonly isDisposed: boolean; /** * Clone the current session with a new clientId. */ clone(): Promise; /** * Update the session based on a session model from the server. */ update(model: Session.IModel): Promise; /** * Dispose of the resources held by the session. */ dispose(): void; /** * Change the session path. * * @param path - The new session path. * * #### Notes * This uses the Jupyter REST API, and the response is validated. * The promise is fulfilled on a valid response and rejected otherwise. */ rename(path: string): Promise; /** * Change the kernel. * * @params options - The name or id of the new kernel. * * #### Notes * This shuts down the existing kernel and creates a new kernel, * keeping the existing session ID and session path. */ changeKernel(options: Kernel.IModel): Promise; /** * Kill the kernel and shutdown the session. * * @returns - The promise fulfilled on a valid response from the server. * * #### Notes * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/sessions), and validates the response. * Emits a [sessionDied] signal on success. */ shutdown(): Promise; /** * Handle connections to a kernel. */ protected setupKernel(kernel: IKernel): void; /** * Handle to changes in the Kernel status. */ protected onKernelStatus(sender: IKernel, state: Kernel.Status): void; /** * Handle iopub kernel messages. */ protected onIOPubMessage(sender: IKernel, msg: KernelMessage.IIOPubMessage): void; /** * Handle unhandled kernel messages. */ protected onUnhandledMessage(sender: IKernel, msg: KernelMessage.IMessage): void; /** * Get the options used to create a new kernel. */ private _getKernelOptions(); /** * Send a PATCH to the server, updating the session path or the kernel. */ private _patch(data); private _id; private _path; private _ajaxSettings; private _kernel; private _uuid; private _baseUrl; private _options; private _updating; } /** * The namespace for `DefaultSession` statics. */ export declare namespace DefaultSession { /** * List the running sessions. */ function listRunning(options?: Session.IOptions): Promise; /** * Start a new session. */ function startNew(options: Session.IOptions): Promise; /** * Find a session by id. */ function findById(id: string, options?: Session.IOptions): Promise; /** * Find a session by path. */ function findByPath(path: string, options?: Session.IOptions): Promise; /** * Connect to a running session. */ function connectTo(id: string, options?: Session.IOptions): Promise; /** * Shut down a session by id. */ function shutdown(id: string, options?: Session.IOptions): Promise; }