コード例 #1
0
        public void TestDeletePublicAccessBlock()
        {
            try
            {
                //Add public access block configuration
                PublicAccessBlockConfiguration configuration;
                Call_PutPublicAccessBlock(s3Client, bucketName, out configuration);

                //Verify the configuration exists
                Call_GetPublicAccessBlock(s3Client, bucketName, configuration);

                //Delete the configuration
                var deleteRequest = new DeletePublicAccessBlockRequest
                {
                    BucketName = bucketName
                };
                var deleteResponse = s3Client.DeletePublicAccessBlock(deleteRequest);
                Assert.AreEqual(true, deleteResponse.HttpStatusCode == HttpStatusCode.NoContent);

                //Verify the configuration was deleted. This call will throw a public access block configuration was not found message.
                Call_GetPublicAccessBlock(s3Client, bucketName, null);
            }
            catch (AmazonS3Exception ex)
            {
                Assert.AreEqual <string>("The public access block configuration was not found", ex.Message);
                throw;
            }
        }
コード例 #2
0
 private Amazon.S3.Model.DeletePublicAccessBlockResponse CallAWSServiceOperation(IAmazonS3 client, Amazon.S3.Model.DeletePublicAccessBlockRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Storage Service (S3)", "DeletePublicAccessBlock");
     try
     {
         #if DESKTOP
         return(client.DeletePublicAccessBlock(request));
         #elif CORECLR
         return(client.DeletePublicAccessBlockAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }