private async Task <TestJobCreateResponse> createTestJob() { RunbookDraft draft = await AutomationRunbookManager.GetRunbookDraft(runbookName, iseClient.automationManagementClient, iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name); if (draft.InEdit == false) { throw new Exception("This runbook has no draft to test because it is in a 'Published' state."); } HybridRunbookWorkerGroupsListResponse hybridGroupResponse = await iseClient.automationManagementClient.HybridRunbookWorkerGroups.ListAsync( iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name, new CancellationToken()); TestJobCreateParameters jobCreationParams = new TestJobCreateParameters(); jobCreationParams.RunbookName = runbookName; if (draft.Parameters.Count > 0 || hybridGroupResponse.HybridRunbookWorkerGroups.Count > 0) { /* User needs to specify some things */ var existingParams = await GetLastTestJobParams(); RunbookParamDialog paramDialog = new RunbookParamDialog(draft.Parameters, existingParams, hybridGroupResponse.HybridRunbookWorkerGroups); if (paramDialog.ShowDialog() == true) { if (draft.Parameters.Count > 0) { jobCreationParams.Parameters = paramDialog.paramValues; } if (!String.IsNullOrEmpty(paramDialog.runOnSelection) && !paramDialog.runOnSelection.Equals("Azure")) { jobCreationParams.RunOn = paramDialog.runOnSelection; } } else { return(null); } } /* start the test job */ CancellationTokenSource cts = new CancellationTokenSource(); cts.CancelAfter(TIMEOUT_MS); TestJobCreateResponse jobResponse = await iseClient.automationManagementClient.TestJobs.CreateAsync( iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name, jobCreationParams, cts.Token); if (jobResponse == null || jobResponse.StatusCode != System.Net.HttpStatusCode.Created) { throw new Exception("The test job could not be created: received HTTP status code " + jobResponse.StatusCode); } return(jobResponse); }
private async Task <TestJobCreateResponse> createTestJob() { RunbookDraft draft = await AutomationRunbookManager.GetRunbookDraft(runbookName, iseClient.automationManagementClient, iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name); if (draft.InEdit == false) { throw new Exception("This runbook has no draft to test because it is in a 'Published' state."); } TestJobCreateParameters jobCreationParams = new TestJobCreateParameters(); jobCreationParams.RunbookName = runbookName; if (draft.Parameters.Count > 0) { /* User needs to specify values for them */ var existingParams = await GetTestJobParams(); RunbookParamDialog paramDialog = new RunbookParamDialog(draft.Parameters, existingParams); if (paramDialog.ShowDialog() == true) { jobCreationParams.Parameters = paramDialog.paramValues; } else { return(null); } } /* start the test job */ TestJobCreateResponse jobResponse = await iseClient.automationManagementClient.TestJobs.CreateAsync( iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name, jobCreationParams, new System.Threading.CancellationToken()); if (jobResponse == null || jobResponse.StatusCode != System.Net.HttpStatusCode.Created) { throw new Exception("The test job could not be created: received HTTP status code " + jobResponse.StatusCode); } return(jobResponse); }
private async Task<TestJobCreateResponse> createTestJob() { RunbookDraft draft = await AutomationRunbookManager.GetRunbookDraft(runbookName, iseClient.automationManagementClient, iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name); if (draft.InEdit == false) throw new Exception("This runbook has no draft to test because it is in a 'Published' state."); HybridRunbookWorkerGroupsListResponse hybridGroupResponse = await iseClient.automationManagementClient.HybridRunbookWorkerGroups.ListAsync( iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name, new CancellationToken()); TestJobCreateParameters jobCreationParams = new TestJobCreateParameters(); jobCreationParams.RunbookName = runbookName; if (draft.Parameters.Count > 0 || hybridGroupResponse.HybridRunbookWorkerGroups.Count > 0) { /* User needs to specify some things */ var existingParams = await GetLastTestJobParams(); RunbookParamDialog paramDialog = new RunbookParamDialog(draft.Parameters, existingParams, hybridGroupResponse.HybridRunbookWorkerGroups); if (paramDialog.ShowDialog() == true) { if (draft.Parameters.Count > 0) jobCreationParams.Parameters = paramDialog.paramValues; if (!String.IsNullOrEmpty(paramDialog.runOnSelection) && !paramDialog.runOnSelection.Equals("Azure")) jobCreationParams.RunOn = paramDialog.runOnSelection; } else { return null; } } /* start the test job */ CancellationTokenSource cts = new CancellationTokenSource(); cts.CancelAfter(TIMEOUT_MS); TestJobCreateResponse jobResponse = await iseClient.automationManagementClient.TestJobs.CreateAsync( iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name, jobCreationParams, cts.Token); if (jobResponse == null || jobResponse.StatusCode != System.Net.HttpStatusCode.Created) throw new Exception("The test job could not be created: received HTTP status code " + jobResponse.StatusCode); return jobResponse; }
private async Task<TestJobCreateResponse> createTestJob() { RunbookDraft draft = await AutomationRunbookManager.GetRunbookDraft(runbookName, iseClient.automationManagementClient, iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name); if (draft.InEdit == false) throw new Exception("This runbook has no draft to test because it is in a 'Published' state."); TestJobCreateParameters jobCreationParams = new TestJobCreateParameters(); jobCreationParams.RunbookName = runbookName; if (draft.Parameters.Count > 0) { /* User needs to specify values for them */ var existingParams = await GetTestJobParams(); RunbookParamDialog paramDialog = new RunbookParamDialog(draft.Parameters,existingParams); if (paramDialog.ShowDialog() == true) jobCreationParams.Parameters = paramDialog.paramValues; else return null; } /* start the test job */ TestJobCreateResponse jobResponse = await iseClient.automationManagementClient.TestJobs.CreateAsync( iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name, jobCreationParams, new System.Threading.CancellationToken()); if (jobResponse == null || jobResponse.StatusCode != System.Net.HttpStatusCode.Created) throw new Exception("The test job could not be created: received HTTP status code " + jobResponse.StatusCode); return jobResponse; }