# ---------------------------------------------------------------------------
# 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/v1alpha1
kind: Kamelet
metadata:
  name: aws-lambda-sink
  annotations:
    camel.apache.org/kamelet.support.level: "Stable"
    camel.apache.org/catalog.version: "3.21.0"
    camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjA2NSIgaGVpZ2h0PSIyNTAwIiB2aWV3Qm94PSIwIDAgMjU2IDMxMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCI+PHBhdGggZD0iTTAgMjQ1LjI2MmwxNi4zMjIgOC4xNjFMMTkgMjQ4LjY2OFY1OS4zMzNsLTIuNjc4LTMuNDk0TDAgNjR2MTgxLjI2MiIgZmlsbD0iIzlENTAyNSIvPjxwYXRoIGQ9Ik00Ny42NzggNjMuNTdsLTMxLjM1Ni03LjczMXYxOTcuNTg0bDMxLjM1Ni03LjMwMlY2My41NyIgZmlsbD0iI0Y2ODUzNiIvPjxwYXRoIGQ9Ik0xNDMuODkzIDc4LjYwNGwyMi4zMzUtMTEuNTk3IDc0LjMwOSAyOC43NzgtMTkuNzU4IDIuNTc3LTc2Ljg4Ni0xOS43NTgiIGZpbGw9IiM2QjNBMTkiLz48cGF0aCBkPSJNMTQ0Ljc1MiAyMzAuNjU4bDIxLjkwNiAxMS41OTcgNzQuMzA4LTI4Ljc3OC0xOS43NTgtMi41NzgtNzYuNDU2IDE5Ljc1OSIgZmlsbD0iI0ZCQkY5MyIvPjxwYXRoIGQ9Ik0xNTAuMzM2IDE5OC44NzJsMzkuMDg3IDUuMTU1IDIuMjQ0LTQuMDI3di05MGwtMi4yNDQtNC43NjUtMzkuMDg3IDUuMTU0djg4LjQ4M00zNS42NTEgNDUuOTZsMjQuMDU0LTEyLjAyN0w2Mi4zMzMgMzl2MjMxbC0yLjYyOCA1LjMyOS0yNC4wNTQtMTIuMDI3VjQ1Ljk2IiBmaWxsPSIjOUQ1MDI1Ii8+PHBhdGggZD0iTTEwOC42NzEgMjU5LjAwN2wtNDguOTY2IDE1Ljg5MlYzMy45MzNsNDguOTY2IDE1Ljg5M3YyMDkuMTgxIiBmaWxsPSIjRjY4NTM2Ii8+PHBhdGggZD0iTTg5Ljc3MiAyODkuOTMzTDEyOCAzMDkuMjYybDQtNC41OTV2LTI5OUwxMjggMCA4OS43NzIgMTkuMzI5djI3MC42MDRNMjE5LjkxOSA5OC4zNjJsMTkuNzU5LTIuNTc3IDEuNjk3IDIuNDY1VjIxMWwtMS42OTcgMi45MDYtMTkuNzU5LTIuNTc3Vjk4LjM2MiIgZmlsbD0iIzlENTAyNSIvPjxwYXRoIGQ9Ik0xODkuNDIzIDEwNS4yMzV2OTkuMjIxbDQwLjgwNS00OS44MjUtNDAuODA1LTQ5LjM5NiIgZmlsbD0iI0Y2ODUzNiIvPjxwYXRoIGQ9Ik0yMzkuNjc4IDU1LjgzOUwxMjggMHYzMDkuMjYybDEyOC02NFY2NGwtMTYuMzIyLTguMTYxem0wIDE1OC4yMTdsLTczLjQ1IDIxLjkzNlY3My4yN2w3My40NSAyMS45MzZ2MTE4Ljg1eiIgZmlsbD0iI0Y2ODUzNiIvPjwvc3ZnPg=="
    camel.apache.org/provider: "Apache Software Foundation"
    camel.apache.org/kamelet.group: "AWS Lambda"
    camel.apache.org/kamelet.namespace: "AWS"
  labels:
    camel.apache.org/kamelet.type: sink
spec:
  definition:
    title: AWS Lambda Sink
    description: |-
      Send a payload to an AWS Lambda function.

      The basic authentication method for the Lambda service is to specify an access key and a secret key. These parameters are optional because the Kamelet provides a default credentials provider.
      
      If you use the default credentials provider, the Lambda client loads the credentials through this provider and doesn't use the basic authentication method.
    required:
      - function
      - region
    type: object
    properties:
      function:
        title: Function Name
        description: The Lambda Function name.
        type: string
      accessKey:
        title: Access Key
        description: The access key obtained from AWS.
        type: string
        format: password
        x-descriptors:
        - urn:alm:descriptor:com.tectonic.ui:password
        - urn:camel:group:credentials
      secretKey:
        title: Secret Key
        description: The secret key obtained from AWS.
        type: string
        format: password
        x-descriptors:
        - urn:alm:descriptor:com.tectonic.ui:password
        - 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", "aws-cn-global", "aws-us-gov-global", "aws-iso-global", "aws-iso-b-global"]
      useDefaultCredentialsProvider:
        title: Default Credentials Provider
        description: If true, the Lambda client loads credentials through a default credentials provider. If false, it uses the basic authentication method (access key and secret key).
        type: boolean
        x-descriptors:
        - 'urn:alm:descriptor:com.tectonic.ui:checkbox'
        default: false
  dependencies:
    - "camel:aws2-lambda"
    - "camel:kamelet"
  template:
    from:
      uri: kamelet:source
      steps:
      - to:
          uri: "aws2-lambda:{{function}}"
          parameters:
            accessKey: "{{?accessKey}}"
            secretKey: "{{?secretKey}}"
            region: "{{region}}"
            useDefaultCredentialsProvider: "{{useDefaultCredentialsProvider}}"