github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/todo-list-strict/client/todos/add_one_parameters.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package todos
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"context"
    10  	"net/http"
    11  	"time"
    12  
    13  	"github.com/go-openapi/errors"
    14  	"github.com/go-openapi/runtime"
    15  	cr "github.com/go-openapi/runtime/client"
    16  	"github.com/go-openapi/strfmt"
    17  
    18  	"github.com/thetreep/go-swagger/examples/todo-list/models"
    19  )
    20  
    21  // NewAddOneParams creates a new AddOneParams object
    22  // with the default values initialized.
    23  func NewAddOneParams() *AddOneParams {
    24  	var ()
    25  	return &AddOneParams{
    26  
    27  		timeout: cr.DefaultTimeout,
    28  	}
    29  }
    30  
    31  // NewAddOneParamsWithTimeout creates a new AddOneParams object
    32  // with the default values initialized, and the ability to set a timeout on a request
    33  func NewAddOneParamsWithTimeout(timeout time.Duration) *AddOneParams {
    34  	var ()
    35  	return &AddOneParams{
    36  
    37  		timeout: timeout,
    38  	}
    39  }
    40  
    41  // NewAddOneParamsWithContext creates a new AddOneParams object
    42  // with the default values initialized, and the ability to set a context for a request
    43  func NewAddOneParamsWithContext(ctx context.Context) *AddOneParams {
    44  	var ()
    45  	return &AddOneParams{
    46  
    47  		Context: ctx,
    48  	}
    49  }
    50  
    51  // NewAddOneParamsWithHTTPClient creates a new AddOneParams object
    52  // with the default values initialized, and the ability to set a custom HTTPClient for a request
    53  func NewAddOneParamsWithHTTPClient(client *http.Client) *AddOneParams {
    54  	var ()
    55  	return &AddOneParams{
    56  		HTTPClient: client,
    57  	}
    58  }
    59  
    60  /*
    61  AddOneParams contains all the parameters to send to the API endpoint
    62  for the add one operation typically these are written to a http.Request
    63  */
    64  type AddOneParams struct {
    65  
    66  	/*Body*/
    67  	Body *models.Item
    68  
    69  	timeout    time.Duration
    70  	Context    context.Context
    71  	HTTPClient *http.Client
    72  }
    73  
    74  // WithTimeout adds the timeout to the add one params
    75  func (o *AddOneParams) WithTimeout(timeout time.Duration) *AddOneParams {
    76  	o.SetTimeout(timeout)
    77  	return o
    78  }
    79  
    80  // SetTimeout adds the timeout to the add one params
    81  func (o *AddOneParams) SetTimeout(timeout time.Duration) {
    82  	o.timeout = timeout
    83  }
    84  
    85  // WithContext adds the context to the add one params
    86  func (o *AddOneParams) WithContext(ctx context.Context) *AddOneParams {
    87  	o.SetContext(ctx)
    88  	return o
    89  }
    90  
    91  // SetContext adds the context to the add one params
    92  func (o *AddOneParams) SetContext(ctx context.Context) {
    93  	o.Context = ctx
    94  }
    95  
    96  // WithHTTPClient adds the HTTPClient to the add one params
    97  func (o *AddOneParams) WithHTTPClient(client *http.Client) *AddOneParams {
    98  	o.SetHTTPClient(client)
    99  	return o
   100  }
   101  
   102  // SetHTTPClient adds the HTTPClient to the add one params
   103  func (o *AddOneParams) SetHTTPClient(client *http.Client) {
   104  	o.HTTPClient = client
   105  }
   106  
   107  // WithBody adds the body to the add one params
   108  func (o *AddOneParams) WithBody(body *models.Item) *AddOneParams {
   109  	o.SetBody(body)
   110  	return o
   111  }
   112  
   113  // SetBody adds the body to the add one params
   114  func (o *AddOneParams) SetBody(body *models.Item) {
   115  	o.Body = body
   116  }
   117  
   118  // WriteToRequest writes these params to a swagger request
   119  func (o *AddOneParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   120  
   121  	if err := r.SetTimeout(o.timeout); err != nil {
   122  		return err
   123  	}
   124  	var res []error
   125  
   126  	if o.Body != nil {
   127  		if err := r.SetBodyParam(o.Body); err != nil {
   128  			return err
   129  		}
   130  	}
   131  
   132  	if len(res) > 0 {
   133  		return errors.CompositeValidationError(res...)
   134  	}
   135  	return nil
   136  }