public static IAsyncResult BeginResume(this Job job, OrchestratorApi orchestratorApi, AsyncCallback callback, object state, string label = null) { return(ActionExtensions.BeginJobAction(job, orchestratorApi, "Resume", callback, state, new OperationParameter[] { new BodyOperationParameter("label", label) })); }
private static Job initiateRunbookJob(OrchestratorApi sma, String runbookName, List <NameValuePair> runbookParameters) { ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback( delegate { return(true); }); List <string> parameterNames = new List <string>(); var runbook = (from rb in sma.Runbooks where rb.RunbookName == runbookName select rb).AsEnumerable().FirstOrDefault(); if (runbook == null) { var msg = string.Format(CultureInfo.InvariantCulture, "{0}: {1}", refStrings.RunbookNotFound, runbookName); throw new Exception(msg); } OperationParameter operationParameters = new BodyOperationParameter(refStrings.JobParameterName, runbookParameters); string uri = string.Concat(sma.Runbooks, string.Format("(guid'{0}')/{1}", runbook.RunbookID, refStrings.StartRunbookActionName)); Uri uriSMA = new Uri(uri, UriKind.Absolute); // Create the job var jobIdValue = sma.Execute <Guid>(uriSMA, refStrings.HttpPost, true, operationParameters) as QueryOperationResponse <Guid>; var jobId = jobIdValue.Single(); var job = sma.Jobs.Where(j => j.JobID == jobId).AsEnumerable().FirstOrDefault(); if (job == null) { throw new Exception(refStrings.JobNotStarted); } return(job); }
public List <OpsLogix.WAP.RunPowerShell.ApiClient.DataContracts.Runbook> GetSMARunbookList() { smaRunbooks = new List <OpsLogix.WAP.RunPowerShell.ApiClient.DataContracts.Runbook>(); System.Configuration.ConnectionStringSettings url = System.Configuration.ConfigurationManager.ConnectionStrings["SMAUrl"]; var api = new OrchestratorApi(new Uri(url.ConnectionString)); //var api = new OrchestratorApi(new Uri(url.ConnectionString)); /* * var api = new OrchestratorApi(new Uri("https://sma.lab.local/00000000-0000-0000-0000-000000000000"));*/ ((DataServiceContext)api).Credentials = CredentialCache.DefaultCredentials; ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return(true); }); //var runbooks = api.Runbooks.Where(r => r.Tags.Contains("TenantRunbook")).AsEnumerable(); var runbooks = api.Runbooks.AsEnumerable(); foreach (OpsLogix.WAP.RunPowerShell.Api.ServiceReference.SMAWebservice.Runbook runbook in runbooks) { smaRunbooks.Add(new OpsLogix.WAP.RunPowerShell.ApiClient.DataContracts.Runbook { RunbookId = runbook.RunbookID.ToString(), RunbookName = runbook.RunbookName, RunbookTag = runbook.Tags }); } return(smaRunbooks); }
public static IAsyncResult BeginStartRunbook(this Runbook runbook, OrchestratorApi orchestratorApi, AsyncCallback callback, object state, List <NameValuePair> jobParameters = null) { return(ActionExtensions.BeginRunbookAction <Guid>(runbook, orchestratorApi, "Start", callback, state, new OperationParameter[] { new BodyOperationParameter("parameters", jobParameters) })); }
private static void EndJobAction(OrchestratorApi orchestratorApi, IAsyncResult asyncResult) { if (!(ActionExtensions.EndExecute <Guid>(orchestratorApi, asyncResult) is QueryOperationResponse <Guid>)) { string message = string.Format("The {0} action did not return the expected response type: QueryOperationResponse<{1}>", new StackFrame(1).GetMethod().Name, typeof(Guid).Name); throw new InvalidOperationException(message); } }
public static SmaClient GetForWorkflow(Uri url, string username, string password) { return(GetClient(url.ToString(), ClientType.Workflow, () => { var ctx = new OrchestratorApi(url); (ctx as DataServiceContext).Credentials = new NetworkCredential(username, password); return new SmaClient(ctx); })); }
public static SmaClient GetForUser(Uri url) { return(GetClient(url.ToString(), ClientType.Workflow, () => { var ctx = new OrchestratorApi(url); (ctx as DataServiceContext).Credentials = CredentialCache.DefaultNetworkCredentials; return new SmaClient(ctx); })); }
private static TElement EndRunbookAction <TElement>(OrchestratorApi orchestratorApi, IAsyncResult asyncResult) { QueryOperationResponse <TElement> queryOperationResponse = ActionExtensions.EndExecute <TElement>(orchestratorApi, asyncResult) as QueryOperationResponse <TElement>; if (queryOperationResponse == null) { string message = string.Format("The {0} action did not return the expected response type: QueryOperationResponse<{1}>", new StackFrame(1).GetMethod().Name, typeof(TElement).Name); throw new InvalidOperationException(message); } return(queryOperationResponse.Single <TElement>()); }
public RunBookOperations(string uri) { if (string.IsNullOrEmpty(uri)) { throw new Exception("Invalid Service Uri"); } this.serviceRoot = uri; this.api = new OrchestratorApi(new Uri(this.serviceRoot)); ((DataServiceContext)this.api).Credentials = CredentialCache.DefaultCredentials; }
/// <summary> /// Constructor /// </summary> public RunBookOperations() { if (String.IsNullOrEmpty(this.serviceRoot)) { this.serviceRoot = ConfigurationManager.AppSettings.Get("SMAService"); if (string.IsNullOrEmpty(this.serviceRoot)) { throw new Exception("Invalid Service Uri"); } } this.api = new OrchestratorApi(new Uri(serviceRoot)); ((DataServiceContext)this.api).Credentials = CredentialCache.DefaultCredentials; }
public RunbookService(string username, string password, string orchestratorApiAddress, string runbookId) { this.username = username; this.password = password; this.runbookId = runbookId; this.orchestratorApi = new OrchestratorApi(new Uri(orchestratorApiAddress)); ((DataServiceContext)orchestratorApi).Credentials = new NetworkCredential(username, password); //This is used here to ignore certificate errors as you might be using test certificates. You can remove this if you are using trusted certificates. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback( delegate { return(true); }); }
private static IAsyncResult BeginJobAction(Job job, OrchestratorApi orchestratorApi, string action, AsyncCallback callback, object state, params OperationParameter[] operationParameters) { if (job == null || job.JobID == Guid.Empty) { throw new ArgumentNullException("job"); } if (orchestratorApi == null) { throw new ArgumentNullException("orchestratorApi"); } if (!ActionExtensions.JobActions.Contains(action)) { throw new ArgumentOutOfRangeException("action", action, "An invalid job action was requested."); } return(orchestratorApi.BeginExecute <Guid>(ActionExtensions.GetActionUri(orchestratorApi.Jobs.RequestUri, job.JobID, action), callback, state, "POST", true, operationParameters)); }
private static IAsyncResult BeginRunbookAction <TElement>(Runbook runbook, OrchestratorApi orchestratorApi, string action, AsyncCallback callback, object state, params OperationParameter[] operationParameters) { if (runbook == null || runbook.RunbookID == Guid.Empty) { throw new ArgumentNullException("runbook"); } if (orchestratorApi == null) { throw new ArgumentNullException("orchestratorApi"); } if (!ActionExtensions.RunbookActions.Contains(action)) { throw new ArgumentOutOfRangeException("action", action, "An invalid Runbook action was requested."); } return(orchestratorApi.BeginExecute <TElement>(ActionExtensions.GetActionUri(orchestratorApi.Runbooks.RequestUri, runbook.RunbookID, action), callback, state, "POST", true, operationParameters)); }
public static IAsyncResult BeginStartOnSchedule(this Runbook runbook, OrchestratorApi orchestratorApi, AsyncCallback callback, object state, Schedule schedule, List <NameValuePair> jobParameters = null) { if (schedule == null) { throw new ArgumentNullException("schedule"); } if (schedule.ScheduleID == Guid.Empty) { orchestratorApi.AddToSchedules(schedule); orchestratorApi.SaveChanges(); } return(ActionExtensions.BeginRunbookAction <Guid>(runbook, orchestratorApi, "StartOnSchedule", callback, state, new OperationParameter[] { new BodyOperationParameter("parameters", jobParameters), new BodyOperationParameter("scheduleId", schedule.ScheduleID) })); }
public void Connect() { if (IsConnected) { return; } Settings.Default.WebServiceUri = WebService; Settings.Default.Save(); api = new OrchestratorApi(new Uri(WebService)); ((DataServiceContext)api).Timeout = 10; ((DataServiceContext)api).Credentials = System.Net.CredentialCache.DefaultCredentials; api.MergeOption = MergeOption.OverwriteChanges; var runbookCount = api.Runbooks.Count(); AppendOutput("#### Connected ####"); IsConnected = true; }
/// <summary> /// Starts a Job for the given Runbook, Waits up to timeout for job to complete /// </summary> /// <param name="sma">Orchestrator Environment Reference</param> /// <param name="runbookName">Path to Runbook</param> /// <param name="runbookParameters">Input Parameters [Parameter Name] [Parameter Value]</param> /// <param name="timeOut">Timespan to wait for job to complete before timing out</param> /// <returns>Job</returns> public static Job startRunbookJob(OrchestratorApi sma, String runbookName, List <NameValuePair> runbookParameters, TimeSpan timeOut) { Job job = initiateRunbookJob(sma, runbookName, runbookParameters); var jobId = job.JobID; var jobStatus = job.JobStatus; DateTime startTime = DateTime.Now; while (jobStatus != "Completed" && jobStatus != "Failed") { // Wait 5 seconds between polling Thread.Sleep(new TimeSpan(0, 0, 0, 5)); jobStatus = sma.Jobs.Where(j => j.JobID == jobId).Select(j => j.JobStatus).AsEnumerable().First(); if (TimeSpan.Compare(DateTime.Now - startTime, timeOut) > 0) { break; } } return(sma.Jobs.Where(j => j.JobID == jobId).AsEnumerable().First()); }
public String Index([FromBody] GoogleCloudDialogflowV2WebhookRequest request) { string jsonstring = ""; OrchestratorApi oApi = new OrchestratorApi("https://platform.uipath.com", "admin", "shan999km", "shanslab"); JObject jobj = new JObject(); JsonSerializer js = new JsonSerializer(); //String jsonstring = "{\"fulfillmentText\": \"response text\",\"fulfillmentMessages\": [{\"simpleResponses\": {\"simpleResponses\": [ {\"textToSpeech\": \"response text\",\"displayText\": \"response text\"}]}}]}"; // String jsonstring = "{\"fulfillmentText\": \"This is a text response\",\"fulfillmentMessages\": [{\"simpleResponses\": {\"textToSpeech\": \"this is text to speech\",\"ssml\": \"this is ssml\",\"displayText\": \"this is display text\"}}]}"; // String jsonstring = "{\"payload\": {\"google\": {\"expectUserResponse\": true,\"richResponse\": {\"items\": [{\"simpleResponse\": {\"textToSpeech\": \"this is a simple response\"}}]}}}}"; //request.QueryResult.Parameters.Add("email", "Testmail"); var j = JsonConvert.SerializeObject(request.QueryResult.Parameters); Console.WriteLine(j); //////ViewData["req"] = ViewData["req"]+request.QueryResult.Parameters["Ops"].ToString()+Environment.NewLine; if (request.QueryResult.Parameters["Ops"].Equals("join")) { oApi.addObjectToQueue(j.ToString(), "Test"); } string username = request.QueryResult.Parameters["username"].ToString().Trim();; string pin = request.QueryResult.Parameters["pin"].ToString().Trim(); string useremail = checkUser(username, pin); if (!useremail.Equals("")) { j = j.Replace("\"}", ",\"email\":\"" + useremail + "\"}"); jsonstring = "{\"fulfillmentText\": \"response text\",\"fulfillmentMessages\": [{\"simpleResponses\": {\"simpleResponses\": [ {\"textToSpeech\": \"response text\",\"displayText\": \"response text\"}]}}],\"followupEventInput\": {\"name\": \"Dummy\",\"languageCode\": \"en-US\",\"parameters\": {\"msg\": \"password is sent to:" + useremail + "\"}}}"; Console.WriteLine(j.ToString()); oApi.addObjectToQueue(j.ToString(), "Test"); } else { jsonstring = "{\"fulfillmentText\": \"response text\",\"fulfillmentMessages\": [{\"simpleResponses\": {\"simpleResponses\": [ {\"textToSpeech\": \"response text\",\"displayText\": \"response text\"}]}}],\"followupEventInput\": {\"name\": \"AD_Pass_Reset\",\"languageCode\": \"en-US\",\"parameters\": {\"msg\": \"Please check your pin!\"}}}"; } return(jsonstring); }
public void ExecuteRunbook(string subscriptionId, OpsLogix.WAP.RunPowerShell.ApiClient.DataContracts.RunbookParameter rbParameter) { System.Configuration.ConnectionStringSettings url = System.Configuration.ConfigurationManager.ConnectionStrings["SMAUrl"]; /* * var api = new OrchestratorApi(new Uri("https://sma.lab.local/00000000-0000-0000-0000-000000000000"));*/ //var api = new OrchestratorApi(new Uri(url.ConnectionString)); var api = new OrchestratorApi(new Uri(url.ConnectionString)); ((DataServiceContext)api).Credentials = CredentialCache.DefaultCredentials; ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return(true); }); var runbook = api.Runbooks.Where(r => r.RunbookName == rbParameter.RunbookName).AsEnumerable().FirstOrDefault(); if (runbook == null) { return; } var runbookParams = new List <NameValuePair> { new NameValuePair() { Name = "Upn", Value = rbParameter.Upn }, new NameValuePair() { Name = "RunbookName", Value = rbParameter.RunbookName }, new NameValuePair() { Name = "SubscriptionId", Value = rbParameter.SubscriptionId }, new NameValuePair() { Name = "SelectedVmId", Value = rbParameter.SelectedVmId }, new NameValuePair() { Name = "ParamBool", Value = rbParameter.ParamBool }, new NameValuePair() { Name = "ParamString", Value = rbParameter.ParamString }, new NameValuePair() { Name = "ParamInt", Value = rbParameter.ParamInt }, new NameValuePair() { Name = "ParamDate", Value = rbParameter.ParamDate }, new NameValuePair() { Name = "ParamStringArray", Value = rbParameter.ParamStringArray } }; OperationParameter operationParameters = new BodyOperationParameter("parameters", runbookParams); var uriSma = new Uri(string.Concat(api.Runbooks, string.Format("(guid'{0}')/{1}", runbook.RunbookID, "Start")), UriKind.Absolute); var jobIdValue = api.Execute <Guid>(uriSma, "POST", true, operationParameters) as QueryOperationResponse <Guid>; if (jobIdValue == null) { return; } var jobId = jobIdValue.Single(); Task.Factory.StartNew(() => QueryJobCompletion(jobId)); }
public static Statistics GetStatistics(this Runbook runbook, OrchestratorApi orchestratorApi, List <NameValuePair> jobParameters = null) { return(runbook.EndGetStatistics(orchestratorApi, runbook.BeginGetStatistics(orchestratorApi, null, null, jobParameters))); }
public static Guid Edit(this Runbook runbook, OrchestratorApi orchestratorApi) { return(runbook.EndEdit(orchestratorApi, runbook.BeginEdit(orchestratorApi, null, null))); }
public static Guid Publish(this Runbook runbook, OrchestratorApi orchestratorApi) { return(runbook.EndPublish(orchestratorApi, runbook.BeginPublish(orchestratorApi, null, null))); }
public SmaClient(OrchestratorApi ctx) { _ctx = ctx; }
public static IAsyncResult BeginEdit(this Runbook runbook, OrchestratorApi orchestratorApi, AsyncCallback callback, object state) { return(ActionExtensions.BeginRunbookAction <Guid>(runbook, orchestratorApi, "Edit", callback, state, null)); }
public static void Resume(this Job job, OrchestratorApi orchestratorApi, string label = null) { job.EndResume(orchestratorApi, job.BeginResume(orchestratorApi, null, null, label)); }
public static Guid TestRunbook(this Runbook runbook, OrchestratorApi orchestratorApi, List <NameValuePair> jobParameters = null) { return(runbook.EndTestRunbook(orchestratorApi, runbook.BeginTestRunbook(orchestratorApi, null, null, jobParameters))); }
/// <summary> /// Starts a Job for the given Runbook, Does not wait for job to complete /// </summary> /// <param name="sma">Orchestrator Environment Reference</param> /// <param name="runbookName">Path to Runbook</param> /// <param name="runbookParameters">Input Parameters [Parameter Name] [Parameter Value]</param> /// <returns>Job</returns> public static Job startRunbookJob(OrchestratorApi sma, String runbookName, List <NameValuePair> runbookParameters) { return(initiateRunbookJob(sma, runbookName, runbookParameters)); }
public static void EndResume(this Job job, OrchestratorApi orchestratorApi, IAsyncResult asyncResult) { ActionExtensions.EndJobAction(orchestratorApi, asyncResult); }
public static Guid StartOnSchedule(this Runbook runbook, OrchestratorApi orchestratorApi, Schedule schedule, List <NameValuePair> jobParameters = null) { return(runbook.EndStartOnSchedule(orchestratorApi, runbook.BeginStartOnSchedule(orchestratorApi, null, null, schedule, jobParameters))); }
public static Guid EndStartRunbook(this Runbook runbook, OrchestratorApi orchestratorApi, IAsyncResult asyncResult) { return(ActionExtensions.EndRunbookAction <Guid>(orchestratorApi, asyncResult)); }
public static Statistics EndGetStatistics(this Runbook runbook, OrchestratorApi orchestratorApi, IAsyncResult asyncResult) { return(ActionExtensions.EndRunbookAction <Statistics>(orchestratorApi, asyncResult)); }