---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  annotations:
    controller-gen.kubebuilder.io/version: v0.19.0
  name: usages.protection.crossplane.io
spec:
  group: protection.crossplane.io
  names:
    categories:
    - crossplane
    kind: Usage
    listKind: UsageList
    plural: usages
    singular: usage
  scope: Namespaced
  versions:
  - additionalPrinterColumns:
    - jsonPath: .metadata.annotations.crossplane\.io/usage-details
      name: DETAILS
      type: string
    - jsonPath: .status.conditions[?(@.type=='Ready')].status
      name: READY
      type: string
    - jsonPath: .metadata.creationTimestamp
      name: AGE
      type: date
    name: v1beta1
    schema:
      openAPIV3Schema:
        description: |-
          A Usage defines a deletion blocking relationship between two resources.

          Usages prevent accidental deletion of a single resource or deletion of
          resources with dependent resources.

          Read the Crossplane documentation for
          [more information about Compositions](https://docs.crossplane.io/latest/managed-resources/usages/).
        properties:
          apiVersion:
            description: |-
              APIVersion defines the versioned schema of this representation of an object.
              Servers should convert recognized schemas to the latest internal value, and
              may reject unrecognized values.
              More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
            type: string
          kind:
            description: |-
              Kind is a string value representing the REST resource this object represents.
              Servers may infer this from the endpoint the client submits requests to.
              Cannot be updated.
              In CamelCase.
              More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
            type: string
          metadata:
            type: object
          spec:
            description: UsageSpec defines the desired state of Usage.
            properties:
              by:
                description: By is the resource that is "using the other resource".
                properties:
                  apiVersion:
                    description: API version of the referent.
                    type: string
                  kind:
                    description: |-
                      Kind of the referent.
                      More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
                    type: string
                  resourceRef:
                    description: Reference to the resource.
                    properties:
                      name:
                        description: Name of the referent.
                        type: string
                    required:
                    - name
                    type: object
                  resourceSelector:
                    description: |-
                      Selector to the resource.
                      This field will be ignored if ResourceRef is set.
                    properties:
                      matchControllerRef:
                        description: |-
                          MatchControllerRef ensures an object with the same controller reference
                          as the selecting object is selected.
                        type: boolean
                      matchLabels:
                        additionalProperties:
                          type: string
                        description: MatchLabels ensures an object with matching labels
                          is selected.
                        type: object
                    type: object
                type: object
                x-kubernetes-validations:
                - message: either a resource reference or a resource selector should
                    be set.
                  rule: has(self.resourceRef) || has(self.resourceSelector)
              of:
                description: Of is the resource that is "being used".
                properties:
                  apiVersion:
                    description: API version of the referent.
                    type: string
                  kind:
                    description: |-
                      Kind of the referent.
                      More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
                    type: string
                  resourceRef:
                    description: Reference to the resource.
                    properties:
                      name:
                        description: Name of the referent.
                        type: string
                      namespace:
                        description: Namespace of the referent.
                        type: string
                    required:
                    - name
                    type: object
                  resourceSelector:
                    description: |-
                      Selector to the resource.
                      This field will be ignored if ResourceRef is set.
                    properties:
                      matchControllerRef:
                        description: |-
                          MatchControllerRef ensures an object with the same controller reference
                          as the selecting object is selected.
                        type: boolean
                      matchLabels:
                        additionalProperties:
                          type: string
                        description: MatchLabels ensures an object with matching labels
                          is selected.
                        type: object
                      namespace:
                        description: |-
                          Namespace ensures an object in the supplied namespace is selected.
                          Omit namespace to only match resources in the Usage's namespace.
                        type: string
                    type: object
                type: object
                x-kubernetes-validations:
                - message: either a resource reference or a resource selector should
                    be set.
                  rule: has(self.resourceRef) || has(self.resourceSelector)
              reason:
                description: Reason is the reason for blocking deletion of the resource.
                type: string
              replayDeletion:
                description: ReplayDeletion will trigger a deletion on the used resource
                  during the deletion of the usage itself, if it was attempted to
                  be deleted at least once.
                type: boolean
            required:
            - of
            type: object
            x-kubernetes-validations:
            - message: either "spec.by" or "spec.reason" must be specified.
              rule: has(self.by) || has(self.reason)
            - message: cross-namespace "spec.of" is not allowed without "spec.by"
                resource.
              rule: has(self.by) || (!has(self.of.resourceRef) || !has(self.of.resourceRef.__namespace__))
                && (!has(self.of.resourceSelector) || !has(self.of.resourceSelector.__namespace__))
          status:
            description: UsageStatus defines the observed state of Usage.
            properties:
              conditions:
                description: Conditions of the resource.
                items:
                  description: A Condition that may apply to a resource.
                  properties:
                    lastTransitionTime:
                      description: |-
                        LastTransitionTime is the last time this condition transitioned from one
                        status to another.
                      format: date-time
                      type: string
                    message:
                      description: |-
                        A Message containing details about this condition's last transition from
                        one status to another, if any.
                      type: string
                    observedGeneration:
                      description: |-
                        ObservedGeneration represents the .metadata.generation that the condition was set based upon.
                        For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
                        with respect to the current state of the instance.
                      format: int64
                      type: integer
                    reason:
                      description: A Reason for this condition's last transition from
                        one status to another.
                      type: string
                    status:
                      description: Status of this condition; is it currently True,
                        False, or Unknown?
                      type: string
                    type:
                      description: |-
                        Type of this condition. At most one of each condition type may apply to
                        a resource at any point in time.
                      type: string
                  required:
                  - lastTransitionTime
                  - reason
                  - status
                  - type
                  type: object
                type: array
                x-kubernetes-list-map-keys:
                - type
                x-kubernetes-list-type: map
            type: object
        required:
        - spec
        type: object
    served: true
    storage: true
    subresources:
      status: {}
