github.com/cilium/cilium@v1.16.2/api/v1/client/policy/get_policy_parameters.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // Copyright Authors of Cilium
     4  // SPDX-License-Identifier: Apache-2.0
     5  
     6  package policy
     7  
     8  // This file was generated by the swagger tool.
     9  // Editing this file might prove futile when you re-run the swagger generate command
    10  
    11  import (
    12  	"context"
    13  	"net/http"
    14  	"time"
    15  
    16  	"github.com/go-openapi/errors"
    17  	"github.com/go-openapi/runtime"
    18  	cr "github.com/go-openapi/runtime/client"
    19  	"github.com/go-openapi/strfmt"
    20  
    21  	"github.com/cilium/cilium/api/v1/models"
    22  )
    23  
    24  // NewGetPolicyParams creates a new GetPolicyParams object,
    25  // with the default timeout for this client.
    26  //
    27  // Default values are not hydrated, since defaults are normally applied by the API server side.
    28  //
    29  // To enforce default values in parameter, use SetDefaults or WithDefaults.
    30  func NewGetPolicyParams() *GetPolicyParams {
    31  	return &GetPolicyParams{
    32  		timeout: cr.DefaultTimeout,
    33  	}
    34  }
    35  
    36  // NewGetPolicyParamsWithTimeout creates a new GetPolicyParams object
    37  // with the ability to set a timeout on a request.
    38  func NewGetPolicyParamsWithTimeout(timeout time.Duration) *GetPolicyParams {
    39  	return &GetPolicyParams{
    40  		timeout: timeout,
    41  	}
    42  }
    43  
    44  // NewGetPolicyParamsWithContext creates a new GetPolicyParams object
    45  // with the ability to set a context for a request.
    46  func NewGetPolicyParamsWithContext(ctx context.Context) *GetPolicyParams {
    47  	return &GetPolicyParams{
    48  		Context: ctx,
    49  	}
    50  }
    51  
    52  // NewGetPolicyParamsWithHTTPClient creates a new GetPolicyParams object
    53  // with the ability to set a custom HTTPClient for a request.
    54  func NewGetPolicyParamsWithHTTPClient(client *http.Client) *GetPolicyParams {
    55  	return &GetPolicyParams{
    56  		HTTPClient: client,
    57  	}
    58  }
    59  
    60  /*
    61  GetPolicyParams contains all the parameters to send to the API endpoint
    62  
    63  	for the get policy operation.
    64  
    65  	Typically these are written to a http.Request.
    66  */
    67  type GetPolicyParams struct {
    68  
    69  	// Labels.
    70  	Labels models.Labels
    71  
    72  	timeout    time.Duration
    73  	Context    context.Context
    74  	HTTPClient *http.Client
    75  }
    76  
    77  // WithDefaults hydrates default values in the get policy params (not the query body).
    78  //
    79  // All values with no default are reset to their zero value.
    80  func (o *GetPolicyParams) WithDefaults() *GetPolicyParams {
    81  	o.SetDefaults()
    82  	return o
    83  }
    84  
    85  // SetDefaults hydrates default values in the get policy params (not the query body).
    86  //
    87  // All values with no default are reset to their zero value.
    88  func (o *GetPolicyParams) SetDefaults() {
    89  	// no default values defined for this parameter
    90  }
    91  
    92  // WithTimeout adds the timeout to the get policy params
    93  func (o *GetPolicyParams) WithTimeout(timeout time.Duration) *GetPolicyParams {
    94  	o.SetTimeout(timeout)
    95  	return o
    96  }
    97  
    98  // SetTimeout adds the timeout to the get policy params
    99  func (o *GetPolicyParams) SetTimeout(timeout time.Duration) {
   100  	o.timeout = timeout
   101  }
   102  
   103  // WithContext adds the context to the get policy params
   104  func (o *GetPolicyParams) WithContext(ctx context.Context) *GetPolicyParams {
   105  	o.SetContext(ctx)
   106  	return o
   107  }
   108  
   109  // SetContext adds the context to the get policy params
   110  func (o *GetPolicyParams) SetContext(ctx context.Context) {
   111  	o.Context = ctx
   112  }
   113  
   114  // WithHTTPClient adds the HTTPClient to the get policy params
   115  func (o *GetPolicyParams) WithHTTPClient(client *http.Client) *GetPolicyParams {
   116  	o.SetHTTPClient(client)
   117  	return o
   118  }
   119  
   120  // SetHTTPClient adds the HTTPClient to the get policy params
   121  func (o *GetPolicyParams) SetHTTPClient(client *http.Client) {
   122  	o.HTTPClient = client
   123  }
   124  
   125  // WithLabels adds the labels to the get policy params
   126  func (o *GetPolicyParams) WithLabels(labels models.Labels) *GetPolicyParams {
   127  	o.SetLabels(labels)
   128  	return o
   129  }
   130  
   131  // SetLabels adds the labels to the get policy params
   132  func (o *GetPolicyParams) SetLabels(labels models.Labels) {
   133  	o.Labels = labels
   134  }
   135  
   136  // WriteToRequest writes these params to a swagger request
   137  func (o *GetPolicyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   138  
   139  	if err := r.SetTimeout(o.timeout); err != nil {
   140  		return err
   141  	}
   142  	var res []error
   143  	if o.Labels != nil {
   144  		if err := r.SetBodyParam(o.Labels); err != nil {
   145  			return err
   146  		}
   147  	}
   148  
   149  	if len(res) > 0 {
   150  		return errors.CompositeValidationError(res...)
   151  	}
   152  	return nil
   153  }