Example #1
0
        private static void CreateBucketWithObjectLockConfiguration()
        {
            bucketName = S3TestUtils.CreateBucketWithWait(Client, new PutBucketRequest
            {
                ObjectLockEnabledForBucket = true,
            });

            var objectLockConfiguration = new ObjectLockConfiguration();

            objectLockConfiguration.ObjectLockEnabled = ObjectLockEnabled.Enabled;
            objectLockConfiguration.Rule = new ObjectLockRule
            {
                DefaultRetention = new DefaultRetention
                {
                    Days = 1,
                    Mode = ObjectLockRetentionMode.Governance
                }
            };

            var putRequest = new PutObjectLockConfigurationRequest
            {
                BucketName              = bucketName,
                RequestPayer            = RequestPayer.Requester,
                ObjectLockConfiguration = objectLockConfiguration
            };

            var putResponse = Client.PutObjectLockConfiguration(putRequest);
        }
Example #2
0
        public PutObjectLockConfigurationResponse AddObjectLockConfiguration()
        {
            var objectLockConfiguration = new ObjectLockConfiguration();

            objectLockConfiguration.ObjectLockEnabled = ObjectLockEnabled.Enabled;
            objectLockConfiguration.Rule = new ObjectLockRule
            {
                DefaultRetention = new DefaultRetention
                {
                    Days = 1,
                    Mode = ObjectLockRetentionMode.Governance
                }
            };

            var putRequest = new PutObjectLockConfigurationRequest
            {
                BucketName              = bucketName,
                RequestPayer            = RequestPayer.Requester,
                ObjectLockConfiguration = objectLockConfiguration
            };

            var putResponse = Client.PutObjectLockConfiguration(putRequest);

            Assert.AreEqual(true, putResponse.HttpStatusCode == HttpStatusCode.OK);

            return(putResponse);
        }
        public PutObjectLockConfigurationResponse AddObjectLockConfiguration()
        {
            var objectLockConfiguration = new ObjectLockConfiguration();

            objectLockConfiguration.ObjectLockEnabled = ObjectLockEnabled.Enabled;
            objectLockConfiguration.Rule = new ObjectLockRule
            {
                DefaultRetention = new DefaultRetention
                {
                    Days = 1,
                    Mode = ObjectLockRetentionMode.Governance
                }
            };

            var putRequest = new PutObjectLockConfigurationRequest
            {
                BucketName              = bucketName,
                RequestPayer            = RequestPayer.Requester,
                ObjectLockConfiguration = objectLockConfiguration
            };

            var putResponse = Client.PutObjectLockConfiguration(putRequest);

            Assert.AreEqual(true, putResponse.HttpStatusCode == HttpStatusCode.OK);

            //Make sure the object lock has been enabled
            var getRequest = new GetObjectLockConfigurationRequest()
            {
                BucketName = bucketName
            };
            var getResponse = S3TestUtils.WaitForConsistency(() =>
            {
                var res = Client.GetObjectLockConfiguration(getRequest);
                return(res.ObjectLockConfiguration?.ObjectLockEnabled == ObjectLockEnabled.Enabled ? res : null);
            });

            return(putResponse);
        }
 public Task <PutObjectLockConfigurationResponse> PutObjectLockConfigurationAsync(PutObjectLockConfigurationRequest request, CancellationToken cancellationToken = default)
 {
     throw new NotImplementedException();
 }