This is an automated email from the ASF dual-hosted git repository.
oscerd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 754589826768 CAMEL-24207: camel-aws2-transcribe - implement the 21
declared but stubbed operations (#24975)
754589826768 is described below
commit 75458982676899e1a2af49d2e103c02b940ff8dd
Author: Andrea Cosentino <[email protected]>
AuthorDate: Tue Jul 21 14:48:04 2026 +0200
CAMEL-24207: camel-aws2-transcribe - implement the 21 declared but stubbed
operations (#24975)
Implements vocabulary filters, custom language models, medical
vocabularies, medical transcription jobs and tagging, which were previously
silent no-ops.
Co-authored-by: Claude Fable 5 <[email protected]>
---
.../camel/catalog/components/aws2-transcribe.json | 11 +-
.../component/aws2/transcribe/aws2-transcribe.json | 11 +-
.../aws2/transcribe/Transcribe2Constants.java | 27 ++
.../aws2/transcribe/Transcribe2Producer.java | 406 ++++++++++++++++++---
...anscribe2ProducerImplementedOperationsTest.java | 199 ++++++++++
.../dsl/Transcribe2EndpointBuilderFactory.java | 111 ++++++
6 files changed, 721 insertions(+), 44 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-transcribe.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-transcribe.json
index 02302171c8ee..36f7202509d1 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-transcribe.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-transcribe.json
@@ -62,7 +62,16 @@
"CamelAwsTranscribeMedicalTranscriptionJobName": { "index": 10, "kind":
"header", "displayName": "", "group": "producer", "label": "producer",
"required": false, "javaType": "String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false, "description": "The
name of the medical transcription job", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#MEDICAL_TRANSCRIPTION_JOB_NAME"
},
"CamelAwsTranscribeResourceArn": { "index": 11, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The Amazon Resource Name (ARN) of the
resource", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#RESOURCE_ARN"
},
"CamelAwsTranscribeTags": { "index": 12, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"Map<String, String>", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "A map of tags to assign to the
resource", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#TAGS" },
- "CamelAwsTranscribeTagKeys": { "index": 13, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "List<String>", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "description": "A list of tag keys to
remove from the resource", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#TAG_KEYS" }
+ "CamelAwsTranscribeTagKeys": { "index": 13, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "List<String>", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "description": "A list of tag keys to
remove from the resource", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#TAG_KEYS" },
+ "CamelAwsTranscribeMaxResults": { "index": 14, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The maximum number of results to return
in a list operation", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#MAX_RESULTS" },
+ "CamelAwsTranscribeNextToken": { "index": 15, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The token to retrieve the next page of
a list operation", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#NEXT_TOKEN" },
+ "CamelAwsTranscribeVocabularyFileUri": { "index": 16, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The S3 location of the vocabulary or
vocabulary filter file", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#VOCABULARY_FILE_URI"
},
+ "CamelAwsTranscribeBaseModelName": { "index": 17, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The base model used when creating a
custom language model", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#BASE_MODEL_NAME"
},
+ "CamelAwsTranscribeInputDataS3Uri": { "index": 18, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The S3 location of the training data
for a custom language model", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#INPUT_DATA_S3_URI"
},
+ "CamelAwsTranscribeDataAccessRoleArn": { "index": 19, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The ARN of the IAM role granting access
to the training data or vocabulary file", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#DATA_ACCESS_ROLE_ARN"
},
+ "CamelAwsTranscribeOutputBucketName": { "index": 20, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The S3 bucket where the transcription
output is stored", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#OUTPUT_BUCKET_NAME"
},
+ "CamelAwsTranscribeSpecialty": { "index": 21, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The medical specialty of a medical
transcription job", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#SPECIALTY" },
+ "CamelAwsTranscribeType": { "index": 22, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"String", "deprecated": false, "deprecationNote": "", "autowired": false,
"secret": false, "description": "The audio type of a medical transcription
job", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#TYPE" }
},
"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.transcribe.Transcribe2Configuration",
"configurationField": "configuration", "description": "Logical name" },
diff --git
a/components/camel-aws/camel-aws2-transcribe/src/generated/resources/META-INF/org/apache/camel/component/aws2/transcribe/aws2-transcribe.json
b/components/camel-aws/camel-aws2-transcribe/src/generated/resources/META-INF/org/apache/camel/component/aws2/transcribe/aws2-transcribe.json
index 02302171c8ee..36f7202509d1 100644
---
a/components/camel-aws/camel-aws2-transcribe/src/generated/resources/META-INF/org/apache/camel/component/aws2/transcribe/aws2-transcribe.json
+++
b/components/camel-aws/camel-aws2-transcribe/src/generated/resources/META-INF/org/apache/camel/component/aws2/transcribe/aws2-transcribe.json
@@ -62,7 +62,16 @@
"CamelAwsTranscribeMedicalTranscriptionJobName": { "index": 10, "kind":
"header", "displayName": "", "group": "producer", "label": "producer",
"required": false, "javaType": "String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false, "description": "The
name of the medical transcription job", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#MEDICAL_TRANSCRIPTION_JOB_NAME"
},
"CamelAwsTranscribeResourceArn": { "index": 11, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The Amazon Resource Name (ARN) of the
resource", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#RESOURCE_ARN"
},
"CamelAwsTranscribeTags": { "index": 12, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"Map<String, String>", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "A map of tags to assign to the
resource", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#TAGS" },
- "CamelAwsTranscribeTagKeys": { "index": 13, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "List<String>", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "description": "A list of tag keys to
remove from the resource", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#TAG_KEYS" }
+ "CamelAwsTranscribeTagKeys": { "index": 13, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "List<String>", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "description": "A list of tag keys to
remove from the resource", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#TAG_KEYS" },
+ "CamelAwsTranscribeMaxResults": { "index": 14, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The maximum number of results to return
in a list operation", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#MAX_RESULTS" },
+ "CamelAwsTranscribeNextToken": { "index": 15, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The token to retrieve the next page of
a list operation", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#NEXT_TOKEN" },
+ "CamelAwsTranscribeVocabularyFileUri": { "index": 16, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The S3 location of the vocabulary or
vocabulary filter file", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#VOCABULARY_FILE_URI"
},
+ "CamelAwsTranscribeBaseModelName": { "index": 17, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The base model used when creating a
custom language model", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#BASE_MODEL_NAME"
},
+ "CamelAwsTranscribeInputDataS3Uri": { "index": 18, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The S3 location of the training data
for a custom language model", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#INPUT_DATA_S3_URI"
},
+ "CamelAwsTranscribeDataAccessRoleArn": { "index": 19, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The ARN of the IAM role granting access
to the training data or vocabulary file", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#DATA_ACCESS_ROLE_ARN"
},
+ "CamelAwsTranscribeOutputBucketName": { "index": 20, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The S3 bucket where the transcription
output is stored", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#OUTPUT_BUCKET_NAME"
},
+ "CamelAwsTranscribeSpecialty": { "index": 21, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The medical specialty of a medical
transcription job", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#SPECIALTY" },
+ "CamelAwsTranscribeType": { "index": 22, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"String", "deprecated": false, "deprecationNote": "", "autowired": false,
"secret": false, "description": "The audio type of a medical transcription
job", "constantName":
"org.apache.camel.component.aws2.transcribe.Transcribe2Constants#TYPE" }
},
"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.transcribe.Transcribe2Configuration",
"configurationField": "configuration", "description": "Logical name" },
diff --git
a/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/Transcribe2Constants.java
b/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/Transcribe2Constants.java
index ed451a937673..515ba13c9c0a 100644
---
a/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/Transcribe2Constants.java
+++
b/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/Transcribe2Constants.java
@@ -51,4 +51,31 @@ public interface Transcribe2Constants {
String TAGS = "CamelAwsTranscribeTags";
@Metadata(label = "producer", description = "A list of tag keys to remove
from the resource", javaType = "List<String>")
String TAG_KEYS = "CamelAwsTranscribeTagKeys";
+ @Metadata(label = "producer", description = "The maximum number of results
to return in a list operation",
+ javaType = "Integer")
+ String MAX_RESULTS = "CamelAwsTranscribeMaxResults";
+ @Metadata(label = "producer", description = "The token to retrieve the
next page of a list operation",
+ javaType = "String")
+ String NEXT_TOKEN = "CamelAwsTranscribeNextToken";
+ @Metadata(label = "producer", description = "The S3 location of the
vocabulary or vocabulary filter file",
+ javaType = "String")
+ String VOCABULARY_FILE_URI = "CamelAwsTranscribeVocabularyFileUri";
+ @Metadata(label = "producer", description = "The base model used when
creating a custom language model",
+ javaType = "String")
+ String BASE_MODEL_NAME = "CamelAwsTranscribeBaseModelName";
+ @Metadata(label = "producer",
+ description = "The S3 location of the training data for a custom
language model", javaType = "String")
+ String INPUT_DATA_S3_URI = "CamelAwsTranscribeInputDataS3Uri";
+ @Metadata(label = "producer",
+ description = "The ARN of the IAM role granting access to the
training data or vocabulary file",
+ javaType = "String")
+ String DATA_ACCESS_ROLE_ARN = "CamelAwsTranscribeDataAccessRoleArn";
+ @Metadata(label = "producer", description = "The S3 bucket where the
transcription output is stored",
+ javaType = "String")
+ String OUTPUT_BUCKET_NAME = "CamelAwsTranscribeOutputBucketName";
+ @Metadata(label = "producer", description = "The medical specialty of a
medical transcription job",
+ javaType = "String")
+ String SPECIALTY = "CamelAwsTranscribeSpecialty";
+ @Metadata(label = "producer", description = "The audio type of a medical
transcription job", javaType = "String")
+ String TYPE = "CamelAwsTranscribeType";
}
diff --git
a/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/Transcribe2Producer.java
b/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/Transcribe2Producer.java
index 8a4f8a7891f0..9521e1d360b8 100644
---
a/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/Transcribe2Producer.java
+++
b/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/Transcribe2Producer.java
@@ -16,6 +16,11 @@
*/
package org.apache.camel.component.aws2.transcribe;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.InvalidPayloadException;
@@ -443,88 +448,405 @@ public class Transcribe2Producer extends DefaultProducer
{
}
}
- private void createVocabularyFilter(TranscribeClient transcribeClient,
Exchange exchange) {
- // Implementation for create vocabulary filter
+ private void createVocabularyFilter(TranscribeClient transcribeClient,
Exchange exchange)
+ throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof CreateVocabularyFilterRequest req) {
+ setResponse(exchange, execute("Create Vocabulary Filter", ()
-> transcribeClient.createVocabularyFilter(req)));
+ }
+ } else {
+ CreateVocabularyFilterRequest.Builder builder =
CreateVocabularyFilterRequest.builder();
+ applyIfPresent(exchange,
Transcribe2Constants.VOCABULARY_FILTER_NAME, builder::vocabularyFilterName);
+ applyIfPresent(exchange, Transcribe2Constants.LANGUAGE_CODE,
builder::languageCode);
+ applyIfPresent(exchange, Transcribe2Constants.VOCABULARY_FILE_URI,
builder::vocabularyFilterFileUri);
+ applyIfPresent(exchange,
Transcribe2Constants.DATA_ACCESS_ROLE_ARN, builder::dataAccessRoleArn);
+ List<String> words =
exchange.getIn().getHeader(Transcribe2Constants.VOCABULARY_PHRASES, List.class);
+ if (ObjectHelper.isNotEmpty(words)) {
+ builder.words(words);
+ }
+ setResponse(exchange,
+ execute("Create Vocabulary Filter", () ->
transcribeClient.createVocabularyFilter(builder.build())));
+ }
+ }
+
+ private void getVocabularyFilter(TranscribeClient transcribeClient,
Exchange exchange) throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof GetVocabularyFilterRequest req) {
+ setResponse(exchange, execute("Get Vocabulary Filter", () ->
transcribeClient.getVocabularyFilter(req)));
+ }
+ } else {
+ GetVocabularyFilterRequest.Builder builder =
GetVocabularyFilterRequest.builder();
+ applyIfPresent(exchange,
Transcribe2Constants.VOCABULARY_FILTER_NAME, builder::vocabularyFilterName);
+ setResponse(exchange,
+ execute("Get Vocabulary Filter", () ->
transcribeClient.getVocabularyFilter(builder.build())));
+ }
+ }
+
+ private void listVocabularyFilters(TranscribeClient transcribeClient,
Exchange exchange) throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof ListVocabularyFiltersRequest req) {
+ setResponse(exchange, execute("List Vocabulary Filters", () ->
transcribeClient.listVocabularyFilters(req)));
+ }
+ } else {
+ ListVocabularyFiltersRequest.Builder builder =
ListVocabularyFiltersRequest.builder();
+ applyIfPresent(exchange, Transcribe2Constants.JOB_NAME_CONTAINS,
builder::nameContains);
+ applyIfPresent(exchange, Transcribe2Constants.NEXT_TOKEN,
builder::nextToken);
+ applyMaxResults(exchange, builder::maxResults);
+ setResponse(exchange,
+ execute("List Vocabulary Filters", () ->
transcribeClient.listVocabularyFilters(builder.build())));
+ }
+ }
+
+ private void updateVocabularyFilter(TranscribeClient transcribeClient,
Exchange exchange)
+ throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof UpdateVocabularyFilterRequest req) {
+ setResponse(exchange, execute("Update Vocabulary Filter", ()
-> transcribeClient.updateVocabularyFilter(req)));
+ }
+ } else {
+ UpdateVocabularyFilterRequest.Builder builder =
UpdateVocabularyFilterRequest.builder();
+ applyIfPresent(exchange,
Transcribe2Constants.VOCABULARY_FILTER_NAME, builder::vocabularyFilterName);
+ applyIfPresent(exchange, Transcribe2Constants.VOCABULARY_FILE_URI,
builder::vocabularyFilterFileUri);
+ applyIfPresent(exchange,
Transcribe2Constants.DATA_ACCESS_ROLE_ARN, builder::dataAccessRoleArn);
+ List<String> words =
exchange.getIn().getHeader(Transcribe2Constants.VOCABULARY_PHRASES, List.class);
+ if (ObjectHelper.isNotEmpty(words)) {
+ builder.words(words);
+ }
+ setResponse(exchange,
+ execute("Update Vocabulary Filter", () ->
transcribeClient.updateVocabularyFilter(builder.build())));
+ }
+ }
+
+ private void deleteVocabularyFilter(TranscribeClient transcribeClient,
Exchange exchange)
+ throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof DeleteVocabularyFilterRequest req) {
+ setResponse(exchange, execute("Delete Vocabulary Filter", ()
-> transcribeClient.deleteVocabularyFilter(req)));
+ }
+ } else {
+ DeleteVocabularyFilterRequest.Builder builder =
DeleteVocabularyFilterRequest.builder();
+ applyIfPresent(exchange,
Transcribe2Constants.VOCABULARY_FILTER_NAME, builder::vocabularyFilterName);
+ setResponse(exchange,
+ execute("Delete Vocabulary Filter", () ->
transcribeClient.deleteVocabularyFilter(builder.build())));
+ }
}
- private void getVocabularyFilter(TranscribeClient transcribeClient,
Exchange exchange) {
- // Implementation for get vocabulary filter
+ private void createLanguageModel(TranscribeClient transcribeClient,
Exchange exchange) throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof CreateLanguageModelRequest req) {
+ setResponse(exchange, execute("Create Language Model", () ->
transcribeClient.createLanguageModel(req)));
+ }
+ } else {
+ CreateLanguageModelRequest.Builder builder =
CreateLanguageModelRequest.builder();
+ applyIfPresent(exchange, Transcribe2Constants.LANGUAGE_MODEL_NAME,
builder::modelName);
+ applyIfPresent(exchange, Transcribe2Constants.LANGUAGE_CODE,
builder::languageCode);
+ applyIfPresent(exchange, Transcribe2Constants.BASE_MODEL_NAME,
builder::baseModelName);
+ String s3Uri =
exchange.getIn().getHeader(Transcribe2Constants.INPUT_DATA_S3_URI,
String.class);
+ String roleArn =
exchange.getIn().getHeader(Transcribe2Constants.DATA_ACCESS_ROLE_ARN,
String.class);
+ if (ObjectHelper.isNotEmpty(s3Uri) ||
ObjectHelper.isNotEmpty(roleArn)) {
+
builder.inputDataConfig(InputDataConfig.builder().s3Uri(s3Uri).dataAccessRoleArn(roleArn).build());
+ }
+ setResponse(exchange,
+ execute("Create Language Model", () ->
transcribeClient.createLanguageModel(builder.build())));
+ }
}
- private void listVocabularyFilters(TranscribeClient transcribeClient,
Exchange exchange) {
- // Implementation for list vocabulary filters
+ private void describeLanguageModel(TranscribeClient transcribeClient,
Exchange exchange) throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof DescribeLanguageModelRequest req) {
+ setResponse(exchange, execute("Describe Language Model", () ->
transcribeClient.describeLanguageModel(req)));
+ }
+ } else {
+ DescribeLanguageModelRequest.Builder builder =
DescribeLanguageModelRequest.builder();
+ applyIfPresent(exchange, Transcribe2Constants.LANGUAGE_MODEL_NAME,
builder::modelName);
+ setResponse(exchange,
+ execute("Describe Language Model", () ->
transcribeClient.describeLanguageModel(builder.build())));
+ }
}
- private void updateVocabularyFilter(TranscribeClient transcribeClient,
Exchange exchange) {
- // Implementation for update vocabulary filter
+ private void listLanguageModels(TranscribeClient transcribeClient,
Exchange exchange) throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof ListLanguageModelsRequest req) {
+ setResponse(exchange, execute("List Language Models", () ->
transcribeClient.listLanguageModels(req)));
+ }
+ } else {
+ ListLanguageModelsRequest.Builder builder =
ListLanguageModelsRequest.builder();
+ applyIfPresent(exchange, Transcribe2Constants.JOB_NAME_CONTAINS,
builder::nameContains);
+ applyIfPresent(exchange, Transcribe2Constants.STATUS,
builder::statusEquals);
+ applyIfPresent(exchange, Transcribe2Constants.NEXT_TOKEN,
builder::nextToken);
+ applyMaxResults(exchange, builder::maxResults);
+ setResponse(exchange, execute("List Language Models", () ->
transcribeClient.listLanguageModels(builder.build())));
+ }
}
- private void deleteVocabularyFilter(TranscribeClient transcribeClient,
Exchange exchange) {
- // Implementation for delete vocabulary filter
+ private void deleteLanguageModel(TranscribeClient transcribeClient,
Exchange exchange) throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof DeleteLanguageModelRequest req) {
+ setResponse(exchange, execute("Delete Language Model", () ->
transcribeClient.deleteLanguageModel(req)));
+ }
+ } else {
+ DeleteLanguageModelRequest.Builder builder =
DeleteLanguageModelRequest.builder();
+ applyIfPresent(exchange, Transcribe2Constants.LANGUAGE_MODEL_NAME,
builder::modelName);
+ setResponse(exchange,
+ execute("Delete Language Model", () ->
transcribeClient.deleteLanguageModel(builder.build())));
+ }
}
- private void createLanguageModel(TranscribeClient transcribeClient,
Exchange exchange) {
- // Implementation for create language model
+ private void createMedicalVocabulary(TranscribeClient transcribeClient,
Exchange exchange)
+ throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof CreateMedicalVocabularyRequest req) {
+ setResponse(exchange,
+ execute("Create Medical Vocabulary", () ->
transcribeClient.createMedicalVocabulary(req)));
+ }
+ } else {
+ CreateMedicalVocabularyRequest.Builder builder =
CreateMedicalVocabularyRequest.builder();
+ applyIfPresent(exchange, Transcribe2Constants.VOCABULARY_NAME,
builder::vocabularyName);
+ applyIfPresent(exchange, Transcribe2Constants.LANGUAGE_CODE,
builder::languageCode);
+ applyIfPresent(exchange, Transcribe2Constants.VOCABULARY_FILE_URI,
builder::vocabularyFileUri);
+ setResponse(exchange,
+ execute("Create Medical Vocabulary", () ->
transcribeClient.createMedicalVocabulary(builder.build())));
+ }
}
- private void describeLanguageModel(TranscribeClient transcribeClient,
Exchange exchange) {
- // Implementation for describe language model
+ private void getMedicalVocabulary(TranscribeClient transcribeClient,
Exchange exchange) throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof GetMedicalVocabularyRequest req) {
+ setResponse(exchange, execute("Get Medical Vocabulary", () ->
transcribeClient.getMedicalVocabulary(req)));
+ }
+ } else {
+ GetMedicalVocabularyRequest.Builder builder =
GetMedicalVocabularyRequest.builder();
+ applyIfPresent(exchange, Transcribe2Constants.VOCABULARY_NAME,
builder::vocabularyName);
+ setResponse(exchange,
+ execute("Get Medical Vocabulary", () ->
transcribeClient.getMedicalVocabulary(builder.build())));
+ }
}
- private void listLanguageModels(TranscribeClient transcribeClient,
Exchange exchange) {
- // Implementation for list language models
+ private void listMedicalVocabularies(TranscribeClient transcribeClient,
Exchange exchange)
+ throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof ListMedicalVocabulariesRequest req) {
+ setResponse(exchange,
+ execute("List Medical Vocabularies", () ->
transcribeClient.listMedicalVocabularies(req)));
+ }
+ } else {
+ ListMedicalVocabulariesRequest.Builder builder =
ListMedicalVocabulariesRequest.builder();
+ applyIfPresent(exchange, Transcribe2Constants.JOB_NAME_CONTAINS,
builder::nameContains);
+ applyIfPresent(exchange, Transcribe2Constants.STATUS,
builder::stateEquals);
+ applyIfPresent(exchange, Transcribe2Constants.NEXT_TOKEN,
builder::nextToken);
+ applyMaxResults(exchange, builder::maxResults);
+ setResponse(exchange,
+ execute("List Medical Vocabularies", () ->
transcribeClient.listMedicalVocabularies(builder.build())));
+ }
}
- private void deleteLanguageModel(TranscribeClient transcribeClient,
Exchange exchange) {
- // Implementation for delete language model
+ private void updateMedicalVocabulary(TranscribeClient transcribeClient,
Exchange exchange)
+ throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof UpdateMedicalVocabularyRequest req) {
+ setResponse(exchange,
+ execute("Update Medical Vocabulary", () ->
transcribeClient.updateMedicalVocabulary(req)));
+ }
+ } else {
+ UpdateMedicalVocabularyRequest.Builder builder =
UpdateMedicalVocabularyRequest.builder();
+ applyIfPresent(exchange, Transcribe2Constants.VOCABULARY_NAME,
builder::vocabularyName);
+ applyIfPresent(exchange, Transcribe2Constants.LANGUAGE_CODE,
builder::languageCode);
+ applyIfPresent(exchange, Transcribe2Constants.VOCABULARY_FILE_URI,
builder::vocabularyFileUri);
+ setResponse(exchange,
+ execute("Update Medical Vocabulary", () ->
transcribeClient.updateMedicalVocabulary(builder.build())));
+ }
}
- private void createMedicalVocabulary(TranscribeClient transcribeClient,
Exchange exchange) {
- // Implementation for create medical vocabulary
+ private void deleteMedicalVocabulary(TranscribeClient transcribeClient,
Exchange exchange)
+ throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof DeleteMedicalVocabularyRequest req) {
+ setResponse(exchange,
+ execute("Delete Medical Vocabulary", () ->
transcribeClient.deleteMedicalVocabulary(req)));
+ }
+ } else {
+ DeleteMedicalVocabularyRequest.Builder builder =
DeleteMedicalVocabularyRequest.builder();
+ applyIfPresent(exchange, Transcribe2Constants.VOCABULARY_NAME,
builder::vocabularyName);
+ setResponse(exchange,
+ execute("Delete Medical Vocabulary", () ->
transcribeClient.deleteMedicalVocabulary(builder.build())));
+ }
}
- private void getMedicalVocabulary(TranscribeClient transcribeClient,
Exchange exchange) {
- // Implementation for get medical vocabulary
+ private void startMedicalTranscriptionJob(TranscribeClient
transcribeClient, Exchange exchange)
+ throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof StartMedicalTranscriptionJobRequest req) {
+ setResponse(exchange,
+ execute("Start Medical Transcription Job",
+ () ->
transcribeClient.startMedicalTranscriptionJob(req)));
+ }
+ } else {
+ StartMedicalTranscriptionJobRequest.Builder builder =
StartMedicalTranscriptionJobRequest.builder();
+ applyIfPresent(exchange,
Transcribe2Constants.MEDICAL_TRANSCRIPTION_JOB_NAME,
+ builder::medicalTranscriptionJobName);
+ applyIfPresent(exchange, Transcribe2Constants.LANGUAGE_CODE,
builder::languageCode);
+ applyIfPresent(exchange, Transcribe2Constants.MEDIA_FORMAT,
builder::mediaFormat);
+ applyIfPresent(exchange, Transcribe2Constants.OUTPUT_BUCKET_NAME,
builder::outputBucketName);
+ applyIfPresent(exchange, Transcribe2Constants.SPECIALTY,
builder::specialty);
+ applyIfPresent(exchange, Transcribe2Constants.TYPE, builder::type);
+ String mediaUri =
exchange.getIn().getHeader(Transcribe2Constants.MEDIA_URI, String.class);
+ if (ObjectHelper.isNotEmpty(mediaUri)) {
+ builder.media(Media.builder().mediaFileUri(mediaUri).build());
+ }
+ setResponse(exchange, execute("Start Medical Transcription Job",
+ () ->
transcribeClient.startMedicalTranscriptionJob(builder.build())));
+ }
}
- private void listMedicalVocabularies(TranscribeClient transcribeClient,
Exchange exchange) {
- // Implementation for list medical vocabularies
+ private void getMedicalTranscriptionJob(TranscribeClient transcribeClient,
Exchange exchange)
+ throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof GetMedicalTranscriptionJobRequest req) {
+ setResponse(exchange,
+ execute("Get Medical Transcription Job", () ->
transcribeClient.getMedicalTranscriptionJob(req)));
+ }
+ } else {
+ GetMedicalTranscriptionJobRequest.Builder builder =
GetMedicalTranscriptionJobRequest.builder();
+ applyIfPresent(exchange,
Transcribe2Constants.MEDICAL_TRANSCRIPTION_JOB_NAME,
+ builder::medicalTranscriptionJobName);
+ setResponse(exchange, execute("Get Medical Transcription Job",
+ () ->
transcribeClient.getMedicalTranscriptionJob(builder.build())));
+ }
}
- private void updateMedicalVocabulary(TranscribeClient transcribeClient,
Exchange exchange) {
- // Implementation for update medical vocabulary
+ private void listMedicalTranscriptionJobs(TranscribeClient
transcribeClient, Exchange exchange)
+ throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof ListMedicalTranscriptionJobsRequest req) {
+ setResponse(exchange,
+ execute("List Medical Transcription Jobs", () ->
transcribeClient.listMedicalTranscriptionJobs(req)));
+ }
+ } else {
+ ListMedicalTranscriptionJobsRequest.Builder builder =
ListMedicalTranscriptionJobsRequest.builder();
+ applyIfPresent(exchange, Transcribe2Constants.JOB_NAME_CONTAINS,
builder::jobNameContains);
+ applyIfPresent(exchange, Transcribe2Constants.STATUS,
builder::status);
+ applyIfPresent(exchange, Transcribe2Constants.NEXT_TOKEN,
builder::nextToken);
+ applyMaxResults(exchange, builder::maxResults);
+ setResponse(exchange, execute("List Medical Transcription Jobs",
+ () ->
transcribeClient.listMedicalTranscriptionJobs(builder.build())));
+ }
}
- private void deleteMedicalVocabulary(TranscribeClient transcribeClient,
Exchange exchange) {
- // Implementation for delete medical vocabulary
+ private void deleteMedicalTranscriptionJob(TranscribeClient
transcribeClient, Exchange exchange)
+ throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof DeleteMedicalTranscriptionJobRequest req) {
+ setResponse(exchange, execute("Delete Medical Transcription
Job",
+ () ->
transcribeClient.deleteMedicalTranscriptionJob(req)));
+ }
+ } else {
+ DeleteMedicalTranscriptionJobRequest.Builder builder =
DeleteMedicalTranscriptionJobRequest.builder();
+ applyIfPresent(exchange,
Transcribe2Constants.MEDICAL_TRANSCRIPTION_JOB_NAME,
+ builder::medicalTranscriptionJobName);
+ setResponse(exchange, execute("Delete Medical Transcription Job",
+ () ->
transcribeClient.deleteMedicalTranscriptionJob(builder.build())));
+ }
}
- private void startMedicalTranscriptionJob(TranscribeClient
transcribeClient, Exchange exchange) {
- // Implementation for start medical transcription job
+ private void tagResource(TranscribeClient transcribeClient, Exchange
exchange) throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof TagResourceRequest req) {
+ setResponse(exchange, execute("Tag Resource", () ->
transcribeClient.tagResource(req)));
+ }
+ } else {
+ TagResourceRequest.Builder builder = TagResourceRequest.builder();
+ applyIfPresent(exchange, Transcribe2Constants.RESOURCE_ARN,
builder::resourceArn);
+ Map<String, String> tags =
exchange.getIn().getHeader(Transcribe2Constants.TAGS, Map.class);
+ if (ObjectHelper.isNotEmpty(tags)) {
+ builder.tags(tags.entrySet().stream()
+ .map(e ->
Tag.builder().key(e.getKey()).value(e.getValue()).build())
+ .toList());
+ }
+ setResponse(exchange, execute("Tag Resource", () ->
transcribeClient.tagResource(builder.build())));
+ }
}
- private void getMedicalTranscriptionJob(TranscribeClient transcribeClient,
Exchange exchange) {
- // Implementation for get medical transcription job
+ private void untagResource(TranscribeClient transcribeClient, Exchange
exchange) throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof UntagResourceRequest req) {
+ setResponse(exchange, execute("Untag Resource", () ->
transcribeClient.untagResource(req)));
+ }
+ } else {
+ UntagResourceRequest.Builder builder =
UntagResourceRequest.builder();
+ applyIfPresent(exchange, Transcribe2Constants.RESOURCE_ARN,
builder::resourceArn);
+ List<String> tagKeys =
exchange.getIn().getHeader(Transcribe2Constants.TAG_KEYS, List.class);
+ if (ObjectHelper.isNotEmpty(tagKeys)) {
+ builder.tagKeys(tagKeys);
+ }
+ setResponse(exchange, execute("Untag Resource", () ->
transcribeClient.untagResource(builder.build())));
+ }
}
- private void listMedicalTranscriptionJobs(TranscribeClient
transcribeClient, Exchange exchange) {
- // Implementation for list medical transcription jobs
+ private void listTagsForResource(TranscribeClient transcribeClient,
Exchange exchange) throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof ListTagsForResourceRequest req) {
+ setResponse(exchange, execute("List Tags For Resource", () ->
transcribeClient.listTagsForResource(req)));
+ }
+ } else {
+ ListTagsForResourceRequest.Builder builder =
ListTagsForResourceRequest.builder();
+ applyIfPresent(exchange, Transcribe2Constants.RESOURCE_ARN,
builder::resourceArn);
+ setResponse(exchange,
+ execute("List Tags For Resource", () ->
transcribeClient.listTagsForResource(builder.build())));
+ }
}
- private void deleteMedicalTranscriptionJob(TranscribeClient
transcribeClient, Exchange exchange) {
- // Implementation for delete medical transcription job
+ /**
+ * Sets the given header value on the builder when the header is present.
+ */
+ private void applyIfPresent(Exchange exchange, String header,
Consumer<String> setter) {
+ String value = exchange.getIn().getHeader(header, String.class);
+ if (ObjectHelper.isNotEmpty(value)) {
+ setter.accept(value);
+ }
}
- private void tagResource(TranscribeClient transcribeClient, Exchange
exchange) {
- // Implementation for tag resource
+ private void applyMaxResults(Exchange exchange, Consumer<Integer> setter) {
+ Integer maxResults =
exchange.getIn().getHeader(Transcribe2Constants.MAX_RESULTS, Integer.class);
+ if (ObjectHelper.isNotEmpty(maxResults)) {
+ setter.accept(maxResults);
+ }
}
- private void untagResource(TranscribeClient transcribeClient, Exchange
exchange) {
- // Implementation for untag resource
+ /**
+ * Runs an AWS Transcribe call, logging and rethrowing the service error
code like the other operations.
+ */
+ private <T> T execute(String operationName, Supplier<T> call) {
+ try {
+ return call.get();
+ } catch (AwsServiceException ase) {
+ LOG.trace("{} command returned the error code {}", operationName,
ase.awsErrorDetails().errorCode());
+ throw ase;
+ }
}
- private void listTagsForResource(TranscribeClient transcribeClient,
Exchange exchange) {
- // Implementation for list tags for resource
+ private void setResponse(Exchange exchange, Object result) {
+ getMessageForResponse(exchange).setBody(result);
}
protected Transcribe2Configuration getConfiguration() {
diff --git
a/components/camel-aws/camel-aws2-transcribe/src/test/java/org/apache/camel/component/aws2/transcribe/Transcribe2ProducerImplementedOperationsTest.java
b/components/camel-aws/camel-aws2-transcribe/src/test/java/org/apache/camel/component/aws2/transcribe/Transcribe2ProducerImplementedOperationsTest.java
new file mode 100644
index 000000000000..3015d10a0aeb
--- /dev/null
+++
b/components/camel-aws/camel-aws2-transcribe/src/test/java/org/apache/camel/component/aws2/transcribe/Transcribe2ProducerImplementedOperationsTest.java
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.transcribe;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+import software.amazon.awssdk.services.transcribe.TranscribeClient;
+import
software.amazon.awssdk.services.transcribe.model.CreateLanguageModelRequest;
+import
software.amazon.awssdk.services.transcribe.model.CreateLanguageModelResponse;
+import
software.amazon.awssdk.services.transcribe.model.CreateVocabularyFilterRequest;
+import
software.amazon.awssdk.services.transcribe.model.CreateVocabularyFilterResponse;
+import
software.amazon.awssdk.services.transcribe.model.ListTagsForResourceRequest;
+import
software.amazon.awssdk.services.transcribe.model.ListTagsForResourceResponse;
+import
software.amazon.awssdk.services.transcribe.model.ListVocabularyFiltersRequest;
+import
software.amazon.awssdk.services.transcribe.model.ListVocabularyFiltersResponse;
+import
software.amazon.awssdk.services.transcribe.model.StartMedicalTranscriptionJobRequest;
+import
software.amazon.awssdk.services.transcribe.model.StartMedicalTranscriptionJobResponse;
+import software.amazon.awssdk.services.transcribe.model.TagResourceRequest;
+import software.amazon.awssdk.services.transcribe.model.TagResourceResponse;
+import software.amazon.awssdk.services.transcribe.model.UntagResourceRequest;
+import software.amazon.awssdk.services.transcribe.model.UntagResourceResponse;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+/**
+ * These operations were previously declared but implemented as empty methods,
so selecting them was a silent no-op.
+ * Each test proves the operation now reaches the AWS client with the headers
it was given.
+ */
+public class Transcribe2ProducerImplementedOperationsTest extends
CamelTestSupport {
+
+ @BindToRegistry("transcribeClient")
+ private final TranscribeClient transcribeClient =
mock(TranscribeClient.class);
+
+ @Test
+ public void createVocabularyFilterUsesNameLanguageAndWords() throws
Exception {
+
when(transcribeClient.createVocabularyFilter(any(CreateVocabularyFilterRequest.class)))
+ .thenReturn(CreateVocabularyFilterResponse.builder().build());
+
+ template.send("direct:createVocabularyFilter", exchange -> {
+
exchange.getIn().setHeader(Transcribe2Constants.VOCABULARY_FILTER_NAME,
"my-filter");
+ exchange.getIn().setHeader(Transcribe2Constants.LANGUAGE_CODE,
"en-US");
+
exchange.getIn().setHeader(Transcribe2Constants.VOCABULARY_PHRASES,
List.of("foo", "bar"));
+ });
+
+ ArgumentCaptor<CreateVocabularyFilterRequest> captor
+ = ArgumentCaptor.forClass(CreateVocabularyFilterRequest.class);
+ verify(transcribeClient).createVocabularyFilter(captor.capture());
+ assertEquals("my-filter", captor.getValue().vocabularyFilterName());
+ assertEquals("en-US", captor.getValue().languageCodeAsString());
+ assertEquals(List.of("foo", "bar"), captor.getValue().words());
+ }
+
+ @Test
+ public void listVocabularyFiltersUsesNameContainsAndMaxResults() throws
Exception {
+
when(transcribeClient.listVocabularyFilters(any(ListVocabularyFiltersRequest.class)))
+ .thenReturn(ListVocabularyFiltersResponse.builder().build());
+
+ template.send("direct:listVocabularyFilters", exchange -> {
+ exchange.getIn().setHeader(Transcribe2Constants.JOB_NAME_CONTAINS,
"prod");
+ exchange.getIn().setHeader(Transcribe2Constants.MAX_RESULTS, 25);
+ });
+
+ ArgumentCaptor<ListVocabularyFiltersRequest> captor =
ArgumentCaptor.forClass(ListVocabularyFiltersRequest.class);
+ verify(transcribeClient).listVocabularyFilters(captor.capture());
+ assertEquals("prod", captor.getValue().nameContains());
+ assertEquals(25, captor.getValue().maxResults());
+ }
+
+ @Test
+ public void createLanguageModelBuildsInputDataConfig() throws Exception {
+
when(transcribeClient.createLanguageModel(any(CreateLanguageModelRequest.class)))
+ .thenReturn(CreateLanguageModelResponse.builder().build());
+
+ template.send("direct:createLanguageModel", exchange -> {
+
exchange.getIn().setHeader(Transcribe2Constants.LANGUAGE_MODEL_NAME,
"my-model");
+ exchange.getIn().setHeader(Transcribe2Constants.BASE_MODEL_NAME,
"WideBand");
+ exchange.getIn().setHeader(Transcribe2Constants.INPUT_DATA_S3_URI,
"s3://bucket/training");
+
exchange.getIn().setHeader(Transcribe2Constants.DATA_ACCESS_ROLE_ARN,
"arn:aws:iam::1:role/r");
+ });
+
+ ArgumentCaptor<CreateLanguageModelRequest> captor =
ArgumentCaptor.forClass(CreateLanguageModelRequest.class);
+ verify(transcribeClient).createLanguageModel(captor.capture());
+ assertEquals("my-model", captor.getValue().modelName());
+ assertEquals("WideBand", captor.getValue().baseModelNameAsString());
+ assertEquals("s3://bucket/training",
captor.getValue().inputDataConfig().s3Uri());
+ assertEquals("arn:aws:iam::1:role/r",
captor.getValue().inputDataConfig().dataAccessRoleArn());
+ }
+
+ @Test
+ public void startMedicalTranscriptionJobBuildsMediaAndSpecialty() throws
Exception {
+
when(transcribeClient.startMedicalTranscriptionJob(any(StartMedicalTranscriptionJobRequest.class)))
+
.thenReturn(StartMedicalTranscriptionJobResponse.builder().build());
+
+ template.send("direct:startMedicalTranscriptionJob", exchange -> {
+
exchange.getIn().setHeader(Transcribe2Constants.MEDICAL_TRANSCRIPTION_JOB_NAME,
"job-1");
+ exchange.getIn().setHeader(Transcribe2Constants.LANGUAGE_CODE,
"en-US");
+ exchange.getIn().setHeader(Transcribe2Constants.MEDIA_URI,
"s3://bucket/audio.wav");
+
exchange.getIn().setHeader(Transcribe2Constants.OUTPUT_BUCKET_NAME,
"out-bucket");
+ exchange.getIn().setHeader(Transcribe2Constants.SPECIALTY,
"PRIMARYCARE");
+ exchange.getIn().setHeader(Transcribe2Constants.TYPE, "DICTATION");
+ });
+
+ ArgumentCaptor<StartMedicalTranscriptionJobRequest> captor
+ =
ArgumentCaptor.forClass(StartMedicalTranscriptionJobRequest.class);
+
verify(transcribeClient).startMedicalTranscriptionJob(captor.capture());
+ assertEquals("job-1", captor.getValue().medicalTranscriptionJobName());
+ assertEquals("s3://bucket/audio.wav",
captor.getValue().media().mediaFileUri());
+ assertEquals("out-bucket", captor.getValue().outputBucketName());
+ assertEquals("PRIMARYCARE", captor.getValue().specialtyAsString());
+ assertEquals("DICTATION", captor.getValue().typeAsString());
+ }
+
+ @Test
+ public void tagResourceConvertsTheTagMap() throws Exception {
+ when(transcribeClient.tagResource(any(TagResourceRequest.class)))
+ .thenReturn(TagResourceResponse.builder().build());
+
+ template.send("direct:tagResource", exchange -> {
+ exchange.getIn().setHeader(Transcribe2Constants.RESOURCE_ARN,
"arn:aws:transcribe:::job/j");
+ exchange.getIn().setHeader(Transcribe2Constants.TAGS,
Map.of("env", "prod"));
+ });
+
+ ArgumentCaptor<TagResourceRequest> captor =
ArgumentCaptor.forClass(TagResourceRequest.class);
+ verify(transcribeClient).tagResource(captor.capture());
+ assertEquals("arn:aws:transcribe:::job/j",
captor.getValue().resourceArn());
+ assertEquals(1, captor.getValue().tags().size());
+ assertEquals("env", captor.getValue().tags().get(0).key());
+ assertEquals("prod", captor.getValue().tags().get(0).value());
+ }
+
+ @Test
+ public void untagResourceUsesTagKeys() throws Exception {
+ when(transcribeClient.untagResource(any(UntagResourceRequest.class)))
+ .thenReturn(UntagResourceResponse.builder().build());
+
+ template.send("direct:untagResource", exchange -> {
+ exchange.getIn().setHeader(Transcribe2Constants.RESOURCE_ARN,
"arn:aws:transcribe:::job/j");
+ exchange.getIn().setHeader(Transcribe2Constants.TAG_KEYS,
List.of("env", "team"));
+ });
+
+ ArgumentCaptor<UntagResourceRequest> captor =
ArgumentCaptor.forClass(UntagResourceRequest.class);
+ verify(transcribeClient).untagResource(captor.capture());
+ assertEquals(List.of("env", "team"), captor.getValue().tagKeys());
+ }
+
+ @Test
+ public void listTagsForResourceUsesResourceArn() throws Exception {
+
when(transcribeClient.listTagsForResource(any(ListTagsForResourceRequest.class)))
+ .thenReturn(ListTagsForResourceResponse.builder().build());
+
+ template.send("direct:listTagsForResource",
+ exchange ->
exchange.getIn().setHeader(Transcribe2Constants.RESOURCE_ARN,
"arn:aws:transcribe:::job/j"));
+
+ ArgumentCaptor<ListTagsForResourceRequest> captor =
ArgumentCaptor.forClass(ListTagsForResourceRequest.class);
+ verify(transcribeClient).listTagsForResource(captor.capture());
+ assertEquals("arn:aws:transcribe:::job/j",
captor.getValue().resourceArn());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ String base =
"aws2-transcribe://transcribe?transcribeClient=#transcribeClient&operation=";
+ from("direct:createVocabularyFilter").to(base +
"createVocabularyFilter");
+ from("direct:listVocabularyFilters").to(base +
"listVocabularyFilters");
+ from("direct:createLanguageModel").to(base +
"createLanguageModel");
+ from("direct:startMedicalTranscriptionJob").to(base +
"startMedicalTranscriptionJob");
+ from("direct:tagResource").to(base + "tagResource");
+ from("direct:untagResource").to(base + "untagResource");
+ from("direct:listTagsForResource").to(base +
"listTagsForResource");
+ }
+ };
+ }
+}
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Transcribe2EndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Transcribe2EndpointBuilderFactory.java
index 32cc2985d301..1dfd0656a6be 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Transcribe2EndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Transcribe2EndpointBuilderFactory.java
@@ -822,6 +822,117 @@ public interface Transcribe2EndpointBuilderFactory {
public String awsTranscribeTagKeys() {
return "CamelAwsTranscribeTagKeys";
}
+ /**
+ * The maximum number of results to return in a list operation.
+ *
+ * The option is a: {@code Integer} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code AwsTranscribeMaxResults}.
+ */
+ public String awsTranscribeMaxResults() {
+ return "CamelAwsTranscribeMaxResults";
+ }
+ /**
+ * The token to retrieve the next page of a list operation.
+ *
+ * The option is a: {@code String} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code AwsTranscribeNextToken}.
+ */
+ public String awsTranscribeNextToken() {
+ return "CamelAwsTranscribeNextToken";
+ }
+ /**
+ * The S3 location of the vocabulary or vocabulary filter file.
+ *
+ * The option is a: {@code String} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code
+ * AwsTranscribeVocabularyFileUri}.
+ */
+ public String awsTranscribeVocabularyFileUri() {
+ return "CamelAwsTranscribeVocabularyFileUri";
+ }
+ /**
+ * The base model used when creating a custom language model.
+ *
+ * The option is a: {@code String} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code AwsTranscribeBaseModelName}.
+ */
+ public String awsTranscribeBaseModelName() {
+ return "CamelAwsTranscribeBaseModelName";
+ }
+ /**
+ * The S3 location of the training data for a custom language model.
+ *
+ * The option is a: {@code String} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code AwsTranscribeInputDataS3Uri}.
+ */
+ public String awsTranscribeInputDataS3Uri() {
+ return "CamelAwsTranscribeInputDataS3Uri";
+ }
+ /**
+ * The ARN of the IAM role granting access to the training data or
+ * vocabulary file.
+ *
+ * The option is a: {@code String} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code
+ * AwsTranscribeDataAccessRoleArn}.
+ */
+ public String awsTranscribeDataAccessRoleArn() {
+ return "CamelAwsTranscribeDataAccessRoleArn";
+ }
+ /**
+ * The S3 bucket where the transcription output is stored.
+ *
+ * The option is a: {@code String} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code
AwsTranscribeOutputBucketName}.
+ */
+ public String awsTranscribeOutputBucketName() {
+ return "CamelAwsTranscribeOutputBucketName";
+ }
+ /**
+ * The medical specialty of a medical transcription job.
+ *
+ * The option is a: {@code String} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code AwsTranscribeSpecialty}.
+ */
+ public String awsTranscribeSpecialty() {
+ return "CamelAwsTranscribeSpecialty";
+ }
+ /**
+ * The audio type of a medical transcription job.
+ *
+ * The option is a: {@code String} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code AwsTranscribeType}.
+ */
+ public String awsTranscribeType() {
+ return "CamelAwsTranscribeType";
+ }
}
static Transcribe2EndpointBuilder endpointBuilder(String componentName,
String path) {
class Transcribe2EndpointBuilderImpl extends AbstractEndpointBuilder
implements Transcribe2EndpointBuilder, AdvancedTranscribe2EndpointBuilder {