User guide
Resource APIs
The SDK for .NET provides the AWS Resource APIs for .NET for programming with Amazon Glacier.
These resource APIs provide a resource-level programming model that enables you to write code to work
more directly with Amazon Glacier resources as compared to their low-level and high-level API counterparts.
(For more information about the AWS Resource APIs for .NET, including how to download and reference
these resource APIs, see AWS Resource APIs for .NET (p. 41).)
The following example shows how to use the AWS Resource APIs for .NET to list accessible vaults in
Amazon Glacier:
// using Amazon.Glacier.Resources;
// using Amazon.Runtime.Resources;
var g = new Glacier();
foreach (var vault in g.GetVaults())
{
Console.WriteLine("Vault: {0}", vault.Name);
Console.WriteLine(" Creation date: {0}", vault.CreationDate);
Console.WriteLine(" Size in bytes: {0}", vault.SizeInBytes);
Console.WriteLine(" Number of archives: {0}", vault.NumberOfArchives);
try
{
var n = vault.GetNotification();
Console.WriteLine(" Notifications:");
Console.WriteLine(" Topic: {0}", n.SNSTopic);
var events = n.Events;
if (events.Any())
{
Console.WriteLine(" Events:");
foreach (var e in events)
{
Console.WriteLine("{0}", e);
}
}
else
{
Console.WriteLine(" No events set.");
}
}
catch (ResourceLoadException)
{
Console.WriteLine(" No notifications set.");
}
var jobs = vault.GetJobs();
if (jobs.Any())
{
Console.WriteLine(" Jobs:");
Version v2.0.0
90
AWS SDK for .NET Developer Guide
Programming Models