/// <summary>
 /// Sets the database server security policy of the given database server in the given resource group
 /// </summary>
 public void SetServerSecurityPolicy(string resourceGroupName, string serverName,  string clientRequestId, DatabaseSecurityPolicyUpdateParameters parameters)
 {
     ISecurityOperations operations = GetCurrentSqlClient(clientRequestId).DatabaseSecurity;
     operations.Update(resourceGroupName, serverName, Constants.ServerPolicyId, parameters);
 }
 /// <summary>
 /// Updates an Azure SQL Database security policy object.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the Microsoft.Azure.Management.Sql.ISecurityOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the Resource Group to which the Azure SQL
 /// Database Server belongs.
 /// </param>
 /// <param name='serverName'>
 /// Required. The name of the Azure SQL Database Server to which the
 /// Azure SQL Database belongs.
 /// </param>
 /// <param name='databaseName'>
 /// Required. The name of the Azure SQL Database to which the security
 /// policy is applied.
 /// </param>
 /// <param name='parameters'>
 /// Required. The required parameters for updating a security policy.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static Task<OperationResponse> UpdateAsync(this ISecurityOperations operations, string resourceGroupName, string serverName, string databaseName, DatabaseSecurityPolicyUpdateParameters parameters)
 {
     return operations.UpdateAsync(resourceGroupName, serverName, databaseName, parameters, CancellationToken.None);
 }
 /// <summary>
 /// Unwrap the cmdlets model object and transform it to the communication model object
 /// </summary>
 /// <param name="policy">The AuditingPolicy object</param>
 /// <returns>The communication model object</returns>
 private DatabaseSecurityPolicyUpdateParameters UnwrapPolicy(AuditingPolicy policy)
 {
     DatabaseSecurityPolicyUpdateParameters updateParameters = new DatabaseSecurityPolicyUpdateParameters();
     DatabaseSecurityPolicyProperties properties = new DatabaseSecurityPolicyProperties();
     updateParameters.Properties = properties;
     properties.RetentionDays = 90;
     properties.IsAuditingEnabled = policy.IsEnabled;
     properties.UseServerDefault = policy.UseServerDefault;
     properties.IsBlockDirectAccessEnabled = !policy.DirectAccessEnabled;
     UpdateEventTypes(policy, properties);
     UpdateStorage(policy, properties);
     return updateParameters;
 }
 /// <summary>
 /// Updates an Azure SQL Database security policy object.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the Microsoft.Azure.Management.Sql.ISecurityOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the Resource Group to which the Azure SQL
 /// Database Server belongs.
 /// </param>
 /// <param name='serverName'>
 /// Required. The name of the Azure SQL Database Server to which the
 /// Azure SQL Database belongs.
 /// </param>
 /// <param name='databaseName'>
 /// Required. The name of the Azure SQL Database to which the security
 /// policy is applied.
 /// </param>
 /// <param name='parameters'>
 /// Required. The required parameters for updating a security policy.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static OperationResponse Update(this ISecurityOperations operations, string resourceGroupName, string serverName, string databaseName, DatabaseSecurityPolicyUpdateParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((ISecurityOperations)s).UpdateAsync(resourceGroupName, serverName, databaseName, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }