mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-08 09:38:25 -05:00
Initial admin and DR services. (#329)
* Add initial services for admin, tasks, and DR * Fix up some of the contract interfaces * Make fields public to allow Json.Net to work * Fix a couple issues in backup contracts
This commit is contained in:
66
src/Microsoft.SqlTools.ServiceLayer/Admin/AdminService.cs
Normal file
66
src/Microsoft.SqlTools.ServiceLayer/Admin/AdminService.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Microsoft.SqlTools.Hosting.Protocol;
|
||||
using Microsoft.SqlTools.ServiceLayer.Admin.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Hosting;
|
||||
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
{
|
||||
/// <summary>
|
||||
/// Datasource admin task service class
|
||||
/// </summary>
|
||||
public class AdminService
|
||||
{
|
||||
private static readonly Lazy<AdminService> instance = new Lazy<AdminService>(() => new AdminService());
|
||||
|
||||
/// <summary>
|
||||
/// Default, parameterless constructor.
|
||||
/// </summary>
|
||||
internal AdminService()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the singleton instance object
|
||||
/// </summary>
|
||||
public static AdminService Instance
|
||||
{
|
||||
get { return instance.Value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the service instance
|
||||
/// </summary>
|
||||
public void InitializeService(ServiceHost serviceHost)
|
||||
{
|
||||
serviceHost.SetRequestHandler(CreateDatabaseRequest.Type, HandleCreateDatabaseRequest);
|
||||
serviceHost.SetRequestHandler(CreateLoginRequest.Type, HandleCreateLoginRequest);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles a create database request
|
||||
/// </summary>
|
||||
internal static async Task HandleCreateDatabaseRequest(
|
||||
CreateDatabaseParams databaseParams,
|
||||
RequestContext<CreateDatabaseResponse> requestContext)
|
||||
{
|
||||
await requestContext.SendResult(new CreateDatabaseResponse());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles a create login request
|
||||
/// </summary>
|
||||
internal static async Task HandleCreateLoginRequest(
|
||||
CreateLoginParams loginParams,
|
||||
RequestContext<CreateLoginResponse> requestContext)
|
||||
{
|
||||
await requestContext.SendResult(new CreateLoginResponse());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user