github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/client/user/search_users_parameters.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package user 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 "github.com/go-openapi/swag" 18 ) 19 20 // NewSearchUsersParams creates a new SearchUsersParams 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 NewSearchUsersParams() *SearchUsersParams { 27 return &SearchUsersParams{ 28 timeout: cr.DefaultTimeout, 29 } 30 } 31 32 // NewSearchUsersParamsWithTimeout creates a new SearchUsersParams object 33 // with the ability to set a timeout on a request. 34 func NewSearchUsersParamsWithTimeout(timeout time.Duration) *SearchUsersParams { 35 return &SearchUsersParams{ 36 timeout: timeout, 37 } 38 } 39 40 // NewSearchUsersParamsWithContext creates a new SearchUsersParams object 41 // with the ability to set a context for a request. 42 func NewSearchUsersParamsWithContext(ctx context.Context) *SearchUsersParams { 43 return &SearchUsersParams{ 44 Context: ctx, 45 } 46 } 47 48 // NewSearchUsersParamsWithHTTPClient creates a new SearchUsersParams object 49 // with the ability to set a custom HTTPClient for a request. 50 func NewSearchUsersParamsWithHTTPClient(client *http.Client) *SearchUsersParams { 51 return &SearchUsersParams{ 52 HTTPClient: client, 53 } 54 } 55 56 /* 57 SearchUsersParams contains all the parameters to send to the API endpoint 58 59 for the search users operation. 60 61 Typically these are written to a http.Request. 62 */ 63 type SearchUsersParams struct { 64 65 /* XRequestID. 66 67 An unique ID for the request 68 */ 69 XRequestID *string 70 71 /* Page. 72 73 The page number 74 75 Format: int64 76 Default: 1 77 */ 78 Page *int64 79 80 /* PageSize. 81 82 The size of per page 83 84 Format: int64 85 Default: 10 86 */ 87 PageSize *int64 88 89 /* Username. 90 91 Username for filtering results. 92 */ 93 Username string 94 95 timeout time.Duration 96 Context context.Context 97 HTTPClient *http.Client 98 } 99 100 // WithDefaults hydrates default values in the search users params (not the query body). 101 // 102 // All values with no default are reset to their zero value. 103 func (o *SearchUsersParams) WithDefaults() *SearchUsersParams { 104 o.SetDefaults() 105 return o 106 } 107 108 // SetDefaults hydrates default values in the search users params (not the query body). 109 // 110 // All values with no default are reset to their zero value. 111 func (o *SearchUsersParams) SetDefaults() { 112 var ( 113 pageDefault = int64(1) 114 115 pageSizeDefault = int64(10) 116 ) 117 118 val := SearchUsersParams{ 119 Page: &pageDefault, 120 PageSize: &pageSizeDefault, 121 } 122 123 val.timeout = o.timeout 124 val.Context = o.Context 125 val.HTTPClient = o.HTTPClient 126 *o = val 127 } 128 129 // WithTimeout adds the timeout to the search users params 130 func (o *SearchUsersParams) WithTimeout(timeout time.Duration) *SearchUsersParams { 131 o.SetTimeout(timeout) 132 return o 133 } 134 135 // SetTimeout adds the timeout to the search users params 136 func (o *SearchUsersParams) SetTimeout(timeout time.Duration) { 137 o.timeout = timeout 138 } 139 140 // WithContext adds the context to the search users params 141 func (o *SearchUsersParams) WithContext(ctx context.Context) *SearchUsersParams { 142 o.SetContext(ctx) 143 return o 144 } 145 146 // SetContext adds the context to the search users params 147 func (o *SearchUsersParams) SetContext(ctx context.Context) { 148 o.Context = ctx 149 } 150 151 // WithHTTPClient adds the HTTPClient to the search users params 152 func (o *SearchUsersParams) WithHTTPClient(client *http.Client) *SearchUsersParams { 153 o.SetHTTPClient(client) 154 return o 155 } 156 157 // SetHTTPClient adds the HTTPClient to the search users params 158 func (o *SearchUsersParams) SetHTTPClient(client *http.Client) { 159 o.HTTPClient = client 160 } 161 162 // WithXRequestID adds the xRequestID to the search users params 163 func (o *SearchUsersParams) WithXRequestID(xRequestID *string) *SearchUsersParams { 164 o.SetXRequestID(xRequestID) 165 return o 166 } 167 168 // SetXRequestID adds the xRequestId to the search users params 169 func (o *SearchUsersParams) SetXRequestID(xRequestID *string) { 170 o.XRequestID = xRequestID 171 } 172 173 // WithPage adds the page to the search users params 174 func (o *SearchUsersParams) WithPage(page *int64) *SearchUsersParams { 175 o.SetPage(page) 176 return o 177 } 178 179 // SetPage adds the page to the search users params 180 func (o *SearchUsersParams) SetPage(page *int64) { 181 o.Page = page 182 } 183 184 // WithPageSize adds the pageSize to the search users params 185 func (o *SearchUsersParams) WithPageSize(pageSize *int64) *SearchUsersParams { 186 o.SetPageSize(pageSize) 187 return o 188 } 189 190 // SetPageSize adds the pageSize to the search users params 191 func (o *SearchUsersParams) SetPageSize(pageSize *int64) { 192 o.PageSize = pageSize 193 } 194 195 // WithUsername adds the username to the search users params 196 func (o *SearchUsersParams) WithUsername(username string) *SearchUsersParams { 197 o.SetUsername(username) 198 return o 199 } 200 201 // SetUsername adds the username to the search users params 202 func (o *SearchUsersParams) SetUsername(username string) { 203 o.Username = username 204 } 205 206 // WriteToRequest writes these params to a swagger request 207 func (o *SearchUsersParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { 208 209 if err := r.SetTimeout(o.timeout); err != nil { 210 return err 211 } 212 var res []error 213 214 if o.XRequestID != nil { 215 216 // header param X-Request-Id 217 if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { 218 return err 219 } 220 } 221 222 if o.Page != nil { 223 224 // query param page 225 var qrPage int64 226 227 if o.Page != nil { 228 qrPage = *o.Page 229 } 230 qPage := swag.FormatInt64(qrPage) 231 if qPage != "" { 232 233 if err := r.SetQueryParam("page", qPage); err != nil { 234 return err 235 } 236 } 237 } 238 239 if o.PageSize != nil { 240 241 // query param page_size 242 var qrPageSize int64 243 244 if o.PageSize != nil { 245 qrPageSize = *o.PageSize 246 } 247 qPageSize := swag.FormatInt64(qrPageSize) 248 if qPageSize != "" { 249 250 if err := r.SetQueryParam("page_size", qPageSize); err != nil { 251 return err 252 } 253 } 254 } 255 256 // query param username 257 qrUsername := o.Username 258 qUsername := qrUsername 259 if qUsername != "" { 260 261 if err := r.SetQueryParam("username", qUsername); err != nil { 262 return err 263 } 264 } 265 266 if len(res) > 0 { 267 return errors.CompositeValidationError(res...) 268 } 269 return nil 270 }