public void SetDefaultValue(RunbookParameter runbookParameter) { if (runbookParameter.DefaultValue != null) { DefaultValue = runbookParameter.DefaultValue.Replace("'", ""); } ; }
public async Task ExecuteRunbook(string subscriptionId, RunbookParameter rb) { var requestUrl = this.CreateRequestUri( string.Format(CultureInfo.InvariantCulture, TenantExecuteRunbook, subscriptionId)); await this.PostAsync <RunbookParameter>(requestUrl, rb); }
public override void SetParameterType(RunbookParameter runbookParameter) { switch (runbookParameter.Type) { case "System.String[]": case "System.Management.Automation.PSObject[]": case "System.Object[]": ParameterType = ParameterTypes.array; break; case "System.DateTime": ParameterType = ParameterTypes.datetime; break; case "System.Int32": ParameterType = ParameterTypes.@int; break; default: ParameterType = ParameterTypes.@string; break; } }
public void AddToRunbookParameters(RunbookParameter runbookParameter) { base.AddObject("RunbookParameters", runbookParameter); }
public static RunbookParameter CreateRunbookParameter(global::System.Guid runbookVersionID, string name, string type, bool isMandatory, int position) { RunbookParameter runbookParameter = new RunbookParameter(); runbookParameter.RunbookVersionID = runbookVersionID; runbookParameter.Name = name; runbookParameter.Type = type; runbookParameter.IsMandatory = isMandatory; runbookParameter.Position = position; return runbookParameter; }
/// <summary> /// Retrieve a list of runbook versions filtered by parameters. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/XXXXX.aspx /// for more information) /// </summary> /// <param name='automationAccount'> /// Required. The automation account name. /// </param> /// <param name='runbookVersionId'> /// Required. The runbook version id. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// The response model for the list runbook parameter operation. /// </returns> public async Task <RunbookParameterListResponse> ListByRunbookVersionIdAsync(string automationAccount, string runbookVersionId, CancellationToken cancellationToken) { // Validate if (automationAccount == null) { throw new ArgumentNullException("automationAccount"); } if (runbookVersionId == null) { throw new ArgumentNullException("runbookVersionId"); } // Tracing bool shouldTrace = CloudContext.Configuration.Tracing.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = Tracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("automationAccount", automationAccount); tracingParameters.Add("runbookVersionId", runbookVersionId); Tracing.Enter(invocationId, this, "ListByRunbookVersionIdAsync", tracingParameters); } // Construct URL string url = "/" + (this.Client.Credentials.SubscriptionId != null ? this.Client.Credentials.SubscriptionId.Trim() : "") + "/cloudservices/OaaSCS/resources/automation/~/Accounts/" + automationAccount.Trim() + "/RunbookParameters?"; bool appendFilter = true; appendFilter = false; url = url + "$filter=" + "RunbookVersionID eq guid'" + Uri.EscapeDataString(runbookVersionId.Trim()) + "'"; url = url + "&api-version=2014-03-13_Preview"; string baseUrl = this.Client.BaseUri.AbsoluteUri; // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.Length - 1] == '/') { baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); } if (url[0] == '/') { url = url.Substring(1); } url = baseUrl + "/" + url; url = url.Replace(" ", "%20"); // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Get; httpRequest.RequestUri = new Uri(url); // Set Headers httpRequest.Headers.Add("Accept", "application/json"); httpRequest.Headers.Add("MaxDataServiceVersion", "3.0"); httpRequest.Headers.Add("MinDataServiceVersion", "3.0"); httpRequest.Headers.Add("x-ms-version", "2013-06-01"); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { Tracing.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { Tracing.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; if (statusCode != HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); if (shouldTrace) { Tracing.Error(invocationId, ex); } throw ex; } // Create Result RunbookParameterListResponse result = null; // Deserialize Response cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); result = new RunbookParameterListResponse(); JToken responseDoc = null; if (string.IsNullOrEmpty(responseContent) == false) { responseDoc = JToken.Parse(responseContent); } if (responseDoc != null && responseDoc.Type != JTokenType.Null) { JToken valueArray = responseDoc["value"]; if (valueArray != null && valueArray.Type != JTokenType.Null) { foreach (JToken valueValue in ((JArray)valueArray)) { RunbookParameter runbookParameterInstance = new RunbookParameter(); result.RunbookParameters.Add(runbookParameterInstance); JToken runbookVersionIDValue = valueValue["RunbookVersionID"]; if (runbookVersionIDValue != null && runbookVersionIDValue.Type != JTokenType.Null) { string runbookVersionIDInstance = ((string)runbookVersionIDValue); runbookParameterInstance.RunbookVersionId = runbookVersionIDInstance; } JToken nameValue = valueValue["Name"]; if (nameValue != null && nameValue.Type != JTokenType.Null) { string nameInstance = ((string)nameValue); runbookParameterInstance.Name = nameInstance; } JToken typeValue = valueValue["Type"]; if (typeValue != null && typeValue.Type != JTokenType.Null) { string typeInstance = ((string)typeValue); runbookParameterInstance.Type = typeInstance; } JToken isMandatoryValue = valueValue["IsMandatory"]; if (isMandatoryValue != null && isMandatoryValue.Type != JTokenType.Null) { bool isMandatoryInstance = ((bool)isMandatoryValue); runbookParameterInstance.IsMandatory = isMandatoryInstance; } JToken positionValue = valueValue["Position"]; if (positionValue != null && positionValue.Type != JTokenType.Null) { int positionInstance = ((int)positionValue); runbookParameterInstance.Position = positionInstance; } } } } result.StatusCode = statusCode; if (httpResponse.Headers.Contains("x-ms-request-id")) { result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (shouldTrace) { Tracing.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }
public static RunbookParameter CreateRunbookParameter(global::System.Guid ID, global::System.Guid runbookId, string name, string type, string direction) { RunbookParameter runbookParameter = new RunbookParameter(); runbookParameter.Id = ID; runbookParameter.RunbookId = runbookId; runbookParameter.Name = name; runbookParameter.Type = type; runbookParameter.Direction = direction; return runbookParameter; }
public abstract void SetParameterType(RunbookParameter runbookParameter);
public RunbookParameterDefinition(RunbookParameter runbookParameter) { SetParameterType(runbookParameter); IsRequired = (bool)runbookParameter.IsMandatory; SetDefaultValue(runbookParameter); }
public PowershellRunbookParameterDefinition(RunbookParameter runbookParameter) : base(runbookParameter) { }