Ejemplo n.º 1
0
        /// <summary>
        /// Provides a server Advanced Threat Protection policy model for the given database
        /// </summary>
        public ServerAdvancedThreatProtectionPolicyModel GetServerAdvancedThreatProtectionPolicy(string resourceGroup, string serverName)
        {
            // Currently Advanced Threat Protection policy is a TD policy until the backend will support Advanced Threat Protection APIs
            var threatDetectionPolicy = SqlThreatDetectionAdapter.GetServerThreatDetectionPolicy(resourceGroup, serverName);
            var serverAdvancedThreatProtectionPolicyModel = new ServerAdvancedThreatProtectionPolicyModel()
            {
                ResourceGroupName = resourceGroup,
                ServerName        = serverName,
                IsEnabled         = (threatDetectionPolicy.ThreatDetectionState == ThreatDetectionStateType.Enabled)
            };

            return(serverAdvancedThreatProtectionPolicyModel);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets a server Advanced Threat Protection policy model for the given database
        /// </summary>
        public ServerAdvancedThreatProtectionPolicyModel SetServerAdvancedThreatProtection(ServerAdvancedThreatProtectionPolicyModel model)
        {
            // Currently Advanced Threat Protection policy is a TD policy until the backend will support Advanced Threat Protection APIs
            var threatDetectionPolicy = SqlThreatDetectionAdapter.GetServerThreatDetectionPolicy(model.ResourceGroupName, model.ServerName);

            threatDetectionPolicy.ThreatDetectionState = model.IsEnabled ? ThreatDetectionStateType.Enabled : ThreatDetectionStateType.Disabled;

            SqlThreatDetectionAdapter.SetServerThreatDetectionPolicy(threatDetectionPolicy, AzureEnvironment.Endpoint.StorageEndpointSuffix);

            return(model);
        }
 /// <summary>
 /// No sending is needed as this is a Get cmdlet
 /// </summary>
 /// <param name="model">The model object with the data to be sent to the REST endpoints</param>
 protected override ServerAdvancedThreatProtectionPolicyModel PersistChanges(ServerAdvancedThreatProtectionPolicyModel model)
 {
     return(model);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// This method is responsible to call the right API in the communication layer that will eventually send the information in the
 /// object to the REST endpoint
 /// </summary>
 /// <param name="model">The model object with the data to be sent to the REST endpoints</param>
 protected override ServerAdvancedThreatProtectionPolicyModel PersistChanges(ServerAdvancedThreatProtectionPolicyModel model)
 {
     model.IsEnabled = true;
     ModelAdapter.SetServerAdvancedThreatProtection(model);
     return(model);
 }
        /// <summary>
        /// Provides the model element that this cmdlet operates on
        /// </summary>
        /// <returns>A model object</returns>
        protected override ServerAdvancedThreatProtectionPolicyModel GetEntity()
        {
            ServerAdvancedThreatProtectionPolicyModel model = base.GetEntity();

            return(ModelAdapter.GetServerAdvancedThreatProtectionPolicy(model.ResourceGroupName, model.ServerName));
        }