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