com.amazonaws.services.stepfunctions.AWSStepFunctionsClientBuilder Java Examples
The following examples show how to use
com.amazonaws.services.stepfunctions.AWSStepFunctionsClientBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AmazonAsyncDockerClientsHolder.java From spring-localstack with Apache License 2.0 | 5 votes |
@Override public AWSStepFunctions awsStepFunctions() { return decorateWithConfigsAndBuild( AWSStepFunctionsClientBuilder.standard(), LocalstackDocker::getEndpointStepFunction ); }
Example #2
Source File: AmazonDockerClientsHolder.java From spring-localstack with Apache License 2.0 | 5 votes |
@Override public AWSStepFunctions awsStepFunctions() { return decorateWithConfigsAndBuild( AWSStepFunctionsClientBuilder.standard(), LocalstackDocker::getEndpointStepFunction ); }
Example #3
Source File: S3TriggerImageProcessingHandler.java From smart-security-camera with GNU General Public License v3.0 | 5 votes |
@Override public Parameters handleRequest(S3Event event, Context context) { context.getLogger() .log("Input Function [" + context.getFunctionName() + "], S3Event [" + event.toJson().toString() + "]"); Parameters parameters = new Parameters( event.getRecords().get(0).getS3().getBucket().getName(), event.getRecords().get(0).getS3().getObject().getKey(), UUID.randomUUID()); AWSStepFunctions client = AWSStepFunctionsClientBuilder.defaultClient(); ObjectMapper jsonMapper = new ObjectMapper(); StartExecutionRequest request = new StartExecutionRequest(); request.setStateMachineArn(System.getenv("STEP_MACHINE_ARN")); request.setName(parameters.getStepFunctionID().toString()); try { request.setInput(jsonMapper.writeValueAsString(parameters)); } catch (JsonProcessingException e) { throw new AmazonServiceException("Error in ["+context.getFunctionName()+"]", e); } context.getLogger() .log("Step Function [" + request.getStateMachineArn() + "] will be called with [" + request.getInput() + "]"); StartExecutionResult result = client.startExecution(request); context.getLogger() .log("Output Function [" + context.getFunctionName() + "], Result [" + result.toString() + "]"); return parameters; }
Example #4
Source File: StepFunctionsSample.java From aws-doc-sdk-examples with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { /* * The ProfileCredentialsProvider will return your [default] * credential profile by reading from the credentials file located at * (~/.aws/credentials). * * It is possible to use another profile with: * credentialsProvider = new ProfileCredentialsProvider("your-profile") */ ProfileCredentialsProvider credentialsProvider = new ProfileCredentialsProvider(); try { credentialsProvider.getCredentials(); } catch (Exception e) { throw new AmazonClientException( "Cannot load the credentials from the credential profiles " + "file. Please make sure that your credentials file is " + "at the correct location (~/.aws/credentials), and is " + "in valid format.", e); } Regions region = Regions.US_EAST_1; AWSStepFunctions sfnClient = AWSStepFunctionsClientBuilder.standard() .withCredentials(credentialsProvider) .withRegion(region) .build(); System.out.println("==========================================="); System.out.println("Getting Started with Amazon Step Functions"); System.out.println("===========================================\n"); try { System.out.println("Listing state machines"); ListStateMachinesResult listStateMachinesResult = sfnClient. listStateMachines(new ListStateMachinesRequest()); List<StateMachineListItem> stateMachines = listStateMachinesResult .getStateMachines(); System.out.println("State machines count: " + stateMachines.size()); if (!stateMachines.isEmpty()) { stateMachines.forEach(sm -> { System.out.println("\t- Name: " + sm.getName()); System.out.println("\t- Arn: " + sm.getStateMachineArn()); ListExecutionsRequest listRequest = new ListExecutionsRequest().withStateMachineArn(sm .getStateMachineArn()); ListExecutionsResult listExecutionsResult = sfnClient .listExecutions(listRequest); List<ExecutionListItem> executions = listExecutionsResult .getExecutions(); System.out.println("\t- Total: " + executions.size()); executions.forEach(ex -> { System.out.println("\t\t-Start: " + ex.getStartDate()); System.out.println("\t\t-Stop: " + ex.getStopDate()); System.out.println("\t\t-Name: " + ex.getName()); System.out.println("\t\t-Status: " + ex.getStatus()); System.out.println(); }); }); } } catch (AmazonServiceException ase) { System.out.println("Caught an AmazonServiceException, which means" + " your request made it to Amazon Step Functions, but was" + " rejected with an error response for some reason."); System.out.println("Error Message: " + ase.getMessage()); System.out.println("HTTP Status Code: " + ase.getStatusCode()); System.out.println("AWS Error Code: " + ase.getErrorCode()); System.out.println("Error Type: " + ase.getErrorType()); System.out.println("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { System.out.println("Caught an AmazonClientException, which means " + "the client encountered a serious internal problem while " + "trying to communicate with Step Functions, such as not " + "being able to access the network."); System.out.println("Error Message: " + ace.getMessage()); } }