# ---------------------------------------------------------------------------
# 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: azure-storage-queue-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,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgOTEgODEiIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgc3Ryb2tlPSIjMDAwIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjx1c2UgeGxpbms6aHJlZj0iI0EiIHg9Ii41IiB5PSIuNSIvPjxzeW1ib2wgaWQ9IkEiIG92ZXJmbG93PSJ2aXNpYmxlIj48cGF0aCBkPSJNNzAuMDUzIDM0LjYzNEg1MC41OGw5LjczNiA3LjgwNXptLTM5LjQyIDEwLjQ4OGMtLjIzOCAwLS40NzUgMC0uNzEzLS4yNDRsLTkuMDI0LTcuMzE3djExLjk1MWgyMC42NlYzNy4zMTdsLTkuNzM2IDcuNTYxYy0uNDc1LjI0NC0uOTUuMjQ0LTEuMTg3LjI0NHptMjkuNjgzIDBjLS4yMzggMC0uNzEzIDAtLjcxMy0uMjQ0bC05Lj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Gw9IiMwMDc4ZDciIHN0cm9rZT0ibm9uZSIvPjwvc3ltYm9sPjwvc3ZnPg=="
    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: "sink"
spec:
  definition:
    title: "Azure Storage Queue Sink"
    description: |-
      Send events to Azure Storage queues.

      In the header, you can set the `partition` / `ce-partition` property to determine how long an event remains in the Azure Storage queue. Use `PnDTnHnMn.nS.` format. For example, `PT20.345S` parses as 20.345 seconds and `P2D` parses as 2 days. If you not set the property in the header, the Kamelet uses the default of `P27D` (7 days).
    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:camel:group:credentials
      credentialType:
        title: Credential Type
        description: Determines the credential strategy to adopt.
        type: string
        enum: ["SHARED_ACCOUNT_KEY", "SHARED_KEY_CREDENTIAL", "AZURE_IDENTITY"]
        default: "SHARED_ACCOUNT_KEY"
  dependencies:
    - "camel:core"
    - "camel:azure-storage-queue"
    - "camel:kamelet"
  template:
    from:
      uri: "kamelet:source"
      steps:
      - choice:
          when:
          - simple: "${header[expiration]}"
            steps:
            - setHeader:
                name: CamelAzureStorageQueueTimeToLive
                simple: "${header[expiration]}"
          - simple: "${header[ce-expiration]}"
            steps:
            - setHeader:
                name: CamelAzureStorageQueueTimeToLive
                simple: "${header[ce-expiration]}"
      - to:
          uri: "azure-storage-queue://{{accountName}}/{{queueName}}"
          parameters:
            accessKey: "{{accessKey}}"
            credentialType: "{{credentialType}}"