diff --git a/extensions/azurecore/resources/dark/mysql_server_inverse.svg b/extensions/azurecore/resources/dark/mysql_server_inverse.svg new file mode 100644 index 0000000000..05147c4c72 --- /dev/null +++ b/extensions/azurecore/resources/dark/mysql_server_inverse.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + diff --git a/extensions/azurecore/resources/light/mysql_server.svg b/extensions/azurecore/resources/light/mysql_server.svg new file mode 100644 index 0000000000..75c531a725 --- /dev/null +++ b/extensions/azurecore/resources/light/mysql_server.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/extensions/azurecore/src/azureResource/providers/mysqlFlexibleServer/mysqlFlexibleServerProvider.ts b/extensions/azurecore/src/azureResource/providers/mysqlFlexibleServer/mysqlFlexibleServerProvider.ts new file mode 100644 index 0000000000..3968ba4a9f --- /dev/null +++ b/extensions/azurecore/src/azureResource/providers/mysqlFlexibleServer/mysqlFlexibleServerProvider.ts @@ -0,0 +1,26 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the Source EULA. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { ExtensionContext } from 'vscode'; + +import { azureResource } from 'azurecore'; +import { IAzureResourceService } from '../../interfaces'; +import { MysqlFlexibleServerTreeDataProvider } from './mysqlFlexibleServerTreeDataProvider'; + +export class MysqlFlexibleServerProvider implements azureResource.IAzureResourceProvider { + public constructor( + private _databaseServerService: IAzureResourceService, + private _extensionContext: ExtensionContext + ) { + } + + public getTreeDataProvider(): azureResource.IAzureResourceTreeDataProvider { + return new MysqlFlexibleServerTreeDataProvider(this._databaseServerService, this._extensionContext); + } + + public get providerId(): string { + return 'azure.resource.providers.mysqlFlexibleServer'; + } +} diff --git a/extensions/azurecore/src/azureResource/providers/mysqlFlexibleServer/mysqlFlexibleServerService.ts b/extensions/azurecore/src/azureResource/providers/mysqlFlexibleServer/mysqlFlexibleServerService.ts new file mode 100644 index 0000000000..4f42453f2c --- /dev/null +++ b/extensions/azurecore/src/azureResource/providers/mysqlFlexibleServer/mysqlFlexibleServerService.ts @@ -0,0 +1,41 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the Source EULA. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + + +import { ResourceServiceBase, GraphData } from '../resourceTreeDataProviderBase'; +import { azureResource } from 'azurecore'; + + +interface DbServerGraphData extends GraphData { + properties: { + fullyQualifiedDomainName: string; + administratorLogin: string; + }; +} + +const serversQuery = `where type == "${azureResource.AzureResourceType.mysqlFlexibleServer}"`; + +export class MysqlFlexibleServerService extends ResourceServiceBase { + + protected get query(): string { + return serversQuery; + } + + protected convertResource(resource: DbServerGraphData): azureResource.AzureResourceDatabaseServer { + return { + id: resource.id, + name: resource.name, + fullName: resource.properties.fullyQualifiedDomainName, + loginName: resource.properties.administratorLogin, + defaultDatabaseName: '', + tenant: resource.tenantId, + subscription: { + id: resource.subscriptionId, + name: resource.subscriptionName + }, + resourceGroup: resource.resourceGroup + }; + } +} diff --git a/extensions/azurecore/src/azureResource/providers/mysqlFlexibleServer/mysqlFlexibleServerTreeDataProvider.ts b/extensions/azurecore/src/azureResource/providers/mysqlFlexibleServer/mysqlFlexibleServerTreeDataProvider.ts new file mode 100644 index 0000000000..b2b879d402 --- /dev/null +++ b/extensions/azurecore/src/azureResource/providers/mysqlFlexibleServer/mysqlFlexibleServerTreeDataProvider.ts @@ -0,0 +1,81 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the Source EULA. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { TreeItemCollapsibleState, ExtensionContext } from 'vscode'; +import * as nls from 'vscode-nls'; +const localize = nls.loadMessageBundle(); + +import { AzureResourceItemType } from '../../constants'; +import { generateGuid } from '../../utils'; +import { IAzureResourceService } from '../../interfaces'; +import { ResourceTreeDataProviderBase } from '../resourceTreeDataProviderBase'; +import { azureResource } from 'azurecore'; +import { Account, ExtensionNodeType, TreeItem } from 'azdata'; + +export class MysqlFlexibleServerTreeDataProvider extends ResourceTreeDataProviderBase { + private static readonly MYSQL_FLEXIBLE_SERVER_PROVIDER_ID = 'MySQL'; + private static readonly CONTAINER_ID = 'azure.resource.providers.databaseServer.treeDataProvider.mysqlFlexibleServerContainer'; + private static readonly CONTAINER_LABEL = localize('azure.resource.providers.databaseServer.treeDataProvider.mysqlFlexibleServerContainerLabel', "Azure Database for MySQL Flexible server"); + + public constructor( + databaseServerService: IAzureResourceService, + private _extensionContext: ExtensionContext + ) { + super(databaseServerService); + } + + protected getTreeItemForResource(databaseServer: azureResource.AzureResourceDatabaseServer, account: Account): TreeItem { + return { + id: `databaseServer_${databaseServer.id ? databaseServer.id : databaseServer.name}`, + label: this.browseConnectionMode ? `${databaseServer.name} (${MysqlFlexibleServerTreeDataProvider.CONTAINER_LABEL}, ${databaseServer.subscription.name})` : databaseServer.name, + iconPath: { + dark: this._extensionContext.asAbsolutePath('resources/dark/mysql_server_inverse.svg'), + light: this._extensionContext.asAbsolutePath('resources/light/mysql_server.svg') + }, + collapsibleState: this.browseConnectionMode ? TreeItemCollapsibleState.None : TreeItemCollapsibleState.Collapsed, + contextValue: AzureResourceItemType.databaseServer, + payload: { + id: generateGuid(), + connectionName: undefined, + serverName: databaseServer.fullName, + databaseName: databaseServer.defaultDatabaseName, + userName: databaseServer.loginName, + password: '', + authenticationType: 'SqlLogin', + savePassword: true, + groupFullName: '', + groupId: '', + providerName: MysqlFlexibleServerTreeDataProvider.MYSQL_FLEXIBLE_SERVER_PROVIDER_ID, + saveProfile: false, + options: { + }, + azureAccount: account.key.accountId, + azureTenantId: databaseServer.tenant, + azureResourceId: databaseServer.id, + azurePortalEndpoint: account.properties.providerSettings.settings.portalEndpoint + }, + childProvider: MysqlFlexibleServerTreeDataProvider.MYSQL_FLEXIBLE_SERVER_PROVIDER_ID, + type: ExtensionNodeType.Server + }; + } + + protected createContainerNode(): azureResource.IAzureResourceNode { + return { + account: undefined, + subscription: undefined, + tenantId: undefined, + treeItem: { + id: MysqlFlexibleServerTreeDataProvider.CONTAINER_ID, + label: MysqlFlexibleServerTreeDataProvider.CONTAINER_LABEL, + iconPath: { + dark: this._extensionContext.asAbsolutePath('resources/dark/folder_inverse.svg'), + light: this._extensionContext.asAbsolutePath('resources/light/folder.svg') + }, + collapsibleState: TreeItemCollapsibleState.Collapsed, + contextValue: AzureResourceItemType.databaseServerContainer + } + }; + } +} diff --git a/extensions/azurecore/src/azurecore.d.ts b/extensions/azurecore/src/azurecore.d.ts index e004fc18b0..cdf5bde387 100644 --- a/extensions/azurecore/src/azurecore.d.ts +++ b/extensions/azurecore/src/azurecore.d.ts @@ -347,7 +347,8 @@ declare module 'azurecore' { azureArcService = 'microsoft.azuredata/datacontrollers', storageAccount = 'microsoft.storage/storageaccounts', logAnalytics = 'microsoft.operationalinsights/workspaces', - cosmosDbAccount = 'microsoft.documentdb/databaseaccounts' + cosmosDbAccount = 'microsoft.documentdb/databaseaccounts', + mysqlFlexibleServer = 'microsoft.dbformysql/flexibleservers' } export interface IAzureResourceProvider extends azdata.DataProvider { diff --git a/extensions/azurecore/src/extension.ts b/extensions/azurecore/src/extension.ts index ab4f0bcbae..affdce8560 100644 --- a/extensions/azurecore/src/extension.ts +++ b/extensions/azurecore/src/extension.ts @@ -39,6 +39,8 @@ import { PostgresServerArcProvider } from './azureResource/providers/postgresArc import { PostgresServerArcService } from './azureResource/providers/postgresArcServer/postgresServerService'; import { CosmosDbMongoProvider } from './azureResource/providers/cosmosdb/mongo/cosmosDbMongoProvider'; import { CosmosDbMongoService } from './azureResource/providers/cosmosdb/mongo/cosmosDbMongoService'; +import { MysqlFlexibleServerProvider } from './azureResource/providers/mysqlFlexibleServer/mysqlFlexibleServerProvider'; +import { MysqlFlexibleServerService } from './azureResource/providers/mysqlFlexibleServer/mysqlFlexibleServerService'; import * as azurecore from 'azurecore'; import * as azureResourceUtils from './azureResource/utils'; import * as utils from './utils'; @@ -136,7 +138,8 @@ export async function activate(context: vscode.ExtensionContext): Promise([ ['PGSQL', 'microsoft.azuredatastudio-postgresql'], ['KUSTO', 'microsoft.kusto'], ['LOGANALYTICS', 'microsoft.azuremonitor'], - ['COSMOSDB_MONGO', 'microsoft.azure-cosmosdb-ads-extension'] + ['COSMOSDB_MONGO', 'microsoft.azure-cosmosdb-ads-extension'], + ['MySQL', 'microsoft.azuredatastudio-mysql'] ]); /**