...

Source file src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceslice.go

Documentation: k8s.io/client-go/kubernetes/typed/resource/v1alpha2

     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 v1alpha2
    20  
    21  import (
    22  	"context"
    23  	json "encoding/json"
    24  	"fmt"
    25  	"time"
    26  
    27  	v1alpha2 "k8s.io/api/resource/v1alpha2"
    28  	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    29  	types "k8s.io/apimachinery/pkg/types"
    30  	watch "k8s.io/apimachinery/pkg/watch"
    31  	resourcev1alpha2 "k8s.io/client-go/applyconfigurations/resource/v1alpha2"
    32  	scheme "k8s.io/client-go/kubernetes/scheme"
    33  	rest "k8s.io/client-go/rest"
    34  )
    35  
    36  // ResourceSlicesGetter has a method to return a ResourceSliceInterface.
    37  // A group's client should implement this interface.
    38  type ResourceSlicesGetter interface {
    39  	ResourceSlices() ResourceSliceInterface
    40  }
    41  
    42  // ResourceSliceInterface has methods to work with ResourceSlice resources.
    43  type ResourceSliceInterface interface {
    44  	Create(ctx context.Context, resourceSlice *v1alpha2.ResourceSlice, opts v1.CreateOptions) (*v1alpha2.ResourceSlice, error)
    45  	Update(ctx context.Context, resourceSlice *v1alpha2.ResourceSlice, opts v1.UpdateOptions) (*v1alpha2.ResourceSlice, error)
    46  	Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
    47  	DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
    48  	Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha2.ResourceSlice, error)
    49  	List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.ResourceSliceList, error)
    50  	Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
    51  	Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.ResourceSlice, err error)
    52  	Apply(ctx context.Context, resourceSlice *resourcev1alpha2.ResourceSliceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.ResourceSlice, err error)
    53  	ResourceSliceExpansion
    54  }
    55  
    56  // resourceSlices implements ResourceSliceInterface
    57  type resourceSlices struct {
    58  	client rest.Interface
    59  }
    60  
    61  // newResourceSlices returns a ResourceSlices
    62  func newResourceSlices(c *ResourceV1alpha2Client) *resourceSlices {
    63  	return &resourceSlices{
    64  		client: c.RESTClient(),
    65  	}
    66  }
    67  
    68  // Get takes name of the resourceSlice, and returns the corresponding resourceSlice object, and an error if there is any.
    69  func (c *resourceSlices) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.ResourceSlice, err error) {
    70  	result = &v1alpha2.ResourceSlice{}
    71  	err = c.client.Get().
    72  		Resource("resourceslices").
    73  		Name(name).
    74  		VersionedParams(&options, scheme.ParameterCodec).
    75  		Do(ctx).
    76  		Into(result)
    77  	return
    78  }
    79  
    80  // List takes label and field selectors, and returns the list of ResourceSlices that match those selectors.
    81  func (c *resourceSlices) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ResourceSliceList, err error) {
    82  	var timeout time.Duration
    83  	if opts.TimeoutSeconds != nil {
    84  		timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
    85  	}
    86  	result = &v1alpha2.ResourceSliceList{}
    87  	err = c.client.Get().
    88  		Resource("resourceslices").
    89  		VersionedParams(&opts, scheme.ParameterCodec).
    90  		Timeout(timeout).
    91  		Do(ctx).
    92  		Into(result)
    93  	return
    94  }
    95  
    96  // Watch returns a watch.Interface that watches the requested resourceSlices.
    97  func (c *resourceSlices) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
    98  	var timeout time.Duration
    99  	if opts.TimeoutSeconds != nil {
   100  		timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
   101  	}
   102  	opts.Watch = true
   103  	return c.client.Get().
   104  		Resource("resourceslices").
   105  		VersionedParams(&opts, scheme.ParameterCodec).
   106  		Timeout(timeout).
   107  		Watch(ctx)
   108  }
   109  
   110  // Create takes the representation of a resourceSlice and creates it.  Returns the server's representation of the resourceSlice, and an error, if there is any.
   111  func (c *resourceSlices) Create(ctx context.Context, resourceSlice *v1alpha2.ResourceSlice, opts v1.CreateOptions) (result *v1alpha2.ResourceSlice, err error) {
   112  	result = &v1alpha2.ResourceSlice{}
   113  	err = c.client.Post().
   114  		Resource("resourceslices").
   115  		VersionedParams(&opts, scheme.ParameterCodec).
   116  		Body(resourceSlice).
   117  		Do(ctx).
   118  		Into(result)
   119  	return
   120  }
   121  
   122  // Update takes the representation of a resourceSlice and updates it. Returns the server's representation of the resourceSlice, and an error, if there is any.
   123  func (c *resourceSlices) Update(ctx context.Context, resourceSlice *v1alpha2.ResourceSlice, opts v1.UpdateOptions) (result *v1alpha2.ResourceSlice, err error) {
   124  	result = &v1alpha2.ResourceSlice{}
   125  	err = c.client.Put().
   126  		Resource("resourceslices").
   127  		Name(resourceSlice.Name).
   128  		VersionedParams(&opts, scheme.ParameterCodec).
   129  		Body(resourceSlice).
   130  		Do(ctx).
   131  		Into(result)
   132  	return
   133  }
   134  
   135  // Delete takes name of the resourceSlice and deletes it. Returns an error if one occurs.
   136  func (c *resourceSlices) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
   137  	return c.client.Delete().
   138  		Resource("resourceslices").
   139  		Name(name).
   140  		Body(&opts).
   141  		Do(ctx).
   142  		Error()
   143  }
   144  
   145  // DeleteCollection deletes a collection of objects.
   146  func (c *resourceSlices) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
   147  	var timeout time.Duration
   148  	if listOpts.TimeoutSeconds != nil {
   149  		timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
   150  	}
   151  	return c.client.Delete().
   152  		Resource("resourceslices").
   153  		VersionedParams(&listOpts, scheme.ParameterCodec).
   154  		Timeout(timeout).
   155  		Body(&opts).
   156  		Do(ctx).
   157  		Error()
   158  }
   159  
   160  // Patch applies the patch and returns the patched resourceSlice.
   161  func (c *resourceSlices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.ResourceSlice, err error) {
   162  	result = &v1alpha2.ResourceSlice{}
   163  	err = c.client.Patch(pt).
   164  		Resource("resourceslices").
   165  		Name(name).
   166  		SubResource(subresources...).
   167  		VersionedParams(&opts, scheme.ParameterCodec).
   168  		Body(data).
   169  		Do(ctx).
   170  		Into(result)
   171  	return
   172  }
   173  
   174  // Apply takes the given apply declarative configuration, applies it and returns the applied resourceSlice.
   175  func (c *resourceSlices) Apply(ctx context.Context, resourceSlice *resourcev1alpha2.ResourceSliceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.ResourceSlice, err error) {
   176  	if resourceSlice == nil {
   177  		return nil, fmt.Errorf("resourceSlice provided to Apply must not be nil")
   178  	}
   179  	patchOpts := opts.ToPatchOptions()
   180  	data, err := json.Marshal(resourceSlice)
   181  	if err != nil {
   182  		return nil, err
   183  	}
   184  	name := resourceSlice.Name
   185  	if name == nil {
   186  		return nil, fmt.Errorf("resourceSlice.Name must be provided to Apply")
   187  	}
   188  	result = &v1alpha2.ResourceSlice{}
   189  	err = c.client.Patch(types.ApplyPatchType).
   190  		Resource("resourceslices").
   191  		Name(*name).
   192  		VersionedParams(&patchOpts, scheme.ParameterCodec).
   193  		Body(data).
   194  		Do(ctx).
   195  		Into(result)
   196  	return
   197  }
   198  

View as plain text