/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Text;
using System.IO;
namespace Amazon.S3.Model
{
///
/// Describes where logs are stored and the prefix that Amazon S3 assigns to all log object
/// keys for a bucket. For more information, see PUT
/// Bucket logging in the Amazon S3 API Reference.
///
public class S3BucketLoggingConfig
{
private List targetGrants = new List();
///
/// Specifies the bucket where you want Amazon S3 to store server access logs. You can have your logs delivered to any bucket that you own,
/// including the same bucket that is being logged. You can also configure multiple buckets to deliver their logs to the same target bucket. In
/// this case you should choose a different TargetPrefix for each source bucket so that the delivered log files can be distinguished by key.
///
public string TargetBucketName { get; set; }
// Check to see if TargetBucket property is set
internal bool IsSetTargetBucket()
{
return this.TargetBucketName != null;
}
///
/// A collection of grants.
///
///
/// Buckets that use the bucket owner enforced setting for Object Ownership don't support
/// target grants. For more information, see Permissions
/// for server access log delivery in the Amazon S3 User Guide.
///
///
public List Grants
{
get { return this.targetGrants; }
set { this.targetGrants = value; }
}
// Check to see if TargetGrants property is set
internal bool IsSetGrants()
{
return this.targetGrants.Count > 0;
}
///
/// Gets and sets the property TargetPrefix.
///
/// A prefix for all log object keys. If you store log files from multiple Amazon S3 buckets
/// in a single bucket, you can use a prefix to distinguish which log files came from
/// which bucket.
///
///
public string TargetPrefix { get; set; }
// Check to see if TargetPrefix property is set
internal bool IsSetTargetPrefix()
{
return this.TargetPrefix != null;
}
///
/// Creates a S3Grant and adds it to the list of grants.
///
/// The grantee for the grant.
/// The permission for the grantee.
public void AddGrant(S3Grantee grantee, S3Permission permission)
{
S3Grant grant = new S3Grant{ Grantee = grantee, Permission = permission };
Grants.Add(grant);
}
///
/// Removes a specific permission for the given grantee.
///
/// The grantee
/// The permission for the grantee to remove
public void RemoveGrant(S3Grantee grantee, S3Permission permission)
{
foreach (S3Grant grant in Grants)
{
if (grant.Grantee.Equals(grantee) && grant.Permission == permission)
{
Grants.Remove(grant);
break;
}
}
}
///
/// Removes all permissions for the given grantee.
///
///
public void RemoveGrant(S3Grantee grantee)
{
List removeList = new List();
foreach (S3Grant grant in Grants)
{
if (grant.Grantee.Equals(grantee))
{
removeList.Add(grant);
}
}
foreach (S3Grant grant in removeList)
{
this.Grants.Remove(grant);
}
}
}
}