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 scale 18 19 import ( 20 "context" 21 22 autoscalingapi "k8s.io/api/autoscaling/v1" 23 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 24 "k8s.io/apimachinery/pkg/runtime/schema" 25 "k8s.io/apimachinery/pkg/types" 26 ) 27 28 // ScalesGetter can produce a ScaleInterface 29 type ScalesGetter interface { 30 // Scales produces a ScaleInterface for a particular namespace. 31 // Set namespace to the empty string for non-namespaced resources. 32 Scales(namespace string) ScaleInterface 33 } 34 35 // ScaleInterface can fetch and update scales for 36 // resources in a particular namespace which implement 37 // the scale subresource. 38 type ScaleInterface interface { 39 // Get fetches the scale of the given scalable resource. 40 Get(ctx context.Context, resource schema.GroupResource, name string, opts metav1.GetOptions) (*autoscalingapi.Scale, error) 41 42 // Update updates the scale of the given scalable resource. 43 Update(ctx context.Context, resource schema.GroupResource, scale *autoscalingapi.Scale, opts metav1.UpdateOptions) (*autoscalingapi.Scale, error) 44 45 // Patch patches the scale of the given scalable resource. 46 Patch(ctx context.Context, gvr schema.GroupVersionResource, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions) (*autoscalingapi.Scale, error) 47 } 48