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