Beispiel #1
0
        public void AzureStorageServiceDeleteRetentionPolicy_PassThru()
        {
            int retentionDays = 7;

            //Enable DeleteRetentionPolicy
            Test.Assert(CommandAgent.EnableAzureStorageDeleteRetentionPolicy(retentionDays, PassThru: true), "EnableAzureStorageDeleteRetentionPolicy with retentionDays {0} should success.", retentionDays);
            PSDeleteRetentionPolicy policy = CommandAgent.Output[0][PowerShellAgent.BaseObject] as PSDeleteRetentionPolicy;

            Test.Assert(policy.Enabled, "DeleteRetentionPolicy Enabled should be enabled.");
            ExpectEqual(retentionDays, policy.RetentionDays.Value, "retentionDays");

            //Disable DeleteRetentionPolicy
            Test.Assert(CommandAgent.DisableAzureStorageDeleteRetentionPolicy(PassThru: true), "DisableAzureStorageDeleteRetentionPolicy should success.");
            policy = CommandAgent.Output[0][PowerShellAgent.BaseObject] as PSDeleteRetentionPolicy;

            Test.Assert(!policy.Enabled, "DeleteRetentionPolicy Enabled should be disabled.");
            Test.Assert(policy.RetentionDays == null, "DeleteRetentionPolicy RetentionDays should be null.");
        }
        public override void ExecuteCmdlet()
        {
            StorageServiceType serviceType = StorageServiceType.Blob;

            if (ShouldProcess(serviceType.ToString(), "Enable Delete Retention Policy"))
            {
                ServiceProperties serviceProperties = Channel.GetStorageServiceProperties(serviceType, GetRequestOptions(serviceType), OperationContext);

                DisableDeleteRetentionProperties(serviceProperties);

                Channel.SetStorageServiceProperties(serviceType, serviceProperties,
                                                    GetRequestOptions(serviceType), OperationContext);

                if (PassThru)
                {
                    WriteObject(PSDeleteRetentionPolicy.ParsePSDeleteRetentionPolicy(serviceProperties.DeleteRetentionPolicy));
                }
            }
        }