# ---------------------------------------------------------------------------
# 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-sns-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,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+DQo8c3ZnICAgdmlld0JveD0iMCAwIDI1NiAyNTciIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQiPg0KCTxnPg0KCQk8cGF0aCBkPSJNOTguODc1LDIzMi4wMzMgTDcyLjQ0MiwyMjQuNjI1IEw0Ny40NDEsMTk2LjExNyBMNzguNzEzLDE5NS4yNTQgTDk4Ljg3NSwyMzIuMDMzIiBmaWxsPSIjOTk1QjgwIj48L3BhdGg+DQoJCTxwYXRoIGQ9Ik0zNy43NSwyMTMuMjMzIEwyMi44NzUsMjA5LjA2NyBMOC44MTcsMTkzLjAzMyBMMjUuODk5LDE5MC4yMjQgTDM3Ljc1LDIxMy4yMzMiIGZpbGw9IiM5OTVCODAiPjwvcGF0aD4NCgkJPHBhdGggZD0iTTAsMT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g5LjU5MSwxOS4xNTggTDg5LjU5MSwyMDguOTUiIGZpbGw9IiM3QjNGNjUiPjwvcGF0aD4NCgkJPHBhdGggZD0iTTI1Niw2NC4wMzMgTDEyNy45MjUsMCBMMTI3LjkyNSwyMTYuMzY3IEwxNTAuNTIyLDIxMS44MzkgTDE4MS44MzMsMjU2LjQ5MiBMMjA4LjczNCwyMDAuMTgzIEwyMDguNzE3LDIwMC4xODEgTDI1NiwxOTAuNzA4IEwyNTYsNjQuMDMzIiBmaWxsPSIjQzE3QjlEIj48L3BhdGg+DQoJPC9nPg0KPC9zdmc+DQo="
    camel.apache.org/provider: "Apache Software Foundation"
    camel.apache.org/kamelet.group: "AWS SNS"
    camel.apache.org/kamelet.namespace: "AWS"
  labels:
    camel.apache.org/kamelet.type: sink
spec:
  definition:
    title: AWS SNS Sink
    description: |-
      Send message to an Amazon Simple Notification Service (SNS) topic.

      The basic authentication method for the SNS 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 SNS client loads the credentials through this provider and doesn't use the basic authentication method.

      In the header, you can optionally set the `subject` / `ce-subject` property to specify the subject of the message.
    required:
      - topicNameOrArn
      - region
    type: object
    properties:
      topicNameOrArn:
        title: Topic Name
        description: The SNS topic name name or Amazon Resource Name (ARN).
        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"]
      autoCreateTopic:
        title: Autocreate Topic
        description: Setting the autocreation of the SNS topic. 
        type: boolean
        x-descriptors:
        - 'urn:alm:descriptor:com.tectonic.ui:checkbox'
        default: false
      useDefaultCredentialsProvider:
        title: Default Credentials Provider
        description: If true, the SNS 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
      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
        x-descriptors:
          - 'urn:alm:descriptor:com.tectonic.ui:checkbox'
        default: false
  dependencies:
    - "camel:core"
    - "camel:aws2-sns"
    - "camel:kamelet"
  template:
    from:
      uri: kamelet:source
      steps:
      - choice:
          when:
          - simple: "${header[subject]}"
            steps:
            - set-header:
                name: CamelAwsSnsSubject
                simple: "${header[subject]}"
          - simple: "${header[ce-subject]}"
            steps:
            - set-header:
                name: CamelAwsSnsSubject
                simple: "${header[ce-subject]}"
      - to:
          uri: "aws2-sns:{{topicNameOrArn}}"
          parameters:
            autoCreateTopic: "{{autoCreateTopic}}"
            accessKey: "{{?accessKey}}"
            secretKey: "{{?secretKey}}"
            region: "{{region}}"
            useDefaultCredentialsProvider: "{{useDefaultCredentialsProvider}}"
            uriEndpointOverride: "{{?uriEndpointOverride}}"
            overrideEndpoint: "{{overrideEndpoint}}"