Add AzureFunctionsService to expose AddSqlBinding (#17036)
* add AzureFunctionsService to expose AddSqlBinding * remove getAzureFunctions changes * added docstrings Co-authored-by: Aditya Bist <adbist@microsoft.com>
This commit is contained in:
Родитель
feff95534e
Коммит
40213e0cf3
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"service": {
|
||||
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/v{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
|
||||
"version": "3.0.0-release.115",
|
||||
"version": "3.0.0-release.118",
|
||||
"downloadFileNames": {
|
||||
"Windows_7_86": "win-x86-net5.0.zip",
|
||||
"Windows_7_64": "win-x64-net5.0.zip",
|
||||
|
|
|
@ -34,6 +34,7 @@ import { DacFxService } from '../services/dacFxService';
|
|||
import { IConnectionInfo } from 'vscode-mssql';
|
||||
import { SchemaCompareService } from '../services/schemaCompareService';
|
||||
import { SqlTasksService } from '../services/sqlTasksService';
|
||||
import { AzureFunctionsService } from '../services/azureFunctionsService';
|
||||
|
||||
/**
|
||||
* The main controller class that initializes the extension
|
||||
|
@ -59,6 +60,7 @@ export default class MainController implements vscode.Disposable {
|
|||
public sqlTasksService: SqlTasksService;
|
||||
public dacFxService: DacFxService;
|
||||
public schemaCompareService: SchemaCompareService;
|
||||
public azureFunctionsService: AzureFunctionsService;
|
||||
|
||||
/**
|
||||
* The main controller constructor
|
||||
|
@ -153,6 +155,7 @@ export default class MainController implements vscode.Disposable {
|
|||
this.sqlTasksService = new SqlTasksService(SqlToolsServerClient.instance, this._untitledSqlDocumentService);
|
||||
this.dacFxService = new DacFxService(SqlToolsServerClient.instance);
|
||||
this.schemaCompareService = new SchemaCompareService(SqlToolsServerClient.instance);
|
||||
this.azureFunctionsService = new AzureFunctionsService(SqlToolsServerClient.instance);
|
||||
|
||||
// Add handlers for VS Code generated commands
|
||||
this._vscodeWrapper.onDidCloseTextDocument(async (params) => await this.onDidCloseTextDocument(params));
|
||||
|
|
|
@ -58,7 +58,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<IExten
|
|||
return ObjectExplorerUtils.getDatabaseName(node);
|
||||
},
|
||||
dacFx: controller.dacFxService,
|
||||
schemaCompare: controller.schemaCompareService
|
||||
schemaCompare: controller.schemaCompareService,
|
||||
azureFunctions: controller.azureFunctionsService
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
/* --------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
* ------------------------------------------------------------------------------------------ */
|
||||
|
||||
import { RequestType } from 'vscode-languageclient';
|
||||
import * as mssql from 'vscode-mssql';
|
||||
|
||||
/**
|
||||
* Adds a SQL Binding inside generated Azure Functions in a file
|
||||
*/
|
||||
export namespace AddSqlBindingRequest {
|
||||
export const type = new RequestType<mssql.AddSqlBindingParams, mssql.ResultStatus, void, void>('azureFunctions/sqlBinding');
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/* --------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
* ------------------------------------------------------------------------------------------ */
|
||||
|
||||
import SqlToolsServiceClient from '../languageservice/serviceclient';
|
||||
import * as mssql from 'vscode-mssql';
|
||||
import * as azureFunctionsContracts from '../models/contracts/azureFunctions/azureFunctionsContracts';
|
||||
|
||||
export const hostFileName: string = 'host.json';
|
||||
|
||||
/**
|
||||
* Adds SQL Bindings to generated Azure Functions in a file
|
||||
*/
|
||||
export class AzureFunctionsService implements mssql.IAzureFunctionsService {
|
||||
|
||||
constructor(private _client: SqlToolsServiceClient) { }
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bindingType Type of SQL Binding
|
||||
* @param filePath Path of the file where the Azure Functions are
|
||||
* @param functionName Name of the function where the SQL Binding is to be added
|
||||
* @param objectName Name of Object for the SQL Query
|
||||
* @param connectionStringSetting Setting for the connection string
|
||||
* @returns
|
||||
*/
|
||||
addSqlBinding(
|
||||
bindingType: mssql.BindingType,
|
||||
filePath: string,
|
||||
functionName: string,
|
||||
objectName: string,
|
||||
connectionStringSetting: string
|
||||
): Thenable<mssql.ResultStatus> {
|
||||
const params: mssql.AddSqlBindingParams = {
|
||||
bindingType: bindingType,
|
||||
filePath: filePath,
|
||||
functionName: functionName,
|
||||
objectName: objectName,
|
||||
connectionStringSetting: connectionStringSetting
|
||||
};
|
||||
|
||||
return this._client.sendRequest(azureFunctionsContracts.AddSqlBindingRequest.type, params);
|
||||
}
|
||||
}
|
|
@ -34,6 +34,11 @@ declare module 'vscode-mssql' {
|
|||
*/
|
||||
readonly schemaCompare: ISchemaCompareService;
|
||||
|
||||
/**
|
||||
* Service for accessing AzureFunctions functionality
|
||||
*/
|
||||
readonly azureFunctions: IAzureFunctionsService;
|
||||
|
||||
/**
|
||||
* Prompts the user to select an existing connection or create a new one, and then returns the result
|
||||
* @param ignoreFocusOut Whether the quickpick prompt ignores focus out (default false)
|
||||
|
@ -247,6 +252,10 @@ declare module 'vscode-mssql' {
|
|||
validateStreamingJob(packageFilePath: string, createStreamingJobTsql: string): Thenable<ValidateStreamingJobResult>;
|
||||
}
|
||||
|
||||
export interface IAzureFunctionsService {
|
||||
addSqlBinding(bindingType: BindingType, filePath: string, functionName: string, objectName: string, connectionStringSetting: string): Thenable<ResultStatus>;
|
||||
}
|
||||
|
||||
export const enum TaskExecutionMode {
|
||||
execute = 0,
|
||||
script = 1,
|
||||
|
@ -521,4 +530,17 @@ declare module 'vscode-mssql' {
|
|||
|
||||
schema: string;
|
||||
}
|
||||
|
||||
export const enum BindingType {
|
||||
input,
|
||||
output
|
||||
}
|
||||
|
||||
export interface AddSqlBindingParams {
|
||||
filePath: string;
|
||||
functionName: string;
|
||||
objectName: string;
|
||||
bindingType: BindingType;
|
||||
connectionStringSetting: string;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче