/// <summary> /// The non-boilerplated test code of the APIs for managing the lifecycle of a given server's auditing policy. It is meant to be called with a name of an already existing server (and therefore already existing /// resource group). This test does not create these resources and does not remove them. /// </summary> private void TestServerAuditingAPIs(SqlManagementClient sqlClient, string resourceGroupName, Server server) { ServerAuditingPolicyGetResponse getDefaultServerPolicyResponse = sqlClient.AuditingPolicy.GetServerPolicy(resourceGroupName, server.Name); ServerAuditingPolicyProperties properties = getDefaultServerPolicyResponse.AuditingPolicy.Properties; // Verify that the initial Get request contains the default policy. TestUtilities.ValidateOperationResponse(getDefaultServerPolicyResponse, HttpStatusCode.OK); VerifyServerAuditingPolicyInformation(GetDefaultServerAuditProperties(), properties); // Modify the policy properties, send and receive, see it its still ok ChangeServerAuditPolicy(properties); ServerAuditingPolicyCreateOrUpdateParameters updateParams = new ServerAuditingPolicyCreateOrUpdateParameters { Properties = properties }; var updateResponse = sqlClient.AuditingPolicy.CreateOrUpdateServerPolicy(resourceGroupName, server.Name, updateParams); // Verify that the initial Get request of contains the default policy. TestUtilities.ValidateOperationResponse(updateResponse, HttpStatusCode.OK); ServerAuditingPolicyGetResponse getUpdatedPolicyResponse = sqlClient.AuditingPolicy.GetServerPolicy(resourceGroupName, server.Name); ServerAuditingPolicyProperties updatedProperties = getUpdatedPolicyResponse.AuditingPolicy.Properties; // Verify that the Get request contains the updated policy. TestUtilities.ValidateOperationResponse(getUpdatedPolicyResponse, HttpStatusCode.OK); VerifyServerAuditingPolicyInformation(properties, updatedProperties); }
/// <summary> /// Gets the database server auditing policy for the given database server in the given resource group /// </summary> public void GetServerAuditingPolicy(string resourceGroupName, string serverName, string clientRequestId, out ServerAuditingPolicy policy) { IAuditingPolicyOperations operations = GetCurrentSqlClient(clientRequestId).AuditingPolicy; ServerAuditingPolicyGetResponse response = operations.GetServerPolicy(resourceGroupName, serverName); policy = response.AuditingPolicy; }