1 /* 2 Copyright 2024 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v2 18 19 import ( 20 v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 ) 22 23 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 24 25 // APIGroupDiscoveryList is a resource containing a list of APIGroupDiscovery. 26 // This is one of the types able to be returned from the /api and /apis endpoint and contains an aggregated 27 // list of API resources (built-ins, Custom Resource Definitions, resources from aggregated servers) 28 // that a cluster supports. 29 type APIGroupDiscoveryList struct { 30 v1.TypeMeta `json:",inline"` 31 // ResourceVersion will not be set, because this does not have a replayable ordering among multiple apiservers. 32 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 33 // +optional 34 v1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 35 // items is the list of groups for discovery. The groups are listed in priority order. 36 Items []APIGroupDiscovery `json:"items" protobuf:"bytes,2,rep,name=items"` 37 } 38 39 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 40 41 // APIGroupDiscovery holds information about which resources are being served for all version of the API Group. 42 // It contains a list of APIVersionDiscovery that holds a list of APIResourceDiscovery types served for a version. 43 // Versions are in descending order of preference, with the first version being the preferred entry. 44 type APIGroupDiscovery struct { 45 v1.TypeMeta `json:",inline"` 46 // Standard object's metadata. 47 // The only field completed will be name. For instance, resourceVersion will be empty. 48 // name is the name of the API group whose discovery information is presented here. 49 // name is allowed to be "" to represent the legacy, ungroupified resources. 50 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 51 // +optional 52 v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 53 // versions are the versions supported in this group. They are sorted in descending order of preference, 54 // with the preferred version being the first entry. 55 // +listType=map 56 // +listMapKey=version 57 Versions []APIVersionDiscovery `json:"versions,omitempty" protobuf:"bytes,2,rep,name=versions"` 58 } 59 60 // APIVersionDiscovery holds a list of APIResourceDiscovery types that are served for a particular version within an API Group. 61 type APIVersionDiscovery struct { 62 // version is the name of the version within a group version. 63 Version string `json:"version" protobuf:"bytes,1,opt,name=version"` 64 // resources is a list of APIResourceDiscovery objects for the corresponding group version. 65 // +listType=map 66 // +listMapKey=resource 67 Resources []APIResourceDiscovery `json:"resources,omitempty" protobuf:"bytes,2,rep,name=resources"` 68 // freshness marks whether a group version's discovery document is up to date. 69 // "Current" indicates the discovery document was recently 70 // refreshed. "Stale" indicates the discovery document could not 71 // be retrieved and the returned discovery document may be 72 // significantly out of date. Clients that require the latest 73 // version of the discovery information be retrieved before 74 // performing an operation should not use the aggregated document 75 Freshness DiscoveryFreshness `json:"freshness,omitempty" protobuf:"bytes,3,opt,name=freshness"` 76 } 77 78 // APIResourceDiscovery provides information about an API resource for discovery. 79 type APIResourceDiscovery struct { 80 // resource is the plural name of the resource. This is used in the URL path and is the unique identifier 81 // for this resource across all versions in the API group. 82 // Resources with non-empty groups are located at /apis/<APIGroupDiscovery.objectMeta.name>/<APIVersionDiscovery.version>/<APIResourceDiscovery.Resource> 83 // Resources with empty groups are located at /api/v1/<APIResourceDiscovery.Resource> 84 Resource string `json:"resource" protobuf:"bytes,1,opt,name=resource"` 85 // responseKind describes the group, version, and kind of the serialization schema for the object type this endpoint typically returns. 86 // APIs may return other objects types at their discretion, such as error conditions, requests for alternate representations, or other operation specific behavior. 87 // This value will be null or empty if an APIService reports subresources but supports no operations on the parent resource 88 ResponseKind *v1.GroupVersionKind `json:"responseKind,omitempty" protobuf:"bytes,2,opt,name=responseKind"` 89 // scope indicates the scope of a resource, either Cluster or Namespaced 90 Scope ResourceScope `json:"scope" protobuf:"bytes,3,opt,name=scope"` 91 // singularResource is the singular name of the resource. This allows clients to handle plural and singular opaquely. 92 // For many clients the singular form of the resource will be more understandable to users reading messages and should be used when integrating the name of the resource into a sentence. 93 // The command line tool kubectl, for example, allows use of the singular resource name in place of plurals. 94 // The singular form of a resource should always be an optional element - when in doubt use the canonical resource name. 95 SingularResource string `json:"singularResource" protobuf:"bytes,4,opt,name=singularResource"` 96 // verbs is a list of supported API operation types (this includes 97 // but is not limited to get, list, watch, create, update, patch, 98 // delete, deletecollection, and proxy). 99 // +listType=set 100 Verbs []string `json:"verbs" protobuf:"bytes,5,opt,name=verbs"` 101 // shortNames is a list of suggested short names of the resource. 102 // +listType=set 103 ShortNames []string `json:"shortNames,omitempty" protobuf:"bytes,6,rep,name=shortNames"` 104 // categories is a list of the grouped resources this resource belongs to (e.g. 'all'). 105 // Clients may use this to simplify acting on multiple resource types at once. 106 // +listType=set 107 Categories []string `json:"categories,omitempty" protobuf:"bytes,7,rep,name=categories"` 108 // subresources is a list of subresources provided by this resource. Subresources are located at /apis/<APIGroupDiscovery.objectMeta.name>/<APIVersionDiscovery.version>/<APIResourceDiscovery.Resource>/name-of-instance/<APIResourceDiscovery.subresources[i].subresource> 109 // +listType=map 110 // +listMapKey=subresource 111 Subresources []APISubresourceDiscovery `json:"subresources,omitempty" protobuf:"bytes,8,rep,name=subresources"` 112 } 113 114 // ResourceScope is an enum defining the different scopes available to a resource. 115 type ResourceScope string 116 117 const ( 118 ScopeCluster ResourceScope = "Cluster" 119 ScopeNamespace ResourceScope = "Namespaced" 120 ) 121 122 // DiscoveryFreshness is an enum defining whether the Discovery document published by an apiservice is up to date (fresh). 123 type DiscoveryFreshness string 124 125 const ( 126 DiscoveryFreshnessCurrent DiscoveryFreshness = "Current" 127 DiscoveryFreshnessStale DiscoveryFreshness = "Stale" 128 ) 129 130 // APISubresourceDiscovery provides information about an API subresource for discovery. 131 type APISubresourceDiscovery struct { 132 // subresource is the name of the subresource. This is used in the URL path and is the unique identifier 133 // for this resource across all versions. 134 Subresource string `json:"subresource" protobuf:"bytes,1,opt,name=subresource"` 135 // responseKind describes the group, version, and kind of the serialization schema for the object type this endpoint typically returns. 136 // Some subresources do not return normal resources, these will have null or empty return types. 137 ResponseKind *v1.GroupVersionKind `json:"responseKind,omitempty" protobuf:"bytes,2,opt,name=responseKind"` 138 // acceptedTypes describes the kinds that this endpoint accepts. 139 // Subresources may accept the standard content types or define 140 // custom negotiation schemes. The list may not be exhaustive for 141 // all operations. 142 // +listType=map 143 // +listMapKey=group 144 // +listMapKey=version 145 // +listMapKey=kind 146 AcceptedTypes []v1.GroupVersionKind `json:"acceptedTypes,omitempty" protobuf:"bytes,3,rep,name=acceptedTypes"` 147 // verbs is a list of supported API operation types (this includes 148 // but is not limited to get, list, watch, create, update, patch, 149 // delete, deletecollection, and proxy). Subresources may define 150 // custom verbs outside the standard Kubernetes verb set. Clients 151 // should expect the behavior of standard verbs to align with 152 // Kubernetes interaction conventions. 153 // +listType=set 154 Verbs []string `json:"verbs" protobuf:"bytes,4,opt,name=verbs"` 155 } 156