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);
        }
Пример #2
0
 public Task <GetObjectLockConfigurationResponse> GetObjectLockConfigurationAsync(GetObjectLockConfigurationRequest request, CancellationToken cancellationToken = default)
 {
     throw new NotImplementedException();
 }