Simplify Object Management APIs (#2015)

* unify requests-wip

* wip

* unify api

* fix test

* add credential handler

* fix credential handler issue.

* generic type update

* fix scripting for user
This commit is contained in:
Alan Ren
2023-04-19 15:43:01 -07:00
committed by GitHub
parent 98ad0197e4
commit e314f839d8
57 changed files with 1802 additions and 2234 deletions

View File

@@ -0,0 +1,23 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
#nullable disable
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement.Contracts
{
public class DisposeViewRequestParams : GeneralRequestDetails
{
public string ContextId { get; set; }
}
public class DisposeViewRequestResponse { }
public class DisposeViewRequest
{
public static readonly RequestType<DisposeViewRequestParams, DisposeViewRequestResponse> Type = RequestType<DisposeViewRequestParams, DisposeViewRequestResponse>.Create("objectManagement/disposeView");
}
}

View File

@@ -11,6 +11,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement.Contracts
{
public class DropRequestParams : GeneralRequestDetails
{
/// <summary>
/// The object type.
/// </summary>
public SqlObjectType ObjectType { get; set; }
/// <summary>
/// SFC (SMO) URN identifying the object
/// </summary>
@@ -25,8 +29,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement.Contracts
public bool ThrowIfNotExist { get; set; } = false;
}
public class DropRequestResponse { }
public class DropRequest
{
public static readonly RequestType<DropRequestParams, bool> Type = RequestType<DropRequestParams, bool>.Create("objectManagement/drop");
public static readonly RequestType<DropRequestParams, DropRequestResponse> Type = RequestType<DropRequestParams, DropRequestResponse>.Create("objectManagement/drop");
}
}

View File

@@ -0,0 +1,48 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
#nullable disable
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement.Contracts
{
public class InitializeViewRequestParams : GeneralRequestDetails
{
/// <summary>
/// The connection uri.
/// </summary>
public string ConnectionUri { get; set; }
/// <summary>
/// The target database name.
/// </summary>
public string Database { get; set; }
/// <summary>
/// The object type.
/// </summary>
public SqlObjectType ObjectType { get; set; }
/// <summary>
/// Whether the view is for a new object.
/// </summary>
public bool IsNewObject { get; set; }
/// <summary>
/// The object view context id.
/// </summary>
public string ContextId { get; set; }
/// <summary>
/// Urn of the parent object.
/// </summary>
public string ParentUrn { get; set; }
/// <summary>
/// Urn of the object. Only set when the view is for an existing object.
/// </summary>
public string ObjectUrn { get; set; }
}
public class InitializeViewRequest
{
public static readonly RequestType<InitializeViewRequestParams, SqlObjectViewInfo> Type = RequestType<InitializeViewRequestParams, SqlObjectViewInfo>.Create("objectManagement/initializeView");
}
}

View File

@@ -11,6 +11,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement.Contracts
{
public class RenameRequestParams : GeneralRequestDetails
{
/// <summary>
/// The object type.
/// </summary>
public SqlObjectType ObjectType { get; set; }
/// <summary>
/// SFC (SMO) URN identifying the object
/// </summary>
@@ -24,8 +28,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement.Contracts
/// </summary>
public string ConnectionUri { get; set; }
}
public class RenameRequestResponse { }
public class RenameRequest
{
public static readonly RequestType<RenameRequestParams, bool> Type = RequestType<RenameRequestParams, bool>.Create("objectManagement/rename");
public static readonly RequestType<RenameRequestParams, RenameRequestResponse> Type = RequestType<RenameRequestParams, RenameRequestResponse>.Create("objectManagement/rename");
}
}

View File

@@ -0,0 +1,31 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
#nullable disable
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.Utility;
using Newtonsoft.Json.Linq;
namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement.Contracts
{
public class SaveObjectRequestParams : GeneralRequestDetails
{
/// <summary>
/// The context id.
/// </summary>
public string ContextId { get; set; }
/// <summary>
/// The object information.
/// </summary>
public JToken Object { get; set; }
}
public class SaveObjectRequestResponse { }
public class SaveObjectRequest
{
public static readonly RequestType<SaveObjectRequestParams, SaveObjectRequestResponse> Type = RequestType<SaveObjectRequestParams, SaveObjectRequestResponse>.Create("objectManagement/save");
}
}

View File

@@ -0,0 +1,29 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
#nullable disable
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.Utility;
using Newtonsoft.Json.Linq;
namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement.Contracts
{
public class ScriptObjectRequestParams : GeneralRequestDetails
{
/// <summary>
/// The context id.
/// </summary>
public string ContextId { get; set; }
/// <summary>
/// The object information.
/// </summary>
public JToken Object { get; set; }
}
public class ScriptObjectRequest
{
public static readonly RequestType<ScriptObjectRequestParams, string> Type = RequestType<ScriptObjectRequestParams, string>.Create("objectManagement/script");
}
}