# ---------------------------------------------------------------------------
# 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: azure-storage-queue-source
  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,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgOTEgODEiIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgc3Ryb2tlPSIjMDAwIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjx1c2UgeGxpbms6aHJlZj0iI0EiIHg9Ii41IiB5PSIuNSIvPjxzeW1ib2wgaWQ9IkEiIG92ZXJmbG93PSJ2aXNpYmxlIj48cGF0aCBkPSJNNzAuMDUzIDM0LjYzNEg1MC41OGw5LjczNiA3LjgwNXptLTM5LjQyIDEwLjQ4OGMtLjIzOCAwLS40NzUgMC0uNzEzLS4yNDRsLTkuMDI0LTcuMzE3djExLjk1MWgyMC42NlYzNy4zMTdsLTkuNzM2IDcuNTYxYy0uNDc1LjI0NC0uOTUuMjQ0LTEuMTg3LjI0NHptMjkuNjgzIDBjLS4yMzggMC0uNzEzIDAtLjcxMy0uMjQ0bC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ZpbGw9IiMwMDc4ZDciIHN0cm9rZT0ibm9uZSIvPjwvc3ltYm9sPjwvc3ZnPg=="
    camel.apache.org/provider: "Apache Software Foundation"
    camel.apache.org/kamelet.group: "Azure Storage Queue"
    camel.apache.org/kamelet.namespace: "Azure"
  labels:
    camel.apache.org/kamelet.type: "source"
spec:
  definition:
    title: "Azure Storage Queue Source"
    description: |-
      Receive events from Azure Storage queues.

      One header will be duplicated with different names for clarity at sink level, CamelAzureStorageQueueMessageId will be duplicated into azure.storage.queue.message.id
    required:
      - accountName
      - queueName
      - accessKey
    type: object
    properties:
      accountName:
        title: Account Name
        description: The Azure Storage Queue account name.
        type: string
        x-descriptors:
        - urn:camel:group:credentials
      queueName:
        title: Queue Name
        description: The Azure Storage Queue container name.
        type: string
      accessKey:
        title: Access Key
        description: The Azure Storage Queue access key.
        type: string
        format: password
        x-descriptors:
        - urn:alm:descriptor:com.tectonic.ui:password        
        - urn:camel:group:credentials
      maxMessages:
        title: Maximum Messages
        description: The maximum number of messages to get. You can specify a value between 1 and 32. The default is 1 (one message). If there are fewer than the maximum number of messages in the queue, then all the messages are returned.
        type: integer
        default: 1
  dependencies:
    - "camel:azure-storage-queue"
    - "camel:kamelet"
    - "mvn:org.apache.camel.kamelets:camel-kamelets-utils:3.21.0"
    - "camel:core"
  template:
    beans:
      - name: renameHeaders
        type: "#class:org.apache.camel.kamelets.utils.headers.DuplicateNamingHeaders"
        property:
          - key: prefix
            value: 'CamelAzureStorageQueue'
          - key: renamingPrefix
            value: 'azure.storage.queue.'
          - key: mode
            value: 'filtering'
          - key: selectedHeaders
            value: 'CamelAzureStorageQueueMessageId'
    from:
      uri: "azure-storage-queue://{{accountName}}/{{queueName}}"
      parameters:
        accessKey: "{{accessKey}}"
        maxMessages: "{{maxMessages}}"
      steps:
      - process:
          ref: "{{renameHeaders}}"
      - to: "kamelet:sink"