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