mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Adding azure resource provider for mysql flexible server (#20529)
This commit is contained in:
@@ -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<azureResource.AzureResourceDatabaseServer>,
|
||||
private _extensionContext: ExtensionContext
|
||||
) {
|
||||
}
|
||||
|
||||
public getTreeDataProvider(): azureResource.IAzureResourceTreeDataProvider {
|
||||
return new MysqlFlexibleServerTreeDataProvider(this._databaseServerService, this._extensionContext);
|
||||
}
|
||||
|
||||
public get providerId(): string {
|
||||
return 'azure.resource.providers.mysqlFlexibleServer';
|
||||
}
|
||||
}
|
||||
@@ -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<DbServerGraphData, azureResource.AzureResourceDatabaseServer> {
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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<azureResource.AzureResourceDatabaseServer> {
|
||||
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<azureResource.AzureResourceDatabaseServer>,
|
||||
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
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
3
extensions/azurecore/src/azurecore.d.ts
vendored
3
extensions/azurecore/src/azurecore.d.ts
vendored
@@ -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 {
|
||||
|
||||
@@ -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<azurec
|
||||
new AzureResourceDatabaseProvider(new AzureResourceDatabaseService(), extensionContext),
|
||||
new SqlInstanceProvider(new SqlInstanceResourceService(), extensionContext),
|
||||
new PostgresServerProvider(new PostgresServerService(), extensionContext),
|
||||
new CosmosDbMongoProvider(new CosmosDbMongoService(), extensionContext)
|
||||
new CosmosDbMongoProvider(new CosmosDbMongoService(), extensionContext),
|
||||
new MysqlFlexibleServerProvider(new MysqlFlexibleServerService(), extensionContext)
|
||||
];
|
||||
if (arcFeaturedEnabled) {
|
||||
providers.push(
|
||||
|
||||
Reference in New Issue
Block a user