예제 #1
0
        internal virtual GetExecutionHistoryResponse GetExecutionHistory(GetExecutionHistoryRequest request)
        {
            var marshaller   = new GetExecutionHistoryRequestMarshaller();
            var unmarshaller = GetExecutionHistoryResponseUnmarshaller.Instance;

            return(Invoke <GetExecutionHistoryRequest, GetExecutionHistoryResponse>(request, marshaller, unmarshaller));
        }
        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);

            GetExecutionHistoryResponse resp = new GetExecutionHistoryResponse();

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

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

                foreach (var obj in resp.Events)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
예제 #3
0
        /// <summary>
        /// Initiates the asynchronous execution of the GetExecutionHistory operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the GetExecutionHistory operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/states-2016-11-23/GetExecutionHistory">REST API Reference for GetExecutionHistory Operation</seealso>
        public virtual Task <GetExecutionHistoryResponse> GetExecutionHistoryAsync(GetExecutionHistoryRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new GetExecutionHistoryRequestMarshaller();
            var unmarshaller = GetExecutionHistoryResponseUnmarshaller.Instance;

            return(InvokeAsync <GetExecutionHistoryRequest, GetExecutionHistoryResponse>(request, marshaller,
                                                                                         unmarshaller, cancellationToken));
        }
        /// <summary>
        /// Initiates the asynchronous execution of the GetExecutionHistory operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the GetExecutionHistory operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/states-2016-11-23/GetExecutionHistory">REST API Reference for GetExecutionHistory Operation</seealso>
        public virtual Task <GetExecutionHistoryResponse> GetExecutionHistoryAsync(GetExecutionHistoryRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = GetExecutionHistoryRequestMarshaller.Instance;
            options.ResponseUnmarshaller = GetExecutionHistoryResponseUnmarshaller.Instance;

            return(InvokeAsync <GetExecutionHistoryResponse>(request, options, cancellationToken));
        }
        internal virtual GetExecutionHistoryResponse GetExecutionHistory(GetExecutionHistoryRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = GetExecutionHistoryRequestMarshaller.Instance;
            options.ResponseUnmarshaller = GetExecutionHistoryResponseUnmarshaller.Instance;

            return(Invoke <GetExecutionHistoryResponse>(request, options));
        }
예제 #6
0
        public async Task Can_be_invoked_from_step_functions_local()
        {
            // 1. Create the StepFunctions Client
            var credentials = new BasicAWSCredentials("not", "used");
            var config      = new AmazonStepFunctionsConfig
            {
                ServiceURL = _stepFunctionsServiceUrl.ToString()
            };
            var client = new AmazonStepFunctionsClient(credentials, config);

            // 2. Create step machine with a single task the invokes a lambda function
            // The FunctionName contains the lambda to be invoked.
            var request = new CreateStateMachineRequest
            {
                Name       = "Foo",
                Type       = StateMachineType.STANDARD,
                Definition = @"{
  ""Comment"": ""A Hello World example demonstrating various state types of the Amazon States Language"",
  ""StartAt"": ""Invoke Lambda function"",
  ""States"": {
    ""Invoke Lambda function"": {
      ""Type"": ""Task"",
      ""Resource"": ""arn:aws:states:::lambda:invoke"",
      ""Parameters"": {
        ""FunctionName"": ""arn:aws:lambda:us-east-1:123456789012:function:SimpleLambdaFunction:$LATEST"",
        ""Payload"": {
          ""Input.$"": ""$.Payload""
        }
      },
      ""End"": true
    }
  }
}"
            };
            var createStateMachineResponse = await client.CreateStateMachineAsync(request);

            // 3. Create a StepFunction execution.
            var startExecutionRequest = new StartExecutionRequest
            {
                Name            = Guid.NewGuid().ToString(),
                StateMachineArn = createStateMachineResponse.StateMachineArn,
                Input           = @"{
""Payload"": { 
  ""Foo"": ""Bar"" 
  }
}"
            };
            var startExecutionResponse = await client.StartExecutionAsync(startExecutionRequest);

            var getExecutionHistoryRequest = new GetExecutionHistoryRequest
            {
                ExecutionArn         = startExecutionResponse.ExecutionArn,
                IncludeExecutionData = true,
            };

            // 4. Poll and wait for the
            while (true)
            {
                var getExecutionHistoryResponse = await client.GetExecutionHistoryAsync(getExecutionHistoryRequest);

                var historyEvent = getExecutionHistoryResponse.Events.Last();

                if (historyEvent.ExecutionSucceededEventDetails != null)
                {
                    _outputHelper.WriteLine("Execution succeeded");
                    _outputHelper.WriteLine(historyEvent.ExecutionSucceededEventDetails.Output);
                    break;
                }

                if (historyEvent.ExecutionFailedEventDetails != null)
                {
                    _outputHelper.WriteLine("Execution failed");
                    _outputHelper.WriteLine(historyEvent.ExecutionFailedEventDetails.Cause);
                    break;
                }
            }
        }