/// <summary>
 /// Update a certificate.  (see
 /// http://aka.ms/azureautomationsdk/certificateoperations for more
 /// information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Automation.ICertificateOperations.
 /// </param>
 /// <param name='automationAccount'>
 /// Required. The automation account name.
 /// </param>
 /// <param name='parameters'>
 /// Required. The parameters supplied to the update certificate
 /// operation.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static Task<AzureOperationResponse> UpdateAsync(this ICertificateOperations operations, string automationAccount, CertificateUpdateParameters parameters)
 {
     return operations.UpdateAsync(automationAccount, parameters, CancellationToken.None);
 }
        public CertificateInfo UpdateCertificate(string automationAccountName, string name, string path, SecureString password,
            string description, bool? exportable)
        {
            if (String.IsNullOrWhiteSpace(path) && (password != null || exportable.HasValue))
            {
                throw new ResourceCommonException(typeof(CertificateInfo),
                    string.Format(CultureInfo.CurrentCulture, Resources.SetCertificateInvalidArgs, name));
            }

            var certificateModel = this.TryGetCertificateModel(automationAccountName, name);
            if (certificateModel == null)
            {
                throw new ResourceCommonException(typeof(CertificateInfo),
                    string.Format(CultureInfo.CurrentCulture, Resources.CertificateNotFound, name));
            }
            
            var createOrUpdateDescription  = description ?? certificateModel.Properties.Description;
            var createOrUpdateIsExportable = (exportable.HasValue) ? exportable.Value : certificateModel.Properties.IsExportable;

            if (path != null)
            {
                return this.CreateCertificateInternal(automationAccountName, name, path, password, createOrUpdateDescription,
                    createOrUpdateIsExportable);
            }

            var cuparam = new CertificateUpdateParameters() 
            { 
                Name = name, 
                Properties = new CertificateUpdateProperties()
                {
                    Description = createOrUpdateDescription,
                    IsExportable = createOrUpdateIsExportable
                } 
            };

            this.automationManagementClient.Certificates.Update(automationAccountName, cuparam);

            return new CertificateInfo(automationAccountName, this.automationManagementClient.Certificates.Get(automationAccountName, name).Certificate);
        }
 /// <summary>
 /// Update a certificate.  (see
 /// http://aka.ms/azureautomationsdk/certificateoperations for more
 /// information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Automation.ICertificateOperations.
 /// </param>
 /// <param name='automationAccount'>
 /// Required. The automation account name.
 /// </param>
 /// <param name='parameters'>
 /// Required. The parameters supplied to the update certificate
 /// operation.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static AzureOperationResponse Update(this ICertificateOperations operations, string automationAccount, CertificateUpdateParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((ICertificateOperations)s).UpdateAsync(automationAccount, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }