mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-01 17:23:35 -05:00
* Added Azure Log Analytics resource for generating AAD Token. * Fixed AzureResource * Removed debug code from connectionManagementService * Moved AzureLogAnalytics from AzureResource enum in azdata.d.ts to azdata.proposed.d.ts. Added azureLogAnalyticsResource to all azureSettings in providerSettings.ts * Updated endpoint for generating AAD Token for LogAnalytics for UsGov, UsNat, and China * Initial Commit of Azure Monitor Extension * Added extension name to azuremonitor package strings * Removed azureMonitor resource from germanyCloud in providerSettings * Added logic to exclude menuItems in object explorer for LogAnalytics * Changed exe from AzureMonitor to Kusto * Added if clause for queryName for new queries * Changed queryWindow name from KustoQuery to KQLQuery for Kusto and LogAnalytics. * Added LogAnalytics for setTaskBarContent * Added serialization and telemetry feature classes to AzureMonitor. Added references for azdata and vscode. * Added azure monitor light and dark icons * Added config for Dashboard in package.json * Added workspace information to dashboard * Added language support for LogAnalytics * Added Notebook support * Added Hide flag to package.json for databaseName * Changed providerId from LogAnalytics to LOGANALYTICS * Changed Workspace to Workspace ID in package.nls.json * Added support for Azure Widget browser * Changed fullName to use workspaceId when connecting * Changed providerId from alertsManagement to azureMonitor * Added .gitignore and *.vsix to vscodeignore. * Removed unused devDependencies * Code Review Feedback * Changed tsconfig.json to match Kusto and Sql * Changed package.json to match kusto package. * Changed tsconfig to validate unused params and implictAny. Changed existing code to satisfy build. * Fixed tsconfig to use the correct base class. * Added objectExplorerNodeProvider and all related classes. * Removed unused tmLanguage file * Added logic to to download extension from toolservice * Fixed launchArgs. Removed commented code from extension.ts. Changed config.json to use net5.0 * Added displayName to package.nls.json. Removed hide flag from databaseName. Other code review feedback. * Added readme info to AzureMonitor * Removed unused client-error-handler and ui-references files. Combined outputChannel in azuremonitorServer. Removed TODO from contextProvider. Renamed function in extension.ts. Removed unneeded 'use strict' from cancelableStream.ts. Removed second outputChannel from objectExplorerNodeProvider. * Removed unused files
83 lines
3.2 KiB
TypeScript
83 lines
3.2 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import * as azdata from 'azdata';
|
|
import * as nls from 'vscode-nls';
|
|
const localize = nls.loadMessageBundle();
|
|
|
|
import * as constants from '../constants';
|
|
|
|
export class AzureMonitorClusterConnection {
|
|
private _connection: azdata.connection.Connection;
|
|
private _profile!: azdata.IConnectionProfile;
|
|
private _user: string;
|
|
private _password: string;
|
|
|
|
constructor(connectionInfo: azdata.connection.Connection | azdata.IConnectionProfile) {
|
|
this.validate(connectionInfo);
|
|
|
|
if ('id' in connectionInfo) {
|
|
this._profile = connectionInfo;
|
|
this._connection = this.toConnection(this._profile);
|
|
} else {
|
|
this._connection = connectionInfo;
|
|
}
|
|
this._user = this._connection.options[constants.userPropName];
|
|
this._password = this._connection.options[constants.passwordPropName];
|
|
}
|
|
|
|
public get connection(): azdata.connection.Connection { return this._connection; }
|
|
public get user(): string { return this._user; }
|
|
public get password(): string { return this._password; }
|
|
|
|
public isMatch(connection: AzureMonitorClusterConnection | azdata.ConnectionInfo): boolean {
|
|
if (!connection) { return false; }
|
|
let options1 = connection instanceof AzureMonitorClusterConnection ?
|
|
connection._connection.options : connection.options;
|
|
let options2 = this._connection.options;
|
|
return [constants.serverPropName, constants.userPropName]
|
|
.every(e => options1[e] === options2[e]);
|
|
}
|
|
|
|
public isIntegratedAuth(): boolean {
|
|
let authType: string = this._connection.options[constants.authenticationTypePropName];
|
|
return authType?.toLowerCase() === constants.integratedAuth;
|
|
}
|
|
|
|
public updatePassword(password: string): void {
|
|
if (password) {
|
|
this._password = password;
|
|
}
|
|
}
|
|
|
|
private validate(connectionInfo: azdata.ConnectionInfo): void {
|
|
if (!connectionInfo) {
|
|
throw new Error(localize('connectionInfoUndefined', 'ConnectionInfo is undefined.'));
|
|
}
|
|
if (!connectionInfo.options) {
|
|
throw new Error(localize('connectionInfoOptionsUndefined', 'ConnectionInfo.options is undefined.'));
|
|
}
|
|
let missingProperties: string[] = this.getMissingProperties(connectionInfo)!;
|
|
if (missingProperties && missingProperties.length > 0) {
|
|
throw new Error(localize('connectionInfoOptionsMissingProperties',
|
|
'Some missing properties in connectionInfo.options: {0}',
|
|
missingProperties.join(', ')));
|
|
}
|
|
}
|
|
|
|
private getMissingProperties(connectionInfo: azdata.ConnectionInfo): string[] | undefined {
|
|
if (!connectionInfo || !connectionInfo.options) { return undefined; }
|
|
let requiredProps = [constants.serverPropName];
|
|
requiredProps.push(constants.userPropName);
|
|
return requiredProps.filter(e => connectionInfo.options[e] === undefined);
|
|
}
|
|
|
|
private toConnection(connProfile: azdata.IConnectionProfile): azdata.connection.Connection {
|
|
let connection: azdata.connection.Connection = Object.assign(connProfile,
|
|
{ connectionId: this._profile.id });
|
|
return connection;
|
|
}
|
|
}
|