# ---------------------------------------------------------------------------
# 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: cassandra-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, 7036 characters]"
    camel.apache.org/provider: "Apache Software Foundation"
    camel.apache.org/kamelet.group: "Cassandra"
    camel.apache.org/kamelet.namespace: "Nosql"
  labels:
    camel.apache.org/kamelet.type: "source"
spec:
  definition:
    title: "Cassandra Source"
    description: |-
      Send a query to an Apache Cassandra cluster table.
    required:
      - connectionHost
      - connectionPort
      - keyspace
      - query
    type: object
    properties:
      connectionHost:
        title: Connection Host
        description: The hostname(s) for the Cassandra server(s). Use a comma to separate multiple hostnames.
        type: string
        example: localhost
      connectionPort:
        title: Connection Port
        description: The port number(s) of the cassandra server(s). Use a comma to separate multiple port numbers.
        type: string
        example: 9042
      keyspace:
        title: Keyspace 
        description: The keyspace to use.
        type: string
        example: customers
      username:
        title: Username
        description: The username for accessing a secured Cassandra cluster.
        type: string
        x-descriptors:
        - urn:camel:group:credentials
      password:
        title: Password
        description: The password for accessing a secured Cassandra cluster.
        type: string
        format: password
        x-descriptors:
        - urn:camel:group:credentials
      resultStrategy:
        title: Result Strategy
        description: The strategy to convert the result set of the query. 
        type: string
        default: ALL
        enum: ["ALL", "ONE", "LIMIT_10", "LIMIT_100"]
      consistencyLevel:
        title: Consistency Level
        description: The consistency level to use.
        type: string
        default: QUORUM
        enum: ["ONE", "TWO", "THREE", "QUORUM", "ALL", "LOCAL_QUORUM", "EACH_QUORUM", "SERIAL", "LOCAL_SERIAL", "LOCAL_ONE"]
      query:
        title: Query
        description: The query to execute against the Cassandra cluster table.
        type: string
      extraTypeCodecs:
        title: Extra Type Codecs
        description: To use a specific comma separated list of Extra Type codecs. 
        type: string
        enum: ["BLOB_TO_ARRAY", "BOOLEAN_LIST_TO_ARRAY", "BYTE_LIST_TO_ARRAY", "SHORT_LIST_TO_ARRAY", "INT_LIST_TO_ARRAY", "LONG_LIST_TO_ARRAY", "FLOAT_LIST_TO_ARRAY", "DOUBLE_LIST_TO_ARRAY", "TIMESTAMP_UTC", "TIMESTAMP_MILLIS_SYSTEM", "TIMESTAMP_MILLIS_UTC", "ZONED_TIMESTAMP_SYSTEM", "ZONED_TIMESTAMP_UTC", "ZONED_TIMESTAMP_PERSISTED", "LOCAL_TIMESTAMP_SYSTEM", "LOCAL_TIMESTAMP_UTC"]
  types:
    out:
      mediaType: application/json
  dependencies:
  - "camel:jackson"
  - "camel:kamelet"
  - "camel:cassandraql"
  template:
    beans:
      - name: local-sql-cassandraql-source
        type: "#class:org.apache.camel.component.cassandra.CassandraComponent"
        properties:
          autowiredEnabled: "false"
    from:
      uri: "{{local-sql-cassandraql-source}}://{{connectionHost}}:{{connectionPort}}/{{keyspace}}"
      parameters:
        username: "{{?username}}"
        password: "{{?password}}"
        cql: "{{query}}"
        consistencyLevel: "{{consistencyLevel}}"
        resultSetConversionStrategy: "{{resultStrategy}}"
        extraTypeCodecs: "{{?extraTypeCodecs}}"
      steps:
      - marshal:
          json: {}
      - to: "kamelet:sink"