k8s.io/client-go@v0.31.1/kubernetes/typed/extensions/v1beta1/replicaset.go (about)

     1  /*
     2  Copyright 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  // Code generated by client-gen. DO NOT EDIT.
    18  
    19  package v1beta1
    20  
    21  import (
    22  	"context"
    23  	json "encoding/json"
    24  	"fmt"
    25  
    26  	v1beta1 "k8s.io/api/extensions/v1beta1"
    27  	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    28  	types "k8s.io/apimachinery/pkg/types"
    29  	watch "k8s.io/apimachinery/pkg/watch"
    30  	extensionsv1beta1 "k8s.io/client-go/applyconfigurations/extensions/v1beta1"
    31  	gentype "k8s.io/client-go/gentype"
    32  	scheme "k8s.io/client-go/kubernetes/scheme"
    33  )
    34  
    35  // ReplicaSetsGetter has a method to return a ReplicaSetInterface.
    36  // A group's client should implement this interface.
    37  type ReplicaSetsGetter interface {
    38  	ReplicaSets(namespace string) ReplicaSetInterface
    39  }
    40  
    41  // ReplicaSetInterface has methods to work with ReplicaSet resources.
    42  type ReplicaSetInterface interface {
    43  	Create(ctx context.Context, replicaSet *v1beta1.ReplicaSet, opts v1.CreateOptions) (*v1beta1.ReplicaSet, error)
    44  	Update(ctx context.Context, replicaSet *v1beta1.ReplicaSet, opts v1.UpdateOptions) (*v1beta1.ReplicaSet, error)
    45  	// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
    46  	UpdateStatus(ctx context.Context, replicaSet *v1beta1.ReplicaSet, opts v1.UpdateOptions) (*v1beta1.ReplicaSet, error)
    47  	Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
    48  	DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
    49  	Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.ReplicaSet, error)
    50  	List(ctx context.Context, opts v1.ListOptions) (*v1beta1.ReplicaSetList, error)
    51  	Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
    52  	Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ReplicaSet, err error)
    53  	Apply(ctx context.Context, replicaSet *extensionsv1beta1.ReplicaSetApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.ReplicaSet, err error)
    54  	// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
    55  	ApplyStatus(ctx context.Context, replicaSet *extensionsv1beta1.ReplicaSetApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.ReplicaSet, err error)
    56  	GetScale(ctx context.Context, replicaSetName string, options v1.GetOptions) (*v1beta1.Scale, error)
    57  	UpdateScale(ctx context.Context, replicaSetName string, scale *v1beta1.Scale, opts v1.UpdateOptions) (*v1beta1.Scale, error)
    58  	ApplyScale(ctx context.Context, replicaSetName string, scale *extensionsv1beta1.ScaleApplyConfiguration, opts v1.ApplyOptions) (*v1beta1.Scale, error)
    59  
    60  	ReplicaSetExpansion
    61  }
    62  
    63  // replicaSets implements ReplicaSetInterface
    64  type replicaSets struct {
    65  	*gentype.ClientWithListAndApply[*v1beta1.ReplicaSet, *v1beta1.ReplicaSetList, *extensionsv1beta1.ReplicaSetApplyConfiguration]
    66  }
    67  
    68  // newReplicaSets returns a ReplicaSets
    69  func newReplicaSets(c *ExtensionsV1beta1Client, namespace string) *replicaSets {
    70  	return &replicaSets{
    71  		gentype.NewClientWithListAndApply[*v1beta1.ReplicaSet, *v1beta1.ReplicaSetList, *extensionsv1beta1.ReplicaSetApplyConfiguration](
    72  			"replicasets",
    73  			c.RESTClient(),
    74  			scheme.ParameterCodec,
    75  			namespace,
    76  			func() *v1beta1.ReplicaSet { return &v1beta1.ReplicaSet{} },
    77  			func() *v1beta1.ReplicaSetList { return &v1beta1.ReplicaSetList{} }),
    78  	}
    79  }
    80  
    81  // GetScale takes name of the replicaSet, and returns the corresponding v1beta1.Scale object, and an error if there is any.
    82  func (c *replicaSets) GetScale(ctx context.Context, replicaSetName string, options v1.GetOptions) (result *v1beta1.Scale, err error) {
    83  	result = &v1beta1.Scale{}
    84  	err = c.GetClient().Get().
    85  		Namespace(c.GetNamespace()).
    86  		Resource("replicasets").
    87  		Name(replicaSetName).
    88  		SubResource("scale").
    89  		VersionedParams(&options, scheme.ParameterCodec).
    90  		Do(ctx).
    91  		Into(result)
    92  	return
    93  }
    94  
    95  // UpdateScale takes the top resource name and the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any.
    96  func (c *replicaSets) UpdateScale(ctx context.Context, replicaSetName string, scale *v1beta1.Scale, opts v1.UpdateOptions) (result *v1beta1.Scale, err error) {
    97  	result = &v1beta1.Scale{}
    98  	err = c.GetClient().Put().
    99  		Namespace(c.GetNamespace()).
   100  		Resource("replicasets").
   101  		Name(replicaSetName).
   102  		SubResource("scale").
   103  		VersionedParams(&opts, scheme.ParameterCodec).
   104  		Body(scale).
   105  		Do(ctx).
   106  		Into(result)
   107  	return
   108  }
   109  
   110  // ApplyScale takes top resource name and the apply declarative configuration for scale,
   111  // applies it and returns the applied scale, and an error, if there is any.
   112  func (c *replicaSets) ApplyScale(ctx context.Context, replicaSetName string, scale *extensionsv1beta1.ScaleApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.Scale, err error) {
   113  	if scale == nil {
   114  		return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
   115  	}
   116  	patchOpts := opts.ToPatchOptions()
   117  	data, err := json.Marshal(scale)
   118  	if err != nil {
   119  		return nil, err
   120  	}
   121  
   122  	result = &v1beta1.Scale{}
   123  	err = c.GetClient().Patch(types.ApplyPatchType).
   124  		Namespace(c.GetNamespace()).
   125  		Resource("replicasets").
   126  		Name(replicaSetName).
   127  		SubResource("scale").
   128  		VersionedParams(&patchOpts, scheme.ParameterCodec).
   129  		Body(data).
   130  		Do(ctx).
   131  		Into(result)
   132  	return
   133  }