简体   繁体   中英

AWS DataPipeline EvaluateExpression using Java SDK

Using the AWS DataPipeline API , I'm trying to programmatically evaluate an Expression like the following:

sometext-#{format(@scheduledStartTime, 'YYYYMMddHHmmss')

To evaluate the expression, I'm using a PipelineObject that looks something like the following:

Id:@MyPipelineObject_2018-08-26T01:00:00
Name:@MyPipelineObject_2018-08-26T01:00:00
     - Key:@scheduledStartTime
     - StringValue:2018-08-26T01:00:00
     - Key:@scheduledEndTime
     - StringValue:2018-08-27T01:00:00

How can I evaluate the expression, given that I know the pipelineId and pipelineObjectId? I'm using the Java AWS SDK , and creating an EvaluateExpressionRequest like so:

String expressionToBeEvaluated = "sometext-#{format(@scheduledStartTime, 'YYYYMMddHHmmss')";
String myPipelineObjectId = "@MyPipelineObject_2018-08-26T01:00:00";

EvaluateExpressionRequest evaluateExpressionRequest = new EvaluateExpressionRequest()
                .withPipelineId(myPipelineId)
                .withExpression(expressionToBeEvaluated)
                .withObjectId(myPipelineObjectId);

However, from the docs it's not clear to me how to actually issue the request with the EvaluateExpressionRequest object. I've looked at EvaluateExpressionResult but the setEvaluatedExpression method only takes a String as input.

Am I doing something wrong, missing something fundamental, or does the SDK just not support what I'm trying to do?

Any input or suggestions would be really appreciated. Thanks!

So I figured it out a few minutes after posting my question. It turns out the answer is very simple and I've just been looking at this stuff for too long. The DataPipeline object has the method evaluateExpression() which takes an EvaluateExpressionRequest and returns the EvaluateExpressionResult . You get the evaluated result by calling getEvaluatedExpression on the returned object.

EvaluateExpressionRequest evaluateExpressionRequest = new EvaluateExpressionRequest()
                .withPipelineId(myPipelineId)
                .withExpression(expressionToBeEvaluated)
                .withObjectId(myPipelineObjectId);

dataPipeline.evaluateExpression(evaluateExpressionRequest).getEvaluatedExpression(); //evaluates to sometext-20180826010000

Hope that helps anyone with a similar affliction!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM