AWS SDK for .NET Documentation
GetLifecycleConfigurationRequest Class
AmazonAmazon.S3.ModelGetLifecycleConfigurationRequest Did this page help you?   Yes   No    Tell us about it...
The parameters to request the lifecycle configuration settings for a bucket.
Declaration Syntax
C#
public class GetLifecycleConfigurationRequest : S3Request
Members
All MembersConstructorsMethodsProperties



IconMemberDescription
GetLifecycleConfigurationRequest()()()()
Initializes a new instance of the GetLifecycleConfigurationRequest class

AddHeader(String, String)
Adds the header to the collection of headers for the request.
(Inherited from S3Request.)
AddHeaders(NameValueCollection)
Adds all of the specified key/value pairs into the request headers collection.
(Inherited from S3Request.)
BucketName
The name of the bucket to be queried.

Equals(Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
GetHashCode()()()()
Serves as a hash function for a particular type.
(Inherited from Object.)
GetType()()()()
Gets the type of the current instance.
(Inherited from Object.)
InputStream
Input stream for the request; content for the request will be read from the stream.
(Inherited from S3Request.)
ReadWriteTimeout
Overrides the default HttpWebRequest ReadWriteTimeout value.
(Inherited from S3Request.)
Timeout
Overrides the default HttpWebRequest timeout value.
(Inherited from S3Request.)
ToString()()()() (Inherited from S3Request.)
WithBucketName(String) Obsolete.
Sets the name of the bucket to be queried.

WithInputStream(Stream) Obsolete.
Sets an input stream for the request; content for the request will be read from the stream.
(Inherited from S3Request.)
WithReadWriteTimeout(Int32) Obsolete.
Overrides the default HttpWebRequest ReadWriteTimeout value.
(Inherited from S3Request.)
WithTimeout(Int32) Obsolete.
Overrides the default HttpWebRequest timeout value.
(Inherited from S3Request.)
Examples

This example shows how to Get, Put and Delete bucket Lifecycle Configurations.
A Lifecycle Configuration allows an owner to configure when specific objects should be deleted. Objects to be deleted are specified with a prefix.
The configuration being used has rules that delete objects with a specific prefix and objects in a specific subdirectory.

CopyLifecycleConfiguration samples
// Create a client
AmazonS3Client client = new AmazonS3Client();


// Put sample lifecycle configuration (overwrite an existing configuration)
LifecycleConfiguration newConfiguration = new LifecycleConfiguration
{
    Rules = new List<LifecycleRule>
    {
        // Rule to delete keys with prefix "Test-" after 5 days
        new LifecycleRule
        {
            Prefix = "Test-",
            Expiration = new LifecycleRuleExpiration { Days = 5 }
        },
        // Rule to delete keys in subdirectory "Logs" after 2 days
        new LifecycleRule
        {
            Prefix = "Logs/",
            Expiration = new LifecycleRuleExpiration  { Days = 2 },
            Id = "log-file-removal"
        }
    }
};
PutLifecycleConfigurationRequest putRequest = new PutLifecycleConfigurationRequest
{
    BucketName = "SampleBucket",
    Configuration = newConfiguration
};
client.PutLifecycleConfiguration(putRequest);


// Retrieve current configuration
GetLifecycleConfigurationRequest getRequest = new GetLifecycleConfigurationRequest
{
    BucketName = "SampleBucket"
};
LifecycleConfiguration configuration = client.GetLifecycleConfiguration(getRequest).Configuration;

Console.WriteLine("Configuration contains {0} rules", configuration.Rules.Count);
foreach (LifecycleRule rule in configuration.Rules)
{
    Console.WriteLine("Rule");
    Console.WriteLine(" Prefix = " + rule.Prefix);
    Console.WriteLine(" Expiration (days) = " + rule.Expiration.Days);
    Console.WriteLine(" Id = " + rule.Id);
    Console.WriteLine(" Status = " + rule.Status);
}


// Put a new configuration and overwrite the existing configuration
configuration.Rules.RemoveAt(0);    // remove first rule
client.PutLifecycleConfiguration(putRequest);

// Delete current configuration
DeleteLifecycleConfigurationRequest deleteRequest = new DeleteLifecycleConfigurationRequest
{
    BucketName = "SampleBucket"
};
client.DeleteLifecycleConfiguration(deleteRequest);


// Retrieve current configuration and verify that it is null
configuration = client.GetLifecycleConfiguration(getRequest).Configuration;
Debug.Assert(configuration == null);
Inheritance Hierarchy
Object
S3Request
 GetLifecycleConfigurationRequest

Assembly: AWSSDK (Module: AWSSDK) Version: 1.5.60.0 (1.5.60.0)