# ---------------------------------------------------------------------------
# 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-eventhubs-source
  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,PHN2ZyBoZWlnaHQ9IjI1MDAiIHZpZXdCb3g9Ii0uMDc1IC0uMTc0IDE1OC40IDE2My4xMDEiIHdpZHRoPSIyNDM5IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxnIGZpbGw9IiMwMDZmZDQiPjxwYXRoIGQ9Im02LjIyNS4wMjZoMTQ2LjZjMS4zIDAgMy0uMiA0LjEuNS45LjYuOCAxLjUuOCAyLjR2MzEuOGMwIC45LS4xIDEuOC0uOCAyLjQtLjguOC0xLjcuOC0yLjguOGgtMTQuMWMtMS4yIDAtMi40LS4xLTMuMi0xLS43LS44LS43LTEuOS0uNy0yLjl2LTEyLjVoLTExNHYxMi44YzAgMS0uMSAyLS44IDIuOC0uOC44LTEuOC44LTIuOC44aC0xNC44Yy0xIDAtMiAwLTIuOC0uOC0uOC0uOC0uOC0xLjctLjktMi44di0yOC44YzAtMS4xLS4xLTIuMy4xLTMuNC4yLTEgMS4xLTEuOCAyLjEtMiAxLjQtLjIgMi43LS4xIDQtLjF6Ii8+PHBhdGggZD0ibTM2LjYyNSAzNy42MjdoMTkuNGMxLjIgMCAyLjYuM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0uOCAxLjYtLjggMi42LS45em0tMzYuMSAxNmgxNy44YzEgMCAxLjkuMSAyLjYuOXMuNyAxLjcuNyAyLjd2MTQuMWMwIDEgMCAxLjktLjcgMi43cy0xLjcuOS0yLjcuOWgtMTkuOGMtMS4xIDAtMi4yIDAtMi45LTEtLjctLjktLjctMS45LS43LTN2LTE0LjFjMC0xLjMuNS0yLjQgMS43LTIuOSAxLjItLjQgMi43LS4yIDQtLjN6bS0zNC41IDIxLjZoMTQuNGMxLjEgMCAyLjIuMSAzIDEgLjcuOC42IDEuNy43IDIuN3YxMi43aDExNC40di0xMi40YzAtMSAwLTIgLjgtMi44LjktLjkgMS45LS45IDMuMS0uOWgxMy40YzEgMCAyLjIgMCAzIC42LjkuNyAxLjMgMS45IDEuMyAzdjMwLjVjMCAxLjEtLjEgMi0uOSAyLjctMSAxLTIuOC42LTQuMS43aC0xNDkuM2MtLjkgMC0xLjctLjEtMi4zLS43LS44LS43LS45LTEuNy0uOS0yLjd2LTMwLjhjMC0xLjIuMi0yLjMgMS4xLTMuMS41LS41IDEuNC0uNCAyLjMtLjV6Ii8+PC9nPjwvc3ZnPg=="
    camel.apache.org/provider: "Apache Software Foundation"
    camel.apache.org/kamelet.group: "Azure Eventhubs"
    camel.apache.org/kamelet.namespace: "Azure"
  labels:
    camel.apache.org/kamelet.type: "source"
spec:
  definition:
    title: "Azure Eventhubs Source"
    description: Receive events from Azure Event Hubs.
    required:
      - namespaceName
      - eventhubName
      - blobAccountName
      - blobAccessKey
      - blobContainerName
    type: object
    properties:
      namespaceName:
        title: Eventhubs Namespace
        description: The Event Hubs namespace.
        type: string
      eventhubName:
        title: Eventhubs Name
        description: The Event Hub name.
        type: string
      sharedAccessName:
        title: Share Access Name
        description: The Event Hubs SAS key name.
        type: string
        x-descriptors:
        - urn:camel:group:credentials
      sharedAccessKey:
        title: Share Access Key
        description: The key for the Event Hubs SAS key name.
        type: string
        format: password
        x-descriptors:
        - urn:camel:group:credentials
      blobAccountName:
        title: Azure Storage Blob Account Name
        description: The name of the Storage Blob account.
        type: string
      blobContainerName:
        title: Azure Storage Blob Container Name
        description: The name of the Storage Blob container.
        type: string
      blobAccessKey:
        title: Azure Storage Blob Access Key
        description: The key for the Azure Storage Blob service that is associated with the Storage Blob account name.
        type: string
        format: password
        x-descriptors:
        - urn:camel:group:credentials
      credentialType:
        title: Credential Type
        description: Determines the credential strategy to adopt.
        type: string
        enum: ["CONNECTION_STRING", "AZURE_IDENTITY"]
        default: "CONNECTION_STRING"
  dataTypes:
    out:
      default: binary
      headers:
        CamelAzureEventHubsPartitionId:
          title: Azure Storage Event Hubs Partiton Id
          description: It sets the partition id of the Event Hub.
          type: string
        CamelAzureEventHubsOffset :
          title: Azure Storage Event Hubs Event Offset
          description: It sets the offset of the event when it was received from the associated Event Hub partition. This is only present on a received EventData.
          type: string
        CamelAzureEventHubsEnqueuedTime:
          title: Azure Event Hubs Event Enqueued Time
          description: It sets the instant, in UTC, of when the event was enqueued in the Event Hub partition. This is only present on a received EventData.
          type: java.time.Instant
        CamelAzureEventHubsSequenceNumber:
          title: Azure Event Hubs Event Sequence Number
          description: |-
            It sets the sequence number assigned to the event when it was enqueued in the associated Event Hub partition. This is unique for every message received in the Event Hub partition. This is only present on a received EventData.
          type: long
        CamelAzureEventHubsMetadata:
          title: Azure Event Hubs Event Metadata
          description: The set of free-form event properties which may be used for passing metadata associated with the event with the event body during Event Hubs operations.
          type: object
        CamelMessageTimestamp:
          title: Azure Event Hubs Message Timestamp
          description: The timestamp of the message.
          type: long
        CamelAzureEventHubsCheckpointUpdatedBy:
          title: Azure Event Hubs Checkpoint Updated By
          description: It sets the reason for the checkpoint to have been updated. This is only present on a received EventData.
          type: string
      types:
        binary:
          format: "application-octet-stream"
          description: Default binary representation of the Azure Event Hubs Event retrieved.
          mediaType: application/octet-stream
        cloudevents:
          format: "azure-eventhubs:application-cloudevents"
          description: |-
            Data type transformer converts Azure Eventhubs consumer response to CloudEvent v1_0 data format. The data type sets
            Camel specific CloudEvent headers with values extracted from Azure Eventhubs consumer response.
          headers:
            CamelCloudEventID:
              title: CloudEvent ID
              description: The Camel exchange id set as event id
              type: string
            CamelCloudEventType:
              title: CloudEvent Type
              description: The event type
              default: "org.apache.camel.event.azure.eventhubs.consume"
              type: string
            CamelCloudEventSource:
              title: CloudEvent Source
              description: The event source. By default, the Partition Id with prefix "azure.eventhubs.".
              type: string
            CamelCloudEventSubject:
              title: CloudEvent Subject
              description: The event subject. The Azure Event Hubs Event Sequence Number.
              type: string
            CamelCloudEventTime:
              title: CloudEvent Time
              description: The exchange creation timestamp as event time.
              type: string
  dependencies:
  - "camel:azure-eventhubs"
  - "camel:kamelet"
  - "camel:jackson"
  template:
    from:
      uri: 'azure-eventhubs://{{namespaceName}}/{{eventhubName}}'
      parameters:
        sharedAccessName: "{{?sharedAccessName}}"
        sharedAccessKey: "{{?sharedAccessKey}}"
        blobAccountName: "{{blobAccountName}}"
        blobAccessKey: "{{blobAccessKey}}"
        blobContainerName: "{{blobContainerName}}"
        credentialType: "{{credentialType}}"
      steps:
      - to: "kamelet:sink"