github.com/cilium/cilium@v1.16.2/api/v1/client/ipam/post_ipam_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 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  )
    21  
    22  // NewPostIpamIPParams creates a new PostIpamIPParams 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 NewPostIpamIPParams() *PostIpamIPParams {
    29  	return &PostIpamIPParams{
    30  		timeout: cr.DefaultTimeout,
    31  	}
    32  }
    33  
    34  // NewPostIpamIPParamsWithTimeout creates a new PostIpamIPParams object
    35  // with the ability to set a timeout on a request.
    36  func NewPostIpamIPParamsWithTimeout(timeout time.Duration) *PostIpamIPParams {
    37  	return &PostIpamIPParams{
    38  		timeout: timeout,
    39  	}
    40  }
    41  
    42  // NewPostIpamIPParamsWithContext creates a new PostIpamIPParams object
    43  // with the ability to set a context for a request.
    44  func NewPostIpamIPParamsWithContext(ctx context.Context) *PostIpamIPParams {
    45  	return &PostIpamIPParams{
    46  		Context: ctx,
    47  	}
    48  }
    49  
    50  // NewPostIpamIPParamsWithHTTPClient creates a new PostIpamIPParams object
    51  // with the ability to set a custom HTTPClient for a request.
    52  func NewPostIpamIPParamsWithHTTPClient(client *http.Client) *PostIpamIPParams {
    53  	return &PostIpamIPParams{
    54  		HTTPClient: client,
    55  	}
    56  }
    57  
    58  /*
    59  PostIpamIPParams contains all the parameters to send to the API endpoint
    60  
    61  	for the post ipam IP operation.
    62  
    63  	Typically these are written to a http.Request.
    64  */
    65  type PostIpamIPParams struct {
    66  
    67  	/* IP.
    68  
    69  	   IP address
    70  	*/
    71  	IP string
    72  
    73  	// Owner.
    74  	Owner *string
    75  
    76  	// Pool.
    77  	Pool *string
    78  
    79  	timeout    time.Duration
    80  	Context    context.Context
    81  	HTTPClient *http.Client
    82  }
    83  
    84  // WithDefaults hydrates default values in the post ipam IP params (not the query body).
    85  //
    86  // All values with no default are reset to their zero value.
    87  func (o *PostIpamIPParams) WithDefaults() *PostIpamIPParams {
    88  	o.SetDefaults()
    89  	return o
    90  }
    91  
    92  // SetDefaults hydrates default values in the post ipam IP params (not the query body).
    93  //
    94  // All values with no default are reset to their zero value.
    95  func (o *PostIpamIPParams) SetDefaults() {
    96  	// no default values defined for this parameter
    97  }
    98  
    99  // WithTimeout adds the timeout to the post ipam IP params
   100  func (o *PostIpamIPParams) WithTimeout(timeout time.Duration) *PostIpamIPParams {
   101  	o.SetTimeout(timeout)
   102  	return o
   103  }
   104  
   105  // SetTimeout adds the timeout to the post ipam IP params
   106  func (o *PostIpamIPParams) SetTimeout(timeout time.Duration) {
   107  	o.timeout = timeout
   108  }
   109  
   110  // WithContext adds the context to the post ipam IP params
   111  func (o *PostIpamIPParams) WithContext(ctx context.Context) *PostIpamIPParams {
   112  	o.SetContext(ctx)
   113  	return o
   114  }
   115  
   116  // SetContext adds the context to the post ipam IP params
   117  func (o *PostIpamIPParams) SetContext(ctx context.Context) {
   118  	o.Context = ctx
   119  }
   120  
   121  // WithHTTPClient adds the HTTPClient to the post ipam IP params
   122  func (o *PostIpamIPParams) WithHTTPClient(client *http.Client) *PostIpamIPParams {
   123  	o.SetHTTPClient(client)
   124  	return o
   125  }
   126  
   127  // SetHTTPClient adds the HTTPClient to the post ipam IP params
   128  func (o *PostIpamIPParams) SetHTTPClient(client *http.Client) {
   129  	o.HTTPClient = client
   130  }
   131  
   132  // WithIP adds the ip to the post ipam IP params
   133  func (o *PostIpamIPParams) WithIP(ip string) *PostIpamIPParams {
   134  	o.SetIP(ip)
   135  	return o
   136  }
   137  
   138  // SetIP adds the ip to the post ipam IP params
   139  func (o *PostIpamIPParams) SetIP(ip string) {
   140  	o.IP = ip
   141  }
   142  
   143  // WithOwner adds the owner to the post ipam IP params
   144  func (o *PostIpamIPParams) WithOwner(owner *string) *PostIpamIPParams {
   145  	o.SetOwner(owner)
   146  	return o
   147  }
   148  
   149  // SetOwner adds the owner to the post ipam IP params
   150  func (o *PostIpamIPParams) SetOwner(owner *string) {
   151  	o.Owner = owner
   152  }
   153  
   154  // WithPool adds the pool to the post ipam IP params
   155  func (o *PostIpamIPParams) WithPool(pool *string) *PostIpamIPParams {
   156  	o.SetPool(pool)
   157  	return o
   158  }
   159  
   160  // SetPool adds the pool to the post ipam IP params
   161  func (o *PostIpamIPParams) SetPool(pool *string) {
   162  	o.Pool = pool
   163  }
   164  
   165  // WriteToRequest writes these params to a swagger request
   166  func (o *PostIpamIPParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   167  
   168  	if err := r.SetTimeout(o.timeout); err != nil {
   169  		return err
   170  	}
   171  	var res []error
   172  
   173  	// path param ip
   174  	if err := r.SetPathParam("ip", o.IP); err != nil {
   175  		return err
   176  	}
   177  
   178  	if o.Owner != nil {
   179  
   180  		// query param owner
   181  		var qrOwner string
   182  
   183  		if o.Owner != nil {
   184  			qrOwner = *o.Owner
   185  		}
   186  		qOwner := qrOwner
   187  		if qOwner != "" {
   188  
   189  			if err := r.SetQueryParam("owner", qOwner); err != nil {
   190  				return err
   191  			}
   192  		}
   193  	}
   194  
   195  	if o.Pool != nil {
   196  
   197  		// query param pool
   198  		var qrPool string
   199  
   200  		if o.Pool != nil {
   201  			qrPool = *o.Pool
   202  		}
   203  		qPool := qrPool
   204  		if qPool != "" {
   205  
   206  			if err := r.SetQueryParam("pool", qPool); err != nil {
   207  				return err
   208  			}
   209  		}
   210  	}
   211  
   212  	if len(res) > 0 {
   213  		return errors.CompositeValidationError(res...)
   214  	}
   215  	return nil
   216  }