| 1 |
/* |
| 2 |
Copyright 2017 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 custom_metrics |
| 18 |
|
| 19 |
import ( |
| 20 |
"k8s.io/apimachinery/pkg/labels" |
| 21 |
"k8s.io/apimachinery/pkg/runtime/schema" |
| 22 |
"k8s.io/metrics/pkg/apis/custom_metrics/v1beta2" |
| 23 |
) |
| 24 |
|
| 25 |
// CustomMetricsClient is a client for fetching metrics |
| 26 |
// describing both root-scoped and namespaced resources. |
| 27 |
type CustomMetricsClient interface { |
| 28 |
RootScopedMetricsGetter |
| 29 |
NamespacedMetricsGetter |
| 30 |
} |
| 31 |
|
| 32 |
// RootScopedMetricsGetter provides access to an interface for fetching |
| 33 |
// metrics describing root-scoped objects. Note that metrics describing |
| 34 |
// a namespace are simply considered a special case of root-scoped metrics. |
| 35 |
type RootScopedMetricsGetter interface { |
| 36 |
RootScopedMetrics() MetricsInterface |
| 37 |
} |
| 38 |
|
| 39 |
// NamespacedMetricsGetter provides access to an interface for fetching |
| 40 |
// metrics describing resources in a particular namespace. |
| 41 |
type NamespacedMetricsGetter interface { |
| 42 |
NamespacedMetrics(namespace string) MetricsInterface |
| 43 |
} |
| 44 |
|
| 45 |
// MetricsInterface provides access to metrics describing Kubernetes objects. |
| 46 |
type MetricsInterface interface { |
| 47 |
// GetForObject fetchs the given metric describing the given object. |
| 48 |
GetForObject(groupKind schema.GroupKind, name string, metricName string, metricSelector labels.Selector) (*v1beta2.MetricValue, error) |
| 49 |
|
| 50 |
// GetForObjects fetches the given metric describing all objects of the given |
| 51 |
// type matching the given label selector (or simply all objects of the given type |
| 52 |
// if the selector is nil). |
| 53 |
GetForObjects(groupKind schema.GroupKind, selector labels.Selector, metricName string, metricSelector labels.Selector) (*v1beta2.MetricValueList, error) |
| 54 |
} |