k8s.io/client-go@v0.31.1/kubernetes/typed/extensions/v1beta1/deployment.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  // DeploymentsGetter has a method to return a DeploymentInterface.
    36  // A group's client should implement this interface.
    37  type DeploymentsGetter interface {
    38  	Deployments(namespace string) DeploymentInterface
    39  }
    40  
    41  // DeploymentInterface has methods to work with Deployment resources.
    42  type DeploymentInterface interface {
    43  	Create(ctx context.Context, deployment *v1beta1.Deployment, opts v1.CreateOptions) (*v1beta1.Deployment, error)
    44  	Update(ctx context.Context, deployment *v1beta1.Deployment, opts v1.UpdateOptions) (*v1beta1.Deployment, error)
    45  	// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
    46  	UpdateStatus(ctx context.Context, deployment *v1beta1.Deployment, opts v1.UpdateOptions) (*v1beta1.Deployment, 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.Deployment, error)
    50  	List(ctx context.Context, opts v1.ListOptions) (*v1beta1.DeploymentList, 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.Deployment, err error)
    53  	Apply(ctx context.Context, deployment *extensionsv1beta1.DeploymentApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.Deployment, err error)
    54  	// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
    55  	ApplyStatus(ctx context.Context, deployment *extensionsv1beta1.DeploymentApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.Deployment, err error)
    56  	GetScale(ctx context.Context, deploymentName string, options v1.GetOptions) (*v1beta1.Scale, error)
    57  	UpdateScale(ctx context.Context, deploymentName string, scale *v1beta1.Scale, opts v1.UpdateOptions) (*v1beta1.Scale, error)
    58  	ApplyScale(ctx context.Context, deploymentName string, scale *extensionsv1beta1.ScaleApplyConfiguration, opts v1.ApplyOptions) (*v1beta1.Scale, error)
    59  
    60  	DeploymentExpansion
    61  }
    62  
    63  // deployments implements DeploymentInterface
    64  type deployments struct {
    65  	*gentype.ClientWithListAndApply[*v1beta1.Deployment, *v1beta1.DeploymentList, *extensionsv1beta1.DeploymentApplyConfiguration]
    66  }
    67  
    68  // newDeployments returns a Deployments
    69  func newDeployments(c *ExtensionsV1beta1Client, namespace string) *deployments {
    70  	return &deployments{
    71  		gentype.NewClientWithListAndApply[*v1beta1.Deployment, *v1beta1.DeploymentList, *extensionsv1beta1.DeploymentApplyConfiguration](
    72  			"deployments",
    73  			c.RESTClient(),
    74  			scheme.ParameterCodec,
    75  			namespace,
    76  			func() *v1beta1.Deployment { return &v1beta1.Deployment{} },
    77  			func() *v1beta1.DeploymentList { return &v1beta1.DeploymentList{} }),
    78  	}
    79  }
    80  
    81  // GetScale takes name of the deployment, and returns the corresponding v1beta1.Scale object, and an error if there is any.
    82  func (c *deployments) GetScale(ctx context.Context, deploymentName string, options v1.GetOptions) (result *v1beta1.Scale, err error) {
    83  	result = &v1beta1.Scale{}
    84  	err = c.GetClient().Get().
    85  		Namespace(c.GetNamespace()).
    86  		Resource("deployments").
    87  		Name(deploymentName).
    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 *deployments) UpdateScale(ctx context.Context, deploymentName 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("deployments").
   101  		Name(deploymentName).
   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 *deployments) ApplyScale(ctx context.Context, deploymentName 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("deployments").
   126  		Name(deploymentName).
   127  		SubResource("scale").
   128  		VersionedParams(&patchOpts, scheme.ParameterCodec).
   129  		Body(data).
   130  		Do(ctx).
   131  		Into(result)
   132  	return
   133  }