mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-15 10:58:31 -05:00
Added renaming and pinning agent notebook runs (#855)
* 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 enpointpoint paths
This commit is contained in:
@@ -129,6 +129,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
this.ServiceHost.SetRequestHandler(CreateAgentNotebookRequest.Type, HandleCreateAgentNotebookRequest);
|
||||
this.ServiceHost.SetRequestHandler(DeleteAgentNotebookRequest.Type, HandleDeleteAgentNotebooksRequest);
|
||||
this.ServiceHost.SetRequestHandler(UpdateAgentNotebookRequest.Type, HandleUpdateAgentNotebookRequest);
|
||||
this.ServiceHost.SetRequestHandler(UpdateAgentNotebookRunPinRequest.Type, HandleUpdateAgentNotebookRunPinRequest);
|
||||
this.ServiceHost.SetRequestHandler(UpdateAgentNotebookRunNameRequest.Type, HandleUpdateAgentNotebookRunNameRequest);
|
||||
|
||||
|
||||
serviceHost.RegisterShutdownTask(async (shutdownParams, shutdownRequestContext) =>
|
||||
@@ -1410,6 +1412,64 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
});
|
||||
}
|
||||
|
||||
internal async Task HandleUpdateAgentNotebookRunNameRequest(UpdateAgentNotebookRunNameParams parameters, RequestContext<ResultStatus> requestContext)
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
var result = new ResultStatus();
|
||||
try
|
||||
{
|
||||
ConnectionInfo connInfo;
|
||||
ConnectionServiceInstance.TryFindConnection(
|
||||
parameters.OwnerUri,
|
||||
out connInfo);
|
||||
// Calling update helper function
|
||||
await AgentNotebookHelper.UpdateMaterializedNotebookName(
|
||||
connInfo,
|
||||
parameters.MaterializedId,
|
||||
parameters.TargetDatabase,
|
||||
parameters.MaterializedNotebookName);
|
||||
result.Success = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result.Success = false;
|
||||
result.ErrorMessage = e.ToString();
|
||||
|
||||
}
|
||||
await requestContext.SendResult(result);
|
||||
});
|
||||
}
|
||||
|
||||
internal async Task HandleUpdateAgentNotebookRunPinRequest(UpdateAgentNotebookRunPinParams parameters, RequestContext<ResultStatus> requestContext)
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
var result = new ResultStatus();
|
||||
try
|
||||
{
|
||||
ConnectionInfo connInfo;
|
||||
ConnectionServiceInstance.TryFindConnection(
|
||||
parameters.OwnerUri,
|
||||
out connInfo);
|
||||
// Calling update helper function
|
||||
await AgentNotebookHelper.UpdateMaterializedNotebookPin(
|
||||
connInfo,
|
||||
parameters.MaterializedId,
|
||||
parameters.TargetDatabase,
|
||||
parameters.MaterializedNotebookPin);
|
||||
result.Success = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result.Success = false;
|
||||
result.ErrorMessage = e.ToString();
|
||||
|
||||
}
|
||||
await requestContext.SendResult(result);
|
||||
});
|
||||
}
|
||||
|
||||
public AgentNotebookHistoryResult GetAgentNotebookHistories(
|
||||
ConnectionInfo connInfo,
|
||||
string jobId,
|
||||
@@ -1475,6 +1535,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
{
|
||||
notebookHistory.MaterializedNotebookId = (int)notebookHistoriesDict[jobRuntime]["materialized_id"];
|
||||
notebookHistory.MaterializedNotebookErrorInfo = notebookHistoriesDict[jobRuntime]["notebook_error"] as string;
|
||||
notebookHistory.MaterializedNotebookName = notebookHistoriesDict[jobRuntime]["notebook_name"] as string;
|
||||
notebookHistory.MaterializedNotebookPin = (bool)notebookHistoriesDict[jobRuntime]["pin"];
|
||||
}
|
||||
notebookHistories.Add(notebookHistory);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user