Ejemplo n.º 1
0
        /// <summary>
        /// Enables versioning on the bucket. Once versioning is enabled you can not "un-version" the bucket. You can however suspend versioning on the bucket.
        /// </summary>
        public void EnableBucketVersioning()
        {
            try
            {
                using (AmazonS3 s3 = AWSClientFactory.CreateAmazonS3Client(this.cloudServiceConfigProvider.AWSAccessKeyId, this.cloudServiceConfigProvider.AWSSecretKey))
                {
                    S3BucketVersioningConfig versioningConfig = new S3BucketVersioningConfig()
                        .WithStatus("Enabled");
                    SetBucketVersioningRequest setBucketVersioningReq = new SetBucketVersioningRequest()
                        .WithBucketName(this.cloudServiceConfigProvider.AmazonBucket)
                        .WithVersioningConfig(versioningConfig);

                    s3.SetBucketVersioning(setBucketVersioningReq);
                }
            }
            catch (Exception ex)
            {
                throw new CloudServiceException(ex, "Error occured when enabling versioning on the bucket {0}", this.cloudServiceConfigProvider.AmazonBucket);
            }
        }
 /// <summary>
 /// Sets the versioning configuration to apply to the bucket.
 /// </summary>
 /// <remarks>
 /// Once Versioning has been "Enabled" on a bucket, it can be "Suspended" 
 /// but cannot be switched "Off". If EnableMfaDelete is set,
 /// the MfaCodes property needs to contain the Serial of and current Token
 /// displayed on the MFA device.
 /// </remarks>
 /// <param name="config">The versioning configuration to apply</param>
 /// <returns>this instance</returns>
 public SetBucketVersioningRequest WithVersioningConfig(S3BucketVersioningConfig config)
 {
     VersioningConfig = config;
     return this;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Sets the VersioningConfig property for this request.
 /// The request modifies the Versioning Status of the S3 Bucket to this value.
 /// </summary>
 /// <param name="config">The value that VersioningConfig is set to</param>
 /// <returns>this instance</returns>
 public SetBucketVersioningRequest WithVersioningConfig(S3BucketVersioningConfig config)
 {
     VersioningConfig = config;
     return(this);
 }