# ---------------------------------------------------------------------------
# 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/v1alpha1
kind: Kamelet
metadata:
  name: redis-sink
  labels:
    camel.apache.org/kamelet.type: "sink"
  annotations:
    camel.apache.org/kamelet.support.level: "Stable"
    camel.apache.org/catalog.version: "3.21.0"
    camel.apache.org/provider: "Apache Software Foundation"
    camel.apache.org/kamelet.group: "Redis"
    camel.apache.org/kamelet.namespace: "Cache"
    camel.apache.org/kamelet.icon: data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjUwMCIgaGVpZ2h0PSIyMTQ4IiB2aWV3Qm94PSIwIDAgMjU2IDIyMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWluWU1pbiBtZWV0Ij48cGF0aCBkPSJNMjQ1Ljk3IDE2OC45NDNjLTEzLjY2MiA3LjEyMS04NC40MzQgMzYuMjItOTkuNTAxIDQ0LjA3NS0xNS4wNjcgNy44NTYtMjMuNDM3IDcuNzgtMzUuMzQgMi4wOS0xMS45MDItNS42OS04Ny4yMTYtMzYuMTEyLTEwMC43ODMtNDIuNTk3QzMuNTY2IDE2OS4yNzEgMCAxNjYuNTM1IDAgMTYzLjk1MXYtMjUuODc2czk4LjA1LTIxLjM0NSAxMTMuODc5LTI3LjAyNGMxNS44MjgtNS42NzkgMjEuMzItNS44ODQgMzQuNzktLjk1IDEzLjQ3MiA0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TEtMTMuNzUyIiBmaWxsPSIjOUEyOTI4Ii8+PC9zdmc+
spec:
  definition:
    title: "Redis Sink"
    description: "Write object to a Redis cache."
    required:
      - redisHost
      - redisPort
      - command
    type: object
    properties:
      redisHost:
        title: Redis Host
        description: The host where Redis server is running
        type: string
      redisPort:
        title: Redis Port
        description: The port where Redis server is running
        type: integer
      command:
        title: Command
        description: Redis Command 
        type: string
        default: GET
      channels:
        title: Channels
        description: Redis Channels
        type: string
        default: one
      serializer:
        title: Serializer
        description: RedisSerializer fully qualified name implementation 
        type: string
        default: org.springframework.data.redis.serializer.StringRedisSerializer
  dependencies:
    - "camel:kamelet"
    - "camel:core"
    - "camel:spring-redis"
  template:
    from:
      uri: "kamelet:source"
      steps:
      - choice:
          when:
          - simple: "${header[key]}"
            steps:
            - set-header:
                name: CamelRedis.Key
                simple: "${header[key]}"
          - simple: "${header[ce-key]}"
            steps:
            - set-header:
                name: CamelRedis.Key
                simple: "${header[ce-key]}"
      - choice:
          when:
          - simple: "${header[value]}"
            steps:
            - set-header:
                name: CamelRedis.Value
                simple: "${header[value]}"
          - simple: "${header[ce-value]}"
            steps:
            - set-header:
                name: CamelRedis.Value
                simple: "${header[ce-value]}"
      - choice:
          when:
          - simple: "${header[message]}"
            steps:
            - set-header:
                name: CamelRedis.Message
                simple: "${header[message]}"
          - simple: "${header[ce-message]}"
            steps:
            - set-header:
                name: CamelRedis.Message
                simple: "${header[ce-message]}"
      - choice:
          when:
          - simple: "${header[channel]}"
            steps:
            - set-header:
                name: CamelRedis.Channel
                simple: "${header[channel]}"
          - simple: "${header[ce-channel]}"
            steps:
            - set-header:
                name: CamelRedis.Channel
                simple: "${header[ce-channell]}"
      - set-header:
          name: CamelRedis.Message
          simple: "${body}"
      - set-header:
          name: CamelRedis.Value
          simple: "${body}"
      - to:
          uri: "spring-redis:{{redisHost}}:{{redisPort}}"
          parameters:
            command: "{{command}}"
            channels: "{{channels}}"
            serializer: "#class:{{serializer}}"