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

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/v1alpha2";

// AllocationResult contains attributes of an allocated resource.
message AllocationResult {
  // ResourceHandles contain the state associated with an allocation that
  // should be maintained throughout the lifetime of a claim. Each
  // ResourceHandle contains data that should be passed to a specific kubelet
  // plugin once it lands on a node. This data is returned by the driver
  // after a successful allocation and is opaque to Kubernetes. Driver
  // documentation may explain to users how to interpret this data if needed.
  //
  // Setting this field is optional. It has a maximum size of 32 entries.
  // If null (or empty), it is assumed this allocation will be processed by a
  // single kubelet plugin with no ResourceHandle data attached. The name of
  // the kubelet plugin invoked will match the DriverName set in the
  // ResourceClaimStatus this AllocationResult is embedded in.
  //
  // +listType=atomic
  // +optional
  repeated ResourceHandle resourceHandles = 1;

  // This field will get set by the resource driver after it has allocated
  // the resource to inform the scheduler where it can schedule Pods using
  // the ResourceClaim.
  //
  // Setting this field is optional. If null, the resource is available
  // everywhere.
  // +optional
  optional k8s.io.api.core.v1.NodeSelector availableOnNodes = 2;

  // Shareable determines whether the resource supports more
  // than one consumer at a time.
  // +optional
  optional bool shareable = 3;
}

// AllocationResultModel must have one and only one field set.
message AllocationResultModel {
  // NamedResources describes the allocation result when using the named resources model.
  //
  // +optional
  optional NamedResourcesAllocationResult namedResources = 1;
}

// DriverAllocationResult contains vendor parameters and the allocation result for
// one request.
message DriverAllocationResult {
  // VendorRequestParameters are the per-request configuration parameters
  // from the time that the claim was allocated.
  //
  // +optional
  optional k8s.io.apimachinery.pkg.runtime.RawExtension vendorRequestParameters = 1;

  optional AllocationResultModel allocationResultModel = 2;
}

// DriverRequests describes all resources that are needed from one particular driver.
message DriverRequests {
  // DriverName is the name used by the DRA driver kubelet plugin.
  optional string driverName = 1;

  // VendorParameters are arbitrary setup parameters for all requests of the
  // claim. They are ignored while allocating the claim.
  //
  // +optional
  optional k8s.io.apimachinery.pkg.runtime.RawExtension vendorParameters = 2;

  // Requests describes all resources that are needed from the driver.
  // +listType=atomic
  repeated ResourceRequest requests = 3;
}

// NamedResourcesAllocationResult is used in AllocationResultModel.
message NamedResourcesAllocationResult {
  // Name is the name of the selected resource instance.
  optional string name = 1;
}

// NamedResourcesAttribute is a combination of an attribute name and its value.
message NamedResourcesAttribute {
  // Name is unique identifier among all resource instances managed by
  // the driver on the node. It must be a DNS subdomain.
  optional string name = 1;

  optional NamedResourcesAttributeValue attributeValue = 2;
}

// NamedResourcesAttributeValue must have one and only one field set.
message NamedResourcesAttributeValue {
  // QuantityValue is a quantity.
  optional k8s.io.apimachinery.pkg.api.resource.Quantity quantity = 6;

  // BoolValue is a true/false value.
  optional bool bool = 2;

  // IntValue is a 64-bit integer.
  optional int64 int = 7;

  // IntSliceValue is an array of 64-bit integers.
  optional NamedResourcesIntSlice intSlice = 8;

  // StringValue is a string.
  optional string string = 5;

  // StringSliceValue is an array of strings.
  optional NamedResourcesStringSlice stringSlice = 9;

  // VersionValue is a semantic version according to semver.org spec 2.0.0.
  optional string version = 10;
}

// NamedResourcesFilter is used in ResourceFilterModel.
message NamedResourcesFilter {
  // Selector is a CEL expression which must evaluate to true if a
  // resource instance is suitable. The language is as defined in
  // https://kubernetes.io/docs/reference/using-api/cel/
  //
  // In addition, for each type NamedResourcesin AttributeValue there is a map that
  // resolves to the corresponding value of the instance under evaluation.
  // For example:
  //
  //    attributes.quantity["a"].isGreaterThan(quantity("0")) &&
  //    attributes.stringslice["b"].isSorted()
  optional string selector = 1;
}

// NamedResourcesInstance represents one individual hardware instance that can be selected based
// on its attributes.
message NamedResourcesInstance {
  // Name is unique identifier among all resource instances managed by
  // the driver on the node. It must be a DNS subdomain.
  optional string name = 1;

  // Attributes defines the attributes of this resource instance.
  // The name of each attribute must be unique.
  //
  // +listType=atomic
  // +optional
  repeated NamedResourcesAttribute attributes = 2;
}

// NamedResourcesIntSlice contains a slice of 64-bit integers.
message NamedResourcesIntSlice {
  // Ints is the slice of 64-bit integers.
  //
  // +listType=atomic
  repeated int64 ints = 1;
}

// NamedResourcesRequest is used in ResourceRequestModel.
message NamedResourcesRequest {
  // Selector is a CEL expression which must evaluate to true if a
  // resource instance is suitable. The language is as defined in
  // https://kubernetes.io/docs/reference/using-api/cel/
  //
  // In addition, for each type NamedResourcesin AttributeValue there is a map that
  // resolves to the corresponding value of the instance under evaluation.
  // For example:
  //
  //    attributes.quantity["a"].isGreaterThan(quantity("0")) &&
  //    attributes.stringslice["b"].isSorted()
  optional string selector = 1;
}

// NamedResourcesResources is used in ResourceModel.
message NamedResourcesResources {
  // The list of all individual resources instances currently available.
  //
  // +listType=atomic
  repeated NamedResourcesInstance instances = 1;
}

// NamedResourcesStringSlice contains a slice of strings.
message NamedResourcesStringSlice {
  // Strings is the slice of strings.
  //
  // +listType=atomic
  repeated string strings = 1;
}

// PodSchedulingContext objects hold information that is needed to schedule
// a Pod with ResourceClaims that use "WaitForFirstConsumer" allocation
// mode.
//
// This is an alpha type and requires enabling the DynamicResourceAllocation
// feature gate.
message PodSchedulingContext {
  // Standard object metadata
  // +optional
  optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;

  // Spec describes where resources for the Pod are needed.
  optional PodSchedulingContextSpec spec = 2;

  // Status describes where resources for the Pod can be allocated.
  // +optional
  optional PodSchedulingContextStatus status = 3;
}

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

  // Items is the list of PodSchedulingContext objects.
  repeated PodSchedulingContext items = 2;
}

// PodSchedulingContextSpec describes where resources for the Pod are needed.
message PodSchedulingContextSpec {
  // SelectedNode is the node for which allocation of ResourceClaims that
  // are referenced by the Pod and that use "WaitForFirstConsumer"
  // allocation is to be attempted.
  // +optional
  optional string selectedNode = 1;

  // PotentialNodes lists nodes where the Pod might be able to run.
  //
  // The size of this field is limited to 128. This is large enough for
  // many clusters. Larger clusters may need more attempts to find a node
  // that suits all pending resources. This may get increased in the
  // future, but not reduced.
  //
  // +listType=atomic
  // +optional
  repeated string potentialNodes = 2;
}

// PodSchedulingContextStatus describes where resources for the Pod can be allocated.
message PodSchedulingContextStatus {
  // ResourceClaims describes resource availability for each
  // pod.spec.resourceClaim entry where the corresponding ResourceClaim
  // uses "WaitForFirstConsumer" allocation mode.
  //
  // +listType=map
  // +listMapKey=name
  // +optional
  repeated ResourceClaimSchedulingStatus resourceClaims = 1;
}

// ResourceClaim describes which resources are needed by a resource consumer.
// Its status tracks whether the resource has been allocated and what the
// resulting attributes are.
//
// This is an alpha type and requires enabling the DynamicResourceAllocation
// feature gate.
message ResourceClaim {
  // Standard object metadata
  // +optional
  optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;

  // Spec describes the desired attributes of a resource that then needs
  // to be allocated. It can only be set once when creating the
  // ResourceClaim.
  optional ResourceClaimSpec spec = 2;

  // Status describes whether the resource is available and with which
  // attributes.
  // +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".
  optional string resource = 3;

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

  // UID identifies exactly one incarnation of the resource.
  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;
}

// ResourceClaimParameters defines resource requests for a ResourceClaim in an
// in-tree format understood by Kubernetes.
message ResourceClaimParameters {
  // Standard object metadata
  optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;

  // If this object was created from some other resource, then this links
  // back to that resource. This field is used to find the in-tree representation
  // of the claim parameters when the parameter reference of the claim refers
  // to some unknown type.
  // +optional
  optional ResourceClaimParametersReference generatedFrom = 2;

  // Shareable indicates whether the allocated claim is meant to be shareable
  // by multiple consumers at the same time.
  // +optional
  optional bool shareable = 3;

  // DriverRequests describes all resources that are needed for the
  // allocated claim. A single claim may use resources coming from
  // different drivers. For each driver, this array has at most one
  // entry which then may have one or more per-driver requests.
  //
  // May be empty, in which case the claim can always be allocated.
  //
  // +listType=atomic
  repeated DriverRequests driverRequests = 4;
}

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

  // Items is the list of node resource capacity objects.
  repeated ResourceClaimParameters items = 2;
}

// ResourceClaimParametersReference contains enough information to let you
// locate the parameters for a ResourceClaim. The object must be in the same
// namespace as the ResourceClaim.
message ResourceClaimParametersReference {
  // 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;

  // Kind is the type of resource being referenced. This is the same
  // value as in the parameter object's metadata, for example "ConfigMap".
  optional string kind = 2;

  // Name is the name of resource being referenced.
  optional string name = 3;
}

// ResourceClaimSchedulingStatus contains information about one particular
// ResourceClaim with "WaitForFirstConsumer" allocation mode.
message ResourceClaimSchedulingStatus {
  // Name matches the pod.spec.resourceClaims[*].Name field.
  // +optional
  optional string name = 1;

  // UnsuitableNodes lists nodes that the ResourceClaim cannot be
  // allocated for.
  //
  // The size of this field is limited to 128, the same as for
  // PodSchedulingSpec.PotentialNodes. This may get increased in the
  // future, but not reduced.
  //
  // +listType=atomic
  // +optional
  repeated string unsuitableNodes = 2;
}

// ResourceClaimSpec defines how a resource is to be allocated.
message ResourceClaimSpec {
  // ResourceClassName references the driver and additional parameters
  // via the name of a ResourceClass that was created as part of the
  // driver deployment.
  optional string resourceClassName = 1;

  // ParametersRef references a separate object with arbitrary parameters
  // that will be used by the driver when allocating a resource for the
  // claim.
  //
  // The object must be in the same namespace as the ResourceClaim.
  // +optional
  optional ResourceClaimParametersReference parametersRef = 2;

  // Allocation can start immediately or when a Pod wants to use the
  // resource. "WaitForFirstConsumer" is the default.
  // +optional
  optional string allocationMode = 3;
}

// ResourceClaimStatus tracks whether the resource has been allocated and what
// the resulting attributes are.
message ResourceClaimStatus {
  // DriverName is a copy of the driver name from the ResourceClass at
  // the time when allocation started.
  // +optional
  optional string driverName = 1;

  // Allocation is set by the resource driver once a resource or set of
  // resources has been allocated successfully. If this is not specified, the
  // resources have not been allocated yet.
  // +optional
  optional AllocationResult allocation = 2;

  // 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.
  //
  // There can be at most 32 such reservations. This may get increased in
  // the future, but not reduced.
  //
  // +listType=map
  // +listMapKey=uid
  // +patchStrategy=merge
  // +patchMergeKey=uid
  // +optional
  repeated ResourceClaimConsumerReference reservedFor = 3;

  // DeallocationRequested indicates that a ResourceClaim is to be
  // deallocated.
  //
  // The driver then must deallocate this claim and reset the field
  // together with clearing the Allocation field.
  //
  // While DeallocationRequested is set, no new consumers may be added to
  // ReservedFor.
  // +optional
  optional bool deallocationRequested = 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 PVC
  // 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;
}

// ResourceClass is used by administrators to influence how resources
// are allocated.
//
// This is an alpha type and requires enabling the DynamicResourceAllocation
// feature gate.
message ResourceClass {
  // Standard object metadata
  // +optional
  optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;

  // DriverName defines the name of the dynamic resource driver that is
  // used for allocation of a ResourceClaim that uses this class.
  //
  // Resource drivers have a unique name in forward domain order
  // (acme.example.com).
  optional string driverName = 2;

  // ParametersRef references an arbitrary separate object that may hold
  // parameters that will be used by the driver when allocating a
  // resource that uses this class. A dynamic resource driver can
  // distinguish between parameters stored here and and those stored in
  // ResourceClaimSpec.
  // +optional
  optional ResourceClassParametersReference parametersRef = 3;

  // Only nodes matching the selector will be considered by the scheduler
  // when trying to find a Node that fits a Pod when that Pod uses
  // a ResourceClaim that has not been allocated yet.
  //
  // Setting this field is optional. If null, all nodes are candidates.
  // +optional
  optional k8s.io.api.core.v1.NodeSelector suitableNodes = 4;

  // If and only if allocation of claims using this class is handled
  // via structured parameters, then StructuredParameters must be set to true.
  // +optional
  optional bool structuredParameters = 5;
}

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

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

// ResourceClassParameters defines resource requests for a ResourceClass in an
// in-tree format understood by Kubernetes.
message ResourceClassParameters {
  // Standard object metadata
  optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;

  // If this object was created from some other resource, then this links
  // back to that resource. This field is used to find the in-tree representation
  // of the class parameters when the parameter reference of the class refers
  // to some unknown type.
  // +optional
  optional ResourceClassParametersReference generatedFrom = 2;

  // VendorParameters are arbitrary setup parameters for all claims using
  // this class. They are ignored while allocating the claim. There must
  // not be more than one entry per driver.
  //
  // +listType=atomic
  // +optional
  repeated VendorParameters vendorParameters = 3;

  // Filters describes additional contraints that must be met when using the class.
  //
  // +listType=atomic
  repeated ResourceFilter filters = 4;
}

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

  // Items is the list of node resource capacity objects.
  repeated ResourceClassParameters items = 2;
}

// ResourceClassParametersReference contains enough information to let you
// locate the parameters for a ResourceClass.
message ResourceClassParametersReference {
  // 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;

  // Kind is the type of resource being referenced. This is the same
  // value as in the parameter object's metadata.
  optional string kind = 2;

  // Name is the name of resource being referenced.
  optional string name = 3;

  // Namespace that contains the referenced resource. Must be empty
  // for cluster-scoped resources and non-empty for namespaced
  // resources.
  // +optional
  optional string namespace = 4;
}

// ResourceFilter is a filter for resources from one particular driver.
message ResourceFilter {
  // DriverName is the name used by the DRA driver kubelet plugin.
  optional string driverName = 1;

  optional ResourceFilterModel resourceFilterModel = 2;
}

// ResourceFilterModel must have one and only one field set.
message ResourceFilterModel {
  // NamedResources describes a resource filter using the named resources model.
  //
  // +optional
  optional NamedResourcesFilter namedResources = 1;
}

// ResourceHandle holds opaque resource data for processing by a specific kubelet plugin.
message ResourceHandle {
  // DriverName specifies the name of the resource driver whose kubelet
  // plugin should be invoked to process this ResourceHandle's data once it
  // lands on a node. This may differ from the DriverName set in
  // ResourceClaimStatus this ResourceHandle is embedded in.
  optional string driverName = 1;

  // Data contains the opaque data associated with this ResourceHandle. It is
  // set by the controller component of the resource driver whose name
  // matches the DriverName set in the ResourceClaimStatus this
  // ResourceHandle is embedded in. It is set at allocation time and is
  // intended for processing by the kubelet plugin whose name matches
  // the DriverName set in this ResourceHandle.
  //
  // The maximum size of this field is 16KiB. This may get increased in the
  // future, but not reduced.
  // +optional
  optional string data = 2;

  // If StructuredData is set, then it needs to be used instead of Data.
  //
  // +optional
  optional StructuredResourceHandle structuredData = 5;
}

// ResourceModel must have one and only one field set.
message ResourceModel {
  // NamedResources describes available resources using the named resources model.
  //
  // +optional
  optional NamedResourcesResources namedResources = 1;
}

// ResourceRequest is a request for resources from one particular driver.
message ResourceRequest {
  // VendorParameters are arbitrary setup parameters for the requested
  // resource. They are ignored while allocating a claim.
  //
  // +optional
  optional k8s.io.apimachinery.pkg.runtime.RawExtension vendorParameters = 1;

  optional ResourceRequestModel resourceRequestModel = 2;
}

// ResourceRequestModel must have one and only one field set.
message ResourceRequestModel {
  // NamedResources describes a request for resources with the named resources model.
  //
  // +optional
  optional NamedResourcesRequest namedResources = 1;
}

// ResourceSlice provides information about available
// resources on individual nodes.
message ResourceSlice {
  // Standard object metadata
  // +optional
  optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;

  // NodeName identifies the node which provides the resources
  // if they are local to a node.
  //
  // A field selector can be used to list only ResourceSlice
  // objects with a certain node name.
  //
  // +optional
  optional string nodeName = 2;

  // DriverName identifies the DRA driver providing the capacity information.
  // A field selector can be used to list only ResourceSlice
  // objects with a certain driver name.
  optional string driverName = 3;

  optional ResourceModel resourceModel = 4;
}

// 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 node resource capacity objects.
  repeated ResourceSlice items = 2;
}

// StructuredResourceHandle is the in-tree representation of the allocation result.
message StructuredResourceHandle {
  // VendorClassParameters are the per-claim configuration parameters
  // from the resource class at the time that the claim was allocated.
  //
  // +optional
  optional k8s.io.apimachinery.pkg.runtime.RawExtension vendorClassParameters = 1;

  // VendorClaimParameters are the per-claim configuration parameters
  // from the resource claim parameters at the time that the claim was
  // allocated.
  //
  // +optional
  optional k8s.io.apimachinery.pkg.runtime.RawExtension vendorClaimParameters = 2;

  // NodeName is the name of the node providing the necessary resources
  // if the resources are local to a node.
  //
  // +optional
  optional string nodeName = 4;

  // Results lists all allocated driver resources.
  //
  // +listType=atomic
  repeated DriverAllocationResult results = 5;
}

// VendorParameters are opaque parameters for one particular driver.
message VendorParameters {
  // DriverName is the name used by the DRA driver kubelet plugin.
  optional string driverName = 1;

  // Parameters can be arbitrary setup parameters. They are ignored while
  // allocating a claim.
  //
  // +optional
  optional k8s.io.apimachinery.pkg.runtime.RawExtension parameters = 2;
}

