# ---------------------------------------------------------------------------
# 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: splunk-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,PHN2ZyB3aWR0aD0iMjRweCIgaGVpZ2h0PSIyNHB4IiB2aWV3Qm94PSIwIDAgMjQgMjQiIHJvbGU9ImltZyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+U3BsdW5rIGljb248L3RpdGxlPjxwYXRoIGQ9Ik0yMy4zNDggMTEuOTExbC0yLjI0MS0xLjA5MXYtLjY1TDI0IDExLjYyMXYuNTkzbC0yLjg5MyAxLjQzOHYtLjYzNnptLTUuMzk3IDEuODQxaC0uOTYxdi01LjMxaC45NjF2My4xMTZoLjEwMmwxLjI4LTEuNDgxLjcyMy4zMS0xLjIzIDEuMzE2IDEuNDUzIDEuODA5LS44ODguMzExLTEuNDQtMS45OTZ6bS0yLjU3Ny0uMDAydi0yLjA2OGEyLjY4NSAyLjY4NSAwIDAgMC0uMDI2LS40Mi43OTEuNzkxIDAgMCAwLS4wOS0uMjZjLS4xMTMtLjIwMi0uMzA4LS4zMDQtLjU5LS4zMDRhLjg4OC44ODggMCAwIDAtLjQ2MS4xMTMuNjczLjY3MyAwIDAgMC0uMjg2LjMzIDEuMDEyIDEuMDEyIDAg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CAxLjMwNiAxLjMwNiAwIDAgMC0uMTg3LS4xNzMgOS4yMzEgOS4yMzEgMCAwIDAtLjMwOC0uMjMyIDYuNzg3IDYuNzg3IDAgMCAxLS4yODEtLjIxIDIuMTEgMi4xMSAwIDAgMS0uMjUyLS4yMzIgMS4wMzkgMS4wMzkgMCAwIDEtLjE4LS4yNzUuODI2LjgyNiAwIDAgMS0uMDY5LS4zNDcuODkzLjg5MyAwIDAgMSAuMDk0LS40MDkuOTM1LjkzNSAwIDAgMSAuMjU1LS4zMTQgMS4yMiAxLjIyIDAgMCAxIC4zOS0uMjAzYy4xNi0uMDUuMzI3LS4wNzQuNDk0LS4wNzIuMTg0IDAgLjM2OC4wMjYuNTQ1LjA3Ni4xNzQuMDUuMzM4LjEyMy40ODguMjE5bC0uMjgyLjQ1NGExLjA1IDEuMDUgMCAwIDAtLjYwOC0uMjAxLjUwNC41MDQgMCAwIDAtLjMyMy4xMDIuMzA3LjMwNyAwIDAgMC0uMTI2LjI1M2MwIC4wOTguMDQxLjE5My4xMTMuMjYuMDc0LjA3OC4yMDMuMTg2LjM4NS4zMjUuMTg1LjEzNi4zMzYuMjUzLjQ1Ny4zNTUuMTA0LjA4NS4yMDIuMTgyLjI4Ni4yODYuMDY1LjA4LjExNS4xNzMuMTQ1LjI3M2EuODA4LjgwOCAwIDAgMSAuMDQ2LjI5OVoiLz48L3N2Zz4="
    camel.apache.org/provider: "Apache Software Foundation"
    camel.apache.org/kamelet.group: "SPLUNK"
    camel.apache.org/kamelet.namespace: "Monitoring"
  labels:
    camel.apache.org/kamelet.type: "source"
spec:
  definition:
    title: "Splunk Source"
    description: |-
      Retrieve data from Splunk and outputs in json format.

      For the fields accepting time specifiers like `earliestTime`, it accepts a wide variety of formats, please check https://docs.splunk.com/Documentation/Splunk/9.0.0/Search/Specifytimemodifiersinyoursearch[Splunk documentation] for more information.

    required:
      - serverHostname
      - username
      - password
      - query
      - initEarliestTime
    type: object
    properties:
      serverHostname:
        title: Splunk Server Address
        description: The address of your Splunk server.
        type: string
        example: my_server_splunk.com
      serverPort:
        title: Splunk Server Port
        description: The address of your Splunk server.
        type: integer
        default: 8089
      username:
        title: Username
        description: The username to authenticate to Splunk Server.
        type: string
      password:
        title: Password
        description: The password to authenticate to Splunk Server.
        type: string
        format: password
        x-descriptors:
        - urn:camel:group:credentials
      index:
        title: Index
        description: Splunk index to write to.
        type: string
      protocol:
        title: Protocol
        description: Connection Protocol to Splunk server.
        type: string
        default: https
        enum: ["http", "https"]
      source:
        title: Source
        description: The source named field of the data.
        type: string
      sourceType:
        title: Source Type
        description: The source named field of the data.
        type: string
      app:
        title: Splunk App
        description: The app name in Splunk.
        type: string
      connectionTimeout:
        title: Connection Timeout
        description: Timeout in milliseconds when connecting to Splunk server
        type: integer
      count:
        title: Count
        description: The maximum number of entities to return.
        type: integer
      repeat:
        title: Repeat
        description: The maximum number of fires.
        type: integer
      delay:
        title: Delay
        description: The number of milliseconds before the next poll.
        type: integer
      query:
        title: Query
        description: The Splunk query to run.
        type: string
      earliestTime:
        title: Earliest Time
        description: Earliest time of the search time window.
        type: string
        example: "05/17/22 08:35:46:456"
      initEarliestTime:
        title: Init Earliest Time
        description: Initial start offset of the first search.
        type: string
        example: "05/17/22 08:35:46:456"
      latestTime:
        title: Latest Time
        description: Latest time of the search time window.
        type: string
        example: "05/17/22 08:35:46:456"
  types:
    out:
      mediaType: application/json
  dependencies:
  - "camel:jackson"
  - "camel:core"
  - "camel:splunk"
  - "camel:kamelet"
  - "mvn:com.fasterxml.jackson.datatype:jackson-datatype-joda:2.12.5"
  template:
    from:
      uri: "splunk:normal"
      parameters:
        host: "{{serverHostname}}"
        port: "{{serverPort}}"
        username: "{{username}}"
        password: "{{password}}"
        index: "{{?index}}"
        scheme: "{{?protocol}}"
        source: "{{?source}}"
        sourceType: "{{?sourceType}}"
        app: "{{?app}}"
        connectionTimeout: "{{?connectionTimeout}}"
        count: "{{?count}}"
        repeatCount: "{{?repeat}}"
        delay: "{{?delay}}"
        search: "{{?query}}"
        earliestTime: "{{?earliestTime}}"
        initEarliestTime: "{{initEarliestTime}}"
        latestTime: "{{?latestTime}}"
        raw: true
      steps:
      - marshal:
          json:
            library: Jackson
            moduleClassNames: com.fasterxml.jackson.datatype.joda.JodaModule
      - to: "kamelet:sink"