Esempio n. 1
0
        public static string CreateEventSourceMapping(string eventSourceArn)
        {
            string uuid = "";

            try
            {
                AmazonLambdaClient lambdaClient;

                using (lambdaClient = new AmazonLambdaClient(Models.MyAWSConfigs.KinesisRegion))
                {
                    CreateEventSourceMappingRequest eventSourceMappingRequest = new CreateEventSourceMappingRequest
                    {
                        EventSourceArn = eventSourceArn,
                        BatchSize      = 100,
                        MaximumBatchingWindowInSeconds = 0,
                        StartingPosition = EventSourcePosition.LATEST,
                        Enabled          = true,
                        FunctionName     = MyAWSConfigs.LambdaFunctionName,
                    };
                    CreateEventSourceMappingResponse eventSourceMappingResponse = lambdaClient.CreateEventSourceMapping(eventSourceMappingRequest);

                    uuid = eventSourceMappingResponse.UUID;

                    string state = eventSourceMappingResponse.State;
                    while (state != "Enabled")
                    {
                        Thread.Sleep(1 * 1000);

                        GetEventSourceMappingRequest getRequest = new GetEventSourceMappingRequest
                        {
                            UUID = uuid,
                        };
                        GetEventSourceMappingResponse getResponse = lambdaClient.GetEventSourceMapping(getRequest);

                        state = getResponse.State;
                    }
                }
            }
            catch (AmazonLambdaException e)
            {
                Console.WriteLine("AmazonLambdaException: " + e);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e);
            }

            return(uuid);
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateEventSourceMappingResponse response = new CreateEventSourceMappingResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("BatchSize", targetDepth))
                {
                    var unmarshaller = IntUnmarshaller.Instance;
                    response.BatchSize = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("EventSourceArn", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.EventSourceArn = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("FunctionArn", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.FunctionArn = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("LastModified", targetDepth))
                {
                    var unmarshaller = DateTimeUnmarshaller.Instance;
                    response.LastModified = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("LastProcessingResult", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.LastProcessingResult = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("State", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.State = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("StateTransitionReason", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.StateTransitionReason = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("UUID", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.UUID = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
Esempio n. 3
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateEventSourceMappingResponse response = new CreateEventSourceMappingResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("BatchSize", targetDepth))
                {
                    var unmarshaller = IntUnmarshaller.Instance;
                    response.BatchSize = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("BisectBatchOnFunctionError", targetDepth))
                {
                    var unmarshaller = BoolUnmarshaller.Instance;
                    response.BisectBatchOnFunctionError = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("DestinationConfig", targetDepth))
                {
                    var unmarshaller = DestinationConfigUnmarshaller.Instance;
                    response.DestinationConfig = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("EventSourceArn", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.EventSourceArn = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("FunctionArn", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.FunctionArn = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("LastModified", targetDepth))
                {
                    var unmarshaller = DateTimeUnmarshaller.Instance;
                    response.LastModified = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("LastProcessingResult", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.LastProcessingResult = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("MaximumBatchingWindowInSeconds", targetDepth))
                {
                    var unmarshaller = IntUnmarshaller.Instance;
                    response.MaximumBatchingWindowInSeconds = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("MaximumRecordAgeInSeconds", targetDepth))
                {
                    var unmarshaller = IntUnmarshaller.Instance;
                    response.MaximumRecordAgeInSeconds = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("MaximumRetryAttempts", targetDepth))
                {
                    var unmarshaller = IntUnmarshaller.Instance;
                    response.MaximumRetryAttempts = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("ParallelizationFactor", targetDepth))
                {
                    var unmarshaller = IntUnmarshaller.Instance;
                    response.ParallelizationFactor = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("State", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.State = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("StateTransitionReason", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.StateTransitionReason = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("UUID", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.UUID = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
Esempio n. 4
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateEventSourceMappingResponse response = new CreateEventSourceMappingResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("BatchSize", targetDepth))
                {
                    var unmarshaller = IntUnmarshaller.Instance;
                    response.BatchSize = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("BisectBatchOnFunctionError", targetDepth))
                {
                    var unmarshaller = BoolUnmarshaller.Instance;
                    response.BisectBatchOnFunctionError = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("DestinationConfig", targetDepth))
                {
                    var unmarshaller = DestinationConfigUnmarshaller.Instance;
                    response.DestinationConfig = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("EventSourceArn", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.EventSourceArn = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("FilterCriteria", targetDepth))
                {
                    var unmarshaller = FilterCriteriaUnmarshaller.Instance;
                    response.FilterCriteria = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("FunctionArn", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.FunctionArn = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("FunctionResponseTypes", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <string, StringUnmarshaller>(StringUnmarshaller.Instance);
                    response.FunctionResponseTypes = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("LastModified", targetDepth))
                {
                    var unmarshaller = DateTimeUnmarshaller.Instance;
                    response.LastModified = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("LastProcessingResult", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.LastProcessingResult = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("MaximumBatchingWindowInSeconds", targetDepth))
                {
                    var unmarshaller = IntUnmarshaller.Instance;
                    response.MaximumBatchingWindowInSeconds = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("MaximumRecordAgeInSeconds", targetDepth))
                {
                    var unmarshaller = IntUnmarshaller.Instance;
                    response.MaximumRecordAgeInSeconds = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("MaximumRetryAttempts", targetDepth))
                {
                    var unmarshaller = IntUnmarshaller.Instance;
                    response.MaximumRetryAttempts = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("ParallelizationFactor", targetDepth))
                {
                    var unmarshaller = IntUnmarshaller.Instance;
                    response.ParallelizationFactor = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Queues", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <string, StringUnmarshaller>(StringUnmarshaller.Instance);
                    response.Queues = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("SelfManagedEventSource", targetDepth))
                {
                    var unmarshaller = SelfManagedEventSourceUnmarshaller.Instance;
                    response.SelfManagedEventSource = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("SourceAccessConfigurations", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <SourceAccessConfiguration, SourceAccessConfigurationUnmarshaller>(SourceAccessConfigurationUnmarshaller.Instance);
                    response.SourceAccessConfigurations = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("StartingPosition", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.StartingPosition = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("StartingPositionTimestamp", targetDepth))
                {
                    var unmarshaller = DateTimeUnmarshaller.Instance;
                    response.StartingPositionTimestamp = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("State", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.State = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("StateTransitionReason", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.StateTransitionReason = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Topics", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <string, StringUnmarshaller>(StringUnmarshaller.Instance);
                    response.Topics = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("TumblingWindowInSeconds", targetDepth))
                {
                    var unmarshaller = IntUnmarshaller.Instance;
                    response.TumblingWindowInSeconds = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("UUID", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.UUID = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }