mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-29 09:35:38 -05:00
Expose the graph API (#11919)
* Exposing the graph API * Azure managed instance retrival * Fix compile error
This commit is contained in:
35
extensions/sql-migration/src/api/azure.ts
Normal file
35
extensions/sql-migration/src/api/azure.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as azdata from 'azdata';
|
||||
import * as azurecore from 'azurecore';
|
||||
import { azureResource } from 'azureResource';
|
||||
|
||||
async function getAzureCoreAPI(): Promise<azurecore.IExtension> {
|
||||
const api = (await vscode.extensions.getExtension(azurecore.extension.name)?.activate()) as azurecore.IExtension;
|
||||
if (!api) {
|
||||
throw new Error('azure core API undefined for sql-migration');
|
||||
}
|
||||
return api;
|
||||
}
|
||||
|
||||
export type Subscription = azureResource.AzureResourceSubscription;
|
||||
export async function getSubscriptions(account: azdata.Account): Promise<Subscription[]> {
|
||||
const api = await getAzureCoreAPI();
|
||||
const subscriptions = await api.getSubscriptions(account, false);
|
||||
|
||||
return subscriptions.subscriptions;
|
||||
}
|
||||
|
||||
export type AzureProduct = azureResource.AzureGraphResource;
|
||||
export type SqlManagedInstance = azureResource.AzureSqlManagedInstanceResource;
|
||||
export async function getAvailableManagedInstanceProducts(account: azdata.Account, subscription: Subscription): Promise<SqlManagedInstance[]> {
|
||||
const api = await getAzureCoreAPI();
|
||||
|
||||
const result = await api.runGraphQuery<azureResource.AzureSqlManagedInstanceResource>(account, subscription, false, 'where type == "microsoft.sql/managedinstances"');
|
||||
|
||||
return result.resources;
|
||||
}
|
||||
Reference in New Issue
Block a user