示例#1
0
        static void DeleteVault(IAmazonGlacier glacier)
        {
            // PLEASE SEE THE IMPORTANT NOTE AT THE START OF THIS SAMPLE.
            //
            // This method shows how to delete a vault using the service api BUT will fail
            // to delete the vault created in the sample because the inventory job, started
            // in the RequestVaultInventory method, will not have completed at the time this
            // method runs. If the RequestVaultInventory method is not run, it can take up to
            // 24 hours for Glacier to schedule an inventory automatically.
            //
            // Check back in the AWS management console after a few hours and once the
            // inventory job is complete, delete the vault from within the console.

            var req = new DeleteVaultRequest
            {
                VaultName = VaultName
            };

            try
            {
                Task <DeleteVaultResponse> res = glacier.DeleteVaultAsync(req);
                Task.WaitAll(res);

                Console.WriteLine($"Deleted vault {VaultName}");
            }
            catch (Exception e)
            {
                Console.WriteLine($"Failed to delete vault {VaultName}. The service returned error: {e.Message}");
            }
        }
示例#2
0
 private Amazon.Glacier.Model.DeleteVaultResponse CallAWSServiceOperation(IAmazonGlacier client, Amazon.Glacier.Model.DeleteVaultRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Glacier", "DeleteVault");
     try
     {
         #if DESKTOP
         return(client.DeleteVault(request));
         #elif CORECLR
         return(client.DeleteVaultAsync(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;
     }
 }