/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { StartExecutionResponse response = new StartExecutionResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("executionArn", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.ExecutionArn = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("startDate", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.StartDate = unmarshaller.Unmarshall(context); continue; } } return(response); }
private async Task <StartExecutionResponse> StartWorkflowInstanceAsync() { StartExecutionResponse status = null; try { LambdaLogger.Log("1. Lambda start1"); List <Quote> quotes = GetQuotesAsPerStage(2, 13);//2 RSM, 13 Submitted, LambdaLogger.Log("1. Lambda start2"); foreach (var item in quotes) { //Check if any Promotion is submitted //LambdaLogger.Log("1. Lambda start3"+ Directory.GetCurrentDirectory() + @"\iam.json"); //_CredentialProfileStoreChain = new CredentialProfileStoreChain( );//@"/iam.json" //LambdaLogger.Log("Profile Location="+_CredentialProfileStoreChain.ProfilesLocation); //AWSCredentials awsCredentials; //if (_CredentialProfileStoreChain.TryGetAWSCredentials("default", out awsCredentials))//local-test-profile //{ // if (awsCredentials != null) // { string inputToStepFunc = "{ \"quoteid\": \"" + item.QuoteID + "\", \"promodesc\" : \"" + item.TPBackground + "\" }"; var aws_access_key_id = Environment.GetEnvironmentVariable("aws_access_key_id"); var aws_secret_access_key = Environment.GetEnvironmentVariable("aws_secret_access_key"); using (AmazonStepFunctionsClient stepfunctions = new AmazonStepFunctionsClient(aws_access_key_id, aws_secret_access_key, Amazon.RegionEndpoint.USEast1)) { LambdaLogger.Log("Gocha credentials going to invoke Step function"); string nameunique = item.QuoteID + "_WF";//+"_" + DateTime.Now.ToString("ddMMyyyyHHmmssfff"); StartExecutionRequest newRequest = new StartExecutionRequest { StateMachineArn = "arn:aws:states:us-east-1:494875521123:stateMachine:ApprovalWorkflow", Input = inputToStepFunc, Name = nameunique }; LambdaLogger.Log("Step Func object is ready to be invoked."); status = await stepfunctions.StartExecutionAsync(newRequest); LambdaLogger.Log("Step Func invoke done" + status.ToString()); } //} //else // LambdaLogger.Log("Null AWS Credentilas found."); //} LambdaLogger.Log("Workflow is created for Quote id = " + item.QuoteID); } } catch (Exception ex) { LambdaLogger.Log("Error" + ex.ToString()); throw ex; } return(status); }
public static StartExecutionResponse Unmarshall(UnmarshallerContext context) { StartExecutionResponse startExecutionResponse = new StartExecutionResponse(); startExecutionResponse.HttpResponse = context.HttpResponse; startExecutionResponse.RequestId = context.StringValue("StartExecution.RequestId"); StartExecutionResponse.StartExecution_Execution execution = new StartExecutionResponse.StartExecution_Execution(); execution.ExecutionId = context.StringValue("StartExecution.Execution.ExecutionId"); execution.TemplateName = context.StringValue("StartExecution.Execution.TemplateName"); execution.TemplateId = context.StringValue("StartExecution.Execution.TemplateId"); execution.TemplateVersion = context.StringValue("StartExecution.Execution.TemplateVersion"); execution.Mode = context.StringValue("StartExecution.Execution.Mode"); execution.LoopMode = context.StringValue("StartExecution.Execution.LoopMode"); execution.ExecutedBy = context.StringValue("StartExecution.Execution.ExecutedBy"); execution.StartDate = context.StringValue("StartExecution.Execution.StartDate"); execution.EndDate = context.StringValue("StartExecution.Execution.EndDate"); execution.CreateDate = context.StringValue("StartExecution.Execution.CreateDate"); execution.UpdateDate = context.StringValue("StartExecution.Execution.UpdateDate"); execution.Status = context.StringValue("StartExecution.Execution.Status"); execution.StatusMessage = context.StringValue("StartExecution.Execution.StatusMessage"); execution.ParentExecutionId = context.StringValue("StartExecution.Execution.ParentExecutionId"); execution.Parameters = context.StringValue("StartExecution.Execution.Parameters"); execution.Outputs = context.StringValue("StartExecution.Execution.Outputs"); execution.SafetyCheck = context.StringValue("StartExecution.Execution.SafetyCheck"); execution.IsParent = context.BooleanValue("StartExecution.Execution.IsParent"); execution.Counters = context.StringValue("StartExecution.Execution.Counters"); execution.RamRole = context.StringValue("StartExecution.Execution.RamRole"); execution.Tags = context.StringValue("StartExecution.Execution.Tags"); execution.Description = context.StringValue("StartExecution.Execution.Description"); List <StartExecutionResponse.StartExecution_Execution.StartExecution_CurrentTask> execution_currentTasks = new List <StartExecutionResponse.StartExecution_Execution.StartExecution_CurrentTask>(); for (int i = 0; i < context.Length("StartExecution.Execution.CurrentTasks.Length"); i++) { StartExecutionResponse.StartExecution_Execution.StartExecution_CurrentTask currentTask = new StartExecutionResponse.StartExecution_Execution.StartExecution_CurrentTask(); currentTask.TaskExecutionId = context.StringValue("StartExecution.Execution.CurrentTasks[" + i + "].TaskExecutionId"); currentTask.TaskName = context.StringValue("StartExecution.Execution.CurrentTasks[" + i + "].TaskName"); currentTask.TaskAction = context.StringValue("StartExecution.Execution.CurrentTasks[" + i + "].TaskAction"); execution_currentTasks.Add(currentTask); } execution.CurrentTasks = execution_currentTasks; startExecutionResponse.Execution = execution; return(startExecutionResponse); }
public static StartExecutionResponse Unmarshall(UnmarshallerContext context) { StartExecutionResponse startExecutionResponse = new StartExecutionResponse(); startExecutionResponse.HttpResponse = context.HttpResponse; startExecutionResponse.RequestId = context.StringValue("StartExecution.RequestId"); startExecutionResponse.Name = context.StringValue("StartExecution.Name"); startExecutionResponse.FlowName = context.StringValue("StartExecution.FlowName"); startExecutionResponse.FlowDefinition = context.StringValue("StartExecution.FlowDefinition"); startExecutionResponse.Input = context.StringValue("StartExecution.Input"); startExecutionResponse.Output = context.StringValue("StartExecution.Output"); startExecutionResponse.Status = context.StringValue("StartExecution.Status"); startExecutionResponse.StartedTime = context.StringValue("StartExecution.StartedTime"); startExecutionResponse.StoppedTime = context.StringValue("StartExecution.StoppedTime"); return(startExecutionResponse); }
public async Task FunctionHandler(S3Event evnt, ILambdaContext context) { var s3Event = evnt.Records?[0].S3; if (s3Event == null) { return; } FileInfo fileInfo = new FileInfo { Bucket = s3Event.Bucket.Name, Key = s3Event.Object.Key }; string input = JsonConvert.SerializeObject(fileInfo); StartExecutionResponse response = await functionsClient.StartExecutionAsync(new StartExecutionRequest { Input = input, Name = Guid.NewGuid().ToString("N"), StateMachineArn = "arn:aws:states:us-east-1:518495728486:stateMachine:hackathon-2018-chegg" }).ConfigureAwait(false); }
public static StartExecutionResponse Unmarshall(UnmarshallerContext _ctx) { StartExecutionResponse startExecutionResponse = new StartExecutionResponse(); startExecutionResponse.HttpResponse = _ctx.HttpResponse; startExecutionResponse.RequestId = _ctx.StringValue("StartExecution.RequestId"); startExecutionResponse.Name = _ctx.StringValue("StartExecution.Name"); startExecutionResponse.FlowName = _ctx.StringValue("StartExecution.FlowName"); startExecutionResponse.FlowDefinition = _ctx.StringValue("StartExecution.FlowDefinition"); startExecutionResponse.Input = _ctx.StringValue("StartExecution.Input"); startExecutionResponse.Output = _ctx.StringValue("StartExecution.Output"); startExecutionResponse.Status = _ctx.StringValue("StartExecution.Status"); startExecutionResponse.StartedTime = _ctx.StringValue("StartExecution.StartedTime"); startExecutionResponse.StoppedTime = _ctx.StringValue("StartExecution.StoppedTime"); startExecutionResponse.ExternalInputUri = _ctx.StringValue("StartExecution.ExternalInputUri"); startExecutionResponse.ExternalOutputUri = _ctx.StringValue("StartExecution.ExternalOutputUri"); return(startExecutionResponse); }
public Status ProcessRequest(ResolverRequest request) { Status status = new Status(); status.Id = request.Id; status.ActionId = request.ActionId; try { String cueId = request.CueId; Config config = JsonTools.Convert <Config>(request.Signal.Cues[cueId].Resolver.Config); StepFunctionArn arn = new StepFunctionArn(config.Arn); RegionEndpoint region = RegionEndpoint.GetBySystemName(System.Environment.GetEnvironmentVariable("AWS_REGION")); if (!String.IsNullOrEmpty(arn.Region)) { region = RegionEndpoint.GetBySystemName(arn.Region); } AmazonStepFunctionsClient client = new AmazonStepFunctionsClient(region); // Set Region StartExecutionRequest exeRequest = new StartExecutionRequest { StateMachineArn = config.Arn, Input = JsonTools.Serialize(request) }; if (config.UseDefaultName == false) { if (String.IsNullOrWhiteSpace(config.ExecutionName)) { exeRequest.Name = $"syntinel-{request.Id}-{request.ActionId}"; } else { exeRequest.Name = config.ExecutionName; } } Task <StartExecutionResponse> t = client.StartExecutionAsync(exeRequest); t.Wait(30000); StartExecutionResponse response = t.Result; if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) { StepFunctionArn eArn = new StepFunctionArn(response.ExecutionArn); status.NewStatus = StatusType.SentToResolver; status.Message = $"Request Sent To Step Function [{eArn.Name}]. Execution Name [{eArn.ExecutionName}]."; } else { status.NewStatus = StatusType.Error; status.Message = $"Error Sending To Step Function [{arn.Name}]. {response.HttpStatusCode}"; } } catch (Exception e) { status.NewStatus = StatusType.Error; status.Message = e.Message; } return(status); }