...

Source file src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/replicaset.go

Documentation: k8s.io/client-go/kubernetes/typed/extensions/v1beta1

     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  	"time"
    26  
    27  	v1beta1 "k8s.io/api/extensions/v1beta1"
    28  	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    29  	types "k8s.io/apimachinery/pkg/types"
    30  	watch "k8s.io/apimachinery/pkg/watch"
    31  	extensionsv1beta1 "k8s.io/client-go/applyconfigurations/extensions/v1beta1"
    32  	scheme "k8s.io/client-go/kubernetes/scheme"
    33  	rest "k8s.io/client-go/rest"
    34  )
    35  
    36  // ReplicaSetsGetter has a method to return a ReplicaSetInterface.
    37  // A group's client should implement this interface.
    38  type ReplicaSetsGetter interface {
    39  	ReplicaSets(namespace string) ReplicaSetInterface
    40  }
    41  
    42  // ReplicaSetInterface has methods to work with ReplicaSet resources.
    43  type ReplicaSetInterface interface {
    44  	Create(ctx context.Context, replicaSet *v1beta1.ReplicaSet, opts v1.CreateOptions) (*v1beta1.ReplicaSet, error)
    45  	Update(ctx context.Context, replicaSet *v1beta1.ReplicaSet, opts v1.UpdateOptions) (*v1beta1.ReplicaSet, error)
    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  	ApplyStatus(ctx context.Context, replicaSet *extensionsv1beta1.ReplicaSetApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.ReplicaSet, err error)
    55  	GetScale(ctx context.Context, replicaSetName string, options v1.GetOptions) (*v1beta1.Scale, error)
    56  	UpdateScale(ctx context.Context, replicaSetName string, scale *v1beta1.Scale, opts v1.UpdateOptions) (*v1beta1.Scale, error)
    57  	ApplyScale(ctx context.Context, replicaSetName string, scale *extensionsv1beta1.ScaleApplyConfiguration, opts v1.ApplyOptions) (*v1beta1.Scale, error)
    58  
    59  	ReplicaSetExpansion
    60  }
    61  
    62  // replicaSets implements ReplicaSetInterface
    63  type replicaSets struct {
    64  	client rest.Interface
    65  	ns     string
    66  }
    67  
    68  // newReplicaSets returns a ReplicaSets
    69  func newReplicaSets(c *ExtensionsV1beta1Client, namespace string) *replicaSets {
    70  	return &replicaSets{
    71  		client: c.RESTClient(),
    72  		ns:     namespace,
    73  	}
    74  }
    75  
    76  // Get takes name of the replicaSet, and returns the corresponding replicaSet object, and an error if there is any.
    77  func (c *replicaSets) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.ReplicaSet, err error) {
    78  	result = &v1beta1.ReplicaSet{}
    79  	err = c.client.Get().
    80  		Namespace(c.ns).
    81  		Resource("replicasets").
    82  		Name(name).
    83  		VersionedParams(&options, scheme.ParameterCodec).
    84  		Do(ctx).
    85  		Into(result)
    86  	return
    87  }
    88  
    89  // List takes label and field selectors, and returns the list of ReplicaSets that match those selectors.
    90  func (c *replicaSets) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ReplicaSetList, err error) {
    91  	var timeout time.Duration
    92  	if opts.TimeoutSeconds != nil {
    93  		timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
    94  	}
    95  	result = &v1beta1.ReplicaSetList{}
    96  	err = c.client.Get().
    97  		Namespace(c.ns).
    98  		Resource("replicasets").
    99  		VersionedParams(&opts, scheme.ParameterCodec).
   100  		Timeout(timeout).
   101  		Do(ctx).
   102  		Into(result)
   103  	return
   104  }
   105  
   106  // Watch returns a watch.Interface that watches the requested replicaSets.
   107  func (c *replicaSets) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
   108  	var timeout time.Duration
   109  	if opts.TimeoutSeconds != nil {
   110  		timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
   111  	}
   112  	opts.Watch = true
   113  	return c.client.Get().
   114  		Namespace(c.ns).
   115  		Resource("replicasets").
   116  		VersionedParams(&opts, scheme.ParameterCodec).
   117  		Timeout(timeout).
   118  		Watch(ctx)
   119  }
   120  
   121  // Create takes the representation of a replicaSet and creates it.  Returns the server's representation of the replicaSet, and an error, if there is any.
   122  func (c *replicaSets) Create(ctx context.Context, replicaSet *v1beta1.ReplicaSet, opts v1.CreateOptions) (result *v1beta1.ReplicaSet, err error) {
   123  	result = &v1beta1.ReplicaSet{}
   124  	err = c.client.Post().
   125  		Namespace(c.ns).
   126  		Resource("replicasets").
   127  		VersionedParams(&opts, scheme.ParameterCodec).
   128  		Body(replicaSet).
   129  		Do(ctx).
   130  		Into(result)
   131  	return
   132  }
   133  
   134  // Update takes the representation of a replicaSet and updates it. Returns the server's representation of the replicaSet, and an error, if there is any.
   135  func (c *replicaSets) Update(ctx context.Context, replicaSet *v1beta1.ReplicaSet, opts v1.UpdateOptions) (result *v1beta1.ReplicaSet, err error) {
   136  	result = &v1beta1.ReplicaSet{}
   137  	err = c.client.Put().
   138  		Namespace(c.ns).
   139  		Resource("replicasets").
   140  		Name(replicaSet.Name).
   141  		VersionedParams(&opts, scheme.ParameterCodec).
   142  		Body(replicaSet).
   143  		Do(ctx).
   144  		Into(result)
   145  	return
   146  }
   147  
   148  // UpdateStatus was generated because the type contains a Status member.
   149  // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
   150  func (c *replicaSets) UpdateStatus(ctx context.Context, replicaSet *v1beta1.ReplicaSet, opts v1.UpdateOptions) (result *v1beta1.ReplicaSet, err error) {
   151  	result = &v1beta1.ReplicaSet{}
   152  	err = c.client.Put().
   153  		Namespace(c.ns).
   154  		Resource("replicasets").
   155  		Name(replicaSet.Name).
   156  		SubResource("status").
   157  		VersionedParams(&opts, scheme.ParameterCodec).
   158  		Body(replicaSet).
   159  		Do(ctx).
   160  		Into(result)
   161  	return
   162  }
   163  
   164  // Delete takes name of the replicaSet and deletes it. Returns an error if one occurs.
   165  func (c *replicaSets) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
   166  	return c.client.Delete().
   167  		Namespace(c.ns).
   168  		Resource("replicasets").
   169  		Name(name).
   170  		Body(&opts).
   171  		Do(ctx).
   172  		Error()
   173  }
   174  
   175  // DeleteCollection deletes a collection of objects.
   176  func (c *replicaSets) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
   177  	var timeout time.Duration
   178  	if listOpts.TimeoutSeconds != nil {
   179  		timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
   180  	}
   181  	return c.client.Delete().
   182  		Namespace(c.ns).
   183  		Resource("replicasets").
   184  		VersionedParams(&listOpts, scheme.ParameterCodec).
   185  		Timeout(timeout).
   186  		Body(&opts).
   187  		Do(ctx).
   188  		Error()
   189  }
   190  
   191  // Patch applies the patch and returns the patched replicaSet.
   192  func (c *replicaSets) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ReplicaSet, err error) {
   193  	result = &v1beta1.ReplicaSet{}
   194  	err = c.client.Patch(pt).
   195  		Namespace(c.ns).
   196  		Resource("replicasets").
   197  		Name(name).
   198  		SubResource(subresources...).
   199  		VersionedParams(&opts, scheme.ParameterCodec).
   200  		Body(data).
   201  		Do(ctx).
   202  		Into(result)
   203  	return
   204  }
   205  
   206  // Apply takes the given apply declarative configuration, applies it and returns the applied replicaSet.
   207  func (c *replicaSets) Apply(ctx context.Context, replicaSet *extensionsv1beta1.ReplicaSetApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.ReplicaSet, err error) {
   208  	if replicaSet == nil {
   209  		return nil, fmt.Errorf("replicaSet provided to Apply must not be nil")
   210  	}
   211  	patchOpts := opts.ToPatchOptions()
   212  	data, err := json.Marshal(replicaSet)
   213  	if err != nil {
   214  		return nil, err
   215  	}
   216  	name := replicaSet.Name
   217  	if name == nil {
   218  		return nil, fmt.Errorf("replicaSet.Name must be provided to Apply")
   219  	}
   220  	result = &v1beta1.ReplicaSet{}
   221  	err = c.client.Patch(types.ApplyPatchType).
   222  		Namespace(c.ns).
   223  		Resource("replicasets").
   224  		Name(*name).
   225  		VersionedParams(&patchOpts, scheme.ParameterCodec).
   226  		Body(data).
   227  		Do(ctx).
   228  		Into(result)
   229  	return
   230  }
   231  
   232  // ApplyStatus was generated because the type contains a Status member.
   233  // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
   234  func (c *replicaSets) ApplyStatus(ctx context.Context, replicaSet *extensionsv1beta1.ReplicaSetApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.ReplicaSet, err error) {
   235  	if replicaSet == nil {
   236  		return nil, fmt.Errorf("replicaSet provided to Apply must not be nil")
   237  	}
   238  	patchOpts := opts.ToPatchOptions()
   239  	data, err := json.Marshal(replicaSet)
   240  	if err != nil {
   241  		return nil, err
   242  	}
   243  
   244  	name := replicaSet.Name
   245  	if name == nil {
   246  		return nil, fmt.Errorf("replicaSet.Name must be provided to Apply")
   247  	}
   248  
   249  	result = &v1beta1.ReplicaSet{}
   250  	err = c.client.Patch(types.ApplyPatchType).
   251  		Namespace(c.ns).
   252  		Resource("replicasets").
   253  		Name(*name).
   254  		SubResource("status").
   255  		VersionedParams(&patchOpts, scheme.ParameterCodec).
   256  		Body(data).
   257  		Do(ctx).
   258  		Into(result)
   259  	return
   260  }
   261  
   262  // GetScale takes name of the replicaSet, and returns the corresponding v1beta1.Scale object, and an error if there is any.
   263  func (c *replicaSets) GetScale(ctx context.Context, replicaSetName string, options v1.GetOptions) (result *v1beta1.Scale, err error) {
   264  	result = &v1beta1.Scale{}
   265  	err = c.client.Get().
   266  		Namespace(c.ns).
   267  		Resource("replicasets").
   268  		Name(replicaSetName).
   269  		SubResource("scale").
   270  		VersionedParams(&options, scheme.ParameterCodec).
   271  		Do(ctx).
   272  		Into(result)
   273  	return
   274  }
   275  
   276  // 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.
   277  func (c *replicaSets) UpdateScale(ctx context.Context, replicaSetName string, scale *v1beta1.Scale, opts v1.UpdateOptions) (result *v1beta1.Scale, err error) {
   278  	result = &v1beta1.Scale{}
   279  	err = c.client.Put().
   280  		Namespace(c.ns).
   281  		Resource("replicasets").
   282  		Name(replicaSetName).
   283  		SubResource("scale").
   284  		VersionedParams(&opts, scheme.ParameterCodec).
   285  		Body(scale).
   286  		Do(ctx).
   287  		Into(result)
   288  	return
   289  }
   290  
   291  // ApplyScale takes top resource name and the apply declarative configuration for scale,
   292  // applies it and returns the applied scale, and an error, if there is any.
   293  func (c *replicaSets) ApplyScale(ctx context.Context, replicaSetName string, scale *extensionsv1beta1.ScaleApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.Scale, err error) {
   294  	if scale == nil {
   295  		return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
   296  	}
   297  	patchOpts := opts.ToPatchOptions()
   298  	data, err := json.Marshal(scale)
   299  	if err != nil {
   300  		return nil, err
   301  	}
   302  
   303  	result = &v1beta1.Scale{}
   304  	err = c.client.Patch(types.ApplyPatchType).
   305  		Namespace(c.ns).
   306  		Resource("replicasets").
   307  		Name(replicaSetName).
   308  		SubResource("scale").
   309  		VersionedParams(&patchOpts, scheme.ParameterCodec).
   310  		Body(data).
   311  		Do(ctx).
   312  		Into(result)
   313  	return
   314  }
   315  

View as plain text