This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch 2722 in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
commit e69c7ae52b183cd66881f0d84b8e1b41fe97ed82 Author: Andrea Cosentino <[email protected]> AuthorDate: Tue Feb 17 10:57:46 2026 +0100 Create an AWS comprehend Sink Kamelet Signed-off-by: Andrea Cosentino <[email protected]> --- docs/modules/ROOT/nav.adoc | 1 + .../partials/aws-comprehend-sink-description.adoc | 42 +++++++ kamelets/aws-comprehend-sink.kamelet.yaml | 130 +++++++++++++++++++++ .../kamelets/catalog/KameletsCatalogTest.java | 2 +- .../kamelets/aws-comprehend-sink.kamelet.yaml | 130 +++++++++++++++++++++ .../pipes/camel-k/aws-comprehend-sink-pipe.yaml | 19 +++ templates/pipes/core/aws-comprehend-sink-pipe.yaml | 13 +++ 7 files changed, 336 insertions(+), 1 deletion(-) diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 62b60c6e1..8d4451ae5 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -5,6 +5,7 @@ * xref:aws-bedrock-text-sink.adoc[] * xref:aws-cloudtrail-source.adoc[] * xref:aws-cloudwatch-sink.adoc[] +* xref:aws-comprehend-sink.adoc[] * xref:aws-ddb-sink.adoc[] * xref:aws-ddb-streams-source.adoc[] * xref:aws-ec2-sink.adoc[] diff --git a/docs/modules/ROOT/partials/aws-comprehend-sink-description.adoc b/docs/modules/ROOT/partials/aws-comprehend-sink-description.adoc new file mode 100644 index 000000000..5bfd9810b --- /dev/null +++ b/docs/modules/ROOT/partials/aws-comprehend-sink-description.adoc @@ -0,0 +1,42 @@ +== AWS Comprehend Sink Kamelet Description + +=== Authentication methods + +In this Kamelet you can avoid using explicit static credentials by specifying the `useDefaultCredentialsProvider` option and set it to `true`. + +The order of evaluation for Default Credentials Provider is the following: + + - Java system properties - `aws.accessKeyId` and `aws.secretKey`. + - Environment variables - `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`. + - Web Identity Token from AWS STS. + - The shared credentials and config files. + - Amazon ECS container credentials - loaded from the Amazon ECS if the environment variable `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI` is set. + - Amazon EC2 Instance profile credentials. + +You can also use the Profile Credentials Provider, by setting the `useProfileCredentialsProvider` option to `true` and `profileCredentialsName` to the profile name. + +Only one of access key/secret key or default credentials provider could be used + +For more information, see the https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/credentials.html[AWS credentials documentation] + +=== Operations + +The kamelet supports the following operations: + + - *detectDominantLanguage* (default) - Detects the dominant language of the input text. + - *detectEntities* - Detects named entities (people, places, organizations, etc.) in the input text. + - *detectKeyPhrases* - Detects key noun phrases in the input text. + - *detectSentiment* - Detects the sentiment (positive, negative, neutral, mixed) of the input text. + - *detectSyntax* - Detects the parts of speech (nouns, verbs, adjectives, etc.) in the input text. + - *detectPiiEntities* - Detects personally identifiable information (PII) in the input text. + - *detectToxicContent* - Detects toxic content in the input text. + - *classifyDocument* - Classifies the input text using a custom document classifier endpoint. + - *containsPiiEntities* - Checks whether the input text contains PII entities. + +=== Language Code + +The `languageCode` parameter is required for all operations except `detectDominantLanguage`. Use a 2-letter ISO 639-1 code (e.g., `en` for English, `es` for Spanish). + +=== Document Classification + +For the `classifyDocument` operation, you must provide the `endpointArn` parameter pointing to your custom classifier endpoint. diff --git a/kamelets/aws-comprehend-sink.kamelet.yaml b/kamelets/aws-comprehend-sink.kamelet.yaml new file mode 100644 index 000000000..798f5bc76 --- /dev/null +++ b/kamelets/aws-comprehend-sink.kamelet.yaml @@ -0,0 +1,130 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +apiVersion: camel.apache.org/v1 +kind: Kamelet +metadata: + name: aws-comprehend-sink + annotations: + camel.apache.org/kamelet.support.level: "Preview" + camel.apache.org/catalog.version: "4.18.0-SNAPSHOT" + camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgZGF0YS1uYW1lPSJMYXllciAxIiBpZD0iTGF5ZXJfMSIgdmlld0JveD0iMCAwIDUxMiA1MTIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQzMC40MiwxOTYuMzJjOC0xMS4zOSwyMS4xNS0zOC4zMywwLTcyLjEzYTUyLjc5LDUyLjc5LDAsMCwwLTE3LjA2LTE3LjMxYy0xLjUzLTgtNy41NC0yNy4yNi0zMS40Mi00My45MUMzNTksNDcsMzI1LjUyLDQ5LjUzLDMxOS40NCw1MC4xNmE2NC4yNyw2NC4yNywwLDAsMC0xNi4wNy0yLjk0Yy0xNy4xNy0uODEtMzAuMzcsMy44OS0zOS43OCwxNC [...] + camel.apache.org/provider: "Apache Software Foundation" + camel.apache.org/kamelet.group: "AWS Comprehend" + camel.apache.org/kamelet.namespace: "AWS" + labels: + camel.apache.org/kamelet.type: "sink" +spec: + definition: + title: "AWS Comprehend Sink" + description: Send data to AWS Comprehend for natural language processing. + required: + - region + type: object + properties: + operation: + title: Operation + description: The operation to perform on the input text. + type: string + default: detectDominantLanguage + enum: ["detectDominantLanguage", "detectEntities", "detectKeyPhrases", "detectSentiment", "detectSyntax", "detectPiiEntities", "detectToxicContent", "classifyDocument", "containsPiiEntities"] + languageCode: + title: Language Code + description: The language code of the input text. Required for all operations except detectDominantLanguage. Use a 2-letter ISO 639-1 code (e.g., 'en' for English, 'es' for Spanish). + type: string + endpointArn: + title: Endpoint ARN + description: The Amazon Resource Name (ARN) of the endpoint to use for document classification. Required for classifyDocument operation. + type: string + accessKey: + title: Access Key + description: The access key obtained from AWS. + type: string + format: password + x-descriptors: + - urn:camel:group:credentials + secretKey: + title: Secret Key + description: The secret key obtained from AWS. + type: string + format: password + x-descriptors: + - urn:camel:group:credentials + region: + title: AWS Region + description: The AWS region to access. + type: string + enum: ["ap-south-1", "eu-south-1", "us-gov-east-1", "me-central-1", "ca-central-1", "eu-central-1", "us-iso-west-1", "us-west-1", "us-west-2", "af-south-1", "eu-north-1", "eu-west-3", "eu-west-2", "eu-west-1", "ap-northeast-3", "ap-northeast-2", "ap-northeast-1", "me-south-1", "sa-east-1", "ap-east-1", "cn-north-1", "us-gov-west-1", "ap-southeast-1", "ap-southeast-2", "us-iso-east-1", "ap-southeast-3", "us-east-1", "us-east-2", "cn-northwest-1", "us-isob-east-1", "aws-global", "a [...] + useDefaultCredentialsProvider: + title: Default Credentials Provider + description: If true, the Comprehend client loads credentials through a default credentials provider. If false, it uses the basic authentication method (access key and secret key). + type: boolean + default: false + useProfileCredentialsProvider: + title: Profile Credentials Provider + description: Set whether the Comprehend client should expect to load credentials through a profile credentials provider. + type: boolean + default: false + useSessionCredentials: + title: Session Credentials + description: Set whether the Comprehend client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Comprehend. + type: boolean + default: false + profileCredentialsName: + title: Profile Credentials Name + description: If using a profile credentials provider this parameter sets the profile name. + type: string + sessionToken: + title: Session Token + description: Amazon AWS Session Token used when the user needs to assume an IAM role. + type: string + format: password + x-descriptors: + - urn:camel:group:credentials + uriEndpointOverride: + title: Overwrite Endpoint URI + description: The overriding endpoint URI. To use this option, you must also select the `overrideEndpoint` option. + type: string + overrideEndpoint: + title: Endpoint Overwrite + description: Select this option to override the endpoint URI. To use this option, you must also provide a URI for the `uriEndpointOverride` option. + type: boolean + default: false + dependencies: + - "camel:core" + - "camel:aws2-comprehend" + - "camel:kamelet" + template: + from: + uri: "kamelet:source" + steps: + - to: + uri: "aws2-comprehend:comprehend" + parameters: + secretKey: "{{?secretKey}}" + accessKey: "{{?accessKey}}" + region: "{{region}}" + operation: "{{operation}}" + languageCode: "{{?languageCode}}" + endpointArn: "{{?endpointArn}}" + useDefaultCredentialsProvider: "{{useDefaultCredentialsProvider}}" + useProfileCredentialsProvider: "{{useProfileCredentialsProvider}}" + useSessionCredentials: "{{useSessionCredentials}}" + uriEndpointOverride: "{{?uriEndpointOverride}}" + profileCredentialsName: "{{?profileCredentialsName}}" + sessionToken: "{{?sessionToken}}" + overrideEndpoint: "{{overrideEndpoint}}" diff --git a/library/camel-kamelets-catalog/src/test/java/org/apache/camel/kamelets/catalog/KameletsCatalogTest.java b/library/camel-kamelets-catalog/src/test/java/org/apache/camel/kamelets/catalog/KameletsCatalogTest.java index fe79189a2..c96f22c3d 100644 --- a/library/camel-kamelets-catalog/src/test/java/org/apache/camel/kamelets/catalog/KameletsCatalogTest.java +++ b/library/camel-kamelets-catalog/src/test/java/org/apache/camel/kamelets/catalog/KameletsCatalogTest.java @@ -121,7 +121,7 @@ public class KameletsCatalogTest { void testGetKameletsByNamespace() throws Exception { List<Kamelet> c = catalog.getKameletsByNamespace("AWS"); assertFalse(c.isEmpty()); - assertEquals(29, c.size()); + assertEquals(30, c.size()); c = catalog.getKameletsByGroups("Not-existing-group"); assertTrue(c.isEmpty()); } diff --git a/library/camel-kamelets/src/main/resources/kamelets/aws-comprehend-sink.kamelet.yaml b/library/camel-kamelets/src/main/resources/kamelets/aws-comprehend-sink.kamelet.yaml new file mode 100644 index 000000000..798f5bc76 --- /dev/null +++ b/library/camel-kamelets/src/main/resources/kamelets/aws-comprehend-sink.kamelet.yaml @@ -0,0 +1,130 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +apiVersion: camel.apache.org/v1 +kind: Kamelet +metadata: + name: aws-comprehend-sink + annotations: + camel.apache.org/kamelet.support.level: "Preview" + camel.apache.org/catalog.version: "4.18.0-SNAPSHOT" + camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgZGF0YS1uYW1lPSJMYXllciAxIiBpZD0iTGF5ZXJfMSIgdmlld0JveD0iMCAwIDUxMiA1MTIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQzMC40MiwxOTYuMzJjOC0xMS4zOSwyMS4xNS0zOC4zMywwLTcyLjEzYTUyLjc5LDUyLjc5LDAsMCwwLTE3LjA2LTE3LjMxYy0xLjUzLTgtNy41NC0yNy4yNi0zMS40Mi00My45MUMzNTksNDcsMzI1LjUyLDQ5LjUzLDMxOS40NCw1MC4xNmE2NC4yNyw2NC4yNywwLDAsMC0xNi4wNy0yLjk0Yy0xNy4xNy0uODEtMzAuMzcsMy44OS0zOS43OCwxNC [...] + camel.apache.org/provider: "Apache Software Foundation" + camel.apache.org/kamelet.group: "AWS Comprehend" + camel.apache.org/kamelet.namespace: "AWS" + labels: + camel.apache.org/kamelet.type: "sink" +spec: + definition: + title: "AWS Comprehend Sink" + description: Send data to AWS Comprehend for natural language processing. + required: + - region + type: object + properties: + operation: + title: Operation + description: The operation to perform on the input text. + type: string + default: detectDominantLanguage + enum: ["detectDominantLanguage", "detectEntities", "detectKeyPhrases", "detectSentiment", "detectSyntax", "detectPiiEntities", "detectToxicContent", "classifyDocument", "containsPiiEntities"] + languageCode: + title: Language Code + description: The language code of the input text. Required for all operations except detectDominantLanguage. Use a 2-letter ISO 639-1 code (e.g., 'en' for English, 'es' for Spanish). + type: string + endpointArn: + title: Endpoint ARN + description: The Amazon Resource Name (ARN) of the endpoint to use for document classification. Required for classifyDocument operation. + type: string + accessKey: + title: Access Key + description: The access key obtained from AWS. + type: string + format: password + x-descriptors: + - urn:camel:group:credentials + secretKey: + title: Secret Key + description: The secret key obtained from AWS. + type: string + format: password + x-descriptors: + - urn:camel:group:credentials + region: + title: AWS Region + description: The AWS region to access. + type: string + enum: ["ap-south-1", "eu-south-1", "us-gov-east-1", "me-central-1", "ca-central-1", "eu-central-1", "us-iso-west-1", "us-west-1", "us-west-2", "af-south-1", "eu-north-1", "eu-west-3", "eu-west-2", "eu-west-1", "ap-northeast-3", "ap-northeast-2", "ap-northeast-1", "me-south-1", "sa-east-1", "ap-east-1", "cn-north-1", "us-gov-west-1", "ap-southeast-1", "ap-southeast-2", "us-iso-east-1", "ap-southeast-3", "us-east-1", "us-east-2", "cn-northwest-1", "us-isob-east-1", "aws-global", "a [...] + useDefaultCredentialsProvider: + title: Default Credentials Provider + description: If true, the Comprehend client loads credentials through a default credentials provider. If false, it uses the basic authentication method (access key and secret key). + type: boolean + default: false + useProfileCredentialsProvider: + title: Profile Credentials Provider + description: Set whether the Comprehend client should expect to load credentials through a profile credentials provider. + type: boolean + default: false + useSessionCredentials: + title: Session Credentials + description: Set whether the Comprehend client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Comprehend. + type: boolean + default: false + profileCredentialsName: + title: Profile Credentials Name + description: If using a profile credentials provider this parameter sets the profile name. + type: string + sessionToken: + title: Session Token + description: Amazon AWS Session Token used when the user needs to assume an IAM role. + type: string + format: password + x-descriptors: + - urn:camel:group:credentials + uriEndpointOverride: + title: Overwrite Endpoint URI + description: The overriding endpoint URI. To use this option, you must also select the `overrideEndpoint` option. + type: string + overrideEndpoint: + title: Endpoint Overwrite + description: Select this option to override the endpoint URI. To use this option, you must also provide a URI for the `uriEndpointOverride` option. + type: boolean + default: false + dependencies: + - "camel:core" + - "camel:aws2-comprehend" + - "camel:kamelet" + template: + from: + uri: "kamelet:source" + steps: + - to: + uri: "aws2-comprehend:comprehend" + parameters: + secretKey: "{{?secretKey}}" + accessKey: "{{?accessKey}}" + region: "{{region}}" + operation: "{{operation}}" + languageCode: "{{?languageCode}}" + endpointArn: "{{?endpointArn}}" + useDefaultCredentialsProvider: "{{useDefaultCredentialsProvider}}" + useProfileCredentialsProvider: "{{useProfileCredentialsProvider}}" + useSessionCredentials: "{{useSessionCredentials}}" + uriEndpointOverride: "{{?uriEndpointOverride}}" + profileCredentialsName: "{{?profileCredentialsName}}" + sessionToken: "{{?sessionToken}}" + overrideEndpoint: "{{overrideEndpoint}}" diff --git a/templates/pipes/camel-k/aws-comprehend-sink-pipe.yaml b/templates/pipes/camel-k/aws-comprehend-sink-pipe.yaml new file mode 100644 index 000000000..8ffbfa244 --- /dev/null +++ b/templates/pipes/camel-k/aws-comprehend-sink-pipe.yaml @@ -0,0 +1,19 @@ +apiVersion: camel.apache.org/v1 +kind: Pipe +metadata: + name: aws-comprehend-sink-pipe +spec: + source: + ref: + kind: KafkaTopic + apiVersion: kafka.strimzi.io/v1beta1 + name: my-topic + sink: + ref: + kind: Kamelet + apiVersion: camel.apache.org/v1 + name: aws-comprehend-sink + properties: + accessKey: "The Access Key" + secretKey: "The Secret Key" + region: "eu-west-1" diff --git a/templates/pipes/core/aws-comprehend-sink-pipe.yaml b/templates/pipes/core/aws-comprehend-sink-pipe.yaml new file mode 100644 index 000000000..0577359f3 --- /dev/null +++ b/templates/pipes/core/aws-comprehend-sink-pipe.yaml @@ -0,0 +1,13 @@ +- route: + from: + uri: "kamelet:timer-source" + parameters: + period: 1000 + message: "Hello Camel JBang" + steps: + - to: + uri: "kamelet:aws-comprehend-sink" + parameters: + accessKey: "The Access Key" + secretKey: "The Secret Key" + region: "eu-west-1"
