---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  annotations:
    controller-gen.kubebuilder.io/version: v0.16.4
  name: backupquotas.retour.thebackup.company
spec:
  group: retour.thebackup.company
  names:
    kind: BackupQuota
    listKind: BackupQuotaList
    plural: backupquotas
    singular: backupquota
  scope: Cluster
  versions:
  - additionalPrinterColumns:
    - jsonPath: .spec.namespaces
      name: Namespaces
      type: string
    - jsonPath: .metadata.creationTimestamp
      name: Age
      type: date
    name: v1
    schema:
      openAPIV3Schema:
        description: |-
          BackupQuota is the Schema for the backupquotas API: cluster-scoped,
          per-namespace guardrails on backup infrastructure usage.
        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: |-
              BackupQuotaSpec defines which namespaces a quota governs and what it limits.

              Precedence when several quotas exist: a quota naming the namespace in
              spec.namespaces wins over one matching it through spec.namespaceSelector,
              which wins over a default quota (one named "default", or one with neither
              namespaces nor a non-empty selector — it governs every namespace no other
              quota matches). Within the same tier the alphabetically first quota name
              wins.
            properties:
              limits:
                description: |-
                  Limits are the guardrails applied per governed namespace. Unset
                  limits are unlimited.
                properties:
                  maxActiveBackups:
                    description: |-
                      MaxActiveBackups caps concurrent non-terminal Backups per governed
                      namespace. A Backup over the cap is held Pending with a
                      QuotaExceeded condition (never failed) until a slot frees up.
                    format: int32
                    minimum: 0
                    type: integer
                  maxBackupsPerDay:
                    description: |-
                      MaxBackupsPerDay caps Backups per rolling 24 hours per governed
                      namespace, counted by Backup creationTimestamp. A Backup over the
                      cap is held Pending until enough prior backups age out of the
                      window.
                    format: int32
                    minimum: 0
                    type: integer
                  maxSchedules:
                    description: |-
                      MaxSchedules caps BackupSchedule objects per governed namespace.
                      Schedules beyond the cap (oldest schedules keep their slots) are
                      marked Failed with a QuotaExceeded condition until the count drops.
                    format: int32
                    minimum: 0
                    type: integer
                  maxTotalSizeBytes:
                    description: |-
                      MaxTotalSizeBytes caps the summed reported size (status.backupSize)
                      of the namespace's non-deleted Backups. Best-effort: sizes are what
                      workers reported. Enforcement only refuses NEW backups while at or
                      over the cap — nothing is ever deleted to get back under it.
                    format: int64
                    minimum: 0
                    type: integer
                  minScheduleInterval:
                    description: |-
                      MinScheduleInterval is the smallest gap allowed between two firings
                      of a BackupSchedule's cron in a governed namespace (e.g. "15m").
                      The admission webhook refuses tighter schedules at create/update;
                      the reconciler also marks existing tighter schedules Failed.
                    type: string
                type: object
              namespaceSelector:
                description: |-
                  NamespaceSelector selects governed namespaces by label. An empty
                  selector does not match everything — it makes the quota a default
                  quota instead (see the precedence note above).
                properties:
                  matchExpressions:
                    description: matchExpressions is a list of label selector requirements.
                      The requirements are ANDed.
                    items:
                      description: |-
                        A label selector requirement is a selector that contains values, a key, and an operator that
                        relates the key and values.
                      properties:
                        key:
                          description: key is the label key that the selector applies
                            to.
                          type: string
                        operator:
                          description: |-
                            operator represents a key's relationship to a set of values.
                            Valid operators are In, NotIn, Exists and DoesNotExist.
                          type: string
                        values:
                          description: |-
                            values is an array of string values. If the operator is In or NotIn,
                            the values array must be non-empty. If the operator is Exists or DoesNotExist,
                            the values array must be empty. This array is replaced during a strategic
                            merge patch.
                          items:
                            type: string
                          type: array
                          x-kubernetes-list-type: atomic
                      required:
                      - key
                      - operator
                      type: object
                    type: array
                    x-kubernetes-list-type: atomic
                  matchLabels:
                    additionalProperties:
                      type: string
                    description: |-
                      matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
                      map is equivalent to an element of matchExpressions, whose key field is "key", the
                      operator is "In", and the values array contains only "value". The requirements are ANDed.
                    type: object
                type: object
                x-kubernetes-map-type: atomic
              namespaces:
                description: |-
                  Namespaces is the explicit list of namespaces this quota governs.
                  Strongest match tier: a namespace listed here is governed by this
                  quota even when another quota's selector also matches it.
                items:
                  type: string
                type: array
            type: object
          status:
            description: BackupQuotaStatus reports per-namespace usage for the governed
              namespaces.
            properties:
              lastUpdated:
                description: LastUpdated is when the usage above was last refreshed.
                format: date-time
                type: string
              namespaces:
                description: |-
                  Namespaces lists current usage per governed namespace, sorted by
                  name. Namespaces with zero usage on every counter are omitted.
                items:
                  description: BackupQuotaNamespaceUsage is one governed namespace's
                    current usage.
                  properties:
                    activeBackups:
                      description: |-
                        ActiveBackups is the number of non-terminal Backups counted against
                        maxActiveBackups (quota-blocked backups are not counted — they hold
                        no backup infrastructure).
                      format: int32
                      type: integer
                    backupsLast24h:
                      description: |-
                        BackupsLast24h is the number of Backups created in the last 24
                        hours (by creationTimestamp).
                      format: int32
                      type: integer
                    namespace:
                      description: Namespace the usage was measured in.
                      type: string
                    schedules:
                      description: Schedules is the number of BackupSchedule objects
                        in the namespace.
                      format: int32
                      type: integer
                    totalSizeBytes:
                      description: |-
                        TotalSizeBytes is the summed status.backupSize of the namespace's
                        Backups.
                      format: int64
                      type: integer
                  required:
                  - namespace
                  type: object
                type: array
            type: object
        type: object
    served: true
    storage: true
    subresources:
      status: {}
