2 Copyright 2014 The Kubernetes Authors.
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
8 http://www.apache.org/licenses/LICENSE-2.0
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.
20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21 "k8s.io/apimachinery/pkg/runtime"
22 "k8s.io/apimachinery/pkg/runtime/schema"
23 "k8s.io/apimachinery/pkg/types"
26 type ListMetaAccessor interface {
30 // List lets you work with list metadata from any of the versioned or
31 // internal API objects. Attempting to set or retrieve a field on an object that does
32 // not support that field will be a no-op and return a default value.
33 type List metav1.ListInterface
35 // Type exposes the type and APIVersion of versioned or internal API objects.
38 // MetadataAccessor lets you work with object and list metadata from any of the versioned or
39 // internal API objects. Attempting to set or retrieve a field on an object that does
40 // not support that field (Name, UID, Namespace on lists) will be a no-op and return
43 // MetadataAccessor exposes Interface in a way that can be used with multiple objects.
44 type MetadataAccessor interface {
45 APIVersion(obj runtime.Object) (string, error)
46 SetAPIVersion(obj runtime.Object, version string) error
48 Kind(obj runtime.Object) (string, error)
49 SetKind(obj runtime.Object, kind string) error
51 Namespace(obj runtime.Object) (string, error)
52 SetNamespace(obj runtime.Object, namespace string) error
54 Name(obj runtime.Object) (string, error)
55 SetName(obj runtime.Object, name string) error
57 GenerateName(obj runtime.Object) (string, error)
58 SetGenerateName(obj runtime.Object, name string) error
60 UID(obj runtime.Object) (types.UID, error)
61 SetUID(obj runtime.Object, uid types.UID) error
63 SelfLink(obj runtime.Object) (string, error)
64 SetSelfLink(obj runtime.Object, selfLink string) error
66 Labels(obj runtime.Object) (map[string]string, error)
67 SetLabels(obj runtime.Object, labels map[string]string) error
69 Annotations(obj runtime.Object) (map[string]string, error)
70 SetAnnotations(obj runtime.Object, annotations map[string]string) error
72 Continue(obj runtime.Object) (string, error)
73 SetContinue(obj runtime.Object, c string) error
75 runtime.ResourceVersioner
78 type RESTScopeName string
81 RESTScopeNameNamespace RESTScopeName = "namespace"
82 RESTScopeNameRoot RESTScopeName = "root"
85 // RESTScope contains the information needed to deal with REST resources that are in a resource hierarchy
86 type RESTScope interface {
91 // RESTMapping contains the information needed to deal with objects of a specific
92 // resource and kind in a RESTful manner.
93 type RESTMapping struct {
94 // Resource is the GroupVersionResource (location) for this endpoint
95 Resource schema.GroupVersionResource
97 // GroupVersionKind is the GroupVersionKind (data format) to submit to this endpoint
98 GroupVersionKind schema.GroupVersionKind
100 // Scope contains the information needed to deal with REST Resources that are in a resource hierarchy
104 // RESTMapper allows clients to map resources to kind, and map kind and version
105 // to interfaces for manipulating those objects. It is primarily intended for
106 // consumers of Kubernetes compatible REST APIs as defined in docs/devel/api-conventions.md.
108 // The Kubernetes API provides versioned resources and object kinds which are scoped
109 // to API groups. In other words, kinds and resources should not be assumed to be
110 // unique across groups.
112 // TODO: split into sub-interfaces
113 type RESTMapper interface {
114 // KindFor takes a partial resource and returns the single match. Returns an error if there are multiple matches
115 KindFor(resource schema.GroupVersionResource) (schema.GroupVersionKind, error)
117 // KindsFor takes a partial resource and returns the list of potential kinds in priority order
118 KindsFor(resource schema.GroupVersionResource) ([]schema.GroupVersionKind, error)
120 // ResourceFor takes a partial resource and returns the single match. Returns an error if there are multiple matches
121 ResourceFor(input schema.GroupVersionResource) (schema.GroupVersionResource, error)
123 // ResourcesFor takes a partial resource and returns the list of potential resource in priority order
124 ResourcesFor(input schema.GroupVersionResource) ([]schema.GroupVersionResource, error)
126 // RESTMapping identifies a preferred resource mapping for the provided group kind.
127 RESTMapping(gk schema.GroupKind, versions ...string) (*RESTMapping, error)
128 // RESTMappings returns all resource mappings for the provided group kind if no
129 // version search is provided. Otherwise identifies a preferred resource mapping for
130 // the provided version(s).
131 RESTMappings(gk schema.GroupKind, versions ...string) ([]*RESTMapping, error)
133 ResourceSingularizer(resource string) (singular string, err error)