@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
212 lines (211 loc) • 6.83 kB
TypeScript
import { PlainVersionedObject } from '../base/versioned-object';
import { EnvironmentConnectionTypeInfo } from '../manifest/environment-modules';
/**
* The connection properties class.
*/
export interface ConnectionProperties extends MsftSme.StringMap<any> {
}
/**
* The reserved connection property name on server.
*/
export declare class ConnectionPropertiesName {
static readonly PropertyDisplayName = "displayName";
static readonly PropertyName = "name";
static readonly PropertyNetworkName = "networkName";
static readonly DisplayNameLocalhost = "localhost";
/**
* Check if the display name is localhost.
*
* @param properties the connection properties.
* @returns true if it's localhost.
*/
static isDisplayNameLocalhost(properties: ConnectionProperties): boolean;
/**
* Gets the display name.
*
* @param properties the connection properties.
* @returns the display name property value.
*/
static getDisplayName(properties: ConnectionProperties): string;
/**
* Gets the name.
*
* @param properties the connection properties.
* @returns the name property value.
*/
static getName(properties: ConnectionProperties): string;
/**
* Gets the network name.
*
* @param properties the connection properties.
* @returns the network name property value.
*/
static getNetworkName(properties: ConnectionProperties): string;
}
/**
* The connection attributes class.
*/
export interface ConnectionAttribute {
/**
* The id string of this attribute
*/
id: string;
/**
* The value of the attribute. used for attributes that can have variable values such as Operating System
*/
value?: string | number;
}
/**
* The connection class.
*/
export interface Connection {
/**
* The id of the connection, this is unique per connection
*/
id: string;
/**
* The type of connection
*/
type: string;
/**
* The name of the connection, this is unique per connection type
*/
name: string;
/**
* The fallback connection aliases list
*/
aliases?: string[];
/**
* The active alias, last known good name, null or undefined if not in use
*/
activeAlias?: string;
/**
* The property bag of the connection
*/
properties?: ConnectionProperties;
/**
* The ids of attributes identified for this connection
*/
attributes?: ConnectionAttribute[];
/**
* The tags the user(s) have assigned to this connection
*/
tags?: string[];
/**
* The groupId of the connection
*/
groupId?: string;
/**
* The settings the users/extensions have assigned to this connection
*/
settings?: PlainVersionedObject;
/**
* Display type name
*/
displayTypeName?: string;
}
/**
* Defines connection type strings known by core
* Be careful that these strings match what is defined by the manifest of @msft-sme/server-manager
*/
export declare const connectionTypeConstants: {
server: string;
cluster: string;
windowsClient: string;
eflowDevice: string;
clusterNodesProperty: string;
};
/**
* Connection Utility class.
*/
export declare class ConnectionUtility {
/**
* Determines if one connection is referring to the same object as another connection
*
* @param a the first connection in the comparison
* @param b the second connection in the comparison
* @returns true if the connections are of the same type and have the same name
*/
static areEqual(a: Connection, b: Connection): boolean;
/**
* Determines if the given connection is to a server
*
* @param connection the connection to check
*/
static isServer(connection: Connection): boolean;
/**
* Determines if the given connection is to a cluster connection.
* Currently we support: HCI and Failover Cluster.
*
* @param connection the connection to check
*/
static isCluster(connection: Connection): boolean;
/**
* Determines if the given connection is to a FailOver cluster
*
* @param connection the connection to check
*/
static isFailoverCluster(connection: Connection): boolean;
/**
* Determines if the given connection is to a windows client
*
* @param connection the connection to check
*/
static isWindowsClient(connection: Connection): boolean;
/**
* Determines if the given connection is to an EFLOW device
*
* @param connection the connection to check
*/
static isEflowDevice(connection: Connection): boolean;
/**
* Determines if the given connection is to a node
*
* @param connection the connection to check
*/
static isNode(connection: Connection): boolean;
/**
* Gets the name of a node from a connection. This assumes the connection is to a single server or cluster.
*
* @param connection the connection object. (should be of type server or cluster)
* @param throwError throw an error if not a server or cluster.
*/
static getNodeName(connection: Connection, throwError?: boolean): string;
/**
* Gets the name of a valid node from a connection. This assumes the connection is to a single server or cluster.
* if activeAlias is used return it, otherwise return connection.name
*
* @param connection the connection object. (should be of type server or cluster)
* @param throwError throw an error if not a server or cluster.
*/
static getValidNodeName(connection: Connection, throwError?: boolean): string;
/**
* Gets nodes of a connection of type cluster
*
* @param connection the connection object. (should be of type cluster)
* @param throwError throw an error if not a cluster.
*/
static getClusterNodes(connection: Connection, throwError?: boolean): string[];
/**
* Gets the connection type info for a given connection
*
* @param connection the connection object.
*/
static getConnectionTypeInfo(connection: Connection): EnvironmentConnectionTypeInfo;
/**
* creates a connection Identifier
*
* @param connectionType the connection type.
* @param connectionName the connection name.
*/
static createConnectionId(connectionType: string, connectionName: string, groupId?: string): string;
/**
* Ensures tat important fields in a connection are lowercase
*/
static forceLowercase(connection: Connection): void;
/**
* Ensures tat important fields in a connection are lowercase
*/
static hasTags(connection: Connection): boolean;
static convertToConnectionName(inputName: string): string;
}