mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// 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.Contracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Admin.Contracts
|
||||
{
|
||||
public class CreateDatabaseParams
|
||||
{
|
||||
public string OwnerUri { get; set; }
|
||||
|
||||
public DatabaseInfo DatabaseInfo { get; set; }
|
||||
}
|
||||
|
||||
public class CreateDatabaseResponse
|
||||
{
|
||||
public bool Result { get; set; }
|
||||
|
||||
public int TaskId { get; set; }
|
||||
}
|
||||
|
||||
public class CreateDatabaseRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<CreateDatabaseParams, CreateDatabaseResponse> Type =
|
||||
RequestType<CreateDatabaseParams, CreateDatabaseResponse>.Create("admin/createdatabase");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// 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.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Admin.Contracts
|
||||
{
|
||||
public class CreateLoginParams
|
||||
{
|
||||
public string OwnerUri { get; set; }
|
||||
|
||||
public LoginInfo DatabaseInfo { get; set; }
|
||||
}
|
||||
|
||||
public class CreateLoginResponse
|
||||
{
|
||||
public bool Result { get; set; }
|
||||
|
||||
public int TaskId { get; set; }
|
||||
}
|
||||
|
||||
public class CreateLoginRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<CreateLoginParams, CreateLoginResponse> Type =
|
||||
RequestType<CreateLoginParams, CreateLoginResponse>.Create("admin/createlogin");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Admin.Contracts
|
||||
{
|
||||
public class DatabaseInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Admin.Contracts
|
||||
{
|
||||
public class LoginInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user