github.com/circl-dev/go-swagger@v0.31.0/examples/contributed-templates/stratoscale/client/pet/pet_list_parameters.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package pet 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 // NewPetListParams creates a new PetListParams 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 NewPetListParams() *PetListParams { 27 return &PetListParams{ 28 timeout: cr.DefaultTimeout, 29 } 30 } 31 32 // NewPetListParamsWithTimeout creates a new PetListParams object 33 // with the ability to set a timeout on a request. 34 func NewPetListParamsWithTimeout(timeout time.Duration) *PetListParams { 35 return &PetListParams{ 36 timeout: timeout, 37 } 38 } 39 40 // NewPetListParamsWithContext creates a new PetListParams object 41 // with the ability to set a context for a request. 42 func NewPetListParamsWithContext(ctx context.Context) *PetListParams { 43 return &PetListParams{ 44 Context: ctx, 45 } 46 } 47 48 // NewPetListParamsWithHTTPClient creates a new PetListParams object 49 // with the ability to set a custom HTTPClient for a request. 50 func NewPetListParamsWithHTTPClient(client *http.Client) *PetListParams { 51 return &PetListParams{ 52 HTTPClient: client, 53 } 54 } 55 56 /* PetListParams contains all the parameters to send to the API endpoint 57 for the pet list operation. 58 59 Typically these are written to a http.Request. 60 */ 61 type PetListParams struct { 62 63 /* Status. 64 65 Status values that need to be considered for filter 66 */ 67 Status []string 68 69 timeout time.Duration 70 Context context.Context 71 HTTPClient *http.Client 72 } 73 74 // WithDefaults hydrates default values in the pet list params (not the query body). 75 // 76 // All values with no default are reset to their zero value. 77 func (o *PetListParams) WithDefaults() *PetListParams { 78 o.SetDefaults() 79 return o 80 } 81 82 // SetDefaults hydrates default values in the pet list params (not the query body). 83 // 84 // All values with no default are reset to their zero value. 85 func (o *PetListParams) SetDefaults() { 86 // no default values defined for this parameter 87 } 88 89 // WithTimeout adds the timeout to the pet list params 90 func (o *PetListParams) WithTimeout(timeout time.Duration) *PetListParams { 91 o.SetTimeout(timeout) 92 return o 93 } 94 95 // SetTimeout adds the timeout to the pet list params 96 func (o *PetListParams) SetTimeout(timeout time.Duration) { 97 o.timeout = timeout 98 } 99 100 // WithContext adds the context to the pet list params 101 func (o *PetListParams) WithContext(ctx context.Context) *PetListParams { 102 o.SetContext(ctx) 103 return o 104 } 105 106 // SetContext adds the context to the pet list params 107 func (o *PetListParams) SetContext(ctx context.Context) { 108 o.Context = ctx 109 } 110 111 // WithHTTPClient adds the HTTPClient to the pet list params 112 func (o *PetListParams) WithHTTPClient(client *http.Client) *PetListParams { 113 o.SetHTTPClient(client) 114 return o 115 } 116 117 // SetHTTPClient adds the HTTPClient to the pet list params 118 func (o *PetListParams) SetHTTPClient(client *http.Client) { 119 o.HTTPClient = client 120 } 121 122 // WithStatus adds the status to the pet list params 123 func (o *PetListParams) WithStatus(status []string) *PetListParams { 124 o.SetStatus(status) 125 return o 126 } 127 128 // SetStatus adds the status to the pet list params 129 func (o *PetListParams) SetStatus(status []string) { 130 o.Status = status 131 } 132 133 // WriteToRequest writes these params to a swagger request 134 func (o *PetListParams) 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 if o.Status != nil { 142 143 // binding items for status 144 joinedStatus := o.bindParamStatus(reg) 145 146 // query array param status 147 if err := r.SetQueryParam("status", joinedStatus...); err != nil { 148 return err 149 } 150 } 151 152 if len(res) > 0 { 153 return errors.CompositeValidationError(res...) 154 } 155 return nil 156 } 157 158 // bindParamPetList binds the parameter status 159 func (o *PetListParams) bindParamStatus(formats strfmt.Registry) []string { 160 statusIR := o.Status 161 162 var statusIC []string 163 for _, statusIIR := range statusIR { // explode []string 164 165 statusIIV := statusIIR // string as string 166 statusIC = append(statusIC, statusIIV) 167 } 168 169 // items.CollectionFormat: "multi" 170 statusIS := swag.JoinByFormat(statusIC, "multi") 171 172 return statusIS 173 }