github.com/cilium/cilium@v1.16.2/api/v1/client/policy/get_ip_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  
    22  // NewGetIPParams creates a new GetIPParams object,
    23  // with the default timeout for this client.
    24  //
    25  // Default values are not hydrated, since defaults are normally applied by the API server side.
    26  //
    27  // To enforce default values in parameter, use SetDefaults or WithDefaults.
    28  func NewGetIPParams() *GetIPParams {
    29  	return &GetIPParams{
    30  		timeout: cr.DefaultTimeout,
    31  	}
    32  }
    33  
    34  // NewGetIPParamsWithTimeout creates a new GetIPParams object
    35  // with the ability to set a timeout on a request.
    36  func NewGetIPParamsWithTimeout(timeout time.Duration) *GetIPParams {
    37  	return &GetIPParams{
    38  		timeout: timeout,
    39  	}
    40  }
    41  
    42  // NewGetIPParamsWithContext creates a new GetIPParams object
    43  // with the ability to set a context for a request.
    44  func NewGetIPParamsWithContext(ctx context.Context) *GetIPParams {
    45  	return &GetIPParams{
    46  		Context: ctx,
    47  	}
    48  }
    49  
    50  // NewGetIPParamsWithHTTPClient creates a new GetIPParams object
    51  // with the ability to set a custom HTTPClient for a request.
    52  func NewGetIPParamsWithHTTPClient(client *http.Client) *GetIPParams {
    53  	return &GetIPParams{
    54  		HTTPClient: client,
    55  	}
    56  }
    57  
    58  /*
    59  GetIPParams contains all the parameters to send to the API endpoint
    60  
    61  	for the get IP operation.
    62  
    63  	Typically these are written to a http.Request.
    64  */
    65  type GetIPParams struct {
    66  
    67  	/* Cidr.
    68  
    69  	   A CIDR range of IPs
    70  	*/
    71  	Cidr *string
    72  
    73  	timeout    time.Duration
    74  	Context    context.Context
    75  	HTTPClient *http.Client
    76  }
    77  
    78  // WithDefaults hydrates default values in the get IP params (not the query body).
    79  //
    80  // All values with no default are reset to their zero value.
    81  func (o *GetIPParams) WithDefaults() *GetIPParams {
    82  	o.SetDefaults()
    83  	return o
    84  }
    85  
    86  // SetDefaults hydrates default values in the get IP params (not the query body).
    87  //
    88  // All values with no default are reset to their zero value.
    89  func (o *GetIPParams) SetDefaults() {
    90  	// no default values defined for this parameter
    91  }
    92  
    93  // WithTimeout adds the timeout to the get IP params
    94  func (o *GetIPParams) WithTimeout(timeout time.Duration) *GetIPParams {
    95  	o.SetTimeout(timeout)
    96  	return o
    97  }
    98  
    99  // SetTimeout adds the timeout to the get IP params
   100  func (o *GetIPParams) SetTimeout(timeout time.Duration) {
   101  	o.timeout = timeout
   102  }
   103  
   104  // WithContext adds the context to the get IP params
   105  func (o *GetIPParams) WithContext(ctx context.Context) *GetIPParams {
   106  	o.SetContext(ctx)
   107  	return o
   108  }
   109  
   110  // SetContext adds the context to the get IP params
   111  func (o *GetIPParams) SetContext(ctx context.Context) {
   112  	o.Context = ctx
   113  }
   114  
   115  // WithHTTPClient adds the HTTPClient to the get IP params
   116  func (o *GetIPParams) WithHTTPClient(client *http.Client) *GetIPParams {
   117  	o.SetHTTPClient(client)
   118  	return o
   119  }
   120  
   121  // SetHTTPClient adds the HTTPClient to the get IP params
   122  func (o *GetIPParams) SetHTTPClient(client *http.Client) {
   123  	o.HTTPClient = client
   124  }
   125  
   126  // WithCidr adds the cidr to the get IP params
   127  func (o *GetIPParams) WithCidr(cidr *string) *GetIPParams {
   128  	o.SetCidr(cidr)
   129  	return o
   130  }
   131  
   132  // SetCidr adds the cidr to the get IP params
   133  func (o *GetIPParams) SetCidr(cidr *string) {
   134  	o.Cidr = cidr
   135  }
   136  
   137  // WriteToRequest writes these params to a swagger request
   138  func (o *GetIPParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   139  
   140  	if err := r.SetTimeout(o.timeout); err != nil {
   141  		return err
   142  	}
   143  	var res []error
   144  
   145  	if o.Cidr != nil {
   146  
   147  		// query param cidr
   148  		var qrCidr string
   149  
   150  		if o.Cidr != nil {
   151  			qrCidr = *o.Cidr
   152  		}
   153  		qCidr := qrCidr
   154  		if qCidr != "" {
   155  
   156  			if err := r.SetQueryParam("cidr", qCidr); err != nil {
   157  				return err
   158  			}
   159  		}
   160  	}
   161  
   162  	if len(res) > 0 {
   163  		return errors.CompositeValidationError(res...)
   164  	}
   165  	return nil
   166  }