...

Source file src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1/flowschema.go

Documentation: k8s.io/client-go/kubernetes/typed/flowcontrol/v1

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

View as plain text