github.com/kubearmor/cilium@v1.6.12/api/v1/server/restapi/policy/get_fqdn_cache_id_urlbuilder.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package policy
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the generate command
     7  
     8  import (
     9  	"errors"
    10  	"net/url"
    11  	golangswaggerpaths "path"
    12  	"strings"
    13  )
    14  
    15  // GetFqdnCacheIDURL generates an URL for the get fqdn cache ID operation
    16  type GetFqdnCacheIDURL struct {
    17  	ID string
    18  
    19  	Cidr         *string
    20  	Matchpattern *string
    21  
    22  	_basePath string
    23  	// avoid unkeyed usage
    24  	_ struct{}
    25  }
    26  
    27  // WithBasePath sets the base path for this url builder, only required when it's different from the
    28  // base path specified in the swagger spec.
    29  // When the value of the base path is an empty string
    30  func (o *GetFqdnCacheIDURL) WithBasePath(bp string) *GetFqdnCacheIDURL {
    31  	o.SetBasePath(bp)
    32  	return o
    33  }
    34  
    35  // SetBasePath sets the base path for this url builder, only required when it's different from the
    36  // base path specified in the swagger spec.
    37  // When the value of the base path is an empty string
    38  func (o *GetFqdnCacheIDURL) SetBasePath(bp string) {
    39  	o._basePath = bp
    40  }
    41  
    42  // Build a url path and query string
    43  func (o *GetFqdnCacheIDURL) Build() (*url.URL, error) {
    44  	var _result url.URL
    45  
    46  	var _path = "/fqdn/cache/{id}"
    47  
    48  	id := o.ID
    49  	if id != "" {
    50  		_path = strings.Replace(_path, "{id}", id, -1)
    51  	} else {
    52  		return nil, errors.New("id is required on GetFqdnCacheIDURL")
    53  	}
    54  
    55  	_basePath := o._basePath
    56  	if _basePath == "" {
    57  		_basePath = "/v1"
    58  	}
    59  	_result.Path = golangswaggerpaths.Join(_basePath, _path)
    60  
    61  	qs := make(url.Values)
    62  
    63  	var cidr string
    64  	if o.Cidr != nil {
    65  		cidr = *o.Cidr
    66  	}
    67  	if cidr != "" {
    68  		qs.Set("cidr", cidr)
    69  	}
    70  
    71  	var matchpattern string
    72  	if o.Matchpattern != nil {
    73  		matchpattern = *o.Matchpattern
    74  	}
    75  	if matchpattern != "" {
    76  		qs.Set("matchpattern", matchpattern)
    77  	}
    78  
    79  	_result.RawQuery = qs.Encode()
    80  
    81  	return &_result, nil
    82  }
    83  
    84  // Must is a helper function to panic when the url builder returns an error
    85  func (o *GetFqdnCacheIDURL) Must(u *url.URL, err error) *url.URL {
    86  	if err != nil {
    87  		panic(err)
    88  	}
    89  	if u == nil {
    90  		panic("url can't be nil")
    91  	}
    92  	return u
    93  }
    94  
    95  // String returns the string representation of the path with query string
    96  func (o *GetFqdnCacheIDURL) String() string {
    97  	return o.Must(o.Build()).String()
    98  }
    99  
   100  // BuildFull builds a full url with scheme, host, path and query string
   101  func (o *GetFqdnCacheIDURL) BuildFull(scheme, host string) (*url.URL, error) {
   102  	if scheme == "" {
   103  		return nil, errors.New("scheme is required for a full url on GetFqdnCacheIDURL")
   104  	}
   105  	if host == "" {
   106  		return nil, errors.New("host is required for a full url on GetFqdnCacheIDURL")
   107  	}
   108  
   109  	base, err := o.Build()
   110  	if err != nil {
   111  		return nil, err
   112  	}
   113  
   114  	base.Scheme = scheme
   115  	base.Host = host
   116  	return base, nil
   117  }
   118  
   119  // StringFull returns the string representation of a complete url
   120  func (o *GetFqdnCacheIDURL) StringFull(scheme, host string) string {
   121  	return o.Must(o.BuildFull(scheme, host)).String()
   122  }