...

Source file src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/replicaset.go

Documentation: k8s.io/client-go/kubernetes/typed/apps/v1beta2

     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 v1beta2
    20  
    21  import (
    22  	"context"
    23  	json "encoding/json"
    24  	"fmt"
    25  	"time"
    26  
    27  	v1beta2 "k8s.io/api/apps/v1beta2"
    28  	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    29  	types "k8s.io/apimachinery/pkg/types"
    30  	watch "k8s.io/apimachinery/pkg/watch"
    31  	appsv1beta2 "k8s.io/client-go/applyconfigurations/apps/v1beta2"
    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 *v1beta2.ReplicaSet, opts v1.CreateOptions) (*v1beta2.ReplicaSet, error)
    45  	Update(ctx context.Context, replicaSet *v1beta2.ReplicaSet, opts v1.UpdateOptions) (*v1beta2.ReplicaSet, error)
    46  	UpdateStatus(ctx context.Context, replicaSet *v1beta2.ReplicaSet, opts v1.UpdateOptions) (*v1beta2.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) (*v1beta2.ReplicaSet, error)
    50  	List(ctx context.Context, opts v1.ListOptions) (*v1beta2.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 *v1beta2.ReplicaSet, err error)
    53  	Apply(ctx context.Context, replicaSet *appsv1beta2.ReplicaSetApplyConfiguration, opts v1.ApplyOptions) (result *v1beta2.ReplicaSet, err error)
    54  	ApplyStatus(ctx context.Context, replicaSet *appsv1beta2.ReplicaSetApplyConfiguration, opts v1.ApplyOptions) (result *v1beta2.ReplicaSet, err error)
    55  	ReplicaSetExpansion
    56  }
    57  
    58  // replicaSets implements ReplicaSetInterface
    59  type replicaSets struct {
    60  	client rest.Interface
    61  	ns     string
    62  }
    63  
    64  // newReplicaSets returns a ReplicaSets
    65  func newReplicaSets(c *AppsV1beta2Client, namespace string) *replicaSets {
    66  	return &replicaSets{
    67  		client: c.RESTClient(),
    68  		ns:     namespace,
    69  	}
    70  }
    71  
    72  // Get takes name of the replicaSet, and returns the corresponding replicaSet object, and an error if there is any.
    73  func (c *replicaSets) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.ReplicaSet, err error) {
    74  	result = &v1beta2.ReplicaSet{}
    75  	err = c.client.Get().
    76  		Namespace(c.ns).
    77  		Resource("replicasets").
    78  		Name(name).
    79  		VersionedParams(&options, scheme.ParameterCodec).
    80  		Do(ctx).
    81  		Into(result)
    82  	return
    83  }
    84  
    85  // List takes label and field selectors, and returns the list of ReplicaSets that match those selectors.
    86  func (c *replicaSets) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.ReplicaSetList, err error) {
    87  	var timeout time.Duration
    88  	if opts.TimeoutSeconds != nil {
    89  		timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
    90  	}
    91  	result = &v1beta2.ReplicaSetList{}
    92  	err = c.client.Get().
    93  		Namespace(c.ns).
    94  		Resource("replicasets").
    95  		VersionedParams(&opts, scheme.ParameterCodec).
    96  		Timeout(timeout).
    97  		Do(ctx).
    98  		Into(result)
    99  	return
   100  }
   101  
   102  // Watch returns a watch.Interface that watches the requested replicaSets.
   103  func (c *replicaSets) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
   104  	var timeout time.Duration
   105  	if opts.TimeoutSeconds != nil {
   106  		timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
   107  	}
   108  	opts.Watch = true
   109  	return c.client.Get().
   110  		Namespace(c.ns).
   111  		Resource("replicasets").
   112  		VersionedParams(&opts, scheme.ParameterCodec).
   113  		Timeout(timeout).
   114  		Watch(ctx)
   115  }
   116  
   117  // 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.
   118  func (c *replicaSets) Create(ctx context.Context, replicaSet *v1beta2.ReplicaSet, opts v1.CreateOptions) (result *v1beta2.ReplicaSet, err error) {
   119  	result = &v1beta2.ReplicaSet{}
   120  	err = c.client.Post().
   121  		Namespace(c.ns).
   122  		Resource("replicasets").
   123  		VersionedParams(&opts, scheme.ParameterCodec).
   124  		Body(replicaSet).
   125  		Do(ctx).
   126  		Into(result)
   127  	return
   128  }
   129  
   130  // 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.
   131  func (c *replicaSets) Update(ctx context.Context, replicaSet *v1beta2.ReplicaSet, opts v1.UpdateOptions) (result *v1beta2.ReplicaSet, err error) {
   132  	result = &v1beta2.ReplicaSet{}
   133  	err = c.client.Put().
   134  		Namespace(c.ns).
   135  		Resource("replicasets").
   136  		Name(replicaSet.Name).
   137  		VersionedParams(&opts, scheme.ParameterCodec).
   138  		Body(replicaSet).
   139  		Do(ctx).
   140  		Into(result)
   141  	return
   142  }
   143  
   144  // UpdateStatus was generated because the type contains a Status member.
   145  // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
   146  func (c *replicaSets) UpdateStatus(ctx context.Context, replicaSet *v1beta2.ReplicaSet, opts v1.UpdateOptions) (result *v1beta2.ReplicaSet, err error) {
   147  	result = &v1beta2.ReplicaSet{}
   148  	err = c.client.Put().
   149  		Namespace(c.ns).
   150  		Resource("replicasets").
   151  		Name(replicaSet.Name).
   152  		SubResource("status").
   153  		VersionedParams(&opts, scheme.ParameterCodec).
   154  		Body(replicaSet).
   155  		Do(ctx).
   156  		Into(result)
   157  	return
   158  }
   159  
   160  // Delete takes name of the replicaSet and deletes it. Returns an error if one occurs.
   161  func (c *replicaSets) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
   162  	return c.client.Delete().
   163  		Namespace(c.ns).
   164  		Resource("replicasets").
   165  		Name(name).
   166  		Body(&opts).
   167  		Do(ctx).
   168  		Error()
   169  }
   170  
   171  // DeleteCollection deletes a collection of objects.
   172  func (c *replicaSets) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
   173  	var timeout time.Duration
   174  	if listOpts.TimeoutSeconds != nil {
   175  		timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
   176  	}
   177  	return c.client.Delete().
   178  		Namespace(c.ns).
   179  		Resource("replicasets").
   180  		VersionedParams(&listOpts, scheme.ParameterCodec).
   181  		Timeout(timeout).
   182  		Body(&opts).
   183  		Do(ctx).
   184  		Error()
   185  }
   186  
   187  // Patch applies the patch and returns the patched replicaSet.
   188  func (c *replicaSets) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.ReplicaSet, err error) {
   189  	result = &v1beta2.ReplicaSet{}
   190  	err = c.client.Patch(pt).
   191  		Namespace(c.ns).
   192  		Resource("replicasets").
   193  		Name(name).
   194  		SubResource(subresources...).
   195  		VersionedParams(&opts, scheme.ParameterCodec).
   196  		Body(data).
   197  		Do(ctx).
   198  		Into(result)
   199  	return
   200  }
   201  
   202  // Apply takes the given apply declarative configuration, applies it and returns the applied replicaSet.
   203  func (c *replicaSets) Apply(ctx context.Context, replicaSet *appsv1beta2.ReplicaSetApplyConfiguration, opts v1.ApplyOptions) (result *v1beta2.ReplicaSet, err error) {
   204  	if replicaSet == nil {
   205  		return nil, fmt.Errorf("replicaSet provided to Apply must not be nil")
   206  	}
   207  	patchOpts := opts.ToPatchOptions()
   208  	data, err := json.Marshal(replicaSet)
   209  	if err != nil {
   210  		return nil, err
   211  	}
   212  	name := replicaSet.Name
   213  	if name == nil {
   214  		return nil, fmt.Errorf("replicaSet.Name must be provided to Apply")
   215  	}
   216  	result = &v1beta2.ReplicaSet{}
   217  	err = c.client.Patch(types.ApplyPatchType).
   218  		Namespace(c.ns).
   219  		Resource("replicasets").
   220  		Name(*name).
   221  		VersionedParams(&patchOpts, scheme.ParameterCodec).
   222  		Body(data).
   223  		Do(ctx).
   224  		Into(result)
   225  	return
   226  }
   227  
   228  // ApplyStatus was generated because the type contains a Status member.
   229  // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
   230  func (c *replicaSets) ApplyStatus(ctx context.Context, replicaSet *appsv1beta2.ReplicaSetApplyConfiguration, opts v1.ApplyOptions) (result *v1beta2.ReplicaSet, err error) {
   231  	if replicaSet == nil {
   232  		return nil, fmt.Errorf("replicaSet provided to Apply must not be nil")
   233  	}
   234  	patchOpts := opts.ToPatchOptions()
   235  	data, err := json.Marshal(replicaSet)
   236  	if err != nil {
   237  		return nil, err
   238  	}
   239  
   240  	name := replicaSet.Name
   241  	if name == nil {
   242  		return nil, fmt.Errorf("replicaSet.Name must be provided to Apply")
   243  	}
   244  
   245  	result = &v1beta2.ReplicaSet{}
   246  	err = c.client.Patch(types.ApplyPatchType).
   247  		Namespace(c.ns).
   248  		Resource("replicasets").
   249  		Name(*name).
   250  		SubResource("status").
   251  		VersionedParams(&patchOpts, scheme.ParameterCodec).
   252  		Body(data).
   253  		Do(ctx).
   254  		Into(result)
   255  	return
   256  }
   257  

View as plain text