github.com/cilium/cilium@v1.16.2/api/v1/client/policy/get_fqdn_cache_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  // NewGetFqdnCacheParams creates a new GetFqdnCacheParams 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 NewGetFqdnCacheParams() *GetFqdnCacheParams {
    29  	return &GetFqdnCacheParams{
    30  		timeout: cr.DefaultTimeout,
    31  	}
    32  }
    33  
    34  // NewGetFqdnCacheParamsWithTimeout creates a new GetFqdnCacheParams object
    35  // with the ability to set a timeout on a request.
    36  func NewGetFqdnCacheParamsWithTimeout(timeout time.Duration) *GetFqdnCacheParams {
    37  	return &GetFqdnCacheParams{
    38  		timeout: timeout,
    39  	}
    40  }
    41  
    42  // NewGetFqdnCacheParamsWithContext creates a new GetFqdnCacheParams object
    43  // with the ability to set a context for a request.
    44  func NewGetFqdnCacheParamsWithContext(ctx context.Context) *GetFqdnCacheParams {
    45  	return &GetFqdnCacheParams{
    46  		Context: ctx,
    47  	}
    48  }
    49  
    50  // NewGetFqdnCacheParamsWithHTTPClient creates a new GetFqdnCacheParams object
    51  // with the ability to set a custom HTTPClient for a request.
    52  func NewGetFqdnCacheParamsWithHTTPClient(client *http.Client) *GetFqdnCacheParams {
    53  	return &GetFqdnCacheParams{
    54  		HTTPClient: client,
    55  	}
    56  }
    57  
    58  /*
    59  GetFqdnCacheParams contains all the parameters to send to the API endpoint
    60  
    61  	for the get fqdn cache operation.
    62  
    63  	Typically these are written to a http.Request.
    64  */
    65  type GetFqdnCacheParams struct {
    66  
    67  	/* Cidr.
    68  
    69  	   A CIDR range of IPs
    70  	*/
    71  	Cidr *string
    72  
    73  	/* Matchpattern.
    74  
    75  	   A toFQDNs compatible matchPattern expression
    76  	*/
    77  	Matchpattern *string
    78  
    79  	/* Source.
    80  
    81  	   Source from which FQDN entries come from
    82  	*/
    83  	Source *string
    84  
    85  	timeout    time.Duration
    86  	Context    context.Context
    87  	HTTPClient *http.Client
    88  }
    89  
    90  // WithDefaults hydrates default values in the get fqdn cache params (not the query body).
    91  //
    92  // All values with no default are reset to their zero value.
    93  func (o *GetFqdnCacheParams) WithDefaults() *GetFqdnCacheParams {
    94  	o.SetDefaults()
    95  	return o
    96  }
    97  
    98  // SetDefaults hydrates default values in the get fqdn cache params (not the query body).
    99  //
   100  // All values with no default are reset to their zero value.
   101  func (o *GetFqdnCacheParams) SetDefaults() {
   102  	// no default values defined for this parameter
   103  }
   104  
   105  // WithTimeout adds the timeout to the get fqdn cache params
   106  func (o *GetFqdnCacheParams) WithTimeout(timeout time.Duration) *GetFqdnCacheParams {
   107  	o.SetTimeout(timeout)
   108  	return o
   109  }
   110  
   111  // SetTimeout adds the timeout to the get fqdn cache params
   112  func (o *GetFqdnCacheParams) SetTimeout(timeout time.Duration) {
   113  	o.timeout = timeout
   114  }
   115  
   116  // WithContext adds the context to the get fqdn cache params
   117  func (o *GetFqdnCacheParams) WithContext(ctx context.Context) *GetFqdnCacheParams {
   118  	o.SetContext(ctx)
   119  	return o
   120  }
   121  
   122  // SetContext adds the context to the get fqdn cache params
   123  func (o *GetFqdnCacheParams) SetContext(ctx context.Context) {
   124  	o.Context = ctx
   125  }
   126  
   127  // WithHTTPClient adds the HTTPClient to the get fqdn cache params
   128  func (o *GetFqdnCacheParams) WithHTTPClient(client *http.Client) *GetFqdnCacheParams {
   129  	o.SetHTTPClient(client)
   130  	return o
   131  }
   132  
   133  // SetHTTPClient adds the HTTPClient to the get fqdn cache params
   134  func (o *GetFqdnCacheParams) SetHTTPClient(client *http.Client) {
   135  	o.HTTPClient = client
   136  }
   137  
   138  // WithCidr adds the cidr to the get fqdn cache params
   139  func (o *GetFqdnCacheParams) WithCidr(cidr *string) *GetFqdnCacheParams {
   140  	o.SetCidr(cidr)
   141  	return o
   142  }
   143  
   144  // SetCidr adds the cidr to the get fqdn cache params
   145  func (o *GetFqdnCacheParams) SetCidr(cidr *string) {
   146  	o.Cidr = cidr
   147  }
   148  
   149  // WithMatchpattern adds the matchpattern to the get fqdn cache params
   150  func (o *GetFqdnCacheParams) WithMatchpattern(matchpattern *string) *GetFqdnCacheParams {
   151  	o.SetMatchpattern(matchpattern)
   152  	return o
   153  }
   154  
   155  // SetMatchpattern adds the matchpattern to the get fqdn cache params
   156  func (o *GetFqdnCacheParams) SetMatchpattern(matchpattern *string) {
   157  	o.Matchpattern = matchpattern
   158  }
   159  
   160  // WithSource adds the source to the get fqdn cache params
   161  func (o *GetFqdnCacheParams) WithSource(source *string) *GetFqdnCacheParams {
   162  	o.SetSource(source)
   163  	return o
   164  }
   165  
   166  // SetSource adds the source to the get fqdn cache params
   167  func (o *GetFqdnCacheParams) SetSource(source *string) {
   168  	o.Source = source
   169  }
   170  
   171  // WriteToRequest writes these params to a swagger request
   172  func (o *GetFqdnCacheParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   173  
   174  	if err := r.SetTimeout(o.timeout); err != nil {
   175  		return err
   176  	}
   177  	var res []error
   178  
   179  	if o.Cidr != nil {
   180  
   181  		// query param cidr
   182  		var qrCidr string
   183  
   184  		if o.Cidr != nil {
   185  			qrCidr = *o.Cidr
   186  		}
   187  		qCidr := qrCidr
   188  		if qCidr != "" {
   189  
   190  			if err := r.SetQueryParam("cidr", qCidr); err != nil {
   191  				return err
   192  			}
   193  		}
   194  	}
   195  
   196  	if o.Matchpattern != nil {
   197  
   198  		// query param matchpattern
   199  		var qrMatchpattern string
   200  
   201  		if o.Matchpattern != nil {
   202  			qrMatchpattern = *o.Matchpattern
   203  		}
   204  		qMatchpattern := qrMatchpattern
   205  		if qMatchpattern != "" {
   206  
   207  			if err := r.SetQueryParam("matchpattern", qMatchpattern); err != nil {
   208  				return err
   209  			}
   210  		}
   211  	}
   212  
   213  	if o.Source != nil {
   214  
   215  		// query param source
   216  		var qrSource string
   217  
   218  		if o.Source != nil {
   219  			qrSource = *o.Source
   220  		}
   221  		qSource := qrSource
   222  		if qSource != "" {
   223  
   224  			if err := r.SetQueryParam("source", qSource); err != nil {
   225  				return err
   226  			}
   227  		}
   228  	}
   229  
   230  	if len(res) > 0 {
   231  		return errors.CompositeValidationError(res...)
   232  	}
   233  	return nil
   234  }