github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/todo-list-strict/client/todos/update_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  // NewUpdateOneParams creates a new UpdateOneParams object
    22  // with the default values initialized.
    23  func NewUpdateOneParams() *UpdateOneParams {
    24  	var ()
    25  	return &UpdateOneParams{
    26  
    27  		timeout: cr.DefaultTimeout,
    28  	}
    29  }
    30  
    31  // NewUpdateOneParamsWithTimeout creates a new UpdateOneParams object
    32  // with the default values initialized, and the ability to set a timeout on a request
    33  func NewUpdateOneParamsWithTimeout(timeout time.Duration) *UpdateOneParams {
    34  	var ()
    35  	return &UpdateOneParams{
    36  
    37  		timeout: timeout,
    38  	}
    39  }
    40  
    41  // NewUpdateOneParamsWithContext creates a new UpdateOneParams object
    42  // with the default values initialized, and the ability to set a context for a request
    43  func NewUpdateOneParamsWithContext(ctx context.Context) *UpdateOneParams {
    44  	var ()
    45  	return &UpdateOneParams{
    46  
    47  		Context: ctx,
    48  	}
    49  }
    50  
    51  // NewUpdateOneParamsWithHTTPClient creates a new UpdateOneParams object
    52  // with the default values initialized, and the ability to set a custom HTTPClient for a request
    53  func NewUpdateOneParamsWithHTTPClient(client *http.Client) *UpdateOneParams {
    54  	var ()
    55  	return &UpdateOneParams{
    56  		HTTPClient: client,
    57  	}
    58  }
    59  
    60  /*
    61  UpdateOneParams contains all the parameters to send to the API endpoint
    62  for the update one operation typically these are written to a http.Request
    63  */
    64  type UpdateOneParams struct {
    65  
    66  	/*Body*/
    67  	Body *models.Item
    68  	/*ID*/
    69  	ID string
    70  
    71  	timeout    time.Duration
    72  	Context    context.Context
    73  	HTTPClient *http.Client
    74  }
    75  
    76  // WithTimeout adds the timeout to the update one params
    77  func (o *UpdateOneParams) WithTimeout(timeout time.Duration) *UpdateOneParams {
    78  	o.SetTimeout(timeout)
    79  	return o
    80  }
    81  
    82  // SetTimeout adds the timeout to the update one params
    83  func (o *UpdateOneParams) SetTimeout(timeout time.Duration) {
    84  	o.timeout = timeout
    85  }
    86  
    87  // WithContext adds the context to the update one params
    88  func (o *UpdateOneParams) WithContext(ctx context.Context) *UpdateOneParams {
    89  	o.SetContext(ctx)
    90  	return o
    91  }
    92  
    93  // SetContext adds the context to the update one params
    94  func (o *UpdateOneParams) SetContext(ctx context.Context) {
    95  	o.Context = ctx
    96  }
    97  
    98  // WithHTTPClient adds the HTTPClient to the update one params
    99  func (o *UpdateOneParams) WithHTTPClient(client *http.Client) *UpdateOneParams {
   100  	o.SetHTTPClient(client)
   101  	return o
   102  }
   103  
   104  // SetHTTPClient adds the HTTPClient to the update one params
   105  func (o *UpdateOneParams) SetHTTPClient(client *http.Client) {
   106  	o.HTTPClient = client
   107  }
   108  
   109  // WithBody adds the body to the update one params
   110  func (o *UpdateOneParams) WithBody(body *models.Item) *UpdateOneParams {
   111  	o.SetBody(body)
   112  	return o
   113  }
   114  
   115  // SetBody adds the body to the update one params
   116  func (o *UpdateOneParams) SetBody(body *models.Item) {
   117  	o.Body = body
   118  }
   119  
   120  // WithID adds the id to the update one params
   121  func (o *UpdateOneParams) WithID(id string) *UpdateOneParams {
   122  	o.SetID(id)
   123  	return o
   124  }
   125  
   126  // SetID adds the id to the update one params
   127  func (o *UpdateOneParams) SetID(id string) {
   128  	o.ID = id
   129  }
   130  
   131  // WriteToRequest writes these params to a swagger request
   132  func (o *UpdateOneParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   133  
   134  	if err := r.SetTimeout(o.timeout); err != nil {
   135  		return err
   136  	}
   137  	var res []error
   138  
   139  	if o.Body != nil {
   140  		if err := r.SetBodyParam(o.Body); err != nil {
   141  			return err
   142  		}
   143  	}
   144  
   145  	// path param id
   146  	if err := r.SetPathParam("id", o.ID); err != nil {
   147  		return err
   148  	}
   149  
   150  	if len(res) > 0 {
   151  		return errors.CompositeValidationError(res...)
   152  	}
   153  	return nil
   154  }