mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Remove REST API from Arc extension (#11888)
* wip * Remove old API * Fix tests
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
import * as azdata from './typings/azdata-ext';
|
||||
import * as vscode from 'vscode';
|
||||
import { findAzdata, IAzdataTool } from './azdata';
|
||||
import { parsePostgresServerListResult, parseSqlInstanceListResult } from './common/azdataUtils';
|
||||
|
||||
let localAzdata: IAzdataTool | undefined = undefined;
|
||||
|
||||
@@ -14,29 +13,51 @@ export async function activate(): Promise<azdata.IExtension> {
|
||||
const outputChannel = vscode.window.createOutputChannel('azdata');
|
||||
localAzdata = await checkForAzdata(outputChannel);
|
||||
return {
|
||||
dc: {
|
||||
endpoint: {
|
||||
list: async () => {
|
||||
return executeLocalAzdataCommand(['arc', 'dc', 'endpoint', 'list']);
|
||||
}
|
||||
},
|
||||
config: {
|
||||
show: async () => {
|
||||
return executeLocalAzdataCommand(['arc', 'dc', 'config', 'show']);
|
||||
}
|
||||
}
|
||||
},
|
||||
login: async (endpoint: string, username: string, password: string) => {
|
||||
return executeLocalAzdataCommand(['login', '-e', endpoint, '-u', username], { 'AZDATA_PASSWORD': password });
|
||||
},
|
||||
postgres: {
|
||||
server: {
|
||||
list: async () => {
|
||||
if (!localAzdata) {
|
||||
throw new Error('No azdata');
|
||||
}
|
||||
return localAzdata.executeCommand(['postgres', 'server', 'list'], parsePostgresServerListResult);
|
||||
return executeLocalAzdataCommand(['arc', 'postgres', 'server', 'list']);
|
||||
},
|
||||
show: async (name: string) => {
|
||||
return executeLocalAzdataCommand(['arc', 'postgres', 'server', 'show', '-n', name]);
|
||||
}
|
||||
}
|
||||
},
|
||||
sql: {
|
||||
instance: {
|
||||
mi: {
|
||||
list: async () => {
|
||||
if (!localAzdata) {
|
||||
throw new Error('No azdata');
|
||||
}
|
||||
return localAzdata.executeCommand(['sql', 'instance', 'list'], parseSqlInstanceListResult);
|
||||
return executeLocalAzdataCommand(['arc', 'sql', 'mi', 'list']);
|
||||
},
|
||||
show: async (name: string) => {
|
||||
return executeLocalAzdataCommand(['arc', 'sql', 'mi', 'show', '-n', name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async function executeLocalAzdataCommand<R>(args: string[], additionalEnvVars?: { [key: string]: string }): Promise<azdata.AzdataOutput<R>> {
|
||||
if (!localAzdata) {
|
||||
throw new Error('No azdata');
|
||||
}
|
||||
return localAzdata.executeCommand(args, additionalEnvVars);
|
||||
}
|
||||
|
||||
async function checkForAzdata(outputChannel: vscode.OutputChannel): Promise<IAzdataTool | undefined> {
|
||||
try {
|
||||
return await findAzdata(outputChannel);
|
||||
|
||||
Reference in New Issue
Block a user