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