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

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

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("nextToken", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.NextToken = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("stateMachines", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <StateMachineListItem, StateMachineListItemUnmarshaller>(StateMachineListItemUnmarshaller.Instance);
                    response.StateMachines = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
コード例 #2
0
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonStepFunctionsConfig config = new AmazonStepFunctionsConfig();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonStepFunctionsClient client = new AmazonStepFunctionsClient(creds, config);

            ListStateMachinesResponse resp = new ListStateMachinesResponse();

            do
            {
                ListStateMachinesRequest req = new ListStateMachinesRequest
                {
                    NextToken = resp.NextToken
                    ,
                    MaxResults = maxItems
                };

                resp = client.ListStateMachines(req);
                CheckError(resp.HttpStatusCode, "200");

                foreach (var obj in resp.StateMachines)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
コード例 #3
0
        public void SetUp()
        {
            _firstPage = new ListStateMachinesResponse
            {
                StateMachines = new List <StateMachineListItem>
                {
                    new StateMachineListItem
                    {
                        CreationDate    = DateTime.UtcNow,
                        Name            = "MyStepFunction1",
                        StateMachineArn = "arn:aws:states:eu-west-1:12345678:stateMachine:MyStepFunction1"
                    }
                },
                NextToken = "token-1"
            };
            _secondPage = new ListStateMachinesResponse
            {
                StateMachines = new List <StateMachineListItem>
                {
                    new StateMachineListItem
                    {
                        CreationDate    = DateTime.UtcNow,
                        Name            = "MyStepFunction2",
                        StateMachineArn = "arn:aws:states:eu-west-1:12345678:stateMachine:MyStepFunction2"
                    }
                },
                NextToken = "token-2"
            };
            _thirdPage = new ListStateMachinesResponse
            {
                StateMachines = new List <StateMachineListItem>
                {
                    new StateMachineListItem
                    {
                        CreationDate    = DateTime.UtcNow,
                        Name            = "MyStepFunction3",
                        StateMachineArn = "arn:aws:states:eu-west-1:12345678:stateMachine:MyStepFunction3"
                    }
                },
                NextToken = null
            };

            var stepFunctionsClient = new Mock <IAmazonStepFunctions>();

            stepFunctionsClient.Setup(c => c.ListStateMachinesAsync(
                                          It.Is <ListStateMachinesRequest>(r => r.NextToken == null),
                                          It.IsAny <CancellationToken>()))
            .ReturnsAsync(_firstPage);

            stepFunctionsClient.Setup(c => c.ListStateMachinesAsync(
                                          It.Is <ListStateMachinesRequest>(r => r.NextToken == "token-1"),
                                          It.IsAny <CancellationToken>()))
            .ReturnsAsync(_secondPage);

            stepFunctionsClient.Setup(c => c.ListStateMachinesAsync(
                                          It.Is <ListStateMachinesRequest>(r => r.NextToken == "token-2"),
                                          It.IsAny <CancellationToken>()))
            .ReturnsAsync(_thirdPage);

            _source = new StepFunctionSource(stepFunctionsClient.Object);
        }