UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

104 lines (102 loc) 3.13 kB
import { EnvironmentModule } from '../manifest/environment-modules'; import { ConnectionUtility } from './connection'; /** * Provides a shortcut to accessing common information about the active connection. */ export class ActiveConnection { connectionManager; cimConnection; powerShellConnection; fileTransfer; /** * map data of connection type information. */ map = null; /** * Gets the active connection */ get value() { return this.connectionManager.activeConnection; } /** * Sets the active connection */ set value(value) { this.connectionManager.activeConnection = value; } /** * Indicates if the active connection is to a server */ get isServer() { return ConnectionUtility.isServer(this.value); } /** * Indicates if the active connection is to a cluster */ get isCluster() { return ConnectionUtility.isCluster(this.value); } /** * Indicates if the active connection is to a node (cluster or server) */ get isNode() { return ConnectionUtility.isNode(this.value); } /** * Indicates if the active connection is to a failover cluster * @deprecated since 09/16/19. Please use isBritannicEnabled from ClusterInventoryCache instead */ get isFailoverCluster() { return ConnectionUtility.isFailoverCluster(this.value); } /** * Indicates if the active connection is to a windows client */ get isWindowsClient() { return ConnectionUtility.isWindowsClient(this.value); } /** * Indicates if the active connection is to an EFLOW device */ get isEflowDevice() { return ConnectionUtility.isEflowDevice(this.value); } /** * If the active connection is a cluster, the cluster node names. Otherwise, an empty array */ get clusterNodes() { return ConnectionUtility.getClusterNodes(this.value); } /** * If the active connection is a node (cluster or server), the node name. Otherwise, null. */ get nodeName() { return ConnectionUtility.getNodeName(this.value); } /** * If the active connection is a node (cluster or server), the valid node name (may be alias). Otherwise, null. */ get validNodeName() { return ConnectionUtility.getValidNodeName(this.value); } /** * Gets the connection type info for the active connection */ get connectionTypeInfo() { if (!this.map) { // create once. this.map = EnvironmentModule.getConnectionMap(); } return this.value ? this.map[this.value.type] : null; } /** * Constructor for the active connection class */ constructor(connectionManager, cimConnection, powerShellConnection, fileTransfer) { this.connectionManager = connectionManager; this.cimConnection = cimConnection; this.powerShellConnection = powerShellConnection; this.fileTransfer = fileTransfer; } } //# sourceMappingURL=active-connection.js.map