github.com/circl-dev/go-swagger@v0.31.0/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/strfmt"
    15  	"github.com/go-openapi/swag"
    16  	"github.com/circl-dev/runtime"
    17  	cr "github.com/circl-dev/runtime/client"
    18  
    19  	"github.com/circl-dev/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  /* UpdateOneParams contains all the parameters to send to the API endpoint
    59     for the update one operation.
    60  
    61     Typically these are written to a http.Request.
    62  */
    63  type UpdateOneParams struct {
    64  
    65  	// Body.
    66  	Body *models.Item
    67  
    68  	// ID.
    69  	//
    70  	// Format: int64
    71  	ID int64
    72  
    73  	timeout    time.Duration
    74  	Context    context.Context
    75  	HTTPClient *http.Client
    76  }
    77  
    78  // WithDefaults hydrates default values in the update one params (not the query body).
    79  //
    80  // All values with no default are reset to their zero value.
    81  func (o *UpdateOneParams) WithDefaults() *UpdateOneParams {
    82  	o.SetDefaults()
    83  	return o
    84  }
    85  
    86  // SetDefaults hydrates default values in the update one params (not the query body).
    87  //
    88  // All values with no default are reset to their zero value.
    89  func (o *UpdateOneParams) SetDefaults() {
    90  	// no default values defined for this parameter
    91  }
    92  
    93  // WithTimeout adds the timeout to the update one params
    94  func (o *UpdateOneParams) WithTimeout(timeout time.Duration) *UpdateOneParams {
    95  	o.SetTimeout(timeout)
    96  	return o
    97  }
    98  
    99  // SetTimeout adds the timeout to the update one params
   100  func (o *UpdateOneParams) SetTimeout(timeout time.Duration) {
   101  	o.timeout = timeout
   102  }
   103  
   104  // WithContext adds the context to the update one params
   105  func (o *UpdateOneParams) WithContext(ctx context.Context) *UpdateOneParams {
   106  	o.SetContext(ctx)
   107  	return o
   108  }
   109  
   110  // SetContext adds the context to the update one params
   111  func (o *UpdateOneParams) SetContext(ctx context.Context) {
   112  	o.Context = ctx
   113  }
   114  
   115  // WithHTTPClient adds the HTTPClient to the update one params
   116  func (o *UpdateOneParams) WithHTTPClient(client *http.Client) *UpdateOneParams {
   117  	o.SetHTTPClient(client)
   118  	return o
   119  }
   120  
   121  // SetHTTPClient adds the HTTPClient to the update one params
   122  func (o *UpdateOneParams) SetHTTPClient(client *http.Client) {
   123  	o.HTTPClient = client
   124  }
   125  
   126  // WithBody adds the body to the update one params
   127  func (o *UpdateOneParams) WithBody(body *models.Item) *UpdateOneParams {
   128  	o.SetBody(body)
   129  	return o
   130  }
   131  
   132  // SetBody adds the body to the update one params
   133  func (o *UpdateOneParams) SetBody(body *models.Item) {
   134  	o.Body = body
   135  }
   136  
   137  // WithID adds the id to the update one params
   138  func (o *UpdateOneParams) WithID(id int64) *UpdateOneParams {
   139  	o.SetID(id)
   140  	return o
   141  }
   142  
   143  // SetID adds the id to the update one params
   144  func (o *UpdateOneParams) SetID(id int64) {
   145  	o.ID = id
   146  }
   147  
   148  // WriteToRequest writes these params to a swagger request
   149  func (o *UpdateOneParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   150  
   151  	if err := r.SetTimeout(o.timeout); err != nil {
   152  		return err
   153  	}
   154  	var res []error
   155  	if o.Body != nil {
   156  		if err := r.SetBodyParam(o.Body); err != nil {
   157  			return err
   158  		}
   159  	}
   160  
   161  	// path param id
   162  	if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil {
   163  		return err
   164  	}
   165  
   166  	if len(res) > 0 {
   167  		return errors.CompositeValidationError(res...)
   168  	}
   169  	return nil
   170  }