github.com/cilium/cilium@v1.16.2/api/v1/server/restapi/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  	"net/http"
    13  
    14  	"github.com/go-openapi/errors"
    15  	"github.com/go-openapi/runtime"
    16  	"github.com/go-openapi/runtime/middleware"
    17  	"github.com/go-openapi/strfmt"
    18  )
    19  
    20  // NewGetFqdnCacheParams creates a new GetFqdnCacheParams object
    21  //
    22  // There are no default values defined in the spec.
    23  func NewGetFqdnCacheParams() GetFqdnCacheParams {
    24  
    25  	return GetFqdnCacheParams{}
    26  }
    27  
    28  // GetFqdnCacheParams contains all the bound params for the get fqdn cache operation
    29  // typically these are obtained from a http.Request
    30  //
    31  // swagger:parameters GetFqdnCache
    32  type GetFqdnCacheParams struct {
    33  
    34  	// HTTP Request Object
    35  	HTTPRequest *http.Request `json:"-"`
    36  
    37  	/*A CIDR range of IPs
    38  	  In: query
    39  	*/
    40  	Cidr *string
    41  	/*A toFQDNs compatible matchPattern expression
    42  	  In: query
    43  	*/
    44  	Matchpattern *string
    45  	/*Source from which FQDN entries come from
    46  	  In: query
    47  	*/
    48  	Source *string
    49  }
    50  
    51  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    52  // for simple values it will use straight method calls.
    53  //
    54  // To ensure default values, the struct must have been initialized with NewGetFqdnCacheParams() beforehand.
    55  func (o *GetFqdnCacheParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    56  	var res []error
    57  
    58  	o.HTTPRequest = r
    59  
    60  	qs := runtime.Values(r.URL.Query())
    61  
    62  	qCidr, qhkCidr, _ := qs.GetOK("cidr")
    63  	if err := o.bindCidr(qCidr, qhkCidr, route.Formats); err != nil {
    64  		res = append(res, err)
    65  	}
    66  
    67  	qMatchpattern, qhkMatchpattern, _ := qs.GetOK("matchpattern")
    68  	if err := o.bindMatchpattern(qMatchpattern, qhkMatchpattern, route.Formats); err != nil {
    69  		res = append(res, err)
    70  	}
    71  
    72  	qSource, qhkSource, _ := qs.GetOK("source")
    73  	if err := o.bindSource(qSource, qhkSource, route.Formats); err != nil {
    74  		res = append(res, err)
    75  	}
    76  	if len(res) > 0 {
    77  		return errors.CompositeValidationError(res...)
    78  	}
    79  	return nil
    80  }
    81  
    82  // bindCidr binds and validates parameter Cidr from query.
    83  func (o *GetFqdnCacheParams) bindCidr(rawData []string, hasKey bool, formats strfmt.Registry) error {
    84  	var raw string
    85  	if len(rawData) > 0 {
    86  		raw = rawData[len(rawData)-1]
    87  	}
    88  
    89  	// Required: false
    90  	// AllowEmptyValue: false
    91  
    92  	if raw == "" { // empty values pass all other validations
    93  		return nil
    94  	}
    95  	o.Cidr = &raw
    96  
    97  	return nil
    98  }
    99  
   100  // bindMatchpattern binds and validates parameter Matchpattern from query.
   101  func (o *GetFqdnCacheParams) bindMatchpattern(rawData []string, hasKey bool, formats strfmt.Registry) error {
   102  	var raw string
   103  	if len(rawData) > 0 {
   104  		raw = rawData[len(rawData)-1]
   105  	}
   106  
   107  	// Required: false
   108  	// AllowEmptyValue: false
   109  
   110  	if raw == "" { // empty values pass all other validations
   111  		return nil
   112  	}
   113  	o.Matchpattern = &raw
   114  
   115  	return nil
   116  }
   117  
   118  // bindSource binds and validates parameter Source from query.
   119  func (o *GetFqdnCacheParams) bindSource(rawData []string, hasKey bool, formats strfmt.Registry) error {
   120  	var raw string
   121  	if len(rawData) > 0 {
   122  		raw = rawData[len(rawData)-1]
   123  	}
   124  
   125  	// Required: false
   126  	// AllowEmptyValue: false
   127  
   128  	if raw == "" { // empty values pass all other validations
   129  		return nil
   130  	}
   131  	o.Source = &raw
   132  
   133  	return nil
   134  }