# ---------------------------------------------------------------------------
# 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-bedrock-agent-runtime-sink
  annotations:
    camel.apache.org/kamelet.support.level: "Stable"
    camel.apache.org/catalog.version: "4.10.2"
    camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,[encoded data, 6680 characters]"
    camel.apache.org/provider: "Apache Software Foundation"
    camel.apache.org/kamelet.group: "AWS Bedrock"
    camel.apache.org/kamelet.namespace: "AWS"
  labels:
    camel.apache.org/kamelet.type: "sink"
spec:
  definition:
    title: "AWS Bedrock Agent Runtime Sink"
    description: Send data for invoking a knowledge base from AWS Bedrock.
    required:
      - modelId
      - knowledgeBaseId
      - region
    type: object
    properties:
      modelId:
        title: Model Id
        description: The model Id to be used to generate responses.
        type: string
        enum: ["anthropic.claude-instant-v1", "anthropic.claude-v2", "anthropic.claude-v2:1", "anthropic.claude-3-sonnet-20240229-v1:0"]
      knowledgeBaseId:
        title: Knowledge Base Id
        description: The Knowledge Base Id to be used to retrieve and generate responses.
        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: ["us-east-1", "us-west-1"]
      useDefaultCredentialsProvider:
        title: Default Credentials Provider
        description: If true, the Bedrock 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 Bedrock client should expect to load credentials through a profile credentials provider.
        type: boolean
        default: false
      useSessionCredentials:
        title: Session Credentials
        description: Set whether the Bedrock client should expect to use Session Credentials. This is useful in situation in which the user needs to assume a IAM role for doing operations in Bedrock.
        type: boolean
        default: false
      profileCredentialsName:
        title: Profile Credentials Name
        description: If using a profile credentials provider this parameter will set the profile name.
        type: string
      sessionToken:
        title: Session Token
        description: Amazon AWS Session Token used when the user needs to assume a 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:aws-bedrock"
    - "camel:kamelet"
  template:
    from:
      uri: "kamelet:source"
      steps:      
      - to:
          uri: "aws-bedrock-agent-runtime:bedrock-knowledge"
          parameters:
            secretKey: "{{?secretKey}}"
            accessKey: "{{?accessKey}}"
            region: "{{region}}"
            modelId: "{{modelId}}"
            knowledgeBaseId: "{{knowledgeBaseId}}"
            operation: retrieveAndGenerate
            useDefaultCredentialsProvider: "{{useDefaultCredentialsProvider}}"
            useProfileCredentialsProvider: "{{useProfileCredentialsProvider}}"
            useSessionCredentials: "{{useSessionCredentials}}" 
            uriEndpointOverride: "{{?uriEndpointOverride}}"
            profileCredentialsName: "{{?profileCredentialsName}}"
            sessionToken: "{{?sessionToken}}"
            overrideEndpoint: "{{overrideEndpoint}}"