github.com/circl-dev/go-swagger@v0.31.0/examples/stream-server/client/operations/elapse_parameters.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package operations 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 20 // NewElapseParams creates a new ElapseParams object, 21 // with the default timeout for this client. 22 // 23 // Default values are not hydrated, since defaults are normally applied by the API server side. 24 // 25 // To enforce default values in parameter, use SetDefaults or WithDefaults. 26 func NewElapseParams() *ElapseParams { 27 return &ElapseParams{ 28 timeout: cr.DefaultTimeout, 29 } 30 } 31 32 // NewElapseParamsWithTimeout creates a new ElapseParams object 33 // with the ability to set a timeout on a request. 34 func NewElapseParamsWithTimeout(timeout time.Duration) *ElapseParams { 35 return &ElapseParams{ 36 timeout: timeout, 37 } 38 } 39 40 // NewElapseParamsWithContext creates a new ElapseParams object 41 // with the ability to set a context for a request. 42 func NewElapseParamsWithContext(ctx context.Context) *ElapseParams { 43 return &ElapseParams{ 44 Context: ctx, 45 } 46 } 47 48 // NewElapseParamsWithHTTPClient creates a new ElapseParams object 49 // with the ability to set a custom HTTPClient for a request. 50 func NewElapseParamsWithHTTPClient(client *http.Client) *ElapseParams { 51 return &ElapseParams{ 52 HTTPClient: client, 53 } 54 } 55 56 /* ElapseParams contains all the parameters to send to the API endpoint 57 for the elapse operation. 58 59 Typically these are written to a http.Request. 60 */ 61 type ElapseParams struct { 62 63 /* Length. 64 65 How many seconds to count down 66 */ 67 Length int64 68 69 timeout time.Duration 70 Context context.Context 71 HTTPClient *http.Client 72 } 73 74 // WithDefaults hydrates default values in the elapse params (not the query body). 75 // 76 // All values with no default are reset to their zero value. 77 func (o *ElapseParams) WithDefaults() *ElapseParams { 78 o.SetDefaults() 79 return o 80 } 81 82 // SetDefaults hydrates default values in the elapse params (not the query body). 83 // 84 // All values with no default are reset to their zero value. 85 func (o *ElapseParams) SetDefaults() { 86 // no default values defined for this parameter 87 } 88 89 // WithTimeout adds the timeout to the elapse params 90 func (o *ElapseParams) WithTimeout(timeout time.Duration) *ElapseParams { 91 o.SetTimeout(timeout) 92 return o 93 } 94 95 // SetTimeout adds the timeout to the elapse params 96 func (o *ElapseParams) SetTimeout(timeout time.Duration) { 97 o.timeout = timeout 98 } 99 100 // WithContext adds the context to the elapse params 101 func (o *ElapseParams) WithContext(ctx context.Context) *ElapseParams { 102 o.SetContext(ctx) 103 return o 104 } 105 106 // SetContext adds the context to the elapse params 107 func (o *ElapseParams) SetContext(ctx context.Context) { 108 o.Context = ctx 109 } 110 111 // WithHTTPClient adds the HTTPClient to the elapse params 112 func (o *ElapseParams) WithHTTPClient(client *http.Client) *ElapseParams { 113 o.SetHTTPClient(client) 114 return o 115 } 116 117 // SetHTTPClient adds the HTTPClient to the elapse params 118 func (o *ElapseParams) SetHTTPClient(client *http.Client) { 119 o.HTTPClient = client 120 } 121 122 // WithLength adds the length to the elapse params 123 func (o *ElapseParams) WithLength(length int64) *ElapseParams { 124 o.SetLength(length) 125 return o 126 } 127 128 // SetLength adds the length to the elapse params 129 func (o *ElapseParams) SetLength(length int64) { 130 o.Length = length 131 } 132 133 // WriteToRequest writes these params to a swagger request 134 func (o *ElapseParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { 135 136 if err := r.SetTimeout(o.timeout); err != nil { 137 return err 138 } 139 var res []error 140 141 // path param length 142 if err := r.SetPathParam("length", swag.FormatInt64(o.Length)); err != nil { 143 return err 144 } 145 146 if len(res) > 0 { 147 return errors.CompositeValidationError(res...) 148 } 149 return nil 150 }