@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
158 lines (157 loc) • 4.92 kB
TypeScript
import { Observable } from 'rxjs';
import { ExtensionBrokerQuery } from '../data/extension-broker/extension-broker';
import { GatewayConnection } from '../data/gateway-connection';
import { NodeConnection } from '../data/node-connection';
import { PowerShellConnection } from '../data/powershell-connection';
import { Rpc } from '../rpc/rpc';
import { AuthorizationManager } from './authorization-manager';
import { Connection } from './connection';
import { ConnectionManager } from './connection-manager';
/**
* Live connection interface.
*/
export interface LiveConnection {
/**
* the connection object.
*/
connection: Connection;
/**
* the loading state while query the connection status.
*/
loading: boolean;
/**
* the date number (Date.now() value).
*/
lastUpdated: number;
/**
* The PowerShell connection.
*/
isPowerShell: boolean;
/**
* The endpoint of PowerShell.
*/
powerShellEndpoint: string;
/**
* the status of connection.
*/
status?: LiveConnectionStatus;
/**
* The extra properties on the connection.
*/
properties?: MsftSme.StringMap<any>;
}
/**
* The live connection status.
*/
export interface LiveConnectionStatus {
/**
* The display string of status.
*/
label?: string;
/**
* The status type.
*/
type: LiveConnectionStatusType;
/**
* The detail connection error message.
*/
details?: string;
}
/**
* The live connection status type.
*/
export declare enum LiveConnectionStatusType {
/**
* Online status.
*/
Online = 0,
/**
* Warning status.
*/
Warning = 1,
/**
* Unauthorized status.
*/
Unauthorized = 2,
/**
* Error status.
*/
Error = 3,
/**
* Fatal status.
*/
Fatal = 4,
/**
* Unknown status (used for loading status).
*/
Unknown = 5,
/**
* Forbidden status.
*/
Forbidden = 6
}
export interface ConnectionStatusResult extends MsftSme.StringMap<any> {
status?: LiveConnectionStatus;
aliases?: string[];
}
/**
* ConnectionStream class that enables to get all connections once and listen to the change.
*
* TODO:
* 1. Support live connection status for a single connection in such a way that one could subscribe to it from ActiveConnection
* with that observable always being for the active connection.
* 2. Support updating all connection status on an interval. (using existing expiration field in cache)
* 3. Support preserving status across sessions during the interval time.
* currently we are using session storage, this may also require credentials to be preserved across sessions.
*/
export declare class ConnectionStream {
private rpc;
private connectionManager;
private powershellConnection;
private gatewayConnection;
private nodeConnection;
private authorizationManager;
private extensionBroker;
private statusLabelMap;
private connectionStrings;
private cacheLiveConnection;
/**
* Initializes a new instance of the ConnectionStream class.
* @param connectionManager the connection manager object.
* @param powershellConnection the powerShell connection object.
* @param gatewayConnection the gateway connection object.
*/
constructor(rpc: Rpc, connectionManager: ConnectionManager, powershellConnection: PowerShellConnection, gatewayConnection: GatewayConnection, nodeConnection: NodeConnection, authorizationManager: AuthorizationManager, extensionBroker: ExtensionBrokerQuery);
/**
* Wraps a connection in a live connection object by retrieving its current status
* @param connection the connection object.
*/
getLiveConnection(connection: Connection): Observable<LiveConnection>;
/**
* Get connection status and aliases from statusProvider, retry alaises when connection nodeName NotFound
* @param statusProvider status provider from typeInfo manifest
* @param connection original connection
* @param nodeName retry nodeName, can be connection.name or alias
*/
private getConnectionStatus;
/**
* Retrieves a connections status from a powershell status provider
* @param nodeName the node name.
* @param options The powershell options.
*/
private getConnectionStatusFromPowershell;
/**
* Retrieves a connections status from a gatewayUrl status provider
* @param nodeName the node name.
* @param relativeUrl the relative url from the relativeGatewayUrl provider.
*/
private getConnectionStatusFromGatewayUrl;
/**
* Retrieves a connections status from a extension service method
*/
private getConnectionStatusFromService;
/**
* Retrieves a connections status from a extension worker method
*/
private getConnectionStatusFromWorker;
}