/// <summary>
 /// Initializes a new instance of the
 /// ServerAuditingPolicyCreateOrUpdateParameters class with required
 /// arguments.
 /// </summary>
 public ServerAuditingPolicyCreateOrUpdateParameters(ServerAuditingPolicyProperties properties)
     : this()
 {
     if (properties == null)
     {
         throw new ArgumentNullException("properties");
     }
     this.Properties = properties;
 }
 /// <summary>
 /// Initializes a new instance of the
 /// ServerAuditingPolicyCreateOrUpdateParameters class with required
 /// arguments.
 /// </summary>
 public ServerAuditingPolicyCreateOrUpdateParameters(ServerAuditingPolicyProperties properties)
     : this()
 {
     if (properties == null)
     {
         throw new ArgumentNullException("properties");
     }
     this.Properties = properties;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Takes the cmdlets model object and transform it to the policy as expected by the endpoint
 /// </summary>
 /// <param name="model">The AuditingPolicy model object</param>
 /// <returns>The communication model object</returns>
 private ServerAuditingPolicyCreateOrUpdateParameters PolicizeServerAuditingModel(ServerAuditingPolicyModel model)
 {
     ServerAuditingPolicyCreateOrUpdateParameters updateParameters = new ServerAuditingPolicyCreateOrUpdateParameters();
     ServerAuditingPolicyProperties properties = new ServerAuditingPolicyProperties();
     updateParameters.Properties = properties;
     properties.AuditingState = PolicizeAuditState(model.AuditState);
     properties.StorageAccountName = ExtractStorageAccountName(model);
     properties.StorageAccountResourceGroupName = ExtractStorageAccountResourceGroup(properties.StorageAccountName);
     properties.StorageAccountSubscriptionId = ExtractStorageAccountSubscriptionId(properties.StorageAccountName);
     properties.StorageTableEndpoint = ExtractStorageAccountTableEndpoint(properties.StorageAccountName);
     properties.StorageAccountKey = ExtractStorageAccountKey(properties.StorageAccountName, model, properties.StorageAccountResourceGroupName, StorageKeyKind.Primary);
     properties.StorageAccountSecondaryKey = ExtractStorageAccountKey(properties.StorageAccountName, model, properties.StorageAccountResourceGroupName, StorageKeyKind.Secondary);
     properties.EventTypesToAudit = ExtractEventTypes(model);
     properties.RetentionDays = model.RetentionInDays.ToString();
     properties.AuditLogsTableName = model.TableIdentifier;
     return updateParameters;
 }
 /// <summary>
 /// Verify that the received properties match their expected values
 /// </summary>
 /// <param name="expected">The expected value of the properties object</param>
 /// <param name="actual">The properties object that needs to be checked</param>
 private static void VerifyServerAuditingPolicyInformation(ServerAuditingPolicyProperties expected , ServerAuditingPolicyProperties actual)
 {
     Assert.Equal(expected.AuditingState, actual.AuditingState);
     Assert.Equal(expected.EventTypesToAudit, actual.EventTypesToAudit);
     Assert.Equal(expected.StorageAccountName, actual.StorageAccountName);
     Assert.Equal(expected.StorageAccountKey, actual.StorageAccountKey);
     Assert.Equal(expected.StorageAccountSecondaryKey, actual.StorageAccountSecondaryKey);
     Assert.Equal(expected.StorageAccountResourceGroupName, actual.StorageAccountResourceGroupName);
     Assert.Equal(expected.StorageTableEndpoint, actual.StorageTableEndpoint);
     Assert.Equal(expected.StorageAccountSubscriptionId, actual.StorageAccountSubscriptionId);
     Assert.Equal(expected.RetentionDays, actual.RetentionDays);
 }
 /// <summary>
 /// Creates and returns a ServerAuditingPolicyProperties object that holds the default settings for a server auditing policy
 /// </summary>
 /// <returns>A ServerAuditingPolicyProperties object with the default audit policy settings</returns>
 private ServerAuditingPolicyProperties GetDefaultServerAuditProperties()
 {
     ServerAuditingPolicyProperties props = new ServerAuditingPolicyProperties
     {
         AuditingState = "New",
         EventTypesToAudit = c_DefualtEventTypesToAudit,
         StorageAccountName = null,
         StorageAccountKey = null,
         StorageAccountSecondaryKey = null,
         StorageAccountResourceGroupName = null,
         StorageAccountSubscriptionId = null,
         StorageTableEndpoint = null,
         RetentionDays = "0"
     };
     return props;
 }
 /// <summary>
 /// Changes the server auditing policy with new values
 /// </summary>
 private void ChangeServerAuditPolicy(ServerAuditingPolicyProperties properties)
 {
     properties.AuditingState = "Disabled";
     properties.EventTypesToAudit = "PlainSQL_Success";
     properties.RetentionDays = "10";
     properties.AuditLogsTableName = "TempHyrdraTestAuditLogsTableName";
 }