# Copyright 2022 TriggerMesh Inc.
#
# Licensed 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: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: splunktargets.targets.triggermesh.io
  labels:
    knative.dev/crd-install: 'true'
    triggermesh.io/crd-install: 'true'
    duck.knative.dev/addressable: 'true'
  annotations:
    registry.triggermesh.io/acceptedEventTypes: |
      [
        { "type": "*" }
      ]
spec:
  group: targets.triggermesh.io
  scope: Namespaced
  names:
    kind: SplunkTarget
    plural: splunktargets
    categories:
    - all
    - knative
    - eventing
    - targets
  versions:
  - name: v1alpha1
    served: true
    storage: true
    subresources:
      status: {}
    schema:
      openAPIV3Schema:
        type: object
        description: TriggerMesh event target for Splunk.
        properties:
          spec:
            type: object
            properties:
              endpoint:
                type: string
                description: URL of the HTTP Event Collector (HEC). Only the scheme, hostname, and port (optionally) are
                  evaluated, the URL path is trimmed if present. See
                  https://docs.splunk.com/Documentation/Splunk/latest/Data/UsetheHTTPEventCollector#Enable_HTTP_Event_Collector.
                format: url
                pattern: ^https?:\/\/.+$
              token:
                type: object
                description: Token for authenticating requests against the HEC. See
                  https://docs.splunk.com/Documentation/Splunk/latest/Data/UsetheHTTPEventCollector#About_Event_Collector_tokens.
                properties:
                  value:
                    type: string
                    format: guid
                    pattern: ^[0-9A-Fa-f]{8}(?:-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}$
                  valueFromSecret:
                    type: object
                    properties:
                      name:
                        type: string
                      key:
                        type: string
                oneOf:
                - required: [value]
                - required: [valueFromSecret]
              index:
                type: string
                description: Name of the index to send events to. When undefined, events are sent to the default index
                  defined in the HEC token's configuration.
                pattern: ^[\w-]+$
              skipTLSVerify:
                description: Control whether the target should verify the SSL/TLS certificate used by the event
                  collector.
                type: boolean
            required:
            - endpoint
            - token
          status:
            type: object
            description: Reported status of the event target.
            properties:
              observedGeneration:
                type: integer
                format: int64
              conditions:
                type: array
                items:
                  type: object
                  properties:
                    type:
                      type: string
                    status:
                      type: string
                      enum: ['True', 'False', Unknown]
                    severity:
                      type: string
                      enum: [Error, Warning, Info]
                    reason:
                      type: string
                    message:
                      type: string
                    lastTransitionTime:
                      type: string
                      format: date-time
                  required:
                  - type
                  - status
              address:
                type: object
                properties:
                  url:
                    type: string
    additionalPrinterColumns:
    - name: URL
      type: string
      jsonPath: .status.address.url
    - name: Ready
      type: string
      jsonPath: .status.conditions[?(@.type=='Ready')].status
    - name: Reason
      type: string
      jsonPath: .status.conditions[?(@.type=='Ready')].reason
    - name: Age
      type: date
      jsonPath: .metadata.creationTimestamp
