/* * Copyright 2010-2013 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 { /// Logging Enabled /// 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. /// 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; } /// /// This element lets you specify a prefix for the keys that the log files will be stored under. /// 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); } } } }