# ---------------------------------------------------------------------------
# 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-files-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,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgOTEgODEiIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgc3Ryb2tlPSIjMDAwIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjx1c2UgeGxpbms6aHJlZj0iI0EiIHg9Ii41IiB5PSIuNSIvPjxzeW1ib2wgaWQ9IkEiIG92ZXJmbG93PSJ2aXNpYmxlIj48cGF0aCBkPSJNNjcuNTU4IDBIMjIuNDQxTDAgNDBsMjIuNDQxIDQwaDQ1LjExN0w5MCA0MCA2Ny41NTggMHptLjIzNCA1Ny45NjRjMCAzLjM1My0yLjgwNSA2LjIyNy02LjA3OCA2LjIyN0gyOC41MmMtMy4yNzMgMC02LjA3OC0yLjg3NC02LjA3OC02LjIyN1YyMi4yNzZjMC0zLjM1MyAyLjgwNS02LjIyOCA2LjA3OC02LjIyOGgyOS45MjJsOS4zNTEg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ure Storage Blob"
    camel.apache.org/kamelet.namespace: "Azure"
  labels:
    camel.apache.org/kamelet.type: "source"
spec:
  definition:
    title: "Azure Storage File Source"
    description: |-
      Consume files from Azure Storage File Shares.
    required:
      - accountName
      - shareName
    type: object
    properties:
      accountName:
        title: Account Name
        description: The Azure Storage File Share account name.
        type: string
        x-descriptors:
        - urn:camel:group:credentials
      shareName:
        title: Share Name
        description: The Azure Storage File Share share name.
        type: string
      sharedKey:
        title: Shared Access Key
        description: The Azure Storage Blob access key.
        type: string
        format: password
        x-descriptors:
        - urn:camel:group:credentials
      delay:
        title: Delay
        description: The number of milliseconds before the next poll of the selected blob.
        type: integer
        default: 500
      deleteAfterRead:
        title: Auto-delete Blob 
        description: Specifies to delete blobs after consuming them
        type: boolean
        default: false
      credentialType:
        title: Credential Type
        description: Determines the credential strategy to adopt.
        type: string
        enum: ["SHARED_ACCOUNT_KEY", "AZURE_IDENTITY", "SHARED_KEY_CREDENTIAL", "AZURE_SAS"]
        default: "SHARED_ACCOUNT_KEY"
      directoryName:
        title: Directory Name
        description: The directory from where the consumer will start reading files.
        type: string
        default: "."
      recursive:
        title: Recursive Mode 
        description: If a directory, the consumer will look for files in all the sub-directories as well.
        type: boolean
        default: false
  dataTypes:
    out:
      default: binary
      headers:
        CamelFileLength:
          title: Azure Storage Files File Length
          description: A long value containing the file size
          type: long
        CamelFileLastModified:
          title: Azure Storage Files File Last Modified Date
          description: A Long value containing the last modified timestamp of the file.
          type: long
        CamelFileNameOnly:
          title: Azure Storage Files File Name Only
          description: Only the file name (the name with no leading paths).
          type: string
        CamelFileName:
          title: Azure Storage Files File Name 
          description: |-
            Name of the consumed file as a relative file path with offset from the starting directory configured on the endpoint.
          type: string
        CamelFileNameConsumed:
          title: Azure Storage Files Consumed File Name
          description: The name of the file that has been consumed.
          type: string
        CamelFileAbsolute:
          title: Azure Storage Files Consumed Absolute Format
          description: |- 
            A boolean option specifying whether the consumed file denotes an absolute path or not. 
            Should normally be false for relative paths. Absolute paths should normally not be used but we added to the move option to allow moving files to absolute paths. 
            But can be used elsewhere as well.
          type: boolean
        CamelFileAbsolutePath:
          title: Azure Storage Files Consumed Absolute Path
          description: The absolute path to the file. For relative files this path holds the relative path instead.
          type: string
        CamelFileExtendedAttributes:
          title: Azure Storage Files Extended Attributes
          description: Additional Metadata of the file of type Map<String,Object>
          type: object
        CamelFileContentType:
          title: Content Type
          description: The content type of the retrieved object.
          default: application/octet-stream
          type: string
        CamelFilePath:
          title: Azure Storage Files File Path
          description: The file path. For relative files this is the starting directory the relative filename. For absolute files this is the absolute path.
          type: string
        CamelFileRelativePath:
          title: Azure Storage Files File Relative Path
          description: The relative path.
          type: string
        CamelFileParent:
          title: Azure Storage Files File Relative Path
          description: The parent path.
          type: string
      types:
        binary:
          format: "application-octet-stream"
          description: Default binary representation of the File retrieved from Azure Storage Files.
          mediaType: application/octet-stream
        cloudevents:
          format: "azure-files:application-cloudevents"
          description: |-
            Data type transformer converts Azure Storage Files poll response to CloudEvent v1_0 data format. The data type sets
            Camel specific CloudEvent headers with values extracted from Azure Storage Files poll 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.storage.files.poll"
              type: string
            CamelCloudEventSource:
              title: CloudEvent Source
              description: The event source. By default, the Host name of the share with prefix "azure.storage.files.".
              type: string
            CamelCloudEventSubject:
              title: CloudEvent Subject
              description: The event subject. Usually the Azure Storage Files file name.
              type: string
            CamelCloudEventTime:
              title: CloudEvent Time
              description: The exchange creation timestamp as event time.
              type: string       
  dependencies:
    - "camel:azure-files"
    - "camel:kamelet"
    - "camel:core"
    - "camel:timer"
  template:
    from:
      uri: "azure-files:{{accountName}}/{{shareName}}/{{directoryName}}"
      parameters:
        sharedKey: "{{?sharedKey}}"
        credentialType: "{{credentialType}}"
        delay: "{{delay}}"
        delete: "{{deleteAfterRead}}"
        recursive: "{{recursive}}"
      steps:
        - to: "kamelet:sink"