/// <summary>
 /// Update the runbook identified by runbook name.  (see
 /// http://aka.ms/azureautomationsdk/runbookoperations for more
 /// information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.Automation.IRunbookOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group
 /// </param>
 /// <param name='automationAccount'>
 /// Required. The automation account name.
 /// </param>
 /// <param name='parameters'>
 /// Required. The patch parameters for runbook.
 /// </param>
 /// <returns>
 /// The response model for the get runbook operation.
 /// </returns>
 public static Task<RunbookGetResponse> PatchAsync(this IRunbookOperations operations, string resourceGroupName, string automationAccount, RunbookPatchParameters parameters)
 {
     return operations.PatchAsync(resourceGroupName, automationAccount, parameters, CancellationToken.None);
 }
        public Runbook UpdateRunbook(string resourceGroupName, string automationAccountName, string runbookName, string description,
            IDictionary tags, bool? logProgress, bool? logVerbose)
        {
            using (var request = new RequestSettings(this.automationManagementClient))
            {
                var runbookModel = this.TryGetRunbookModel(resourceGroupName, automationAccountName, runbookName);
                if (runbookModel == null)
                {
                    throw new ResourceCommonException(typeof (Runbook),
                        string.Format(CultureInfo.CurrentCulture, Resources.RunbookNotFound, runbookName));
                }

                var runbookUpdateParameters = new RunbookPatchParameters();
                runbookUpdateParameters.Name = runbookName;
                runbookUpdateParameters.Tags = null;

                IDictionary<string, string> runbooksTags = null;
                if (tags != null) runbooksTags = tags.Cast<DictionaryEntry>().ToDictionary(kvp => kvp.Key.ToString(), kvp => kvp.Value.ToString());

                runbookUpdateParameters.Properties = new RunbookPatchProperties();
                runbookUpdateParameters.Properties.Description = description ?? runbookModel.Properties.Description;
                runbookUpdateParameters.Properties.LogProgress = (logProgress.HasValue)
                    ? logProgress.Value
                    : runbookModel.Properties.LogProgress;
                runbookUpdateParameters.Properties.LogVerbose = (logVerbose.HasValue)
                    ? logVerbose.Value
                    : runbookModel.Properties.LogVerbose;
                runbookUpdateParameters.Tags = runbooksTags ?? runbookModel.Tags;

                var runbook =
                    this.automationManagementClient.Runbooks.Patch(resourceGroupName, automationAccountName, runbookUpdateParameters)
                        .Runbook;

                return new Runbook(resourceGroupName, automationAccountName, runbook);
            }
        }
 /// <summary>
 /// Update the runbook identified by runbook name.  (see
 /// http://aka.ms/azureautomationsdk/runbookoperations for more
 /// information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.Automation.IRunbookOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group
 /// </param>
 /// <param name='automationAccount'>
 /// Required. The automation account name.
 /// </param>
 /// <param name='parameters'>
 /// Required. The patch parameters for runbook.
 /// </param>
 /// <returns>
 /// The response model for the get runbook operation.
 /// </returns>
 public static RunbookGetResponse Patch(this IRunbookOperations operations, string resourceGroupName, string automationAccount, RunbookPatchParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IRunbookOperations)s).PatchAsync(resourceGroupName, automationAccount, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }