/*
Copyright The Kubernetes Authors.

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.
*/


// This file was autogenerated by go-to-protobuf. Do not edit it manually!

syntax = "proto2";

package k8s.io.api.resource.v1;

import "k8s.io/api/core/v1/generated.proto";
import "k8s.io/apimachinery/pkg/api/resource/generated.proto";
import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto";
import "k8s.io/apimachinery/pkg/runtime/generated.proto";
import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto";

// Package-wide variables from generator "generated".
option go_package = "k8s.io/api/resource/v1";

// AllocatedDeviceStatus contains the status of an allocated device, if the
// driver chooses to report it. This may include driver-specific information.
//
// The combination of Driver, Pool, Device, and ShareID must match the corresponding key
// in Status.Allocation.Devices.
message AllocatedDeviceStatus {
  // Driver specifies the name of the DRA driver whose kubelet
  // plugin should be invoked to process the allocation once the claim is
  // needed on a node.
  //
  // Must be a DNS subdomain and should end with a DNS domain owned by the
  // vendor of the driver. It should use only lower case characters.
  //
  // +required
  optional string driver = 1;

  // This name together with the driver name and the device name field
  // identify which device was allocated (`<driver name>/<pool name>/<device name>`).
  //
  // Must not be longer than 253 characters and may contain one or more
  // DNS sub-domains separated by slashes.
  //
  // +required
  optional string pool = 2;

  // Device references one device instance via its name in the driver's
  // resource pool. It must be a DNS label.
  //
  // +required
  optional string device = 3;

  // ShareID uniquely identifies an individual allocation share of the device.
  //
  // +optional
  // +featureGate=DRAConsumableCapacity
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:format=k8s-uuid
  optional string shareID = 7;

  // Conditions contains the latest observation of the device's state.
  // If the device has been configured according to the class and claim
  // config references, the `Ready` condition should be True.
  //
  // Must not contain more than 8 entries.
  //
  // +optional
  // +listType=map
  // +listMapKey=type
  repeated .k8s.io.apimachinery.pkg.apis.meta.v1.Condition conditions = 4;

  // Data contains arbitrary driver-specific data.
  //
  // The length of the raw data must be smaller or equal to 10 Ki.
  //
  // +optional
  optional .k8s.io.apimachinery.pkg.runtime.RawExtension data = 5;

  // NetworkData contains network-related information specific to the device.
  //
  // +optional
  // +k8s:alpha(since: "1.36")=+k8s:optional
  optional NetworkDeviceData networkData = 6;
}

// AllocationResult contains attributes of an allocated resource.
message AllocationResult {
  // Devices is the result of allocating devices.
  //
  // +optional
  optional DeviceAllocationResult devices = 1;

  // NodeSelector defines where the allocated resources are available. If
  // unset, they are available everywhere.
  //
  // +optional
  optional .k8s.io.api.core.v1.NodeSelector nodeSelector = 3;

  // AllocationTimestamp stores the time when the resources were allocated.
  // This field is not guaranteed to be set, in which case that time is unknown.
  //
  // This is a beta field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
  // feature gate.
  //
  // +optional
  // +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
  optional .k8s.io.apimachinery.pkg.apis.meta.v1.Time allocationTimestamp = 5;
}

// CELDeviceSelector contains a CEL expression for selecting a device.
message CELDeviceSelector {
  // Expression is a CEL expression which evaluates a single device. It
  // must evaluate to true when the device under consideration satisfies
  // the desired criteria, and false when it does not. Any other result
  // is an error and causes allocation of devices to abort.
  //
  // The expression's input is an object named "device", which carries
  // the following properties:
  //  - driver (string): the name of the driver which defines this device.
  //  - attributes (map[string]object): the device's attributes, grouped by prefix
  //    (e.g. device.attributes["dra.example.com"] evaluates to an object with all
  //    of the attributes which were prefixed by "dra.example.com".
  //  - capacity (map[string]object): the device's capacities, grouped by prefix.
  //  - allowMultipleAllocations (bool): the allowMultipleAllocations property of the device
  //    (v1.34+ with the DRAConsumableCapacity feature enabled).
  //
  // Example: Consider a device with driver="dra.example.com", which exposes
  // two attributes named "model" and "ext.example.com/family" and which
  // exposes one capacity named "modules". This input to this expression
  // would have the following fields:
  //
  //     device.driver
  //     device.attributes["dra.example.com"].model
  //     device.attributes["ext.example.com"].family
  //     device.capacity["dra.example.com"].modules
  //
  // The device.driver field can be used to check for a specific driver,
  // either as a high-level precondition (i.e. you only want to consider
  // devices from this driver) or as part of a multi-clause expression
  // that is meant to consider devices from different drivers.
  //
  // The value type of each attribute is defined by the device
  // definition, and users who write these expressions must consult the
  // documentation for their specific drivers. The value type of each
  // capacity is Quantity.
  //
  // If an unknown prefix is used as a lookup in either device.attributes
  // or device.capacity, an empty map will be returned. Any reference to
  // an unknown field will cause an evaluation error and allocation to
  // abort.
  //
  // A robust expression should check for the existence of attributes
  // before referencing them.
  //
  // For ease of use, the cel.bind() function is enabled, and can be used
  // to simplify expressions that access multiple attributes with the
  // same domain. For example:
  //
  //     cel.bind(dra, device.attributes["dra.example.com"], dra.someBool && dra.anotherBool)
  //
  // When the DRAListTypeAttributes feature gate is enabled,
  // the includes() helper is available and it can work for both scalar
  // and list-type attributes. It was introduced to support smooth migration
  // from scalar attributes to list-type attributes while keeping
  // CEL expressions simple. For example:
  //
  //     device.attributes["dra.example.com"].models.includes("some-model")
  //
  // The length of the expression must be smaller or equal to 10 Ki. The
  // cost of evaluating it is also limited based on the estimated number
  // of logical steps.
  //
  // +required
  optional string expression = 1;
}

// CapacityRequestPolicy defines how requests consume device capacity.
//
// Must not set more than one ValidRequestValues.
message CapacityRequestPolicy {
  // Default specifies how much of this capacity is consumed by a request
  // that does not contain an entry for it in DeviceRequest's Capacity.
  //
  // +optional
  optional .k8s.io.apimachinery.pkg.api.resource.Quantity default = 1;

  // ValidValues defines a set of acceptable quantity values in consuming requests.
  //
  // Must not contain more than 10 entries.
  // Must be sorted in ascending order.
  //
  // If this field is set,
  // Default must be defined and it must be included in ValidValues list.
  //
  // If the requested amount does not match any valid value but smaller than some valid values,
  // the scheduler calculates the smallest valid value that is greater than or equal to the request.
  // That is: min(ceil(requestedValue) ∈ validValues), where requestedValue ≤ max(validValues).
  //
  // If the requested amount exceeds all valid values, the request violates the policy,
  // and this device cannot be allocated.
  //
  // +optional
  // +listType=atomic
  // +oneOf=ValidRequestValues
  repeated .k8s.io.apimachinery.pkg.api.resource.Quantity validValues = 3;

  // ValidRange defines an acceptable quantity value range in consuming requests.
  //
  // If this field is set,
  // Default must be defined and it must fall within the defined ValidRange.
  //
  // If the requested amount does not fall within the defined range, the request violates the policy,
  // and this device cannot be allocated.
  //
  // If the request doesn't contain this capacity entry, Default value is used.
  //
  // +optional
  // +oneOf=ValidRequestValues
  optional CapacityRequestPolicyRange validRange = 4;
}

// CapacityRequestPolicyRange defines a valid range for consumable capacity values.
//
//   - If the requested amount is less than Min, it is rounded up to the Min value.
//   - If Step is set and the requested amount is between Min and Max but not aligned with Step,
//     it will be rounded up to the next value equal to Min + (n * Step).
//   - If Step is not set, the requested amount is used as-is if it falls within the range Min to Max (if set).
//   - If the requested or rounded amount exceeds Max (if set), the request does not satisfy the policy,
//     and the device cannot be allocated.
message CapacityRequestPolicyRange {
  // Min specifies the minimum capacity allowed for a consumption request.
  //
  // Min must be greater than or equal to zero,
  // and less than or equal to the capacity value.
  // requestPolicy.default must be more than or equal to the minimum.
  //
  // +required
  optional .k8s.io.apimachinery.pkg.api.resource.Quantity min = 1;

  // Max defines the upper limit for capacity that can be requested.
  //
  // Max must be less than or equal to the capacity value.
  // Min and requestPolicy.default must be less than or equal to the maximum.
  //
  // +optional
  optional .k8s.io.apimachinery.pkg.api.resource.Quantity max = 2;

  // Step defines the step size between valid capacity amounts within the range.
  //
  // Max (if set) and requestPolicy.default must be a multiple of Step.
  // Min + Step must be less than or equal to the capacity value.
  //
  // +optional
  optional .k8s.io.apimachinery.pkg.api.resource.Quantity step = 3;
}

// CapacityRequirements defines the capacity requirements for a specific device request.
message CapacityRequirements {
  // Requests represent individual device resource requests for distinct resources,
  // all of which must be provided by the device.
  //
  // This value is used as an additional filtering condition against the available capacity on the device.
  // This is semantically equivalent to a CEL selector with
  // `device.capacity[<domain>].<name>.compareTo(quantity(<request quantity>)) >= 0`.
  // For example, device.capacity['test-driver.cdi.k8s.io'].counters.compareTo(quantity('2')) >= 0.
  //
  // When a requestPolicy is defined, the requested amount is adjusted upward
  // to the nearest valid value based on the policy.
  // If the requested amount cannot be adjusted to a valid value—because it exceeds what the requestPolicy allows—
  // the device is considered ineligible for allocation.
  //
  // For any capacity that is not explicitly requested:
  // - If no requestPolicy is set, the default consumed capacity is equal to the full device capacity
  //   (i.e., the whole device is claimed).
  // - If a requestPolicy is set, the default consumed capacity is determined according to that policy.
  //
  // If the device allows multiple allocation,
  // the aggregated amount across all requests must not exceed the capacity value.
  // The consumed capacity, which may be adjusted based on the requestPolicy if defined,
  // is recorded in the resource claim’s status.devices[*].consumedCapacity field.
  //
  // +optional
  map<string, .k8s.io.apimachinery.pkg.api.resource.Quantity> requests = 1;
}

// Counter describes a quantity associated with a device.
message Counter {
  // Value defines how much of a certain device counter is available.
  //
  // +required
  optional .k8s.io.apimachinery.pkg.api.resource.Quantity value = 1;
}

// CounterSet defines a named set of counters
// that are available to be used by devices defined in the
// ResourcePool.
//
// The counters are not allocatable by themselves, but
// can be referenced by devices. When a device is allocated,
// the portion of counters it uses will no longer be available for use
// by other devices.
message CounterSet {
  // Name defines the name of the counter set.
  // It must be a DNS label.
  //
  // +required
  // +k8s:alpha(since: "1.36")=+k8s:required
  // +k8s:alpha(since: "1.36")=+k8s:format=k8s-short-name
  optional string name = 1;

  // Counters defines the set of counters for this CounterSet
  // The name of each counter must be unique in that set and must be a DNS label.
  //
  // The maximum number of counters is 32.
  //
  // +required
  // +k8s:alpha(since: "1.36")=+k8s:required
  // +k8s:alpha(since: "1.36")=+k8s:eachKey=+k8s:format=k8s-short-name
  map<string, Counter> counters = 2;
}

// Device represents one individual hardware instance that can be selected based
// on its attributes. Besides the name, exactly one field must be set.
message Device {
  // Name is unique identifier among all devices managed by
  // the driver in the pool. It must be a DNS label.
  //
  // +required
  optional string name = 1;

  // Attributes defines the set of attributes for this device.
  // The name of each attribute must be unique in that set.
  //
  // The maximum number of attributes and capacities combined is 32.
  //
  // +optional
  // +k8s:alpha(since: "1.36")=+k8s:optional
  map<string, DeviceAttribute> attributes = 2;

  // Capacity defines the set of capacities for this device.
  // The name of each capacity must be unique in that set.
  //
  // The maximum number of attributes and capacities combined is 32.
  //
  // +optional
  map<string, DeviceCapacity> capacity = 3;

  // ConsumesCounters defines a list of references to sharedCounters
  // and the set of counters that the device will
  // consume from those counter sets.
  //
  // There can only be a single entry per counterSet.
  //
  // The maximum number of device counter consumptions per
  // device is 2.
  //
  // +optional
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +listType=atomic
  // +k8s:listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:unique=map
  // +k8s:alpha(since: "1.36")=+k8s:listMapKey=counterSet
  // +featureGate=DRAPartitionableDevices
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=2
  repeated DeviceCounterConsumption consumesCounters = 4;

  // NodeName identifies the node where the device is available.
  //
  // Must only be set if Spec.PerDeviceNodeSelection is set to true.
  // At most one of NodeName, NodeSelector and AllNodes can be set.
  //
  // +optional
  // +oneOf=DeviceNodeSelection
  // +featureGate=DRAPartitionableDevices
  optional string nodeName = 5;

  // NodeSelector defines the nodes where the device is available.
  //
  // Must use exactly one term.
  //
  // Must only be set if Spec.PerDeviceNodeSelection is set to true.
  // At most one of NodeName, NodeSelector and AllNodes can be set.
  //
  // +optional
  // +oneOf=DeviceNodeSelection
  // +featureGate=DRAPartitionableDevices
  optional .k8s.io.api.core.v1.NodeSelector nodeSelector = 6;

  // AllNodes indicates that all nodes have access to the device.
  //
  // Must only be set if Spec.PerDeviceNodeSelection is set to true.
  // At most one of NodeName, NodeSelector and AllNodes can be set.
  //
  // +optional
  // +oneOf=DeviceNodeSelection
  // +featureGate=DRAPartitionableDevices
  optional bool allNodes = 7;

  // If specified, these are the driver-defined taints.
  //
  // The maximum number of taints is 16. If taints are set for
  // any device in a ResourceSlice, then the maximum number of
  // allowed devices per ResourceSlice is 64 instead of 128.
  //
  // This is a beta field and requires enabling the DRADeviceTaints
  // feature gate.
  //
  // +optional
  // +listType=atomic
  // +featureGate=DRADeviceTaints
  // +k8s:alpha(since: "1.36")=+k8s:optional
  repeated DeviceTaint taints = 8;

  // BindsToNode indicates if the usage of an allocation involving this device
  // has to be limited to exactly the node that was chosen when allocating the claim.
  // If set to true, the scheduler will set the ResourceClaim.Status.Allocation.NodeSelector
  // to match the node where the allocation was made.
  //
  // This is a beta field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
  // feature gates.
  //
  // +optional
  // +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
  optional bool bindsToNode = 9;

  // BindingConditions defines the conditions for proceeding with binding.
  // All of these conditions must be set in the per-device status
  // conditions with a value of True to proceed with binding the pod to the node
  // while scheduling the pod.
  //
  // The maximum number of binding conditions is 4.
  //
  // The conditions must be a valid condition type string.
  //
  // This is a beta field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
  // feature gates.
  //
  // +optional
  // +listType=atomic
  // +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=4
  repeated string bindingConditions = 10;

  // BindingFailureConditions defines the conditions for binding failure.
  // They may be set in the per-device status conditions.
  // If any is set to "True", a binding failure occurred.
  //
  // The maximum number of binding failure conditions is 4.
  //
  // The conditions must be a valid condition type string.
  //
  // This is a beta field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
  // feature gates.
  //
  // +optional
  // +listType=atomic
  // +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=4
  repeated string bindingFailureConditions = 11;

  // AllowMultipleAllocations marks whether the device is allowed to be allocated to multiple DeviceRequests.
  //
  // If AllowMultipleAllocations is set to true, the device can be allocated more than once,
  // and all of its capacity is consumable, regardless of whether the requestPolicy is defined or not.
  //
  // +optional
  // +featureGate=DRAConsumableCapacity
  optional bool allowMultipleAllocations = 12;

  // NodeAllocatableResourceMappings defines the mapping of node resources
  // that are managed by the DRA driver exposing this device. This includes resources currently
  // reported in v1.Node `status.allocatable` that are not extended resources
  // (see https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#extended-resources).
  // Examples include "cpu", "memory", "ephemeral-storage", and hugepages.
  // In addition to standard requests made through the Pod `spec`, these resources
  // can also be requested through claims and allocated by the DRA driver.
  // For example, a CPU DRA driver might allocate exclusive CPUs or auxiliary node memory
  // dependencies of an accelerator device.
  // The keys of this map are the node-allocatable resource names (e.g., "cpu", "memory").
  // Extended resource names are not permitted as keys.
  // +optional
  // +featureGate=DRANodeAllocatableResources
  map<string, NodeAllocatableResourceMapping> nodeAllocatableResourceMappings = 13;
}

// DeviceAllocationConfiguration gets embedded in an AllocationResult.
message DeviceAllocationConfiguration {
  // Source records whether the configuration comes from a class and thus
  // is not something that a normal user would have been able to set
  // or from a claim.
  //
  // +required
  // +k8s:alpha(since: "1.36")=+k8s:required
  optional string source = 1;

  // Requests lists the names of requests where the configuration applies.
  // If empty, its applies to all requests.
  //
  // References to subrequests must include the name of the main request
  // and may include the subrequest using the format <main request>[/<subrequest>]. If just
  // the main request is given, the configuration applies to all subrequests.
  //
  // +optional
  // +listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:unique=set
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=32
  repeated string requests = 2;

  optional DeviceConfiguration deviceConfiguration = 3;
}

// DeviceAllocationResult is the result of allocating devices.
message DeviceAllocationResult {
  // Results lists all allocated devices.
  //
  // +optional
  // +listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=32
  repeated DeviceRequestAllocationResult results = 1;

  // This field is a combination of all the claim and class configuration parameters.
  // Drivers can distinguish between those based on a flag.
  //
  // This includes configuration parameters for drivers which have no allocated
  // devices in the result because it is up to the drivers which configuration
  // parameters they support. They can silently ignore unknown configuration
  // parameters.
  //
  // +optional
  // +listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=64
  repeated DeviceAllocationConfiguration config = 2;
}

// DeviceAttribute must have exactly one field set.
message DeviceAttribute {
  // IntValue is a number.
  //
  // +optional
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:unionMember
  optional int64 int = 2;

  // BoolValue is a true/false value.
  //
  // +optional
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:unionMember
  optional bool bool = 3;

  // StringValue is a string. Must not be longer than 64 characters.
  //
  // +optional
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:unionMember
  optional string string = 4;

  // VersionValue is a semantic version according to semver.org spec 2.0.0.
  // Must not be longer than 64 characters.
  //
  // +optional
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:unionMember
  optional string version = 5;

  // IntValues is a non-empty list of numbers.
  //
  // This is an alpha field and requires enabling the DRAListTypeAttributes feature gate.
  //
  // +optional
  // +listType=atomic
  // +k8s:listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:unionMember
  // +featureGate=DRAListTypeAttributes
  repeated int64 ints = 6;

  // BoolValues is a non-empty list of true/false values.
  //
  // +optional
  // +listType=atomic
  // +k8s:listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:unionMember
  // +featureGate=DRAListTypeAttributes
  repeated bool bools = 7;

  // StringValues is a non-empty list of strings.
  // Each string must not be longer than 64 characters.
  //
  // This is an alpha field and requires enabling the DRAListTypeAttributes feature gate.
  //
  // +optional
  // +listType=atomic
  // +k8s:listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:unionMember
  // +featureGate=DRAListTypeAttributes
  repeated string strings = 8;

  // VersionValues is a non-empty list of semantic versions according to semver.org spec 2.0.0.
  // Each version string must not be longer than 64 characters.
  //
  // This is an alpha field and requires enabling the DRAListTypeAttributes feature gate.
  //
  // +optional
  // +listType=atomic
  // +k8s:listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:unionMember
  // +featureGate=DRAListTypeAttributes
  repeated string versions = 9;
}

// DeviceCapacity describes a quantity associated with a device.
message DeviceCapacity {
  // Value defines how much of a certain capacity that device has.
  //
  // This field reflects the fixed total capacity and does not change.
  // The consumed amount is tracked separately by scheduler
  // and does not affect this value.
  //
  // +required
  optional .k8s.io.apimachinery.pkg.api.resource.Quantity value = 1;

  // RequestPolicy defines how this DeviceCapacity must be consumed
  // when the device is allowed to be shared by multiple allocations.
  //
  // The Device must have allowMultipleAllocations set to true in order to set a requestPolicy.
  //
  // If unset, capacity requests are unconstrained:
  // requests can consume any amount of capacity, as long as the total consumed
  // across all allocations does not exceed the device's defined capacity.
  // If request is also unset, default is the full capacity value.
  //
  // +optional
  // +featureGate=DRAConsumableCapacity
  optional CapacityRequestPolicy requestPolicy = 2;
}

// DeviceClaim defines how to request devices with a ResourceClaim.
message DeviceClaim {
  // Requests represent individual requests for distinct devices which
  // must all be satisfied. If empty, nothing needs to be allocated.
  //
  // +optional
  // +listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:unique=map
  // +k8s:alpha(since: "1.36")=+k8s:listMapKey=name
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=32
  repeated DeviceRequest requests = 1;

  // These constraints must be satisfied by the set of devices that get
  // allocated for the claim.
  //
  // +optional
  // +listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=32
  repeated DeviceConstraint constraints = 2;

  // This field holds configuration for multiple potential drivers which
  // could satisfy requests in this claim. It is ignored while allocating
  // the claim.
  //
  // +optional
  // +listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=32
  repeated DeviceClaimConfiguration config = 3;
}

// DeviceClaimConfiguration is used for configuration parameters in DeviceClaim.
message DeviceClaimConfiguration {
  // Requests lists the names of requests where the configuration applies.
  // If empty, it applies to all requests.
  //
  // References to subrequests must include the name of the main request
  // and may include the subrequest using the format <main request>[/<subrequest>]. If just
  // the main request is given, the configuration applies to all subrequests.
  //
  // +optional
  // +listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:unique=set
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=32
  repeated string requests = 1;

  optional DeviceConfiguration deviceConfiguration = 2;
}

// DeviceClass is a vendor- or admin-provided resource that contains
// device configuration and selectors. It can be referenced in
// the device requests of a claim to apply these presets.
// Cluster scoped.
message DeviceClass {
  // Standard object metadata
  // +optional
  // +k8s:alpha(since: "1.36")=+k8s:subfield(name)=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:subfield(name)=+k8s:format=k8s-long-name
  optional .k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;

  // Spec defines what can be allocated and how to configure it.
  //
  // This is mutable. Consumers have to be prepared for classes changing
  // at any time, either because they get updated or replaced. Claim
  // allocations are done once based on whatever was set in classes at
  // the time of allocation.
  //
  // Changing the spec automatically increments the metadata.generation number.
  optional DeviceClassSpec spec = 2;
}

// DeviceClassConfiguration is used in DeviceClass.
message DeviceClassConfiguration {
  optional DeviceConfiguration deviceConfiguration = 1;
}

// DeviceClassList is a collection of classes.
message DeviceClassList {
  // Standard list metadata
  // +optional
  optional .k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;

  // Items is the list of resource classes.
  repeated DeviceClass items = 2;
}

// DeviceClassSpec is used in a [DeviceClass] to define what can be allocated
// and how to configure it.
message DeviceClassSpec {
  // Each selector must be satisfied by a device which is claimed via this class.
  //
  // +optional
  // +listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=32
  repeated DeviceSelector selectors = 1;

  // Config defines configuration parameters that apply to each device that is claimed via this class.
  // Some classses may potentially be satisfied by multiple drivers, so each instance of a vendor
  // configuration applies to exactly one driver.
  //
  // They are passed to the driver, but are not considered while allocating the claim.
  //
  // +optional
  // +listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=32
  repeated DeviceClassConfiguration config = 2;

  // ExtendedResourceName is the extended resource name for the devices of this class.
  // The devices of this class can be used to satisfy a pod's extended resource requests.
  // It has the same format as the name of a pod's extended resource.
  // It should be unique among all the device classes in a cluster.
  // If two device classes have the same name, then the class created later
  // is picked to satisfy a pod's extended resource requests.
  // If two classes are created at the same time, then the name of the class
  // lexicographically sorted first is picked.
  //
  // This is a beta field.
  // +optional
  // +featureGate=DRAExtendedResource
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:format=k8s-extended-resource-name
  optional string extendedResourceName = 4;
}

// DeviceConfiguration must have exactly one field set. It gets embedded
// inline in some other structs which have other fields, so field names must
// not conflict with those.
message DeviceConfiguration {
  // Opaque provides driver-specific configuration parameters.
  //
  // +optional
  // +oneOf=ConfigurationType
  // +k8s:alpha(since: "1.36")=+k8s:optional
  optional OpaqueDeviceConfiguration opaque = 1;
}

// DeviceConstraint must have exactly one field set besides Requests.
message DeviceConstraint {
  // Requests is a list of the one or more requests in this claim which
  // must co-satisfy this constraint. If a request is fulfilled by
  // multiple devices, then all of the devices must satisfy the
  // constraint. If this is not specified, this constraint applies to all
  // requests in this claim.
  //
  // References to subrequests must include the name of the main request
  // and may include the subrequest using the format <main request>[/<subrequest>]. If just
  // the main request is given, the constraint applies to all subrequests.
  //
  // +optional
  // +listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:unique=set
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=32
  repeated string requests = 1;

  // MatchAttribute requires that all devices in question have this
  // attribute and that its type and value are the same across those
  // devices.
  //
  // For example, if you specified "dra.example.com/numa" (a hypothetical example!),
  // then only devices in the same NUMA node will be chosen. A device which
  // does not have that attribute will not be chosen. All devices should
  // use a value of the same type for this attribute because that is part of
  // its specification, but if one device doesn't, then it also will not be
  // chosen.
  //
  // When the DRAListTypeAttributes feature gate is enabled, comparison uses
  // set semantics(i.e., element order and duplicates are ignored): list-valued attributes
  // match when the intersection across all devices is non-empty.
  // Scalar values are treated as single-element lists for backward compatibility.
  //
  // Must include the domain qualifier.
  //
  // +optional
  // +oneOf=ConstraintType
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:format=k8s-resource-fully-qualified-name
  optional string matchAttribute = 2;

  // DistinctAttribute requires that all devices in question have this
  // attribute and that its type and value are unique across those devices.
  //
  // When the DRAListTypeAttributes feature gate is enabled, comparison uses
  // set semantics (i.e., element order and duplicates are ignored):
  // list-valued attributes must be pairwise disjoint across devices.
  // Scalar values are treated as singleton sets for backward compatibility.
  //
  // This acts as the inverse of MatchAttribute.
  //
  // This constraint is used to avoid allocating multiple requests to the same device
  // by ensuring attribute-level differentiation.
  //
  // This is useful for scenarios where resource requests must be fulfilled by separate physical devices.
  // For example, a container requests two network interfaces that must be allocated from two different physical NICs.
  //
  // +optional
  // +oneOf=ConstraintType
  // +featureGate=DRAConsumableCapacity
  optional string distinctAttribute = 3;
}

// DeviceCounterConsumption defines a set of counters that
// a device will consume from a CounterSet.
message DeviceCounterConsumption {
  // CounterSet is the name of the set from which the
  // counters defined will be consumed.
  //
  // +required
  // +k8s:alpha(since: "1.36")=+k8s:required
  // +k8s:alpha(since: "1.36")=+k8s:format=k8s-short-name
  optional string counterSet = 1;

  // Counters defines the counters that will be consumed by the device.
  //
  // The maximum number of counters is 32.
  //
  // +required
  // +k8s:alpha(since: "1.36")=+k8s:required
  // +k8s:alpha(since: "1.36")=+k8s:eachKey=+k8s:format=k8s-short-name
  map<string, Counter> counters = 2;
}

// DeviceRequest is a request for devices required for a claim.
// This is typically a request for a single resource like a device, but can
// also ask for several identical devices. With FirstAvailable it is also
// possible to provide a prioritized list of requests.
message DeviceRequest {
  // Name can be used to reference this request in a pod.spec.containers[].resources.claims
  // entry and in a constraint of the claim.
  //
  // References using the name in the DeviceRequest will uniquely
  // identify a request when the Exactly field is set. When the
  // FirstAvailable field is set, a reference to the name of the
  // DeviceRequest will match whatever subrequest is chosen by the
  // scheduler.
  //
  // Must be a DNS label.
  //
  // +required
  optional string name = 1;

  // Exactly specifies the details for a single request that must
  // be met exactly for the request to be satisfied.
  //
  // One of Exactly or FirstAvailable must be set.
  //
  // +optional
  // +oneOf=deviceRequestType
  // +k8s:alpha(since: "1.36")=+k8s:optional
  optional ExactDeviceRequest exactly = 2;

  // FirstAvailable contains subrequests, of which exactly one will be
  // selected by the scheduler. It tries to
  // satisfy them in the order in which they are listed here. So if
  // there are two entries in the list, the scheduler will only check
  // the second one if it determines that the first one can not be used.
  //
  // DRA does not yet implement scoring, so the scheduler will
  // select the first set of devices that satisfies all the
  // requests in the claim. And if the requirements can
  // be satisfied on more than one node, other scheduling features
  // will determine which node is chosen. This means that the set of
  // devices allocated to a claim might not be the optimal set
  // available to the cluster. Scoring will be implemented later.
  //
  // +optional
  // +oneOf=deviceRequestType
  // +listType=atomic
  // +featureGate=DRAPrioritizedList
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:unique=map
  // +k8s:alpha(since: "1.36")=+k8s:listMapKey=name
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=8
  repeated DeviceSubRequest firstAvailable = 3;
}

// DeviceRequestAllocationResult contains the allocation result for one request.
message DeviceRequestAllocationResult {
  // Request is the name of the request in the claim which caused this
  // device to be allocated. If it references a subrequest in the
  // firstAvailable list on a DeviceRequest, this field must
  // include both the name of the main request and the subrequest
  // using the format <main request>/<subrequest>.
  //
  // Multiple devices may have been allocated per request.
  //
  // +required
  optional string request = 1;

  // Driver specifies the name of the DRA driver whose kubelet
  // plugin should be invoked to process the allocation once the claim is
  // needed on a node.
  //
  // Must be a DNS subdomain and should end with a DNS domain owned by the
  // vendor of the driver. It should use only lower case characters.
  //
  // +required
  // +k8s:alpha(since: "1.36")=+k8s:format=k8s-long-name-caseless
  // +k8s:alpha(since: "1.36")=+k8s:required
  // +k8s:alpha(since: "1.36")=+k8s:maxLength=63
  optional string driver = 2;

  // This name together with the driver name and the device name field
  // identify which device was allocated (`<driver name>/<pool name>/<device name>`).
  //
  // Must not be longer than 253 characters and may contain one or more
  // DNS sub-domains separated by slashes.
  //
  // +required
  // +k8s:alpha(since: "1.36")=+k8s:required
  // +k8s:alpha(since: "1.36")=+k8s:format=k8s-resource-pool-name
  optional string pool = 3;

  // Device references one device instance via its name in the driver's
  // resource pool. It must be a DNS label.
  //
  // +required
  optional string device = 4;

  // AdminAccess indicates that this device was allocated for
  // administrative access. See the corresponding request field
  // for a definition of mode.
  //
  // Admin access is disabled if this field is unset or
  // set to false, otherwise it is enabled.
  //
  // +optional
  // +featureGate=DRAAdminAccess
  optional bool adminAccess = 5;

  // A copy of all tolerations specified in the request at the time
  // when the device got allocated.
  //
  // The maximum number of tolerations is 16.
  //
  // This is a beta field and requires enabling the DRADeviceTaints
  // feature gate.
  //
  // +optional
  // +listType=atomic
  // +featureGate=DRADeviceTaints
  // +k8s:alpha(since: "1.36")=+k8s:optional
  repeated DeviceToleration tolerations = 6;

  // BindingConditions contains a copy of the BindingConditions
  // from the corresponding ResourceSlice at the time of allocation.
  //
  // This is a beta field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
  // feature gates.
  //
  // +optional
  // +listType=atomic
  // +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=4
  repeated string bindingConditions = 7;

  // BindingFailureConditions contains a copy of the BindingFailureConditions
  // from the corresponding ResourceSlice at the time of allocation.
  //
  // This is a beta field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
  // feature gates.
  //
  // +optional
  // +listType=atomic
  // +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=4
  repeated string bindingFailureConditions = 8;

  // ShareID uniquely identifies an individual allocation share of the device,
  // used when the device supports multiple simultaneous allocations.
  // It serves as an additional map key to differentiate concurrent shares
  // of the same device.
  //
  // +optional
  // +featureGate=DRAConsumableCapacity
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:format=k8s-uuid
  optional string shareID = 9;

  // ConsumedCapacity tracks the amount of capacity consumed per device as part of the claim request.
  // The consumed amount may differ from the requested amount: it is rounded up to the nearest valid
  // value based on the device’s requestPolicy if applicable (i.e., may not be less than the requested amount).
  //
  // The total consumed capacity for each device must not exceed the DeviceCapacity's Value.
  //
  // This field is populated only for devices that allow multiple allocations.
  // All capacity entries are included, even if the consumed amount is zero.
  //
  // +optional
  // +featureGate=DRAConsumableCapacity
  map<string, .k8s.io.apimachinery.pkg.api.resource.Quantity> consumedCapacity = 10;
}

// DeviceSelector must have exactly one field set.
message DeviceSelector {
  // CEL contains a CEL expression for selecting a device.
  //
  // +optional
  // +oneOf=SelectorType
  optional CELDeviceSelector cel = 1;
}

// DeviceSubRequest describes a request for device provided in the
// claim.spec.devices.requests[].firstAvailable array. Each
// is typically a request for a single resource like a device, but can
// also ask for several identical devices.
//
// DeviceSubRequest is similar to ExactDeviceRequest, but doesn't expose the
// AdminAccess field as that one is only supported when requesting a
// specific device.
message DeviceSubRequest {
  // Name can be used to reference this subrequest in the list of constraints
  // or the list of configurations for the claim. References must use the
  // format <main request>/<subrequest>.
  //
  // Must be a DNS label.
  //
  // +required
  optional string name = 1;

  // DeviceClassName references a specific DeviceClass, which can define
  // additional configuration and selectors to be inherited by this
  // subrequest.
  //
  // A class is required. Which classes are available depends on the cluster.
  //
  // Administrators may use this to restrict which devices may get
  // requested by only installing classes with selectors for permitted
  // devices. If users are free to request anything without restrictions,
  // then administrators can create an empty DeviceClass for users
  // to reference.
  //
  // +required
  // +k8s:alpha(since: "1.36")=+k8s:required
  // +k8s:alpha(since: "1.36")=+k8s:format=k8s-long-name
  optional string deviceClassName = 2;

  // Selectors define criteria which must be satisfied by a specific
  // device in order for that device to be considered for this
  // subrequest. All selectors must be satisfied for a device to be
  // considered.
  //
  // +optional
  // +listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=32
  repeated DeviceSelector selectors = 3;

  // AllocationMode and its related fields define how devices are allocated
  // to satisfy this subrequest. Supported values are:
  //
  // - ExactCount: This request is for a specific number of devices.
  //   This is the default. The exact number is provided in the
  //   count field.
  //
  // - All: This subrequest is for all of the matching devices in a pool.
  //   Allocation will fail if some devices are already allocated,
  //   unless adminAccess is requested.
  //
  // If AllocationMode is not specified, the default mode is ExactCount. If
  // the mode is ExactCount and count is not specified, the default count is
  // one. Any other subrequests must specify this field.
  //
  // More modes may get added in the future. Clients must refuse to handle
  // requests with unknown modes.
  //
  // +optional
  // +k8s:alpha(since: "1.36")=+k8s:optional
  optional string allocationMode = 4;

  // Count is used only when the count mode is "ExactCount". Must be greater than zero.
  // If AllocationMode is ExactCount and this field is not specified, the default is one.
  //
  // +optional
  // +oneOf=AllocationMode
  optional int64 count = 5;

  // If specified, the request's tolerations.
  //
  // Tolerations for NoSchedule are required to allocate a
  // device which has a taint with that effect. The same applies
  // to NoExecute.
  //
  // In addition, should any of the allocated devices get tainted
  // with NoExecute after allocation and that effect is not tolerated,
  // then all pods consuming the ResourceClaim get deleted to evict
  // them. The scheduler will not let new pods reserve the claim while
  // it has these tainted devices. Once all pods are evicted, the
  // claim will get deallocated.
  //
  // The maximum number of tolerations is 16.
  //
  // This is a beta field and requires enabling the DRADeviceTaints
  // feature gate.
  //
  // +optional
  // +listType=atomic
  // +featureGate=DRADeviceTaints
  // +k8s:alpha(since: "1.36")=+k8s:optional
  repeated DeviceToleration tolerations = 6;

  // Capacity define resource requirements against each capacity.
  //
  // If this field is unset and the device supports multiple allocations,
  // the default value will be applied to each capacity according to requestPolicy.
  // For the capacity that has no requestPolicy, default is the full capacity value.
  //
  // Applies to each device allocation.
  // If Count > 1,
  // the request fails if there aren't enough devices that meet the requirements.
  // If AllocationMode is set to All,
  // the request fails if there are devices that otherwise match the request,
  // and have this capacity, with a value >= the requested amount, but which cannot be allocated to this request.
  //
  // +optional
  // +featureGate=DRAConsumableCapacity
  optional CapacityRequirements capacity = 7;
}

// The device this taint is attached to has the "effect" on
// any claim which does not tolerate the taint and, through the claim,
// to pods using the claim.
//
// +protobuf.options.(gogoproto.goproto_stringer)=false
message DeviceTaint {
  // The taint key to be applied to a device.
  // Must be a label name.
  //
  // +required
  optional string key = 1;

  // The taint value corresponding to the taint key.
  // Must be a label value.
  //
  // +optional
  optional string value = 2;

  // The effect of the taint on claims that do not tolerate the taint
  // and through such claims on the pods using them.
  //
  // Valid effects are None, NoSchedule and NoExecute. PreferNoSchedule as used for
  // nodes is not valid here. More effects may get added in the future.
  // Consumers must treat unknown effects like None.
  //
  // +required
  // +k8s:alpha(since: "1.36")=+k8s:required
  optional string effect = 3;

  // TimeAdded represents the time at which the taint was added or
  // (only in a DeviceTaintRule) the effect was modified.
  // Added automatically during create or update if not set.
  //
  // In addition, in a DeviceTaintRule a value provided during
  // an update gets replaced with the current time if the provided
  // value is the same as the old one and the new effect is different.
  // Changing the key and/or value while keeping the effect unchanged
  // is possible and does not update the time stamp because the eviction
  // which uses it is either already started (NoExecute) or
  // not started yet (NoEffect, NoSchedule).
  //
  // +optional
  optional .k8s.io.apimachinery.pkg.apis.meta.v1.Time timeAdded = 4;
}

// The ResourceClaim this DeviceToleration is attached to tolerates any taint that matches
// the triple <key,value,effect> using the matching operator <operator>.
message DeviceToleration {
  // Key is the taint key that the toleration applies to. Empty means match all taint keys.
  // If the key is empty, operator must be Exists; this combination means to match all values and all keys.
  // Must be a label name.
  //
  // +optional
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:format=k8s-label-key
  optional string key = 1;

  // Operator represents a key's relationship to the value.
  // Valid operators are Exists and Equal. Defaults to Equal.
  // Exists is equivalent to wildcard for value, so that a ResourceClaim can
  // tolerate all taints of a particular category.
  //
  // +optional
  // +default="Equal"
  // +k8s:alpha(since: "1.36")=+k8s:optional
  optional string operator = 2;

  // Value is the taint value the toleration matches to.
  // If the operator is Exists, the value must be empty, otherwise just a regular string.
  // Must be a label value.
  //
  // +optional
  optional string value = 3;

  // Effect indicates the taint effect to match. Empty means match all taint effects.
  // When specified, allowed values are NoSchedule and NoExecute.
  //
  // +optional
  // +k8s:alpha(since: "1.36")=+k8s:optional
  optional string effect = 4;

  // TolerationSeconds represents the period of time the toleration (which must be
  // of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default,
  // it is not set, which means tolerate the taint forever (do not evict). Zero and
  // negative values will be treated as 0 (evict immediately) by the system.
  // If larger than zero, the time when the pod needs to be evicted is calculated as <time when
  // taint was adedd> + <toleration seconds>.
  //
  // +optional
  optional int64 tolerationSeconds = 5;
}

// ExactDeviceRequest is a request for one or more identical devices.
message ExactDeviceRequest {
  // DeviceClassName references a specific DeviceClass, which can define
  // additional configuration and selectors to be inherited by this
  // request.
  //
  // A DeviceClassName is required.
  //
  // Administrators may use this to restrict which devices may get
  // requested by only installing classes with selectors for permitted
  // devices. If users are free to request anything without restrictions,
  // then administrators can create an empty DeviceClass for users
  // to reference.
  //
  // +required
  optional string deviceClassName = 1;

  // Selectors define criteria which must be satisfied by a specific
  // device in order for that device to be considered for this
  // request. All selectors must be satisfied for a device to be
  // considered.
  //
  // +optional
  // +listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=32
  repeated DeviceSelector selectors = 2;

  // AllocationMode and its related fields define how devices are allocated
  // to satisfy this request. Supported values are:
  //
  // - ExactCount: This request is for a specific number of devices.
  //   This is the default. The exact number is provided in the
  //   count field.
  //
  // - All: This request is for all of the matching devices in a pool.
  //   At least one device must exist on the node for the allocation to succeed.
  //   Allocation will fail if some devices are already allocated,
  //   unless adminAccess is requested.
  //
  // If AllocationMode is not specified, the default mode is ExactCount. If
  // the mode is ExactCount and count is not specified, the default count is
  // one. Any other requests must specify this field.
  //
  // More modes may get added in the future. Clients must refuse to handle
  // requests with unknown modes.
  //
  // +optional
  // +k8s:alpha(since: "1.36")=+k8s:optional
  optional string allocationMode = 3;

  // Count is used only when the count mode is "ExactCount". Must be greater than zero.
  // If AllocationMode is ExactCount and this field is not specified, the default is one.
  //
  // +optional
  // +oneOf=AllocationMode
  optional int64 count = 4;

  // AdminAccess indicates that this is a claim for administrative access
  // to the device(s). Claims with AdminAccess are expected to be used for
  // monitoring or other management services for a device.  They ignore
  // all ordinary claims to the device with respect to access modes and
  // any resource allocations.
  //
  // Admin access is disabled if this field is unset or
  // set to false, otherwise it is enabled.
  //
  // +optional
  // +featureGate=DRAAdminAccess
  optional bool adminAccess = 5;

  // If specified, the request's tolerations.
  //
  // Tolerations for NoSchedule are required to allocate a
  // device which has a taint with that effect. The same applies
  // to NoExecute.
  //
  // In addition, should any of the allocated devices get tainted
  // with NoExecute after allocation and that effect is not tolerated,
  // then all pods consuming the ResourceClaim get deleted to evict
  // them. The scheduler will not let new pods reserve the claim while
  // it has these tainted devices. Once all pods are evicted, the
  // claim will get deallocated.
  //
  // The maximum number of tolerations is 16.
  //
  // This is a beta field and requires enabling the DRADeviceTaints
  // feature gate.
  //
  // +optional
  // +listType=atomic
  // +featureGate=DRADeviceTaints
  // +k8s:alpha(since: "1.36")=+k8s:optional
  repeated DeviceToleration tolerations = 6;

  // Capacity define resource requirements against each capacity.
  //
  // If this field is unset and the device supports multiple allocations,
  // the default value will be applied to each capacity according to requestPolicy.
  // For the capacity that has no requestPolicy, default is the full capacity value.
  //
  // Applies to each device allocation.
  // If Count > 1,
  // the request fails if there aren't enough devices that meet the requirements.
  // If AllocationMode is set to All,
  // the request fails if there are devices that otherwise match the request,
  // and have this capacity, with a value >= the requested amount, but which cannot be allocated to this request.
  //
  // +optional
  // +featureGate=DRAConsumableCapacity
  optional CapacityRequirements capacity = 7;
}

// NetworkDeviceData provides network-related details for the allocated device.
// This information may be filled by drivers or other components to configure
// or identify the device within a network context.
message NetworkDeviceData {
  // InterfaceName specifies the name of the network interface associated with
  // the allocated device. This might be the name of a physical or virtual
  // network interface being configured in the pod.
  //
  // Must not be longer than 256 bytes.
  //
  // +optional
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:maxBytes=256
  optional string interfaceName = 1;

  // IPs lists the network addresses assigned to the device's network interface.
  // This can include both IPv4 and IPv6 addresses.
  // The IPs are in the CIDR notation, which includes both the address and the
  // associated subnet mask.
  // e.g.: "192.0.2.5/24" for IPv4 and "2001:db8::5/64" for IPv6.
  //
  // +optional
  // +listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:unique=set
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=16
  repeated string ips = 2;

  // HardwareAddress represents the hardware address (e.g. MAC Address) of the device's network interface.
  //
  // Must not be longer than 128 bytes.
  //
  // +optional
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:maxBytes=128
  optional string hardwareAddress = 3;
}

// NodeAllocatableResourceMapping defines the translation between the DRA device/capacity
// units requested to the corresponding quantity of the node allocatable resource.
message NodeAllocatableResourceMapping {
  // CapacityKey references a capacity name defined as a key in the
  // `spec.devices[*].capacity` map. When this field is set, the value associated with
  // this key in the `status.allocation.devices.results[*].consumedCapacity` map
  // (for a specific claim allocation) determines the base quantity for
  // the node allocatable resource. If `allocationMultiplier` is also set, it is
  // multiplied with the base quantity.
  // For example, if `spec.devices[*].capacity` has an entry "dra.example.com/memory": "128Gi",
  // and this field is set to "dra.example.com/memory", then for a claim allocation
  // that consumes { "dra.example.com/memory": "4Gi" } the base quantity for the
  // node allocatable resource mapping will be "4Gi", and `allocationMultiplier` should
  // be omitted or set to "1".
  // +optional
  optional string capacityKey = 1;

  // AllocationMultiplier is used as a multiplier for the allocated device count or the allocated capacity in the claim.
  // It defaults to 1 if not specified. How the field is used also depends on whether `capacityKey` is set.
  // 1.  If `capacityKey` is NOT set: `allocationMultiplier` multiplies the device count allocated to the claim.
  // 	   a. A DRA driver representing each CPU core as a device would have
  //        {ResourceName: "cpu", allocationMultiplier: "2"} in its
  //        `nodeAllocatableResourceMappings`. If 4 devices are allocated to the claim,
  // 		  4 * 2 CPUs would be considered as allocated and subtracted from the node's capacity.
  //     b. A GPU device that needs additional node memory per GPU allocation would
  //        have {ResourceName: "memory", allocationMultiplier: "2Gi"}.  Each allocated
  // 		  GPU device instance of this type will account for 2Gi of memory.
  //
  // 2.  If `capacityKey` IS set: `allocationMultiplier` is multiplied by the amount of that capacity consumed.
  // 	   The final node allocatable resource amount is `consumedCapacity[capacityKey]` * `allocationMultiplier`.
  //     For example, if a Device's capacity "dra.example.com/cores" is consumed,
  //     and each "core" provides 2 "cpu"s, the mapping would be:
  //     {ResourceName: "cpu", capacityKey: "dra.example.com/cores", allocationMultiplier: "2"}.
  //     If a claim consumes 8 "dra.example.com/cores", the CPU footprint is 8 * 2 = 16.
  // +optional
  optional .k8s.io.apimachinery.pkg.api.resource.Quantity allocationMultiplier = 2;
}

// OpaqueDeviceConfiguration contains configuration parameters for a driver
// in a format defined by the driver vendor.
message OpaqueDeviceConfiguration {
  // Driver is used to determine which kubelet plugin needs
  // to be passed these configuration parameters.
  //
  // An admission policy provided by the driver developer could use this
  // to decide whether it needs to validate them.
  //
  // Must be a DNS subdomain and should end with a DNS domain owned by the
  // vendor of the driver. It should use only lower case characters.
  //
  // +required
  // +k8s:alpha(since: "1.36")=+k8s:required
  // +k8s:alpha(since: "1.36")=+k8s:format=k8s-long-name-caseless
  // +k8s:alpha(since: "1.36")=+k8s:maxLength=63
  optional string driver = 1;

  // Parameters can contain arbitrary data. It is the responsibility of
  // the driver developer to handle validation and versioning. Typically this
  // includes self-identification and a version ("kind" + "apiVersion" for
  // Kubernetes types), with conversion between different versions.
  //
  // The length of the raw data must be smaller or equal to 10 Ki.
  //
  // +required
  optional .k8s.io.apimachinery.pkg.runtime.RawExtension parameters = 2;
}

// ResourceClaim describes a request for access to resources in the cluster,
// for use by workloads. For example, if a workload needs an accelerator device
// with specific properties, this is how that request is expressed. The status
// stanza tracks whether this claim has been satisfied and what specific
// resources have been allocated.
message ResourceClaim {
  // Standard object metadata
  // +optional
  optional .k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;

  // Spec describes what is being requested and how to configure it.
  // The spec is immutable.
  // +k8s:alpha(since: "1.36")=+k8s:immutable
  optional ResourceClaimSpec spec = 2;

  // Status describes whether the claim is ready to use and what has been allocated.
  // +optional
  optional ResourceClaimStatus status = 3;
}

// ResourceClaimConsumerReference contains enough information to let you
// locate the consumer of a ResourceClaim. The user must be a resource in the same
// namespace as the ResourceClaim.
message ResourceClaimConsumerReference {
  // APIGroup is the group for the resource being referenced. It is
  // empty for the core API. This matches the group in the APIVersion
  // that is used when creating the resources.
  // +optional
  optional string apiGroup = 1;

  // Resource is the type of resource being referenced, for example "pods".
  // +required
  optional string resource = 3;

  // Name is the name of resource being referenced.
  // +required
  optional string name = 4;

  // UID identifies exactly one incarnation of the resource.
  // +required
  optional string uid = 5;
}

// ResourceClaimList is a collection of claims.
message ResourceClaimList {
  // Standard list metadata
  // +optional
  optional .k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;

  // Items is the list of resource claims.
  repeated ResourceClaim items = 2;
}

// ResourceClaimSpec defines what is being requested in a ResourceClaim and how to configure it.
message ResourceClaimSpec {
  // Devices defines how to request devices.
  //
  // +optional
  optional DeviceClaim devices = 1;
}

// ResourceClaimStatus tracks whether the resource has been allocated and what
// the result of that was.
message ResourceClaimStatus {
  // Allocation is set once the claim has been allocated successfully.
  //
  // +optional
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:update=NoModify
  optional AllocationResult allocation = 1;

  // ReservedFor indicates which entities are currently allowed to use
  // the claim. A Pod which references a ResourceClaim which is not
  // reserved for that Pod will not be started. A claim that is in
  // use or might be in use because it has been reserved must not get
  // deallocated.
  //
  // In a cluster with multiple scheduler instances, two pods might get
  // scheduled concurrently by different schedulers. When they reference
  // the same ResourceClaim which already has reached its maximum number
  // of consumers, only one pod can be scheduled.
  //
  // Both schedulers try to add their pod to the claim.status.reservedFor
  // field, but only the update that reaches the API server first gets
  // stored. The other one fails with an error and the scheduler
  // which issued it knows that it must put the pod back into the queue,
  // waiting for the ResourceClaim to become usable again.
  //
  // There can be at most 256 such reservations. This may get increased in
  // the future, but not reduced.
  //
  // +optional
  // +listType=map
  // +listMapKey=uid
  // +patchStrategy=merge
  // +patchMergeKey=uid
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +k8s:alpha(since: "1.36")=+k8s:listType=map
  // +k8s:alpha(since: "1.36")=+k8s:listMapKey=uid
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=256
  repeated ResourceClaimConsumerReference reservedFor = 2;

  // Devices contains the status of each device allocated for this
  // claim, as reported by the driver. This can include driver-specific
  // information. Entries are owned by their respective drivers.
  //
  // +optional
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +listType=map
  // +listMapKey=driver
  // +listMapKey=device
  // +listMapKey=pool
  // +listMapKey=shareID
  // +featureGate=DRAResourceClaimDeviceStatus
  // +k8s:alpha(since: "1.36")=+k8s:listType=map
  // +k8s:alpha(since: "1.36")=+k8s:listMapKey=driver
  // +k8s:alpha(since: "1.36")=+k8s:listMapKey=device
  // +k8s:alpha(since: "1.36")=+k8s:listMapKey=pool
  // +k8s:alpha(since: "1.36")=+k8s:listMapKey=shareID
  repeated AllocatedDeviceStatus devices = 4;
}

// ResourceClaimTemplate is used to produce ResourceClaim objects.
message ResourceClaimTemplate {
  // Standard object metadata
  // +optional
  optional .k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;

  // Describes the ResourceClaim that is to be generated.
  //
  // This field is immutable. A ResourceClaim will get created by the
  // control plane for a Pod when needed and then not get updated
  // anymore.
  optional ResourceClaimTemplateSpec spec = 2;
}

// ResourceClaimTemplateList is a collection of claim templates.
message ResourceClaimTemplateList {
  // Standard list metadata
  // +optional
  optional .k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;

  // Items is the list of resource claim templates.
  repeated ResourceClaimTemplate items = 2;
}

// ResourceClaimTemplateSpec contains the metadata and fields for a ResourceClaim.
message ResourceClaimTemplateSpec {
  // ObjectMeta may contain labels and annotations that will be copied into the ResourceClaim
  // when creating it. No other fields are allowed and will be rejected during
  // validation.
  // +optional
  optional .k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;

  // Spec for the ResourceClaim. The entire content is copied unchanged
  // into the ResourceClaim that gets created from this template. The
  // same fields as in a ResourceClaim are also valid here.
  optional ResourceClaimSpec spec = 2;
}

// ResourcePool describes the pool that ResourceSlices belong to.
message ResourcePool {
  // Name is used to identify the pool. For node-local devices, this
  // is often the node name, but this is not required.
  //
  // It must not be longer than 253 characters and must consist of one or more DNS sub-domains
  // separated by slashes. This field is immutable.
  //
  // +required
  optional string name = 1;

  // Generation tracks the change in a pool over time. Whenever a driver
  // changes something about one or more of the resources in a pool, it
  // must change the generation in all ResourceSlices which are part of
  // that pool. Consumers of ResourceSlices should only consider
  // resources from the pool with the highest generation number. The
  // generation may be reset by drivers, which should be fine for
  // consumers, assuming that all ResourceSlices in a pool are updated to
  // match or deleted.
  //
  // Combined with ResourceSliceCount, this mechanism enables consumers to
  // detect pools which are comprised of multiple ResourceSlices and are
  // in an incomplete state.
  //
  // +required
  optional int64 generation = 2;

  // ResourceSliceCount is the total number of ResourceSlices in the pool at this
  // generation number. Must be greater than zero.
  //
  // Consumers can use this to check whether they have seen all ResourceSlices
  // belonging to the same pool.
  //
  // +required
  optional int64 resourceSliceCount = 3;
}

// ResourceSlice represents one or more resources in a pool of similar resources,
// managed by a common driver. A pool may span more than one ResourceSlice, and exactly how many
// ResourceSlices comprise a pool is determined by the driver.
//
// At the moment, the only supported resources are devices with attributes and capacities.
// Each device in a given pool, regardless of how many ResourceSlices, must have a unique name.
// The ResourceSlice in which a device gets published may change over time. The unique identifier
// for a device is the tuple <driver name>, <pool name>, <device name>.
//
// Whenever a driver needs to update a pool, it increments the pool.Spec.Pool.Generation number
// and updates all ResourceSlices with that new number and new resource definitions. A consumer
// must only use ResourceSlices with the highest generation number and ignore all others.
//
// When allocating all resources in a pool matching certain criteria or when
// looking for the best solution among several different alternatives, a
// consumer should check the number of ResourceSlices in a pool (included in
// each ResourceSlice) to determine whether its view of a pool is complete and
// if not, should wait until the driver has completed updating the pool.
//
// For resources that are not local to a node, the node name is not set. Instead,
// the driver may use a node selector to specify where the devices are available.
message ResourceSlice {
  // Standard object metadata
  // +optional
  optional .k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;

  // Contains the information published by the driver.
  //
  // Changing the spec automatically increments the metadata.generation number.
  // +required
  optional ResourceSliceSpec spec = 2;
}

// ResourceSliceList is a collection of ResourceSlices.
message ResourceSliceList {
  // Standard list metadata
  // +optional
  optional .k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;

  // Items is the list of resource ResourceSlices.
  repeated ResourceSlice items = 2;
}

// ResourceSliceSpec contains the information published by the driver in one ResourceSlice.
message ResourceSliceSpec {
  // Driver identifies the DRA driver providing the capacity information.
  // A field selector can be used to list only ResourceSlice
  // objects with a certain driver name.
  //
  // Must be a DNS subdomain and should end with a DNS domain owned by the
  // vendor of the driver. It should use only lower case characters.
  // This field is immutable.
  //
  // +required
  optional string driver = 1;

  // Pool describes the pool that this ResourceSlice belongs to.
  //
  // +required
  optional ResourcePool pool = 2;

  // NodeName identifies the node which provides the resources in this pool.
  // A field selector can be used to list only ResourceSlice
  // objects belonging to a certain node.
  //
  // This field can be used to limit access from nodes to ResourceSlices with
  // the same node name. It also indicates to autoscalers that adding
  // new nodes of the same type as some old node might also make new
  // resources available.
  //
  // Exactly one of NodeName, NodeSelector, AllNodes, and PerDeviceNodeSelection must be set.
  // This field is immutable.
  //
  // +optional
  // +oneOf=NodeSelection
  optional string nodeName = 3;

  // NodeSelector defines which nodes have access to the resources in the pool,
  // when that pool is not limited to a single node.
  //
  // Must use exactly one term.
  //
  // Exactly one of NodeName, NodeSelector, AllNodes, and PerDeviceNodeSelection must be set.
  //
  // +optional
  // +oneOf=NodeSelection
  optional .k8s.io.api.core.v1.NodeSelector nodeSelector = 4;

  // AllNodes indicates that all nodes have access to the resources in the pool.
  //
  // Exactly one of NodeName, NodeSelector, AllNodes, and PerDeviceNodeSelection must be set.
  //
  // +optional
  // +oneOf=NodeSelection
  optional bool allNodes = 5;

  // Devices lists some or all of the devices in this pool.
  //
  // Must not have more than 128 entries. If any device uses taints or consumes counters the limit is 64.
  //
  // Only one of Devices and SharedCounters can be set in a ResourceSlice.
  //
  // +optional
  // +listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +zeroOrOneOf=ResourceSliceType
  repeated Device devices = 6;

  // PerDeviceNodeSelection defines whether the access from nodes to
  // resources in the pool is set on the ResourceSlice level or on each
  // device. If it is set to true, every device defined the ResourceSlice
  // must specify this individually.
  //
  // Exactly one of NodeName, NodeSelector, AllNodes, and PerDeviceNodeSelection must be set.
  //
  // +optional
  // +oneOf=NodeSelection
  // +featureGate=DRAPartitionableDevices
  optional bool perDeviceNodeSelection = 7;

  // SharedCounters defines a list of counter sets, each of which
  // has a name and a list of counters available.
  //
  // The names of the counter sets must be unique in the ResourcePool.
  //
  // Only one of Devices and SharedCounters can be set in a ResourceSlice.
  //
  // The maximum number of counter sets is 8.
  //
  // +optional
  // +k8s:alpha(since: "1.36")=+k8s:optional
  // +listType=atomic
  // +k8s:listType=atomic
  // +k8s:alpha(since: "1.36")=+k8s:unique=map
  // +k8s:alpha(since: "1.36")=+k8s:listMapKey=name
  // +featureGate=DRAPartitionableDevices
  // +zeroOrOneOf=ResourceSliceType
  // +k8s:alpha(since: "1.36")=+k8s:maxItems=8
  repeated CounterSet sharedCounters = 8;
}

