private static void UnmarshallResult(XmlUnmarshallerContext context, GetBucketReplicationResponse response)
        {
            int currentDepth = context.get_CurrentDepth();
            int num          = currentDepth + 1;

            if (context.get_IsStartOfDocument())
            {
                num += 2;
            }
            while (context.Read())
            {
                if (context.get_IsStartElement() || context.get_IsAttribute())
                {
                    if (context.TestExpression("Role", num))
                    {
                        response.Configuration.Role = StringUnmarshaller.GetInstance().Unmarshall(context);
                    }
                    else if (context.TestExpression("Rule", num))
                    {
                        response.Configuration.Rules.Add(ReplicationRuleUnmarshaller.Instance.Unmarshall(context));
                    }
                }
                else if (context.get_IsEndElement() && context.get_CurrentDepth() < currentDepth)
                {
                    break;
                }
            }
        }
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            GetBucketReplicationResponse getBucketReplicationResponse = new GetBucketReplicationResponse();

            while (context.Read())
            {
                if (context.get_IsStartElement())
                {
                    UnmarshallResult(context, getBucketReplicationResponse);
                }
            }
            return(getBucketReplicationResponse);
        }
        private static async Task RetrieveReplicationConfigurationAsync(IAmazonS3 client)
        {
            // Retrieve the configuration.
            GetBucketReplicationRequest getRequest = new GetBucketReplicationRequest
            {
                BucketName = sourceBucket
            };
            GetBucketReplicationResponse getResponse = await client.GetBucketReplicationAsync(getRequest);

            // Print.
            Console.WriteLine("Printing replication configuration information...");
            Console.WriteLine("Role ARN: {0}", getResponse.Configuration.Role);
            foreach (var rule in getResponse.Configuration.Rules)
            {
                Console.WriteLine("ID: {0}", rule.Id);
                Console.WriteLine("Prefix: {0}", rule.Prefix);
                Console.WriteLine("Status: {0}", rule.Status);
            }
        }
Example #4
0
        /// <summary>
        /// This method retrieves the replication configuration for the Amazon S3
        /// source bucket and displays the information in the Amazon S3 console.
        /// </summary>
        /// <param name="client">The initialized Amazon S3 client object used to call
        /// GetBucketReplicationAsync.</param>
        /// <param name="sourceBucket">A string representing the name of the
        /// source bucket.</param>
        private static async Task RetrieveReplicationConfigurationAsync(IAmazonS3 client, string sourceBucket)
        {
            // Retrieve the configuration for the source bucket.
            GetBucketReplicationRequest getRequest = new()
            {
                BucketName = sourceBucket,
            };

            GetBucketReplicationResponse getResponse = await client.GetBucketReplicationAsync(getRequest);

            // Display the details of the configuration on the console.
            Console.WriteLine("Printing replication configuration information...");
            Console.WriteLine($"Role ARN: {getResponse.Configuration.Role}");
            foreach (var rule in getResponse.Configuration.Rules)
            {
                Console.WriteLine($"ID: {rule.Id}");
                Console.WriteLine($"Prefix: {rule.Filter}");
                Console.WriteLine($"Status: {rule.Status}");
            }
        }
Example #5
0
        private static void UnmarshallResult(XmlUnmarshallerContext context, GetBucketReplicationResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 2;
            }

            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("Role", targetDepth))
                    {
                        response.Configuration.Role = StringUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }

                    if (context.TestExpression("Rule", targetDepth))
                    {
                        response.Configuration.Rules.Add(ReplicationRuleUnmarshaller.Instance.Unmarshall(context));

                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth < originalDepth)
                {
                    return;
                }
            }



            return;
        }