Backup simple retention policy class.
Inheritance: RetentionPolicyBase
示例#1
0
 /// <summary>
 /// Constructs the retention policy object with default inits
 /// </summary>
 /// <returns>Default retention policy object</returns>
 public RetentionPolicyBase GetDefaultRetentionPolicyObject()
 {
     CmdletModel.SimpleRetentionPolicy defaultRetention =
         new CmdletModel.SimpleRetentionPolicy();
     defaultRetention.RetentionDurationType = defaultSqlRetentionType;
     defaultRetention.RetentionCount        = defaultSqlRetentionCount;
     return(defaultRetention);
 }
示例#2
0
        /// <summary>
        /// Modifies policy using the provider data
        /// </summary>
        /// <returns>Modified policy object as returned by the service</returns>
        public RestAzureNS.AzureOperationResponse <ProtectionPolicyResource> ModifyPolicy()
        {
            string vaultName                    = (string)ProviderData[VaultParams.VaultName];
            string resourceGroupName            = (string)ProviderData[VaultParams.ResourceGroupName];
            RetentionPolicyBase retentionPolicy =
                ProviderData.ContainsKey(PolicyParams.RetentionPolicy) ?
                (RetentionPolicyBase)ProviderData[PolicyParams.RetentionPolicy] :
                null;

            PolicyBase policy =
                ProviderData.ContainsKey(PolicyParams.ProtectionPolicy) ?
                (PolicyBase)ProviderData[PolicyParams.ProtectionPolicy] :
                null;

            // RetentionPolicy
            if (retentionPolicy == null)
            {
                throw new ArgumentException(Resources.RetentionPolicyEmptyInAzureSql);
            }
            else
            {
                ValidateAzureSqlRetentionPolicy(retentionPolicy);
                ((AzureSqlPolicy)policy).RetentionPolicy = retentionPolicy;
                Logger.Instance.WriteDebug("Validation of Retention policy is successful");
            }

            CmdletModel.SimpleRetentionPolicy sqlRetentionPolicy =
                (CmdletModel.SimpleRetentionPolicy)((AzureSqlPolicy)policy).RetentionPolicy;
            ProtectionPolicyResource protectionPolicyResource = new ProtectionPolicyResource()
            {
                Properties = new AzureSqlProtectionPolicy()
                {
                    RetentionPolicy =
                        PolicyHelpers.GetServiceClientSimpleRetentionPolicy(sqlRetentionPolicy)
                }
            };

            return(ServiceClientAdapter.CreateOrUpdateProtectionPolicy(
                       policy.Name,
                       protectionPolicyResource,
                       vaultName: vaultName,
                       resourceGroupName: resourceGroupName));
        }
示例#3
0
        /// <summary>
        /// Modifies policy using the provider data
        /// </summary>
        /// <returns>Modified policy object as returned by the service</returns>
        public ProtectionPolicyResponse ModifyPolicy()
        {
            RetentionPolicyBase retentionPolicy =
                ProviderData.ContainsKey(PolicyParams.RetentionPolicy) ?
                (RetentionPolicyBase)ProviderData[PolicyParams.RetentionPolicy] :
                null;

            PolicyBase policy =
                ProviderData.ContainsKey(PolicyParams.ProtectionPolicy) ?
                (PolicyBase)ProviderData[PolicyParams.ProtectionPolicy] :
                null;

            // RetentionPolicy
            if (retentionPolicy == null)
            {
                throw new ArgumentException(Resources.RetentionPolicyEmptyInAzureSql);
            }
            else
            {
                ValidateAzureSqlRetentionPolicy(retentionPolicy);
                ((AzureSqlPolicy)policy).RetentionPolicy = retentionPolicy;
                Logger.Instance.WriteDebug("Validation of Retention policy is successful");
            }

            CmdletModel.SimpleRetentionPolicy sqlRetentionPolicy =
                (CmdletModel.SimpleRetentionPolicy)((AzureSqlPolicy)policy).RetentionPolicy;
            ProtectionPolicyRequest hydraRequest = new ProtectionPolicyRequest()
            {
                Item = new ProtectionPolicyResource()
                {
                    Properties = new AzureSqlProtectionPolicy()
                    {
                        RetentionPolicy =
                            PolicyHelpers.GetServiceClientSimpleRetentionPolicy(sqlRetentionPolicy)
                    }
                }
            };

            return(ServiceClientAdapter.CreateOrUpdateProtectionPolicy(policy.Name,
                                                                       hydraRequest));
        }
 /// <summary>
 /// Constructs the retention policy object with default inits
 /// </summary>
 /// <returns>Default retention policy object</returns>
 public RetentionPolicyBase GetDefaultRetentionPolicyObject()
 {
     CmdletModel.SimpleRetentionPolicy defaultRetention =
         new CmdletModel.SimpleRetentionPolicy();
     defaultRetention.RetentionDurationType = defaultSqlRetentionType;
     defaultRetention.RetentionCount = defaultSqlRetentionCount;
     return defaultRetention;
 }