# 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: awsdynamodbtargets.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": "*" }
      ]
    registry.knative.dev/eventTypes: |
      [
        { "type": "io.triggermesh.targets.aws.dynamodb.result" }
      ]
spec:
  group: targets.triggermesh.io
  names:
    kind: AWSDynamoDBTarget
    plural: awsdynamodbtargets
    categories:
    - all
    - knative
    - eventing
    - targets
  scope: Namespaced
  versions:
  - name: v1alpha1
    served: true
    storage: true
    subresources:
      status: {}
    schema:
      openAPIV3Schema:
        type: object
        description: TriggerMesh event target for AWS DynamoDB.
        properties:
          spec:
            description: Desired state of event target.
            type: object
            properties:
              awsApiKey:
                type: object
                description: API Key to interact with the Amazon DynamoDB API. For more information about AWS
                  security credentials, please refer to the AWS General Reference at
                  https://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html
                properties:
                  secretKeyRef:
                    description: A reference to a Kubernetes Secret object containing the access key ID.
                    type: object
                    properties:
                      key:
                        type: string
                      name:
                        type: string
              awsApiSecret:
                description: API Key to interact with the Amazon DynamoDB API. For more information about AWS
                  security credentials, please refer to the AWS General Reference at
                  https://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html
                type: object
                properties:
                  secretKeyRef:
                    description: A reference to a Kubernetes Secret object containing the secret access key.
                    type: object
                    properties:
                      key:
                        type: string
                      name:
                        type: string
              arn:
                description: ARN of the DynamoDB table to post events to. The expected format is documented at
                  https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazondynamodb.html
                type: string
                pattern: ^arn:aws(-cn|-us-gov)?:dynamodb:[a-z]{2}(-gov)?-[a-z]+-\d:\d{12}:table\/[a-zA-Z0-9-_.]{3,255}$
            required:
            - arn
            - awsApiSecret
            - awsApiKey
          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
