Esempio n. 1
0
        public async Task PutNotification(string id = "", string functionArn = "", string s3Event = "")
        {
            LambdaFunctionConfiguration lambdaConfig = null;

            if (id != "")
            {
                var events = new List <EventType>();
                events.Add(new EventType(s3Event));
                lambdaConfig = new LambdaFunctionConfiguration()
                {
                    FunctionArn = functionArn,
                    Id          = id,
                    Events      = events
                };
            }

            var request = new PutBucketNotificationRequest()
            {
                BucketName = BucketName,
                LambdaFunctionConfigurations = new List <LambdaFunctionConfiguration>()
                {
                    lambdaConfig
                }
            };
            var response = await client.PutBucketNotificationAsync(request);
        }
        private static void UnmarshallResult(XmlUnmarshallerContext context, GetBucketNotificationResponse 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("TopicConfiguration", targetDepth))
                    {
                        response.TopicConfigurations.Add(TopicConfigurationUnmarshaller.Instance.Unmarshall(context));
                        continue;
                    }
                    if (context.TestExpression("QueueConfiguration", targetDepth))
                    {
                        response.QueueConfigurations.Add(QueueConfigurationUnmarshaller.Instance.Unmarshall(context));
                        continue;
                    }
                    if (context.TestExpression("CloudFunctionConfiguration", targetDepth))
                    {
                        var cfc = CloudFunctionConfigurationUnmarshaller.Instance.Unmarshall(context);
                        if (cfc == null || cfc.IsSetInvocationRole())
                        {
                            response.CloudFunctionConfigurations.Add(cfc);
                        }
                        else
                        {
                            var lfc = new LambdaFunctionConfiguration
                            {
                                FunctionArn = cfc.CloudFunction,
                                Events      = cfc.Events,
                                Id          = cfc.Id
                            };
                            response.LambdaFunctionConfigurations.Add(lfc);
                        }
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth < originalDepth)
                {
                    return;
                }
            }

            return;
        }