github.com/cilium/cilium@v1.16.2/api/v1/client/ipam/post_ipam_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 ipam
     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  	"github.com/go-openapi/swag"
    21  )
    22  
    23  // NewPostIpamParams creates a new PostIpamParams object,
    24  // with the default timeout for this client.
    25  //
    26  // Default values are not hydrated, since defaults are normally applied by the API server side.
    27  //
    28  // To enforce default values in parameter, use SetDefaults or WithDefaults.
    29  func NewPostIpamParams() *PostIpamParams {
    30  	return &PostIpamParams{
    31  		timeout: cr.DefaultTimeout,
    32  	}
    33  }
    34  
    35  // NewPostIpamParamsWithTimeout creates a new PostIpamParams object
    36  // with the ability to set a timeout on a request.
    37  func NewPostIpamParamsWithTimeout(timeout time.Duration) *PostIpamParams {
    38  	return &PostIpamParams{
    39  		timeout: timeout,
    40  	}
    41  }
    42  
    43  // NewPostIpamParamsWithContext creates a new PostIpamParams object
    44  // with the ability to set a context for a request.
    45  func NewPostIpamParamsWithContext(ctx context.Context) *PostIpamParams {
    46  	return &PostIpamParams{
    47  		Context: ctx,
    48  	}
    49  }
    50  
    51  // NewPostIpamParamsWithHTTPClient creates a new PostIpamParams object
    52  // with the ability to set a custom HTTPClient for a request.
    53  func NewPostIpamParamsWithHTTPClient(client *http.Client) *PostIpamParams {
    54  	return &PostIpamParams{
    55  		HTTPClient: client,
    56  	}
    57  }
    58  
    59  /*
    60  PostIpamParams contains all the parameters to send to the API endpoint
    61  
    62  	for the post ipam operation.
    63  
    64  	Typically these are written to a http.Request.
    65  */
    66  type PostIpamParams struct {
    67  
    68  	// Expiration.
    69  	Expiration *bool
    70  
    71  	// Family.
    72  	Family *string
    73  
    74  	// Owner.
    75  	Owner *string
    76  
    77  	// Pool.
    78  	Pool *string
    79  
    80  	timeout    time.Duration
    81  	Context    context.Context
    82  	HTTPClient *http.Client
    83  }
    84  
    85  // WithDefaults hydrates default values in the post ipam params (not the query body).
    86  //
    87  // All values with no default are reset to their zero value.
    88  func (o *PostIpamParams) WithDefaults() *PostIpamParams {
    89  	o.SetDefaults()
    90  	return o
    91  }
    92  
    93  // SetDefaults hydrates default values in the post ipam params (not the query body).
    94  //
    95  // All values with no default are reset to their zero value.
    96  func (o *PostIpamParams) SetDefaults() {
    97  	// no default values defined for this parameter
    98  }
    99  
   100  // WithTimeout adds the timeout to the post ipam params
   101  func (o *PostIpamParams) WithTimeout(timeout time.Duration) *PostIpamParams {
   102  	o.SetTimeout(timeout)
   103  	return o
   104  }
   105  
   106  // SetTimeout adds the timeout to the post ipam params
   107  func (o *PostIpamParams) SetTimeout(timeout time.Duration) {
   108  	o.timeout = timeout
   109  }
   110  
   111  // WithContext adds the context to the post ipam params
   112  func (o *PostIpamParams) WithContext(ctx context.Context) *PostIpamParams {
   113  	o.SetContext(ctx)
   114  	return o
   115  }
   116  
   117  // SetContext adds the context to the post ipam params
   118  func (o *PostIpamParams) SetContext(ctx context.Context) {
   119  	o.Context = ctx
   120  }
   121  
   122  // WithHTTPClient adds the HTTPClient to the post ipam params
   123  func (o *PostIpamParams) WithHTTPClient(client *http.Client) *PostIpamParams {
   124  	o.SetHTTPClient(client)
   125  	return o
   126  }
   127  
   128  // SetHTTPClient adds the HTTPClient to the post ipam params
   129  func (o *PostIpamParams) SetHTTPClient(client *http.Client) {
   130  	o.HTTPClient = client
   131  }
   132  
   133  // WithExpiration adds the expiration to the post ipam params
   134  func (o *PostIpamParams) WithExpiration(expiration *bool) *PostIpamParams {
   135  	o.SetExpiration(expiration)
   136  	return o
   137  }
   138  
   139  // SetExpiration adds the expiration to the post ipam params
   140  func (o *PostIpamParams) SetExpiration(expiration *bool) {
   141  	o.Expiration = expiration
   142  }
   143  
   144  // WithFamily adds the family to the post ipam params
   145  func (o *PostIpamParams) WithFamily(family *string) *PostIpamParams {
   146  	o.SetFamily(family)
   147  	return o
   148  }
   149  
   150  // SetFamily adds the family to the post ipam params
   151  func (o *PostIpamParams) SetFamily(family *string) {
   152  	o.Family = family
   153  }
   154  
   155  // WithOwner adds the owner to the post ipam params
   156  func (o *PostIpamParams) WithOwner(owner *string) *PostIpamParams {
   157  	o.SetOwner(owner)
   158  	return o
   159  }
   160  
   161  // SetOwner adds the owner to the post ipam params
   162  func (o *PostIpamParams) SetOwner(owner *string) {
   163  	o.Owner = owner
   164  }
   165  
   166  // WithPool adds the pool to the post ipam params
   167  func (o *PostIpamParams) WithPool(pool *string) *PostIpamParams {
   168  	o.SetPool(pool)
   169  	return o
   170  }
   171  
   172  // SetPool adds the pool to the post ipam params
   173  func (o *PostIpamParams) SetPool(pool *string) {
   174  	o.Pool = pool
   175  }
   176  
   177  // WriteToRequest writes these params to a swagger request
   178  func (o *PostIpamParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   179  
   180  	if err := r.SetTimeout(o.timeout); err != nil {
   181  		return err
   182  	}
   183  	var res []error
   184  
   185  	if o.Expiration != nil {
   186  
   187  		// header param expiration
   188  		if err := r.SetHeaderParam("expiration", swag.FormatBool(*o.Expiration)); err != nil {
   189  			return err
   190  		}
   191  	}
   192  
   193  	if o.Family != nil {
   194  
   195  		// query param family
   196  		var qrFamily string
   197  
   198  		if o.Family != nil {
   199  			qrFamily = *o.Family
   200  		}
   201  		qFamily := qrFamily
   202  		if qFamily != "" {
   203  
   204  			if err := r.SetQueryParam("family", qFamily); err != nil {
   205  				return err
   206  			}
   207  		}
   208  	}
   209  
   210  	if o.Owner != nil {
   211  
   212  		// query param owner
   213  		var qrOwner string
   214  
   215  		if o.Owner != nil {
   216  			qrOwner = *o.Owner
   217  		}
   218  		qOwner := qrOwner
   219  		if qOwner != "" {
   220  
   221  			if err := r.SetQueryParam("owner", qOwner); err != nil {
   222  				return err
   223  			}
   224  		}
   225  	}
   226  
   227  	if o.Pool != nil {
   228  
   229  		// query param pool
   230  		var qrPool string
   231  
   232  		if o.Pool != nil {
   233  			qrPool = *o.Pool
   234  		}
   235  		qPool := qrPool
   236  		if qPool != "" {
   237  
   238  			if err := r.SetQueryParam("pool", qPool); err != nil {
   239  				return err
   240  			}
   241  		}
   242  	}
   243  
   244  	if len(res) > 0 {
   245  		return errors.CompositeValidationError(res...)
   246  	}
   247  	return nil
   248  }