简体   繁体   English

使用Java SDK的AWS DataPipeline EvaluateExpression

[英]AWS DataPipeline EvaluateExpression using Java SDK

Using the AWS DataPipeline API , I'm trying to programmatically evaluate an Expression like the following: 使用AWS DataPipeline API ,我尝试以编程方式评估表达式 ,如下所示:

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

To evaluate the expression, I'm using a PipelineObject that looks something like the following: 为了评估表达式,我使用了一个类似以下内容的PipelineObject

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? 在知道pipelineId和pipelineObjectId的情况下,如何评估表达式? I'm using the Java AWS SDK , and creating an EvaluateExpressionRequest like so: 我正在使用Java AWS开发工具包 ,并创建一个EvaluateExpressionRequest如下所示:

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. 但是,从文档中我还不清楚如何实际使用EvaluateExpressionRequest对象发出请求。 I've looked at EvaluateExpressionResult but the setEvaluatedExpression method only takes a String as input. 我看过EvaluateExpressionResultsetEvaluatedExpression方法仅将String作为输入。

Am I doing something wrong, missing something fundamental, or does the SDK just not support what I'm trying to do? 我是在做错什么,缺少基本知识,还是SDK只是不支持我正在尝试做的事情?

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 . DataPipeline对象具有方法EvaluateExpressionRequest evaluateExpression() ,该方法接受EvaluateExpressionRequest并返回EvaluateExpressionResult You get the evaluated result by calling getEvaluatedExpression on the returned object. 您可以通过对返回的对象调用getEvaluatedExpression获得评估结果。

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! 希望对任何有类似痛苦的人有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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