mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-02 17:24:50 -05:00
Feat/notebookendpoints (#862)
* Added endpoint for fetching all notebook jobs * Refractored NotebookJobInfo to AgentNotebookInfo to make it more consistent with the rest of the codebase * Added Notebook History endpoint in contracts. * Added Create, Update, Delete notebook endpoints. Also added separate fetch template, materialized notebook endpoints. This will make the Notebook Request and Notebook History responses lighter. * AgentNotebookInfo is now derived from AgentJobInfo * added fetch noteook history endpoint * Added fetching materialized notebook endpoint * Added code for cleaning up the directory * Added create notebook api * Added Update and delete notebook job * Fixed notebook history API * Added last run info to the script and template folder * Added execute database feature for notebook Jobs * SQL commands are now using sqlparameters to prevent any injection attacks * Changed rundate and runtime to string to preserve leading zeros * integration test for agentnotebooks api * Made some changes mentioned in PR * Refactored the code, removed enpoint logic from the notebook handler and wrote test cases * changes select statements, fixed a bug in the test job cleanup and fixed other stuff mentioned in the PR. * added notebook_error column in notebook history select statement * Added get template notebook endpoint * Added renaming and pinning notebook runs * made tables names caps to handle servers with case sensitive queries * made some changes to the enpoint points paths * Added delete materialized notebooks endpoints * Fixed a bug in delete, rename and pin apis where requests from multiple clients with materializedID = 0 could have resulted in multiple rows getting created on notebooks.nb_materialized table. * fixed a merge conflict * Made some changes mentioned in the PR * modified a query to handle space sensitive databases * Made some changes mentioned in the PR * fixed a small query bug
This commit is contained in:
@@ -1470,7 +1470,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
});
|
||||
}
|
||||
|
||||
internal async Task HandleDeleteNotebookMaterializedRequest(DeleteNotebookMaterializedParams parameters, RequestContext<ResultStatus> requestContext)
|
||||
internal async Task HandleDeleteNotebookMaterializedRequest(DeleteMaterializedNotebookParams parameters, RequestContext<ResultStatus> requestContext)
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
|
||||
@@ -214,7 +214,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SQL Agent Notebook templates params
|
||||
/// SQL Agent Notebook name update params
|
||||
/// </summary>
|
||||
public class UpdateAgentNotebookRunNameParams : TaskRequestDetails
|
||||
{
|
||||
@@ -226,7 +226,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SQL Agent Notebook templates request type
|
||||
/// SQL Agent Notebook name update request type
|
||||
/// </summary>
|
||||
public class UpdateAgentNotebookRunNameRequest
|
||||
{
|
||||
@@ -236,7 +236,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SQL Agent Notebook templates params
|
||||
/// SQL Agent Notebook name update params
|
||||
/// </summary>
|
||||
public class UpdateAgentNotebookRunPinParams : TaskRequestDetails
|
||||
{
|
||||
@@ -248,7 +248,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SQL Agent Notebook templates request type
|
||||
/// SQL Agent Notebook pin request type
|
||||
/// </summary>
|
||||
public class UpdateAgentNotebookRunPinRequest
|
||||
{
|
||||
@@ -258,9 +258,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SQL Agent Notebook materialized params
|
||||
/// SQL Agent Notebook pin params
|
||||
/// </summary>
|
||||
public class DeleteNotebookMaterializedParams : TaskRequestDetails
|
||||
public class DeleteMaterializedNotebookParams : TaskRequestDetails
|
||||
{
|
||||
public string OwnerUri { get; set; }
|
||||
public string TargetDatabase { get; set; }
|
||||
@@ -268,20 +268,20 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SQL Agent Notebook materialized result
|
||||
/// SQL Agent delete Notebook materialized result
|
||||
/// </summary>
|
||||
public class DeleteNotebookMaterializedResult : ResultStatus
|
||||
public class DeleteMaterializedNotebookResult : ResultStatus
|
||||
{
|
||||
public string NotebookMaterialized { get; set; }
|
||||
public string MaterializedNotebook { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SQL Agent Notebook materialized request type
|
||||
/// SQL Agent delete materialized request type
|
||||
/// </summary>
|
||||
public class DeleteNotebookMaterializedRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<DeleteNotebookMaterializedParams, ResultStatus> Type =
|
||||
RequestType<DeleteNotebookMaterializedParams, ResultStatus>.Create("agent/deletenotebookmaterialized");
|
||||
RequestType<DeleteMaterializedNotebookParams, ResultStatus> Type =
|
||||
RequestType<DeleteMaterializedNotebookParams, ResultStatus>.Create("agent/deletematerializednotebook");
|
||||
}
|
||||
}
|
||||
@@ -199,8 +199,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
connInfo,
|
||||
notebook.JobId,
|
||||
notebook.TargetDatabase);
|
||||
|
||||
|
||||
}
|
||||
|
||||
internal static async Task UpdateNotebook(
|
||||
@@ -241,7 +239,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
templatePath,
|
||||
notebook.ExecuteDatabase,
|
||||
notebook.TargetDatabase);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -269,7 +266,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
is_deleted
|
||||
FROM
|
||||
notebooks.nb_materialized
|
||||
WHERE JOB_ID = @jobId";
|
||||
WHERE job_id = @jobId";
|
||||
List<SqlParameter> getNotebookHistoryQueryParams = new List<SqlParameter>();
|
||||
getNotebookHistoryQueryParams.Add(new SqlParameter("jobId", JobId));
|
||||
DataSet notebookHistoriesDataSet =
|
||||
@@ -672,7 +669,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
UPDATE notebooks.nb_materialized
|
||||
SET is_deleted = 1,
|
||||
notebook = '',
|
||||
notebook_error = '',
|
||||
notebook_error = ''
|
||||
WHERE
|
||||
job_id = @jobId AND run_time = @startTime AND run_date = @startDate
|
||||
END
|
||||
|
||||
Reference in New Issue
Block a user