# ---------------------------------------------------------------------------
# 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: ceph-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,[encoded data, 4928 characters]"
    camel.apache.org/provider: "Apache Software Foundation"
    camel.apache.org/kamelet.group: "Ceph"
    camel.apache.org/kamelet.namespace: "Cloud"
  labels:
    camel.apache.org/kamelet.type: "source"
spec:
  definition:
    title: "Ceph Source"
    description: |-
      Receive data from an Ceph Bucket, managed by a Object Storage Gateway.

    required:
      - cephUrl
      - accessKey
      - secretKey
      - bucketName
      - zoneGroup
    type: object
    properties:
      bucketName:
        title: Bucket Name
        description: The Ceph Bucket name.
        type: string
      deleteAfterRead:
        title: Auto-delete Objects
        description: Specifies to delete objects after consuming them.
        type: boolean
        default: true
      accessKey:
        title: Access Key
        description: The access key.
        type: string
        format: password
        x-descriptors:
        - urn:camel:group:credentials
      secretKey:
        title: Secret Key
        description: The secret key.
        type: string
        format: password
        x-descriptors:
        - urn:camel:group:credentials
      zoneGroup:
        title: Bucket Zone Group
        description: The bucket zone group.
        type: string
      autoCreateBucket:
        title: Autocreate Bucket
        description: Specifies to automatically create the bucket.
        type: boolean
        default: false
      includeBody:
        title: Include Body
        description: If true, the exchange is consumed and put into the body and closed. If false, the Object stream is put raw into the body and the headers are set with the object metadata.
        type: boolean
        default: true
      prefix:
        title: Prefix
        description: The bucket prefix to consider while searching.
        type: string
        example: 'folder/'
      ignoreBody:
        title: Ignore Body
        description: If true, the Object body is ignored. Setting this to true overrides any behavior defined by the `includeBody` option. If false, the object is put in the body.
        type: boolean
        default: false
      cephUrl:
        title: Ceph Url Address
        description: Set the Ceph Object Storage Address Url.
        type: string
        example: "http://ceph-storage-address.com"
      delay:
        title: Delay
        description: The number of milliseconds before the next poll of the selected bucket.
        type: integer
        default: 500
  dependencies:
    - "camel:aws2-s3"
    - "camel:kamelet"
  template:
    from:
      uri: "aws2-s3:{{bucketName}}"
      parameters:
        autoCreateBucket: "{{autoCreateBucket}}"
        secretKey: "{{?secretKey}}"
        accessKey: "{{?accessKey}}"
        region: "{{zoneGroup}}"
        includeBody: "{{includeBody}}"
        ignoreBody: "{{ignoreBody}}"
        deleteAfterRead: "{{deleteAfterRead}}"
        prefix: "{{?prefix}}"
        uriEndpointOverride: "{{cephUrl}}"
        overrideEndpoint: "true"
        delay: "{{delay}}"
      steps:
      - to: "kamelet:sink"