This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch fix/CAMEL-26098-aws-producers-no-operation in repository https://gitbox.apache.org/repos/asf/camel.git
commit 5620f59e92ac9fc7758c38110f9830fe463ad23e Author: Claus Ibsen <[email protected]> AuthorDate: Fri Oct 23 15:07:47 2026 +0200 CAMEL-26101, CAMEL-26070: camel-aws2-step-functions - the execution input must be JSON text, startSyncExecution sets the status headers; camel-aws-bedrock - aws-bedrock-agent headers override the options Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../catalog/components/aws-bedrock-agent.json | 18 ++-- .../catalog/components/aws2-step-functions.json | 15 +-- .../catalog/docs/aws-bedrock-agent-component.adoc | 7 +- .../docs/aws2-step-functions-component.adoc | 10 ++ .../aws2/bedrock/agent/aws-bedrock-agent.json | 18 ++-- .../src/main/docs/aws-bedrock-agent-component.adoc | 7 +- .../bedrock/agent/BedrockAgentConfiguration.java | 12 +-- .../aws2/bedrock/agent/BedrockAgentConstants.java | 6 +- .../aws2/bedrock/agent/BedrockAgentProducer.java | 105 ++++++--------------- .../bedrock/agent/BedrockAgentProducerTest.java | 64 +++++++++++++ .../aws2/stepfunctions/aws2-step-functions.json | 15 +-- .../main/docs/aws2-step-functions-component.adoc | 10 ++ .../stepfunctions/StepFunctions2Constants.java | 17 +++- .../aws2/stepfunctions/StepFunctions2Producer.java | 40 +++++++- .../AmazonStepFunctionsClientMock.java | 12 +++ .../stepfunctions/StepFunctions2ProducerTest.java | 50 ++++++++++ .../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc | 11 +++ .../AwsBedrockAgentComponentBuilderFactory.java | 13 +-- .../dsl/BedrockAgentEndpointBuilderFactory.java | 51 +++++----- .../dsl/StepFunctions2EndpointBuilderFactory.java | 44 ++++++++- 20 files changed, 367 insertions(+), 158 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-bedrock-agent.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-bedrock-agent.json index 15094023f010..84f63bca5da5 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-bedrock-agent.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-bedrock-agent.json @@ -25,9 +25,9 @@ }, "componentProperties": { "configuration": { "index": 0, "kind": "property", "displayName": "Configuration", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "deprecated": false, "autowired": false, "secret": false, "description": "Component configuration" }, - "dataSourceId": { "index": 1, "kind": "property", "displayName": "Data Source Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Data source Id we are going to use. The consumer and all the [...] - "ingestionJobId": { "index": 2, "kind": "property", "displayName": "Ingestion Job Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Ingestion Job Id we want to track. The consumer and the getIngestionJob operati [...] - "knowledgeBaseId": { "index": 3, "kind": "property", "displayName": "Knowledge Base Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Knowledge Base Id we are going to use. The consumer an [...] + "dataSourceId": { "index": 1, "kind": "property", "displayName": "Data Source Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Data source Id we are going to use. The consumer and all the [...] + "ingestionJobId": { "index": 2, "kind": "property", "displayName": "Ingestion Job Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Ingestion Job Id we want to track. The consumer and the getIngestionJob operati [...] + "knowledgeBaseId": { "index": 3, "kind": "property", "displayName": "Knowledge Base Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Knowledge Base Id we are going to use. The consumer an [...] "operation": { "index": 4, "kind": "property", "displayName": "Operation", "group": "common", "label": "", "required": true, "type": "enum", "javaType": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentOperations", "enum": [ "startIngestionJob", "listIngestionJobs", "getIngestionJob" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurati [...] "overrideEndpoint": { "index": 5, "kind": "property", "displayName": "Override Endpoint", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Set the need for overriding the endpoint. This option needs to be used i [...] "pojoRequest": { "index": 6, "kind": "property", "displayName": "Pojo Request", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "If we want to use a POJO request as body or not" }, @@ -53,17 +53,17 @@ }, "headers": { "CamelAwsBedrockAgentOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation we want to perform", "constantName": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConstants#OPERATION" }, - "CamelAwsBedrockAgentDataSourceId": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The data source Id of the operation, used when the dataSourceId option is not set", "constantName": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConstants#DATASOURCE_ID" }, - "CamelAwsBedrockAgentKnowledgeBaseId": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The knowledge base Id of the operation, used when the knowledgeBaseId option is not set", "constantName": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConstants#KNOWLEDGE_BASE_ID" }, - "CamelAwsBedrockAgentIngestionJobId": { "index": 3, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The id of the ingestion job of the getIngestionJob operation, used when the ingestionJobId option is not set", "constantName": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConstants#INGESTION_JOB_ID" }, + "CamelAwsBedrockAgentDataSourceId": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The data source Id of the operation; it overrides the dataSourceId option", "constantName": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConstants#DATASOURCE_ID" }, + "CamelAwsBedrockAgentKnowledgeBaseId": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The knowledge base Id of the operation; it overrides the knowledgeBaseId option", "constantName": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConstants#KNOWLEDGE_BASE_ID" }, + "CamelAwsBedrockAgentIngestionJobId": { "index": 3, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The id of the ingestion job of the getIngestionJob operation; it overrides the ingestionJobId option", "constantName": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConstants#INGESTION_JOB_ID" }, "CamelAwsBedrockAgentIngestionJobStatus": { "index": 4, "kind": "header", "displayName": "", "group": "common", "label": "common", "required": false, "javaType": "software.amazon.awssdk.services.bedrockagent.model.IngestionJobStatus", "enum": [ "STARTING", "IN_PROGRESS", "COMPLETE", "FAILED", "STOPPING", "STOPPED", "null" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The status of the ingestion job, set by the consumer and by the [...] "CamelAwsBedrockAgentIngestionJobFailureReasons": { "index": 5, "kind": "header", "displayName": "", "group": "common", "label": "common", "required": false, "javaType": "List<String>", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The failure reasons of the ingestion job, set by the consumer and by the getIngestionJob operation when the job has failure reasons", "constantName": "org.apache.camel.component.aws2.bedrock.agent.BedrockA [...] }, "properties": { "label": { "index": 0, "kind": "path", "displayName": "Label", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Logical name" }, - "dataSourceId": { "index": 1, "kind": "parameter", "displayName": "Data Source Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Data source Id we are going to use. The consumer and all th [...] - "ingestionJobId": { "index": 2, "kind": "parameter", "displayName": "Ingestion Job Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Ingestion Job Id we want to track. The consumer and the getIngestionJob operat [...] - "knowledgeBaseId": { "index": 3, "kind": "parameter", "displayName": "Knowledge Base Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Knowledge Base Id we are going to use. The consumer a [...] + "dataSourceId": { "index": 1, "kind": "parameter", "displayName": "Data Source Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Data source Id we are going to use. The consumer and all th [...] + "ingestionJobId": { "index": 2, "kind": "parameter", "displayName": "Ingestion Job Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Ingestion Job Id we want to track. The consumer and the getIngestionJob operat [...] + "knowledgeBaseId": { "index": 3, "kind": "parameter", "displayName": "Knowledge Base Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Knowledge Base Id we are going to use. The consumer a [...] "operation": { "index": 4, "kind": "parameter", "displayName": "Operation", "group": "common", "label": "", "required": true, "type": "enum", "javaType": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentOperations", "enum": [ "startIngestionJob", "listIngestionJobs", "getIngestionJob" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurat [...] "overrideEndpoint": { "index": 5, "kind": "parameter", "displayName": "Override Endpoint", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Set the need for overriding the endpoint. This option needs to be used [...] "pojoRequest": { "index": 6, "kind": "parameter", "displayName": "Pojo Request", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "If we want to use a POJO request as body or not" }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-step-functions.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-step-functions.json index 41c36bc55272..d3a30c8e5f62 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-step-functions.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-step-functions.json @@ -60,12 +60,15 @@ "CamelAwsStepFunctionsActivitiesMaxResults": { "index": 9, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The limit number of results while listing activities", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#ACTIVITIES_MAX_RESULTS" }, "CamelAwsStepFunctionsExecutionArn": { "index": 10, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The Amazon Resource Name (ARN) of the execution.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_ARN" }, "CamelAwsStepFunctionsExecutionName": { "index": 11, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Optional name of the execution.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_NAME" }, - "CamelAwsStepFunctionsExecutionInput": { "index": 12, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The string that contains the JSON input data for the execution.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_INPUT" }, - "CamelAwsStepFunctionsExecutionTraceHeader": { "index": 13, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Passes the X-Ray trace header.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_TRACE_HEADER" }, - "CamelAwsStepFunctionsExecutionHistoryMaxResults": { "index": 14, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The limit number of results while listing execution history", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_HISTORY_MAX_RESULTS" }, - "CamelAwsStepFunctionsExecutionHistoryIncludeExecutionData": { "index": 15, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "You can select whether execution data (input or output of a history event) is returned.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_HISTORY_INCLUDE [...] - "CamelAwsStepFunctionsExecutionHistoryReverseOrder": { "index": 16, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Lists events in descending order of their timeStamp.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_HISTORY_REVERSE_ORDER" }, - "CamelAwsStepFunctionsExecutionMaxResults": { "index": 17, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The limit number of results while listing executions", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTIONS_MAX_RESULTS" } + "CamelAwsStepFunctionsExecutionInput": { "index": 12, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The JSON input data for the execution, as text (a String, a byte array or a stream).", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_INPUT" }, + "CamelAwsStepFunctionsExecutionStatus": { "index": 13, "kind": "header", "displayName": "", "group": "startSyncExecution", "label": "startSyncExecution", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The status of the execution: SUCCEEDED, FAILED or TIMED_OUT. The exchange does not fail when the execution did not succeed: check this header.", "constantName": "org.apache.camel.component.aws2.st [...] + "CamelAwsStepFunctionsExecutionError": { "index": 14, "kind": "header", "displayName": "", "group": "startSyncExecution", "label": "startSyncExecution", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The error code of the failure, when the execution failed.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_ERROR" }, + "CamelAwsStepFunctionsExecutionCause": { "index": 15, "kind": "header", "displayName": "", "group": "startSyncExecution", "label": "startSyncExecution", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The cause of the failure, when the execution failed.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_CAUSE" }, + "CamelAwsStepFunctionsExecutionTraceHeader": { "index": 16, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Passes the X-Ray trace header.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_TRACE_HEADER" }, + "CamelAwsStepFunctionsExecutionHistoryMaxResults": { "index": 17, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The limit number of results while listing execution history", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_HISTORY_MAX_RESULTS" }, + "CamelAwsStepFunctionsExecutionHistoryIncludeExecutionData": { "index": 18, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "You can select whether execution data (input or output of a history event) is returned.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_HISTORY_INCLUDE [...] + "CamelAwsStepFunctionsExecutionHistoryReverseOrder": { "index": 19, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Lists events in descending order of their timeStamp.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_HISTORY_REVERSE_ORDER" }, + "CamelAwsStepFunctionsExecutionMaxResults": { "index": 20, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The limit number of results while listing executions", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTIONS_MAX_RESULTS" } }, "properties": { "label": { "index": 0, "kind": "path", "displayName": "Label", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Configuration", "configurationField": "configuration", "description": "Logical name" }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws-bedrock-agent-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws-bedrock-agent-component.adoc index 18540aee1928..035bd1df5be2 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws-bedrock-agent-component.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws-bedrock-agent-component.adoc @@ -82,9 +82,10 @@ The body is set to the list of `IngestionJobSummary` of the AWS SDK. The body is set to the `IngestionJob` of the AWS SDK, the `CamelAwsBedrockAgentIngestionJobStatus` header to its status, and the `CamelAwsBedrockAgentIngestionJobFailureReasons` header to its failure reasons, if it has any. -The knowledge base, data source and ingestion job ids are taken from the `knowledgeBaseId`, `dataSourceId` and -`ingestionJobId` options. The `CamelAwsBedrockAgentKnowledgeBaseId`, `CamelAwsBedrockAgentDataSourceId` and -`CamelAwsBedrockAgentIngestionJobId` headers are used only when the option is not set. +The knowledge base, data source and ingestion job ids are taken from the `CamelAwsBedrockAgentKnowledgeBaseId`, +`CamelAwsBedrockAgentDataSourceId` and `CamelAwsBedrockAgentIngestionJobId` headers, and else from the +`knowledgeBaseId`, `dataSourceId` and `ingestionJobId` options. So the options are the defaults of the endpoint, and +a header overrides them for one message, for example to get the ingestion job that startIngestionJob returned in the body. With `pojoRequest=true`, the body is the request of the AWS SDK instead (`StartIngestionJobRequest`, `ListIngestionJobsRequest` or `GetIngestionJobRequest`), and the ids are taken from it. diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-step-functions-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-step-functions-component.adoc index 965c1846da6e..a97a02b707db 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-step-functions-component.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-step-functions-component.adoc @@ -96,6 +96,16 @@ Camel-AWS Step Functions component provides the following operation on the produ - listExecutions - getExecutionHistory +The startExecution and startSyncExecution operations take the input of the execution from the +`CamelAwsStepFunctionsExecutionInput` header, which must be JSON text (a String, a byte array or a stream). +A value of another type, such as a `Map`, is not turned into JSON: the exchange fails. + +The startSyncExecution operation waits for the execution to end, and sets the body to the `StartSyncExecutionResponse` +of the AWS SDK, which holds the output. It sets the `CamelAwsStepFunctionsExecutionStatus` header to the status of the +execution (`SUCCEEDED`, `FAILED` or `TIMED_OUT`), and, when the execution failed, the +`CamelAwsStepFunctionsExecutionError` and `CamelAwsStepFunctionsExecutionCause` headers. The exchange does not fail +when the execution did not succeed: check the status header. + == Examples === Producer Examples diff --git a/components/camel-aws/camel-aws-bedrock/src/generated/resources/META-INF/org/apache/camel/component/aws2/bedrock/agent/aws-bedrock-agent.json b/components/camel-aws/camel-aws-bedrock/src/generated/resources/META-INF/org/apache/camel/component/aws2/bedrock/agent/aws-bedrock-agent.json index 15094023f010..84f63bca5da5 100644 --- a/components/camel-aws/camel-aws-bedrock/src/generated/resources/META-INF/org/apache/camel/component/aws2/bedrock/agent/aws-bedrock-agent.json +++ b/components/camel-aws/camel-aws-bedrock/src/generated/resources/META-INF/org/apache/camel/component/aws2/bedrock/agent/aws-bedrock-agent.json @@ -25,9 +25,9 @@ }, "componentProperties": { "configuration": { "index": 0, "kind": "property", "displayName": "Configuration", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "deprecated": false, "autowired": false, "secret": false, "description": "Component configuration" }, - "dataSourceId": { "index": 1, "kind": "property", "displayName": "Data Source Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Data source Id we are going to use. The consumer and all the [...] - "ingestionJobId": { "index": 2, "kind": "property", "displayName": "Ingestion Job Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Ingestion Job Id we want to track. The consumer and the getIngestionJob operati [...] - "knowledgeBaseId": { "index": 3, "kind": "property", "displayName": "Knowledge Base Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Knowledge Base Id we are going to use. The consumer an [...] + "dataSourceId": { "index": 1, "kind": "property", "displayName": "Data Source Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Data source Id we are going to use. The consumer and all the [...] + "ingestionJobId": { "index": 2, "kind": "property", "displayName": "Ingestion Job Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Ingestion Job Id we want to track. The consumer and the getIngestionJob operati [...] + "knowledgeBaseId": { "index": 3, "kind": "property", "displayName": "Knowledge Base Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Knowledge Base Id we are going to use. The consumer an [...] "operation": { "index": 4, "kind": "property", "displayName": "Operation", "group": "common", "label": "", "required": true, "type": "enum", "javaType": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentOperations", "enum": [ "startIngestionJob", "listIngestionJobs", "getIngestionJob" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurati [...] "overrideEndpoint": { "index": 5, "kind": "property", "displayName": "Override Endpoint", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Set the need for overriding the endpoint. This option needs to be used i [...] "pojoRequest": { "index": 6, "kind": "property", "displayName": "Pojo Request", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "If we want to use a POJO request as body or not" }, @@ -53,17 +53,17 @@ }, "headers": { "CamelAwsBedrockAgentOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation we want to perform", "constantName": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConstants#OPERATION" }, - "CamelAwsBedrockAgentDataSourceId": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The data source Id of the operation, used when the dataSourceId option is not set", "constantName": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConstants#DATASOURCE_ID" }, - "CamelAwsBedrockAgentKnowledgeBaseId": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The knowledge base Id of the operation, used when the knowledgeBaseId option is not set", "constantName": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConstants#KNOWLEDGE_BASE_ID" }, - "CamelAwsBedrockAgentIngestionJobId": { "index": 3, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The id of the ingestion job of the getIngestionJob operation, used when the ingestionJobId option is not set", "constantName": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConstants#INGESTION_JOB_ID" }, + "CamelAwsBedrockAgentDataSourceId": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The data source Id of the operation; it overrides the dataSourceId option", "constantName": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConstants#DATASOURCE_ID" }, + "CamelAwsBedrockAgentKnowledgeBaseId": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The knowledge base Id of the operation; it overrides the knowledgeBaseId option", "constantName": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConstants#KNOWLEDGE_BASE_ID" }, + "CamelAwsBedrockAgentIngestionJobId": { "index": 3, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The id of the ingestion job of the getIngestionJob operation; it overrides the ingestionJobId option", "constantName": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConstants#INGESTION_JOB_ID" }, "CamelAwsBedrockAgentIngestionJobStatus": { "index": 4, "kind": "header", "displayName": "", "group": "common", "label": "common", "required": false, "javaType": "software.amazon.awssdk.services.bedrockagent.model.IngestionJobStatus", "enum": [ "STARTING", "IN_PROGRESS", "COMPLETE", "FAILED", "STOPPING", "STOPPED", "null" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The status of the ingestion job, set by the consumer and by the [...] "CamelAwsBedrockAgentIngestionJobFailureReasons": { "index": 5, "kind": "header", "displayName": "", "group": "common", "label": "common", "required": false, "javaType": "List<String>", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The failure reasons of the ingestion job, set by the consumer and by the getIngestionJob operation when the job has failure reasons", "constantName": "org.apache.camel.component.aws2.bedrock.agent.BedrockA [...] }, "properties": { "label": { "index": 0, "kind": "path", "displayName": "Label", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Logical name" }, - "dataSourceId": { "index": 1, "kind": "parameter", "displayName": "Data Source Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Data source Id we are going to use. The consumer and all th [...] - "ingestionJobId": { "index": 2, "kind": "parameter", "displayName": "Ingestion Job Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Ingestion Job Id we want to track. The consumer and the getIngestionJob operat [...] - "knowledgeBaseId": { "index": 3, "kind": "parameter", "displayName": "Knowledge Base Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Knowledge Base Id we are going to use. The consumer a [...] + "dataSourceId": { "index": 1, "kind": "parameter", "displayName": "Data Source Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Data source Id we are going to use. The consumer and all th [...] + "ingestionJobId": { "index": 2, "kind": "parameter", "displayName": "Ingestion Job Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Ingestion Job Id we want to track. The consumer and the getIngestionJob operat [...] + "knowledgeBaseId": { "index": 3, "kind": "parameter", "displayName": "Knowledge Base Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Define the Knowledge Base Id we are going to use. The consumer a [...] "operation": { "index": 4, "kind": "parameter", "displayName": "Operation", "group": "common", "label": "", "required": true, "type": "enum", "javaType": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentOperations", "enum": [ "startIngestionJob", "listIngestionJobs", "getIngestionJob" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurat [...] "overrideEndpoint": { "index": 5, "kind": "parameter", "displayName": "Override Endpoint", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "Set the need for overriding the endpoint. This option needs to be used [...] "pojoRequest": { "index": 6, "kind": "parameter", "displayName": "Pojo Request", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration", "configurationField": "configuration", "description": "If we want to use a POJO request as body or not" }, diff --git a/components/camel-aws/camel-aws-bedrock/src/main/docs/aws-bedrock-agent-component.adoc b/components/camel-aws/camel-aws-bedrock/src/main/docs/aws-bedrock-agent-component.adoc index 18540aee1928..035bd1df5be2 100644 --- a/components/camel-aws/camel-aws-bedrock/src/main/docs/aws-bedrock-agent-component.adoc +++ b/components/camel-aws/camel-aws-bedrock/src/main/docs/aws-bedrock-agent-component.adoc @@ -82,9 +82,10 @@ The body is set to the list of `IngestionJobSummary` of the AWS SDK. The body is set to the `IngestionJob` of the AWS SDK, the `CamelAwsBedrockAgentIngestionJobStatus` header to its status, and the `CamelAwsBedrockAgentIngestionJobFailureReasons` header to its failure reasons, if it has any. -The knowledge base, data source and ingestion job ids are taken from the `knowledgeBaseId`, `dataSourceId` and -`ingestionJobId` options. The `CamelAwsBedrockAgentKnowledgeBaseId`, `CamelAwsBedrockAgentDataSourceId` and -`CamelAwsBedrockAgentIngestionJobId` headers are used only when the option is not set. +The knowledge base, data source and ingestion job ids are taken from the `CamelAwsBedrockAgentKnowledgeBaseId`, +`CamelAwsBedrockAgentDataSourceId` and `CamelAwsBedrockAgentIngestionJobId` headers, and else from the +`knowledgeBaseId`, `dataSourceId` and `ingestionJobId` options. So the options are the defaults of the endpoint, and +a header overrides them for one message, for example to get the ingestion job that startIngestionJob returned in the body. With `pojoRequest=true`, the body is the request of the AWS SDK instead (`StartIngestionJobRequest`, `ListIngestionJobsRequest` or `GetIngestionJobRequest`), and the ids are taken from it. diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentConfiguration.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentConfiguration.java index 896b9520fb65..82f5f98c1b90 100644 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentConfiguration.java +++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentConfiguration.java @@ -272,8 +272,8 @@ public class BedrockAgentConfiguration implements Cloneable, AwsCommonConfigurat } /** - * Define the Knowledge Base Id we are going to use. The consumer and all the operations need it; when set, it is - * used instead of the CamelAwsBedrockAgentKnowledgeBaseId header + * Define the Knowledge Base Id we are going to use. The consumer and all the operations need it; the + * CamelAwsBedrockAgentKnowledgeBaseId header overrides it for the producer */ public void setKnowledgeBaseId(String knowledgeBaseId) { this.knowledgeBaseId = knowledgeBaseId; @@ -284,8 +284,8 @@ public class BedrockAgentConfiguration implements Cloneable, AwsCommonConfigurat } /** - * Define the Data source Id we are going to use. The consumer and all the operations need it; when set, it is used - * instead of the CamelAwsBedrockAgentDataSourceId header + * Define the Data source Id we are going to use. The consumer and all the operations need it; the + * CamelAwsBedrockAgentDataSourceId header overrides it for the producer */ public void setDataSourceId(String dataSourceId) { this.dataSourceId = dataSourceId; @@ -296,8 +296,8 @@ public class BedrockAgentConfiguration implements Cloneable, AwsCommonConfigurat } /** - * Define the Ingestion Job Id we want to track. The consumer and the getIngestionJob operation need it; when set, - * it is used instead of the CamelAwsBedrockAgentIngestionJobId header + * Define the Ingestion Job Id we want to track. The consumer and the getIngestionJob operation need it; the + * CamelAwsBedrockAgentIngestionJobId header overrides it for the producer */ public void setIngestionJobId(String ingestionJobId) { this.ingestionJobId = ingestionJobId; diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentConstants.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentConstants.java index 51206df19d72..4373ba35f968 100644 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentConstants.java +++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentConstants.java @@ -25,15 +25,15 @@ public interface BedrockAgentConstants { @Metadata(description = "The operation we want to perform", javaType = "String", label = "producer") String OPERATION = "CamelAwsBedrockAgentOperation"; - @Metadata(description = "The data source Id of the operation, used when the dataSourceId option is not set", + @Metadata(description = "The data source Id of the operation; it overrides the dataSourceId option", javaType = "String", label = "producer") String DATASOURCE_ID = "CamelAwsBedrockAgentDataSourceId"; - @Metadata(description = "The knowledge base Id of the operation, used when the knowledgeBaseId option is not set", + @Metadata(description = "The knowledge base Id of the operation; it overrides the knowledgeBaseId option", javaType = "String", label = "producer") String KNOWLEDGE_BASE_ID = "CamelAwsBedrockAgentKnowledgeBaseId"; - @Metadata(description = "The id of the ingestion job of the getIngestionJob operation, used when the ingestionJobId option is not set", + @Metadata(description = "The id of the ingestion job of the getIngestionJob operation; it overrides the ingestionJobId option", javaType = "String", label = "producer") String INGESTION_JOB_ID = "CamelAwsBedrockAgentIngestionJobId"; diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentProducer.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentProducer.java index dfcf65c1ca96..a0f75aee3eb0 100644 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentProducer.java +++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentProducer.java @@ -74,6 +74,20 @@ public class BedrockAgentProducer extends DefaultProducer { return operation; } + /** + * The id of the header, or else of the option: the header overrides the option for this message. + */ + private static String getId(Exchange exchange, String header, String option, String name) { + String id = exchange.getMessage().getHeader(header, String.class); + if (ObjectHelper.isEmpty(id)) { + id = option; + } + if (ObjectHelper.isEmpty(id)) { + throw new IllegalArgumentException(name + " must be specified"); + } + return id; + } + protected BedrockAgentConfiguration getConfiguration() { return getEndpoint().getConfiguration(); } @@ -111,29 +125,11 @@ public class BedrockAgentProducer extends DefaultProducer { "startIngestionJob operation requires a StartIngestionJobRequest body when pojoRequest=true"); } } else { - String knowledgeBaseId; - String dataSourceId; StartIngestionJobRequest.Builder builder = StartIngestionJobRequest.builder(); - if (ObjectHelper.isEmpty(getConfiguration().getKnowledgeBaseId())) { - if (ObjectHelper.isNotEmpty(exchange.getMessage().getHeader(BedrockAgentConstants.KNOWLEDGE_BASE_ID))) { - knowledgeBaseId = exchange.getIn().getHeader(BedrockAgentConstants.KNOWLEDGE_BASE_ID, String.class); - } else { - throw new IllegalArgumentException("KnowledgeBaseId must be specified"); - } - } else { - knowledgeBaseId = getConfiguration().getKnowledgeBaseId(); - } - if (ObjectHelper.isEmpty(getConfiguration().getDataSourceId())) { - if (ObjectHelper.isNotEmpty(exchange.getMessage().getHeader(BedrockAgentConstants.DATASOURCE_ID))) { - dataSourceId = exchange.getIn().getHeader(BedrockAgentConstants.DATASOURCE_ID, String.class); - } else { - throw new IllegalArgumentException("DataSourceId must be specified"); - } - } else { - dataSourceId = getConfiguration().getDataSourceId(); - } - builder.knowledgeBaseId(knowledgeBaseId); - builder.dataSourceId(dataSourceId); + builder.knowledgeBaseId(getId(exchange, BedrockAgentConstants.KNOWLEDGE_BASE_ID, + getConfiguration().getKnowledgeBaseId(), "KnowledgeBaseId")); + builder.dataSourceId( + getId(exchange, BedrockAgentConstants.DATASOURCE_ID, getConfiguration().getDataSourceId(), "DataSourceId")); StartIngestionJobResponse output = bedrockAgentClient.startIngestionJob(builder.build()); Message message = getMessageForResponse(exchange); prepareIngestionJobResponse(output, message); @@ -159,29 +155,11 @@ public class BedrockAgentProducer extends DefaultProducer { "listIngestionJobs operation requires a ListIngestionJobsRequest body when pojoRequest=true"); } } else { - String knowledgeBaseId; - String dataSourceId; ListIngestionJobsRequest.Builder builder = ListIngestionJobsRequest.builder(); - if (ObjectHelper.isEmpty(getConfiguration().getKnowledgeBaseId())) { - if (ObjectHelper.isNotEmpty(exchange.getMessage().getHeader(BedrockAgentConstants.KNOWLEDGE_BASE_ID))) { - knowledgeBaseId = exchange.getIn().getHeader(BedrockAgentConstants.KNOWLEDGE_BASE_ID, String.class); - } else { - throw new IllegalArgumentException("KnowledgeBaseId must be specified"); - } - } else { - knowledgeBaseId = getConfiguration().getKnowledgeBaseId(); - } - if (ObjectHelper.isEmpty(getConfiguration().getDataSourceId())) { - if (ObjectHelper.isNotEmpty(exchange.getMessage().getHeader(BedrockAgentConstants.DATASOURCE_ID))) { - dataSourceId = exchange.getIn().getHeader(BedrockAgentConstants.DATASOURCE_ID, String.class); - } else { - throw new IllegalArgumentException("DataSourceId must be specified"); - } - } else { - dataSourceId = getConfiguration().getDataSourceId(); - } - builder.knowledgeBaseId(knowledgeBaseId); - builder.dataSourceId(dataSourceId); + builder.knowledgeBaseId(getId(exchange, BedrockAgentConstants.KNOWLEDGE_BASE_ID, + getConfiguration().getKnowledgeBaseId(), "KnowledgeBaseId")); + builder.dataSourceId( + getId(exchange, BedrockAgentConstants.DATASOURCE_ID, getConfiguration().getDataSourceId(), "DataSourceId")); ListIngestionJobsResponse output = bedrockAgentClient.listIngestionJobs(builder.build()); Message message = getMessageForResponse(exchange); prepareListIngestionJobsResponse(output, message); @@ -207,40 +185,13 @@ public class BedrockAgentProducer extends DefaultProducer { "getIngestionJob operation requires a GetIngestionJobRequest body when pojoRequest=true"); } } else { - String knowledgeBaseId; - String dataSourceId; - String ingestionJobId; GetIngestionJobRequest.Builder builder = GetIngestionJobRequest.builder(); - if (ObjectHelper.isEmpty(getConfiguration().getKnowledgeBaseId())) { - if (ObjectHelper.isNotEmpty(exchange.getMessage().getHeader(BedrockAgentConstants.KNOWLEDGE_BASE_ID))) { - knowledgeBaseId = exchange.getMessage().getHeader(BedrockAgentConstants.KNOWLEDGE_BASE_ID, String.class); - } else { - throw new IllegalArgumentException("KnowledgeBaseId must be specified"); - } - } else { - knowledgeBaseId = getConfiguration().getKnowledgeBaseId(); - } - if (ObjectHelper.isEmpty(getConfiguration().getDataSourceId())) { - if (ObjectHelper.isNotEmpty(exchange.getMessage().getHeader(BedrockAgentConstants.DATASOURCE_ID))) { - dataSourceId = exchange.getMessage().getHeader(BedrockAgentConstants.DATASOURCE_ID, String.class); - } else { - throw new IllegalArgumentException("DataSourceId must be specified"); - } - } else { - dataSourceId = getConfiguration().getDataSourceId(); - } - if (ObjectHelper.isEmpty(getConfiguration().getIngestionJobId())) { - if (ObjectHelper.isNotEmpty(exchange.getMessage().getHeader(BedrockAgentConstants.INGESTION_JOB_ID))) { - ingestionJobId = exchange.getMessage().getHeader(BedrockAgentConstants.INGESTION_JOB_ID, String.class); - } else { - throw new IllegalArgumentException("IngestionJobId must be specified"); - } - } else { - ingestionJobId = getConfiguration().getIngestionJobId(); - } - builder.knowledgeBaseId(knowledgeBaseId); - builder.dataSourceId(dataSourceId); - builder.ingestionJobId(ingestionJobId); + builder.knowledgeBaseId(getId(exchange, BedrockAgentConstants.KNOWLEDGE_BASE_ID, + getConfiguration().getKnowledgeBaseId(), "KnowledgeBaseId")); + builder.dataSourceId( + getId(exchange, BedrockAgentConstants.DATASOURCE_ID, getConfiguration().getDataSourceId(), "DataSourceId")); + builder.ingestionJobId(getId(exchange, BedrockAgentConstants.INGESTION_JOB_ID, + getConfiguration().getIngestionJobId(), "IngestionJobId")); GetIngestionJobResponse output = bedrockAgentClient.getIngestionJob(builder.build()); Message message = getMessageForResponse(exchange); prepareGetIngestionJobResponse(output, message); diff --git a/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentProducerTest.java b/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentProducerTest.java index 13471fff7ce5..161c9f17d7ed 100644 --- a/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentProducerTest.java +++ b/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentProducerTest.java @@ -20,16 +20,20 @@ import org.apache.camel.Exchange; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.support.DefaultExchange; import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; import software.amazon.awssdk.services.bedrockagent.BedrockAgentClient; import software.amazon.awssdk.services.bedrockagent.model.GetIngestionJobRequest; import software.amazon.awssdk.services.bedrockagent.model.GetIngestionJobResponse; import software.amazon.awssdk.services.bedrockagent.model.IngestionJob; import software.amazon.awssdk.services.bedrockagent.model.IngestionJobStatus; +import software.amazon.awssdk.services.bedrockagent.model.StartIngestionJobRequest; +import software.amazon.awssdk.services.bedrockagent.model.StartIngestionJobResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; @@ -75,4 +79,64 @@ class BedrockAgentProducerTest { .isEqualTo(IngestionJobStatus.COMPLETE); assertThat(exchange.getMessage().getBody(IngestionJob.class).ingestionJobId()).isEqualTo("job-1"); } + + @Test + void headersOverrideTheOptions() throws Exception { + when(client.getIngestionJob(any(GetIngestionJobRequest.class))).thenReturn(GetIngestionJobResponse.builder() + .ingestionJob(IngestionJob.builder().ingestionJobId("job-2").status(IngestionJobStatus.COMPLETE).build()) + .build()); + BedrockAgentConfiguration configuration = new BedrockAgentConfiguration(); + configuration.setKnowledgeBaseId("kb-1"); + configuration.setDataSourceId("ds-1"); + configuration.setIngestionJobId("job-1"); + BedrockAgentProducer producer = createProducer(configuration); + Exchange exchange = new DefaultExchange(new DefaultCamelContext()); + exchange.getIn().setHeader(BedrockAgentConstants.OPERATION, BedrockAgentOperations.getIngestionJob); + exchange.getIn().setHeader(BedrockAgentConstants.KNOWLEDGE_BASE_ID, "kb-2"); + exchange.getIn().setHeader(BedrockAgentConstants.DATASOURCE_ID, "ds-2"); + exchange.getIn().setHeader(BedrockAgentConstants.INGESTION_JOB_ID, "job-2"); + + producer.process(exchange); + + ArgumentCaptor<GetIngestionJobRequest> request = ArgumentCaptor.forClass(GetIngestionJobRequest.class); + verify(client).getIngestionJob(request.capture()); + assertThat(request.getValue().knowledgeBaseId()).isEqualTo("kb-2"); + assertThat(request.getValue().dataSourceId()).isEqualTo("ds-2"); + assertThat(request.getValue().ingestionJobId()).isEqualTo("job-2"); + } + + @Test + void optionsAreUsedWithoutHeaders() throws Exception { + when(client.startIngestionJob(any(StartIngestionJobRequest.class))).thenReturn(StartIngestionJobResponse.builder() + .ingestionJob(IngestionJob.builder().ingestionJobId("job-3").build()) + .build()); + BedrockAgentConfiguration configuration = new BedrockAgentConfiguration(); + configuration.setKnowledgeBaseId("kb-1"); + configuration.setDataSourceId("ds-1"); + BedrockAgentProducer producer = createProducer(configuration); + Exchange exchange = new DefaultExchange(new DefaultCamelContext()); + exchange.getIn().setHeader(BedrockAgentConstants.OPERATION, BedrockAgentOperations.startIngestionJob); + + producer.process(exchange); + + ArgumentCaptor<StartIngestionJobRequest> request = ArgumentCaptor.forClass(StartIngestionJobRequest.class); + verify(client).startIngestionJob(request.capture()); + assertThat(request.getValue().knowledgeBaseId()).isEqualTo("kb-1"); + assertThat(request.getValue().dataSourceId()).isEqualTo("ds-1"); + assertThat(exchange.getMessage().getBody()).isEqualTo("job-3"); + } + + @Test + void missingIdFails() { + BedrockAgentConfiguration configuration = new BedrockAgentConfiguration(); + configuration.setKnowledgeBaseId("kb-1"); + BedrockAgentProducer producer = createProducer(configuration); + Exchange exchange = new DefaultExchange(new DefaultCamelContext()); + exchange.getIn().setHeader(BedrockAgentConstants.OPERATION, BedrockAgentOperations.listIngestionJobs); + + assertThatThrownBy(() -> producer.process(exchange)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("DataSourceId must be specified"); + verifyNoInteractions(client); + } } diff --git a/components/camel-aws/camel-aws2-step-functions/src/generated/resources/META-INF/org/apache/camel/component/aws2/stepfunctions/aws2-step-functions.json b/components/camel-aws/camel-aws2-step-functions/src/generated/resources/META-INF/org/apache/camel/component/aws2/stepfunctions/aws2-step-functions.json index 41c36bc55272..d3a30c8e5f62 100644 --- a/components/camel-aws/camel-aws2-step-functions/src/generated/resources/META-INF/org/apache/camel/component/aws2/stepfunctions/aws2-step-functions.json +++ b/components/camel-aws/camel-aws2-step-functions/src/generated/resources/META-INF/org/apache/camel/component/aws2/stepfunctions/aws2-step-functions.json @@ -60,12 +60,15 @@ "CamelAwsStepFunctionsActivitiesMaxResults": { "index": 9, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The limit number of results while listing activities", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#ACTIVITIES_MAX_RESULTS" }, "CamelAwsStepFunctionsExecutionArn": { "index": 10, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The Amazon Resource Name (ARN) of the execution.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_ARN" }, "CamelAwsStepFunctionsExecutionName": { "index": 11, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Optional name of the execution.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_NAME" }, - "CamelAwsStepFunctionsExecutionInput": { "index": 12, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The string that contains the JSON input data for the execution.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_INPUT" }, - "CamelAwsStepFunctionsExecutionTraceHeader": { "index": 13, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Passes the X-Ray trace header.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_TRACE_HEADER" }, - "CamelAwsStepFunctionsExecutionHistoryMaxResults": { "index": 14, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The limit number of results while listing execution history", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_HISTORY_MAX_RESULTS" }, - "CamelAwsStepFunctionsExecutionHistoryIncludeExecutionData": { "index": 15, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "You can select whether execution data (input or output of a history event) is returned.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_HISTORY_INCLUDE [...] - "CamelAwsStepFunctionsExecutionHistoryReverseOrder": { "index": 16, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Lists events in descending order of their timeStamp.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_HISTORY_REVERSE_ORDER" }, - "CamelAwsStepFunctionsExecutionMaxResults": { "index": 17, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The limit number of results while listing executions", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTIONS_MAX_RESULTS" } + "CamelAwsStepFunctionsExecutionInput": { "index": 12, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The JSON input data for the execution, as text (a String, a byte array or a stream).", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_INPUT" }, + "CamelAwsStepFunctionsExecutionStatus": { "index": 13, "kind": "header", "displayName": "", "group": "startSyncExecution", "label": "startSyncExecution", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The status of the execution: SUCCEEDED, FAILED or TIMED_OUT. The exchange does not fail when the execution did not succeed: check this header.", "constantName": "org.apache.camel.component.aws2.st [...] + "CamelAwsStepFunctionsExecutionError": { "index": 14, "kind": "header", "displayName": "", "group": "startSyncExecution", "label": "startSyncExecution", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The error code of the failure, when the execution failed.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_ERROR" }, + "CamelAwsStepFunctionsExecutionCause": { "index": 15, "kind": "header", "displayName": "", "group": "startSyncExecution", "label": "startSyncExecution", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The cause of the failure, when the execution failed.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_CAUSE" }, + "CamelAwsStepFunctionsExecutionTraceHeader": { "index": 16, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Passes the X-Ray trace header.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_TRACE_HEADER" }, + "CamelAwsStepFunctionsExecutionHistoryMaxResults": { "index": 17, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The limit number of results while listing execution history", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_HISTORY_MAX_RESULTS" }, + "CamelAwsStepFunctionsExecutionHistoryIncludeExecutionData": { "index": 18, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "You can select whether execution data (input or output of a history event) is returned.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_HISTORY_INCLUDE [...] + "CamelAwsStepFunctionsExecutionHistoryReverseOrder": { "index": 19, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Lists events in descending order of their timeStamp.", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTION_HISTORY_REVERSE_ORDER" }, + "CamelAwsStepFunctionsExecutionMaxResults": { "index": 20, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The limit number of results while listing executions", "constantName": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Constants#EXECUTIONS_MAX_RESULTS" } }, "properties": { "label": { "index": 0, "kind": "path", "displayName": "Label", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Configuration", "configurationField": "configuration", "description": "Logical name" }, diff --git a/components/camel-aws/camel-aws2-step-functions/src/main/docs/aws2-step-functions-component.adoc b/components/camel-aws/camel-aws2-step-functions/src/main/docs/aws2-step-functions-component.adoc index 965c1846da6e..a97a02b707db 100644 --- a/components/camel-aws/camel-aws2-step-functions/src/main/docs/aws2-step-functions-component.adoc +++ b/components/camel-aws/camel-aws2-step-functions/src/main/docs/aws2-step-functions-component.adoc @@ -96,6 +96,16 @@ Camel-AWS Step Functions component provides the following operation on the produ - listExecutions - getExecutionHistory +The startExecution and startSyncExecution operations take the input of the execution from the +`CamelAwsStepFunctionsExecutionInput` header, which must be JSON text (a String, a byte array or a stream). +A value of another type, such as a `Map`, is not turned into JSON: the exchange fails. + +The startSyncExecution operation waits for the execution to end, and sets the body to the `StartSyncExecutionResponse` +of the AWS SDK, which holds the output. It sets the `CamelAwsStepFunctionsExecutionStatus` header to the status of the +execution (`SUCCEEDED`, `FAILED` or `TIMED_OUT`), and, when the execution failed, the +`CamelAwsStepFunctionsExecutionError` and `CamelAwsStepFunctionsExecutionCause` headers. The exchange does not fail +when the execution did not succeed: check the status header. + == Examples === Producer Examples diff --git a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2Constants.java b/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2Constants.java index 3a302901b3ca..219be86c9bfd 100644 --- a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2Constants.java +++ b/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2Constants.java @@ -57,9 +57,24 @@ public interface StepFunctions2Constants { @Metadata(description = "Optional name of the execution.", javaType = "String") String EXECUTION_NAME = "CamelAwsStepFunctionsExecutionName"; - @Metadata(description = "The string that contains the JSON input data for the execution.", javaType = "String") + @Metadata(description = "The JSON input data for the execution, as text (a String, a byte array or a stream).", + javaType = "String") String EXECUTION_INPUT = "CamelAwsStepFunctionsExecutionInput"; + @Metadata(label = "startSyncExecution", + description = "The status of the execution: SUCCEEDED, FAILED or TIMED_OUT. The exchange does not fail when the" + + " execution did not succeed: check this header.", + javaType = "String") + String EXECUTION_STATUS = "CamelAwsStepFunctionsExecutionStatus"; + + @Metadata(label = "startSyncExecution", description = "The error code of the failure, when the execution failed.", + javaType = "String") + String EXECUTION_ERROR = "CamelAwsStepFunctionsExecutionError"; + + @Metadata(label = "startSyncExecution", description = "The cause of the failure, when the execution failed.", + javaType = "String") + String EXECUTION_CAUSE = "CamelAwsStepFunctionsExecutionCause"; + @Metadata(description = "Passes the X-Ray trace header.", javaType = "String") String EXECUTION_TRACE_HEADER = "CamelAwsStepFunctionsExecutionTraceHeader"; diff --git a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2Producer.java b/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2Producer.java index dc477736e267..ec96267118bc 100644 --- a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2Producer.java +++ b/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2Producer.java @@ -16,6 +16,9 @@ */ package org.apache.camel.component.aws2.stepfunctions; +import java.io.InputStream; +import java.io.Reader; + import org.apache.camel.Endpoint; import org.apache.camel.Exchange; import org.apache.camel.InvalidPayloadException; @@ -522,8 +525,8 @@ public class StepFunctions2Producer extends DefaultProducer { String executionName = exchange.getIn().getHeader(StepFunctions2Constants.EXECUTION_NAME, String.class); builder.name(executionName); } - if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(StepFunctions2Constants.EXECUTION_INPUT))) { - String executionInput = exchange.getIn().getHeader(StepFunctions2Constants.EXECUTION_INPUT, String.class); + String executionInput = getExecutionInput(exchange); + if (ObjectHelper.isNotEmpty(executionInput)) { builder.input(executionInput); } if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(StepFunctions2Constants.EXECUTION_TRACE_HEADER))) { @@ -557,6 +560,7 @@ public class StepFunctions2Producer extends DefaultProducer { } Message message = getMessageForResponse(exchange); message.setBody(result); + setSyncExecutionHeaders(message, result); } else { throw new IllegalArgumentException( "startSyncExecution operation requires StartSyncExecutionRequest in POJO mode"); @@ -571,8 +575,8 @@ public class StepFunctions2Producer extends DefaultProducer { String executionName = exchange.getIn().getHeader(StepFunctions2Constants.EXECUTION_NAME, String.class); builder.name(executionName); } - if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(StepFunctions2Constants.EXECUTION_INPUT))) { - String executionInput = exchange.getIn().getHeader(StepFunctions2Constants.EXECUTION_INPUT, String.class); + String executionInput = getExecutionInput(exchange); + if (ObjectHelper.isNotEmpty(executionInput)) { builder.input(executionInput); } if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(StepFunctions2Constants.EXECUTION_TRACE_HEADER))) { @@ -590,6 +594,34 @@ public class StepFunctions2Producer extends DefaultProducer { } Message message = getMessageForResponse(exchange); message.setBody(result); + setSyncExecutionHeaders(message, result); + } + } + + /** + * The execution input of the header, which must be JSON text. A value that is not text, such as a Map, is not + * turned into JSON, so it fails instead of being sent as its toString(). + */ + private static String getExecutionInput(Exchange exchange) { + Object value = exchange.getIn().getHeader(StepFunctions2Constants.EXECUTION_INPUT); + if (value == null || value instanceof String) { + return (String) value; + } + if (value instanceof byte[] || value instanceof InputStream || value instanceof Reader) { + return exchange.getIn().getHeader(StepFunctions2Constants.EXECUTION_INPUT, String.class); + } + throw new IllegalArgumentException( + "The " + StepFunctions2Constants.EXECUTION_INPUT + " header must be JSON text, but was " + + value.getClass().getName()); + } + + private static void setSyncExecutionHeaders(Message message, StartSyncExecutionResponse result) { + message.setHeader(StepFunctions2Constants.EXECUTION_STATUS, result.statusAsString()); + if (result.error() != null) { + message.setHeader(StepFunctions2Constants.EXECUTION_ERROR, result.error()); + } + if (result.cause() != null) { + message.setHeader(StepFunctions2Constants.EXECUTION_CAUSE, result.cause()); } } diff --git a/components/camel-aws/camel-aws2-step-functions/src/test/java/org/apache/camel/component/aws2/stepfunctions/AmazonStepFunctionsClientMock.java b/components/camel-aws/camel-aws2-step-functions/src/test/java/org/apache/camel/component/aws2/stepfunctions/AmazonStepFunctionsClientMock.java index ed3f27d955ad..2315bc7f99b0 100644 --- a/components/camel-aws/camel-aws2-step-functions/src/test/java/org/apache/camel/component/aws2/stepfunctions/AmazonStepFunctionsClientMock.java +++ b/components/camel-aws/camel-aws2-step-functions/src/test/java/org/apache/camel/component/aws2/stepfunctions/AmazonStepFunctionsClientMock.java @@ -25,6 +25,8 @@ import software.amazon.awssdk.services.sfn.model.*; public class AmazonStepFunctionsClientMock implements SfnClient { + private StartSyncExecutionRequest lastStartSyncExecutionRequest; + private ListExecutionsRequest lastListExecutionsRequest; public AmazonStepFunctionsClientMock() { @@ -137,11 +139,21 @@ public class AmazonStepFunctionsClientMock implements SfnClient { @Override public StartSyncExecutionResponse startSyncExecution(StartSyncExecutionRequest startSyncExecutionRequest) { + lastStartSyncExecutionRequest = startSyncExecutionRequest; StartSyncExecutionResponse.Builder result = StartSyncExecutionResponse.builder(); result.executionArn("aws:sfn-execution::test:arn"); + if ("failing".equals(startSyncExecutionRequest.name())) { + result.status(SyncExecutionStatus.FAILED).error("States.TaskFailed").cause("The task failed"); + } else { + result.status(SyncExecutionStatus.SUCCEEDED).output(startSyncExecutionRequest.input()); + } return result.build(); } + public StartSyncExecutionRequest getLastStartSyncExecutionRequest() { + return lastStartSyncExecutionRequest; + } + @Override public StopExecutionResponse stopExecution(StopExecutionRequest stopExecutionRequest) { StopExecutionResponse.Builder result = StopExecutionResponse.builder(); diff --git a/components/camel-aws/camel-aws2-step-functions/src/test/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2ProducerTest.java b/components/camel-aws/camel-aws2-step-functions/src/test/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2ProducerTest.java index e1fdef089e87..b490b178947a 100644 --- a/components/camel-aws/camel-aws2-step-functions/src/test/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2ProducerTest.java +++ b/components/camel-aws/camel-aws2-step-functions/src/test/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2ProducerTest.java @@ -16,7 +16,9 @@ */ package org.apache.camel.component.aws2.stepfunctions; +import java.nio.charset.StandardCharsets; import java.util.Date; +import java.util.Map; import org.apache.camel.BindToRegistry; import org.apache.camel.EndpointInject; @@ -32,7 +34,9 @@ import software.amazon.awssdk.services.sfn.model.*; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; public class StepFunctions2ProducerTest extends CamelTestSupport { @@ -269,6 +273,52 @@ public class StepFunctions2ProducerTest extends CamelTestSupport { assertEquals("aws:sfn-execution::test:arn", resultGet.executionArn()); } + @Test + public void sfnStartSyncExecutionSetsStatusHeaderTest() { + Exchange exchange = template.request("direct:startSyncExecution", e -> { + e.getIn().setHeader(StepFunctions2Constants.EXECUTION_INPUT, "{\"a\":1}"); + }); + + assertNull(exchange.getException()); + assertEquals("{\"a\":1}", clientMock.getLastStartSyncExecutionRequest().input()); + assertEquals("SUCCEEDED", exchange.getMessage().getHeader(StepFunctions2Constants.EXECUTION_STATUS)); + assertNull(exchange.getMessage().getHeader(StepFunctions2Constants.EXECUTION_ERROR)); + } + + @Test + public void sfnStartSyncExecutionFailedSetsErrorHeadersTest() { + Exchange exchange = template.request("direct:startSyncExecution", e -> { + e.getIn().setHeader(StepFunctions2Constants.EXECUTION_NAME, "failing"); + }); + + assertNull(exchange.getException()); + assertEquals("FAILED", exchange.getMessage().getHeader(StepFunctions2Constants.EXECUTION_STATUS)); + assertEquals("States.TaskFailed", exchange.getMessage().getHeader(StepFunctions2Constants.EXECUTION_ERROR)); + assertEquals("The task failed", exchange.getMessage().getHeader(StepFunctions2Constants.EXECUTION_CAUSE)); + } + + @Test + public void sfnStartSyncExecutionInputAsBytesTest() { + Exchange exchange = template.request("direct:startSyncExecution", e -> { + e.getIn().setHeader(StepFunctions2Constants.EXECUTION_INPUT, "{\"b\":2}".getBytes(StandardCharsets.UTF_8)); + }); + + assertNull(exchange.getException()); + assertEquals("{\"b\":2}", clientMock.getLastStartSyncExecutionRequest().input()); + } + + @Test + public void sfnStartExecutionInputAsMapFailsTest() { + Exchange exchange = template.request("direct:startExecution", e -> { + e.getIn().setHeader(StepFunctions2Constants.EXECUTION_INPUT, Map.of("a", 1)); + }); + + assertInstanceOf(IllegalArgumentException.class, exchange.getException()); + assertEquals("The CamelAwsStepFunctionsExecutionInput header must be JSON text, but was " + + Map.of("a", 1).getClass().getName(), + exchange.getException().getMessage()); + } + @Test public void sfnStopExecutionTest() throws Exception { diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc index 3654ea38595a..e48ee3db8bf2 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc @@ -2625,3 +2625,14 @@ The `CamelAwsEKSDescription` header of `aws2-eks` is removed, together with the its method in the header builder of the endpoint DSL. No operation of the component read it. The `aws2-mq` component, which manages Amazon MQ brokers, is now in the `management` category instead of `messaging`. + +In `aws2-step-functions`, the `CamelAwsStepFunctionsExecutionInput` header of startExecution and startSyncExecution +must be JSON text (a String, a byte array or a stream). A value of another type, such as a `Map`, was sent as its +`toString()`, which is not JSON; now the exchange fails. startSyncExecution now sets the +`CamelAwsStepFunctionsExecutionStatus` header to the status of the execution (`SUCCEEDED`, `FAILED` or `TIMED_OUT`), +and the `CamelAwsStepFunctionsExecutionError` and `CamelAwsStepFunctionsExecutionCause` headers when it failed. The +exchange still does not fail when the execution did not succeed. + +In `aws-bedrock-agent`, the `CamelAwsBedrockAgentKnowledgeBaseId`, `CamelAwsBedrockAgentDataSourceId` and +`CamelAwsBedrockAgentIngestionJobId` headers now override the `knowledgeBaseId`, `dataSourceId` and `ingestionJobId` +options, as the headers of the other AWS components do. Before, a header was used only when the option was not set. diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsBedrockAgentComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsBedrockAgentComponentBuilderFactory.java index 1abbb8295ad1..a426af6087f1 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsBedrockAgentComponentBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsBedrockAgentComponentBuilderFactory.java @@ -68,8 +68,8 @@ public interface AwsBedrockAgentComponentBuilderFactory { /** * Define the Data source Id we are going to use. The consumer and all - * the operations need it; when set, it is used instead of the - * CamelAwsBedrockAgentDataSourceId header. + * the operations need it; the CamelAwsBedrockAgentDataSourceId header + * overrides it for the producer. * * The option is a: <code>java.lang.String</code> type. * @@ -85,8 +85,9 @@ public interface AwsBedrockAgentComponentBuilderFactory { /** * Define the Ingestion Job Id we want to track. The consumer and the - * getIngestionJob operation need it; when set, it is used instead of - * the CamelAwsBedrockAgentIngestionJobId header. + * getIngestionJob operation need it; the + * CamelAwsBedrockAgentIngestionJobId header overrides it for the + * producer. * * The option is a: <code>java.lang.String</code> type. * @@ -102,8 +103,8 @@ public interface AwsBedrockAgentComponentBuilderFactory { /** * Define the Knowledge Base Id we are going to use. The consumer and - * all the operations need it; when set, it is used instead of the - * CamelAwsBedrockAgentKnowledgeBaseId header. + * all the operations need it; the CamelAwsBedrockAgentKnowledgeBaseId + * header overrides it for the producer. * * The option is a: <code>java.lang.String</code> type. * diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BedrockAgentEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BedrockAgentEndpointBuilderFactory.java index 7f0173d11b01..5ce9558daa2c 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BedrockAgentEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BedrockAgentEndpointBuilderFactory.java @@ -45,8 +45,8 @@ public interface BedrockAgentEndpointBuilderFactory { } /** * Define the Data source Id we are going to use. The consumer and all - * the operations need it; when set, it is used instead of the - * CamelAwsBedrockAgentDataSourceId header. + * the operations need it; the CamelAwsBedrockAgentDataSourceId header + * overrides it for the producer. * * The option is a: <code>java.lang.String</code> type. * @@ -61,8 +61,9 @@ public interface BedrockAgentEndpointBuilderFactory { } /** * Define the Ingestion Job Id we want to track. The consumer and the - * getIngestionJob operation need it; when set, it is used instead of - * the CamelAwsBedrockAgentIngestionJobId header. + * getIngestionJob operation need it; the + * CamelAwsBedrockAgentIngestionJobId header overrides it for the + * producer. * * The option is a: <code>java.lang.String</code> type. * @@ -77,8 +78,8 @@ public interface BedrockAgentEndpointBuilderFactory { } /** * Define the Knowledge Base Id we are going to use. The consumer and - * all the operations need it; when set, it is used instead of the - * CamelAwsBedrockAgentKnowledgeBaseId header. + * all the operations need it; the CamelAwsBedrockAgentKnowledgeBaseId + * header overrides it for the producer. * * The option is a: <code>java.lang.String</code> type. * @@ -1184,8 +1185,8 @@ public interface BedrockAgentEndpointBuilderFactory { /** * Define the Data source Id we are going to use. The consumer and all - * the operations need it; when set, it is used instead of the - * CamelAwsBedrockAgentDataSourceId header. + * the operations need it; the CamelAwsBedrockAgentDataSourceId header + * overrides it for the producer. * * The option is a: <code>java.lang.String</code> type. * @@ -1200,8 +1201,9 @@ public interface BedrockAgentEndpointBuilderFactory { } /** * Define the Ingestion Job Id we want to track. The consumer and the - * getIngestionJob operation need it; when set, it is used instead of - * the CamelAwsBedrockAgentIngestionJobId header. + * getIngestionJob operation need it; the + * CamelAwsBedrockAgentIngestionJobId header overrides it for the + * producer. * * The option is a: <code>java.lang.String</code> type. * @@ -1216,8 +1218,8 @@ public interface BedrockAgentEndpointBuilderFactory { } /** * Define the Knowledge Base Id we are going to use. The consumer and - * all the operations need it; when set, it is used instead of the - * CamelAwsBedrockAgentKnowledgeBaseId header. + * all the operations need it; the CamelAwsBedrockAgentKnowledgeBaseId + * header overrides it for the producer. * * The option is a: <code>java.lang.String</code> type. * @@ -1727,8 +1729,8 @@ public interface BedrockAgentEndpointBuilderFactory { /** * Define the Data source Id we are going to use. The consumer and all - * the operations need it; when set, it is used instead of the - * CamelAwsBedrockAgentDataSourceId header. + * the operations need it; the CamelAwsBedrockAgentDataSourceId header + * overrides it for the producer. * * The option is a: <code>java.lang.String</code> type. * @@ -1743,8 +1745,9 @@ public interface BedrockAgentEndpointBuilderFactory { } /** * Define the Ingestion Job Id we want to track. The consumer and the - * getIngestionJob operation need it; when set, it is used instead of - * the CamelAwsBedrockAgentIngestionJobId header. + * getIngestionJob operation need it; the + * CamelAwsBedrockAgentIngestionJobId header overrides it for the + * producer. * * The option is a: <code>java.lang.String</code> type. * @@ -1759,8 +1762,8 @@ public interface BedrockAgentEndpointBuilderFactory { } /** * Define the Knowledge Base Id we are going to use. The consumer and - * all the operations need it; when set, it is used instead of the - * CamelAwsBedrockAgentKnowledgeBaseId header. + * all the operations need it; the CamelAwsBedrockAgentKnowledgeBaseId + * header overrides it for the producer. * * The option is a: <code>java.lang.String</code> type. * @@ -2293,8 +2296,8 @@ public interface BedrockAgentEndpointBuilderFactory { return "CamelAwsBedrockAgentOperation"; } /** - * The data source Id of the operation, used when the dataSourceId - * option is not set. + * The data source Id of the operation; it overrides the dataSourceId + * option. * * The option is a: {@code String} type. * @@ -2306,8 +2309,8 @@ public interface BedrockAgentEndpointBuilderFactory { return "CamelAwsBedrockAgentDataSourceId"; } /** - * The knowledge base Id of the operation, used when the knowledgeBaseId - * option is not set. + * The knowledge base Id of the operation; it overrides the + * knowledgeBaseId option. * * The option is a: {@code String} type. * @@ -2320,8 +2323,8 @@ public interface BedrockAgentEndpointBuilderFactory { return "CamelAwsBedrockAgentKnowledgeBaseId"; } /** - * The id of the ingestion job of the getIngestionJob operation, used - * when the ingestionJobId option is not set. + * The id of the ingestion job of the getIngestionJob operation; it + * overrides the ingestionJobId option. * * The option is a: {@code String} type. * diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/StepFunctions2EndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/StepFunctions2EndpointBuilderFactory.java index 24777b06b79e..07b8ba26b769 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/StepFunctions2EndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/StepFunctions2EndpointBuilderFactory.java @@ -746,7 +746,8 @@ public interface StepFunctions2EndpointBuilderFactory { return "CamelAwsStepFunctionsExecutionName"; } /** - * The string that contains the JSON input data for the execution. + * The JSON input data for the execution, as text (a String, a byte + * array or a stream). * * The option is a: {@code String} type. * @@ -758,6 +759,47 @@ public interface StepFunctions2EndpointBuilderFactory { public String awsStepFunctionsExecutionInput() { return "CamelAwsStepFunctionsExecutionInput"; } + /** + * The status of the execution: SUCCEEDED, FAILED or TIMED_OUT. The + * exchange does not fail when the execution did not succeed: check this + * header. + * + * The option is a: {@code String} type. + * + * Group: startSyncExecution + * + * @return the name of the header {@code + * AwsStepFunctionsExecutionStatus}. + */ + public String awsStepFunctionsExecutionStatus() { + return "CamelAwsStepFunctionsExecutionStatus"; + } + /** + * The error code of the failure, when the execution failed. + * + * The option is a: {@code String} type. + * + * Group: startSyncExecution + * + * @return the name of the header {@code + * AwsStepFunctionsExecutionError}. + */ + public String awsStepFunctionsExecutionError() { + return "CamelAwsStepFunctionsExecutionError"; + } + /** + * The cause of the failure, when the execution failed. + * + * The option is a: {@code String} type. + * + * Group: startSyncExecution + * + * @return the name of the header {@code + * AwsStepFunctionsExecutionCause}. + */ + public String awsStepFunctionsExecutionCause() { + return "CamelAwsStepFunctionsExecutionCause"; + } /** * Passes the X-Ray trace header. *
