mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-24 09:35:39 -05:00
Added new Kusto ServiceLayer (#1009)
* Copy smoModel some rename * Copy entire service layer * Building copy * Fixing some references * Launch profile * Resolve namespace issues * Compiling tests. Correct manifest. * Fixing localization resources * ReliableKustoClient * Some trimming of extra code and Kusto code * Kusto client creation in bindingContent * Removing Smo and new Kusto classes * More trimming * Kusto schema hookup * Solidying DataSource abstraction * Solidifying further * Latest refatoring * More refactoring * Building and launching Kusto service layer * Working model which enumerates databases * Refactoring to pass IDataSource to all tree nodes * Removing some dependencies on the context * Working with tables and schema * Comment checkin * Refactoring to give out select script * Query created and sent back to ADS * Fix query generation * Fix listing of databases * Tunneling the query through. * Successful query execution * Return only results table * Deleting Cms * Delete DacFx * Delete SchemaCompare and TaskServices * Change build definition to not stop at launch * Fix error after merge * Save Kusto results in different formats (#935) * save results as csv etc * some fixes Co-authored-by: Monica Gupta <mogupt@microsoft.com> * 2407 Added OrderBy clause in KustoDataSource > GetDatabaseMetaData and GetColumnMetadata (#959) * 2405 Defaulted Options when setting ServerInfo in ConnectionService > GetConnectionCompleteParams (#965) * 2747 Fixed IsUnknownType error for Kusto (#989) * 2747 Removed unused directives in Kusto > DbColumnWrapper. Refactored IsUnknownType to handle null DataTypeName * 2747 Reverted IsUnknownType change in DbColumnWrapper. Changed DataTypeName to get calue from ColumnType. Refactored SafeGetValue to type check before hard casting to reduce case exceptions. * Added EmbeddedResourceUseDependentUponConvention to Microsoft.Kusto.ServiceLayer.csproj. Also renamed DACfx to match Microsoft.SqlTools.ServiceLayer. Added to compile Exclude="**/obj/**/*.cs" * Srahman cleanup sql code (#992) * Removed Management and Security Service Code. * Remove FileBrowser service * Comment why we are using SqlServer library * Remove SQL specific type definitions * clean up formatter service (#996) Co-authored-by: Monica Gupta <mogupt@microsoft.com> * Code clean up and Kusto intellisense (#994) * Code clean up and Kusto intellisense * Addressed few comments * Addressed few comments * addressed comments Co-authored-by: Monica Gupta <mogupt@microsoft.com> * Return multiple tables for Kusto * Changes required for Kusto manage dashboard (#1039) * Changes required for manage dashboard * Addressed comments Co-authored-by: Monica Gupta <mogupt@microsoft.com> * 2728 Kusto function support (#1038) * loc update (#914) * loc update * loc updates * 2728 moved ColumnInfo and KustoResultsReader to separate files. Added Folder and Function to TreeNode.cs * 2728 Added FunctionInfo. Added Folder to ColumnInfo. Removed partial class from KustoResultsReader. Set Function.IsAlwaysLeaf=true in TreeNode.cs. In KustoDataSource changed tableMetadata type to TableMetaData. Added folder and function dictionaries. Refactored GetSchema function. Renamed GenerateColumnMetadataKey to GenerateMetadataKey * 2728 Added FunctionInfo. Added Folder to ColumnInfo. Removed partial class from KustoResultsReader. Set Function.IsAlwaysLeaf=true in TreeNode.cs. In KustoDataSource changed tableMetadata type to TableMetaData. Added folder and function dictionaries. Refactored GetSchema function. Renamed GenerateColumnMetadataKey to GenerateMetadataKey * 2728 Created new SqlConnection within using block. Refactored KustoDataSource > columnmetadata to sort on get instead of insert. * 2728 Added GetFunctionInfo function to KustoDataSource. * 2728 Reverted change to Microsoft.Kusto.ServiceLayer.csproj from merge * 2728 Reverted change to SqlTools.ServiceLayer\Localization\transXliff * 2728 Reverted change to sr.de.xlf and sr.zh-hans.xlf * 2728 Refactored KustoDataSource Function folders to support subfolders * 2728 Refactored KustoDataSource to use urn for folders, functions, and tables instead of name. * Merge remote-tracking branch 'origin/main' into feature-ADE # Conflicts: # Packages.props * 2728 Moved metadata files into Metadata subdirectory. Added GenerateAlterFunction to IDataSource and DataSourceBase. * 2728 Added summary information to SafeAdd in SystemExtensions. Renamed local variable in SetTableMetadata * 2728 Moved SafeAdd from SystemExtensions to KustoQueryUtils. Added check when getting database schema to return existing records before querying again. Added AddRange function to KustoQueryUtils. Created SetFolderMetadataForFunctions method. * 2728 Added DatabaseKeyPrefix to only return tables to a database for the dashboard. Added logic to store all database tables within the tableMetadata dictionary for the dashboard. * 2728 Created TableInfo and moved info objects into Models directory. Refactored KustoDataSource to lazy load columns for tables. Refactored logic to load tables using cslschema instead of schema. * 2728 Renamed LoadColumnSchema to GetTableSchema to be consistent. Co-authored-by: khoiph1 <khoiph@microsoft.com> * Addressed comments Co-authored-by: Shafiq Rahman <srahman@microsoft.com> Co-authored-by: Monica Gupta <mogupt@microsoft.com> Co-authored-by: Justin M <63619224+JustinMDotNet@users.noreply.github.com> Co-authored-by: rkselfhost <rkselfhost@outlook.com> Co-authored-by: khoiph1 <khoiph@microsoft.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// 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.Kusto.ServiceLayer.Scripting.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters to cancel a scripting request.
|
||||
/// </summary>
|
||||
public class ScriptingCancelParams : ScriptingEventParams { }
|
||||
|
||||
/// <summary>
|
||||
/// Parameters returned from a scripting request.
|
||||
/// </summary>
|
||||
public class ScriptingCancelResult { }
|
||||
|
||||
/// <summary>
|
||||
/// Defines the scripting cancel request type.
|
||||
/// </summary>
|
||||
public class ScriptingCancelRequest
|
||||
{
|
||||
public static readonly RequestType<ScriptingCancelParams, ScriptingCancelResult> Type =
|
||||
RequestType<ScriptingCancelParams, ScriptingCancelResult>.Create("scripting/scriptCancel");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// 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.Kusto.ServiceLayer.Scripting.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters sent to when a scripting operation has completed.
|
||||
/// </summary>
|
||||
public class ScriptingCompleteParams : ScriptingEventParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Get or sets the error details for an error that occurred during the scripting operation.
|
||||
/// </summary>
|
||||
public string ErrorDetails { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get or sets the error message for an error that occurred during the scripting operation.
|
||||
/// </summary>
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get or sets a value to indicate an error occurred during the scripting operation.
|
||||
/// </summary>
|
||||
public bool HasError { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get or sets a value to indicate the scripting operation was canceled.
|
||||
/// </summary>
|
||||
public bool Canceled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get or sets a value to indicate the scripting operation successfully completed.
|
||||
/// </summary>
|
||||
public bool Success { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event sent to indicate a scripting operation has completed.
|
||||
/// </summary>
|
||||
public class ScriptingCompleteEvent
|
||||
{
|
||||
public static readonly EventType<ScriptingCompleteParams> Type =
|
||||
EventType<ScriptingCompleteParams>.Create("scripting/scriptComplete");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
namespace Microsoft.Kusto.ServiceLayer.Scripting.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for all scripting event parameters.
|
||||
/// </summary>
|
||||
public abstract class ScriptingEventParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the operation id of the scripting operation this event is associated with.
|
||||
/// </summary>
|
||||
public string OperationId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the sequence number. The sequence number starts at 1, and is incremented each time a scripting event is
|
||||
/// raised for the current scripting operation.
|
||||
/// </summary>
|
||||
public int SequenceNumber { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
|
||||
namespace Microsoft.Kusto.ServiceLayer.Scripting.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters sent when a list objects operation has completed.
|
||||
/// </summary>
|
||||
public class ScriptingListObjectsCompleteParams : ScriptingCompleteParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the list of database objects returned from the list objects operation.
|
||||
/// </summary>
|
||||
public List<ScriptingObject> ScriptingObjects { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the count of database object returned from the list objects operation.
|
||||
/// </summary>
|
||||
public int Count { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event sent to indicate a list objects operation has completed.
|
||||
/// </summary>
|
||||
public class ScriptingListObjectsCompleteEvent
|
||||
{
|
||||
public static readonly EventType<ScriptingListObjectsCompleteParams> Type =
|
||||
EventType<ScriptingListObjectsCompleteParams>.Create("scripting/listObjectsComplete");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
|
||||
namespace Microsoft.Kusto.ServiceLayer.Scripting.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters for a list objects request.
|
||||
/// </summary>
|
||||
public class ScriptingListObjectsParams
|
||||
{
|
||||
public string ConnectionString { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameters returned from a list objects request.
|
||||
/// </summary>
|
||||
public class ScriptingListObjectsResult
|
||||
{
|
||||
public string OperationId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the scripting list objects request type.
|
||||
/// </summary>
|
||||
public class ScriptingListObjectsRequest
|
||||
{
|
||||
public static readonly RequestType<ScriptingListObjectsParams, ScriptingListObjectsResult> Type =
|
||||
RequestType<ScriptingListObjectsParams, ScriptingListObjectsResult>.Create("scripting/listObjects");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Kusto.ServiceLayer.Scripting.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Class to represent a database object that can be scripted.
|
||||
/// </summary>
|
||||
public sealed class ScriptingObject : IEquatable<ScriptingObject>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the database object type.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This underlying values are determined by the SqlScriptPublishModel.GetDatabaseObjectTypes() and
|
||||
/// can change depending on the version of SMO used by the tools service. Values can be:
|
||||
/// Table,
|
||||
/// View,
|
||||
/// StoredProcedure,
|
||||
/// UserDefinedFunction,
|
||||
/// UserDefinedDataType,
|
||||
/// User,
|
||||
/// Default,
|
||||
/// Rule,
|
||||
/// DatabaseRole,
|
||||
/// ApplicationRole,
|
||||
/// SqlAssembly,
|
||||
/// DdlTrigger,
|
||||
/// Synonym,
|
||||
/// XmlSchemaCollection,
|
||||
/// Schema,
|
||||
/// PlanGuide,
|
||||
/// UserDefinedType,
|
||||
/// UserDefinedAggregate,
|
||||
/// FullTextCatalog,
|
||||
/// UserDefinedTableType
|
||||
/// </remarks>
|
||||
public string Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the schema of the database object.
|
||||
/// </summary>
|
||||
public string Schema { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the database object name.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string objectName = string.IsNullOrEmpty(this.Schema)
|
||||
? this.Name
|
||||
: this.Schema + "." + this.Name;
|
||||
|
||||
return objectName;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return
|
||||
StringComparer.OrdinalIgnoreCase.GetHashCode(this.Type ?? string.Empty) ^
|
||||
StringComparer.OrdinalIgnoreCase.GetHashCode(this.Schema ?? string.Empty) ^
|
||||
StringComparer.OrdinalIgnoreCase.GetHashCode(this.Name ?? string.Empty);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return
|
||||
obj != null &&
|
||||
this.GetType() == obj.GetType() &&
|
||||
this.Equals((ScriptingObject)obj);
|
||||
}
|
||||
|
||||
public bool Equals(ScriptingObject other)
|
||||
{
|
||||
if (other == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return
|
||||
string.Equals(this.Type, other.Type, StringComparison.OrdinalIgnoreCase) &&
|
||||
string.Equals(this.Schema, other.Schema, StringComparison.OrdinalIgnoreCase) &&
|
||||
string.Equals(this.Name, other.Name, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
namespace Microsoft.Kusto.ServiceLayer.Scripting.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Scripting Operation type
|
||||
/// </summary>
|
||||
public enum ScriptingOperationType
|
||||
{
|
||||
Select = 0,
|
||||
Create = 1,
|
||||
Insert = 2,
|
||||
Update = 3,
|
||||
Delete = 4,
|
||||
Execute = 5,
|
||||
Alter = 6
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
namespace Microsoft.Kusto.ServiceLayer.Scripting.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the scripting options.
|
||||
/// </summary>
|
||||
public class ScriptOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Generate ANSI padding statements
|
||||
/// </summary>
|
||||
public virtual bool? ScriptAnsiPadding { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Append the generated script to a file
|
||||
/// </summary>
|
||||
public virtual bool? AppendToFile { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Continue to script if an error occurs. Otherwise, stop.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default is true.
|
||||
/// </remarks>
|
||||
public virtual bool? ContinueScriptingOnError { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Convert user-defined data types to base types.
|
||||
/// </summary>
|
||||
public virtual bool? ConvertUDDTToBaseType { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Generate script for dependent objects for each object scripted.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default is false.
|
||||
/// </remarks>
|
||||
public virtual bool? GenerateScriptForDependentObjects { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Include descriptive headers for each object generated.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default is true.
|
||||
/// </remarks>
|
||||
public virtual bool? IncludeDescriptiveHeaders { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Check that an object with the given name exists before dropping or altering or that an object with the given name does not exist before creating.
|
||||
/// </summary>
|
||||
public virtual bool? IncludeIfNotExists { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Script options to set vardecimal storage format.
|
||||
/// </summary>
|
||||
public virtual bool? IncludeVarDecimal { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Include system generated constraint names to enforce declarative referential integrity.
|
||||
/// </summary>
|
||||
public virtual bool? ScriptDriIncludeSystemNames { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Include statements in the script that are not supported on the specified SQL Server database engine type.
|
||||
/// </summary>
|
||||
public virtual bool? IncludeUnsupportedStatements { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Prefix object names with the object schema.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default is true.
|
||||
/// </remarks>
|
||||
public virtual bool? SchemaQualify { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Script options to set bindings option.
|
||||
/// </summary>
|
||||
public virtual bool? Bindings { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Script the objects that use collation.
|
||||
/// </summary>
|
||||
public virtual bool? Collation { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Script the default values.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default is true.
|
||||
/// </remarks>
|
||||
public virtual bool? Default { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Script Object CREATE/DROP statements.
|
||||
/// Possible values:
|
||||
/// ScriptCreate
|
||||
/// ScriptDrop
|
||||
/// ScriptCreateDrop
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default is ScriptCreate.
|
||||
/// </remarks>
|
||||
public virtual string ScriptCreateDrop { get; set; } = "ScriptCreate";
|
||||
|
||||
/// <summary>
|
||||
/// Script the Extended Properties for each object scripted.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default is true.
|
||||
/// </remarks>
|
||||
public virtual bool? ScriptExtendedProperties { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Script only features compatible with the specified version of SQL Server. Possible values:
|
||||
/// Script90Compat
|
||||
/// Script100Compat
|
||||
/// Script105Compat
|
||||
/// Script110Compat
|
||||
/// Script120Compat
|
||||
/// Script130Compat
|
||||
/// Script140Compat
|
||||
/// Script150Compat
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default is Script140Compat.
|
||||
/// </remarks>
|
||||
public virtual string ScriptCompatibilityOption { get; set; } = "Script140Compat";
|
||||
|
||||
/// <summary>
|
||||
/// Script only features compatible with the specified SQL Server database engine type.
|
||||
/// Possible Values:
|
||||
/// SingleInstance
|
||||
/// SqlAzure
|
||||
/// </summary>
|
||||
public virtual string TargetDatabaseEngineType { get; set; } = "SingleInstance";
|
||||
|
||||
/// <summary>
|
||||
/// Script only features compatible with the specified SQL Server database engine edition.
|
||||
/// Possible Values:
|
||||
/// SqlServerPersonalEdition
|
||||
/// SqlServerStandardEdition
|
||||
/// SqlServerEnterpriseEdition
|
||||
/// SqlServerExpressEdition
|
||||
/// SqlAzureDatabaseEdition
|
||||
/// SqlDatawarehouseEdition
|
||||
/// SqlServerStretchEdition
|
||||
/// SqlManagedInstanceEdition
|
||||
/// </summary>
|
||||
public virtual string TargetDatabaseEngineEdition { get; set; } = "SqlServerEnterpriseEdition";
|
||||
|
||||
/// <summary>
|
||||
/// Script all logins available on the server. Passwords will not be scripted.
|
||||
/// </summary>
|
||||
public virtual bool? ScriptLogins { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Generate object-level permissions.
|
||||
/// </summary>
|
||||
public virtual bool? ScriptObjectLevelPermissions { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Script owner for the objects.
|
||||
/// </summary>
|
||||
public virtual bool? ScriptOwner { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Script statistics, and optionally include histograms, for each selected table or view.
|
||||
/// Possible values:
|
||||
/// ScriptStatsNone
|
||||
/// ScriptStatsDDL
|
||||
/// ScriptStatsAll
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default value is ScriptStatsNone.
|
||||
/// </remarks>
|
||||
public virtual string ScriptStatistics { get; set; } = "ScriptStatsNone";
|
||||
|
||||
/// <summary>
|
||||
/// Generate USE DATABASE statement.
|
||||
/// </summary>
|
||||
public virtual bool? ScriptUseDatabase { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Generate script that contains schema only or schema and data.
|
||||
/// Possible Values:
|
||||
/// SchemaAndData
|
||||
/// DataOnly
|
||||
/// SchemaOnly
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default value is SchemaOnly.
|
||||
/// </remarks>
|
||||
public virtual string TypeOfDataToScript { get; set; } = "SchemaOnly";
|
||||
|
||||
/// <summary>
|
||||
/// Scripts the change tracking information.
|
||||
/// </summary>
|
||||
public virtual bool? ScriptChangeTracking { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Script the check constraints for each table or view scripted.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default value is true.
|
||||
/// </remarks>
|
||||
public virtual bool? ScriptCheckConstraints { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Scripts the data compression information.
|
||||
/// </summary>
|
||||
public virtual bool? ScriptDataCompressionOptions { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Script the foreign keys for each table scripted.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default value is true.
|
||||
/// </remarks>
|
||||
public virtual bool? ScriptForeignKeys { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Script the full-text indexes for each table or indexed view scripted.
|
||||
/// </summary>
|
||||
public virtual bool? ScriptFullTextIndexes { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Script the indexes (including XML and clustered indexes) for each table or indexed view scripted.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default value is true.
|
||||
/// </remarks>
|
||||
public virtual bool? ScriptIndexes { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Script the primary keys for each table or view scripted
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default value is true.
|
||||
/// </remarks>
|
||||
public virtual bool? ScriptPrimaryKeys { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Script the triggers for each table or view scripted
|
||||
/// </summary>
|
||||
public virtual bool? ScriptTriggers { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Script the unique keys for each table or view scripted.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default value is true.
|
||||
/// </remarks>
|
||||
public virtual bool? UniqueKeys { get; set; } = true;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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 System.Collections.Generic;
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
|
||||
namespace Microsoft.Kusto.ServiceLayer.Scripting.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters to indicate the script operation has resolved the objects to be scripted.
|
||||
/// </summary>
|
||||
public class ScriptingPlanNotificationParams : ScriptingEventParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the list of database objects whose progress has changed.
|
||||
/// </summary>
|
||||
public List<ScriptingObject> ScriptingObjects { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the count of database objects whose progress has changed.
|
||||
/// </summary>
|
||||
public int Count { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event sent to indicate a script operation has determined which objects will be scripted.
|
||||
/// </summary>
|
||||
public class ScriptingPlanNotificationEvent
|
||||
{
|
||||
public static readonly EventType<ScriptingPlanNotificationParams> Type = EventType<ScriptingPlanNotificationParams>.Create("scripting/scriptPlanNotification");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// 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.Kusto.ServiceLayer.Scripting.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters sent when a scripting operation has made progress.
|
||||
/// </summary>
|
||||
public class ScriptingProgressNotificationParams : ScriptingEventParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the scripting object whose progress has changed.
|
||||
/// </summary>
|
||||
public ScriptingObject ScriptingObject { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the status of the scripting operation for the scripting object.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Values can be: 'Completed', 'Progress', and 'Error'.
|
||||
/// </remarks>
|
||||
public string Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or count of completed scripting operations.
|
||||
/// </summary>
|
||||
public int CompletedCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets this total count of objects to script.
|
||||
/// </summary>
|
||||
public int TotalCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the error details if an error occurred scripting a database object.
|
||||
/// </summary>
|
||||
public string ErrorDetails { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get or sets the error message for an error that occurred scripting a database object.
|
||||
/// </summary>
|
||||
public string ErrorMessage { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event to indicate the scripting operation has made progress.
|
||||
/// </summary>
|
||||
public class ScriptingProgressNotificationEvent
|
||||
{
|
||||
public static readonly EventType<ScriptingProgressNotificationParams> Type =
|
||||
EventType<ScriptingProgressNotificationParams>.Create("scripting/scriptProgressNotification");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
|
||||
namespace Microsoft.Kusto.ServiceLayer.Scripting.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters for a script request.
|
||||
/// </summary>
|
||||
public class ScriptingParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the file path used when writing out the script.
|
||||
/// </summary>
|
||||
public string FilePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether scripting to a single file or file per object.
|
||||
/// </summary>
|
||||
public string ScriptDestination { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets connection string of the target database the scripting operation will run against.
|
||||
/// </summary>
|
||||
public string ConnectionString { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of scripting objects to script.
|
||||
/// </summary>
|
||||
public List<ScriptingObject> ScriptingObjects { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of scripting object which specify the include criteria of objects to script.
|
||||
/// </summary>
|
||||
public List<ScriptingObject> IncludeObjectCriteria { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of scripting object which specify the exclude criteria of objects to not script.
|
||||
/// </summary>
|
||||
public List<ScriptingObject> ExcludeObjectCriteria { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of schema name of objects to script.
|
||||
/// </summary>
|
||||
public List<string> IncludeSchemas { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of schema name of objects to not script.
|
||||
/// </summary>
|
||||
public List<string> ExcludeSchemas { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of type name of objects to script.
|
||||
/// </summary>
|
||||
public List<string> IncludeTypes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of type name of objects to not script
|
||||
/// </summary>
|
||||
public List<string> ExcludeTypes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the scripting options.
|
||||
/// </summary>
|
||||
public ScriptOptions ScriptOptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the connection owner URI
|
||||
/// </summary>
|
||||
public string OwnerUri { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The script operation
|
||||
/// </summary>
|
||||
public ScriptingOperationType Operation { get; set; } = ScriptingOperationType.Create;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameters returned from a script request.
|
||||
/// </summary>
|
||||
public class ScriptingResult
|
||||
{
|
||||
public string OperationId { get; set; }
|
||||
|
||||
public string Script { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the scripting request type.
|
||||
/// </summary>
|
||||
public class ScriptingRequest
|
||||
{
|
||||
public static readonly RequestType<ScriptingParams, ScriptingResult> Type =
|
||||
RequestType<ScriptingParams, ScriptingResult>.Create("scripting/script");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user