github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/client/project/list_projects_parameters.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package project 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 // NewListProjectsParams creates a new ListProjectsParams 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 NewListProjectsParams() *ListProjectsParams { 27 return &ListProjectsParams{ 28 timeout: cr.DefaultTimeout, 29 } 30 } 31 32 // NewListProjectsParamsWithTimeout creates a new ListProjectsParams object 33 // with the ability to set a timeout on a request. 34 func NewListProjectsParamsWithTimeout(timeout time.Duration) *ListProjectsParams { 35 return &ListProjectsParams{ 36 timeout: timeout, 37 } 38 } 39 40 // NewListProjectsParamsWithContext creates a new ListProjectsParams object 41 // with the ability to set a context for a request. 42 func NewListProjectsParamsWithContext(ctx context.Context) *ListProjectsParams { 43 return &ListProjectsParams{ 44 Context: ctx, 45 } 46 } 47 48 // NewListProjectsParamsWithHTTPClient creates a new ListProjectsParams object 49 // with the ability to set a custom HTTPClient for a request. 50 func NewListProjectsParamsWithHTTPClient(client *http.Client) *ListProjectsParams { 51 return &ListProjectsParams{ 52 HTTPClient: client, 53 } 54 } 55 56 /* 57 ListProjectsParams contains all the parameters to send to the API endpoint 58 59 for the list projects operation. 60 61 Typically these are written to a http.Request. 62 */ 63 type ListProjectsParams struct { 64 65 /* XRequestID. 66 67 An unique ID for the request 68 */ 69 XRequestID *string 70 71 /* Name. 72 73 The name of project. 74 */ 75 Name *string 76 77 /* Owner. 78 79 The name of project owner. 80 */ 81 Owner *string 82 83 /* Page. 84 85 The page number 86 87 Format: int64 88 Default: 1 89 */ 90 Page *int64 91 92 /* PageSize. 93 94 The size of per page 95 96 Format: int64 97 Default: 10 98 */ 99 PageSize *int64 100 101 /* Public. 102 103 The project is public or private. 104 */ 105 Public *bool 106 107 /* Q. 108 109 Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] 110 */ 111 Q *string 112 113 /* Sort. 114 115 Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" 116 */ 117 Sort *string 118 119 /* WithDetail. 120 121 Bool value indicating whether return detailed information of the project 122 123 Default: true 124 */ 125 WithDetail *bool 126 127 timeout time.Duration 128 Context context.Context 129 HTTPClient *http.Client 130 } 131 132 // WithDefaults hydrates default values in the list projects params (not the query body). 133 // 134 // All values with no default are reset to their zero value. 135 func (o *ListProjectsParams) WithDefaults() *ListProjectsParams { 136 o.SetDefaults() 137 return o 138 } 139 140 // SetDefaults hydrates default values in the list projects params (not the query body). 141 // 142 // All values with no default are reset to their zero value. 143 func (o *ListProjectsParams) SetDefaults() { 144 var ( 145 pageDefault = int64(1) 146 147 pageSizeDefault = int64(10) 148 149 withDetailDefault = bool(true) 150 ) 151 152 val := ListProjectsParams{ 153 Page: &pageDefault, 154 PageSize: &pageSizeDefault, 155 WithDetail: &withDetailDefault, 156 } 157 158 val.timeout = o.timeout 159 val.Context = o.Context 160 val.HTTPClient = o.HTTPClient 161 *o = val 162 } 163 164 // WithTimeout adds the timeout to the list projects params 165 func (o *ListProjectsParams) WithTimeout(timeout time.Duration) *ListProjectsParams { 166 o.SetTimeout(timeout) 167 return o 168 } 169 170 // SetTimeout adds the timeout to the list projects params 171 func (o *ListProjectsParams) SetTimeout(timeout time.Duration) { 172 o.timeout = timeout 173 } 174 175 // WithContext adds the context to the list projects params 176 func (o *ListProjectsParams) WithContext(ctx context.Context) *ListProjectsParams { 177 o.SetContext(ctx) 178 return o 179 } 180 181 // SetContext adds the context to the list projects params 182 func (o *ListProjectsParams) SetContext(ctx context.Context) { 183 o.Context = ctx 184 } 185 186 // WithHTTPClient adds the HTTPClient to the list projects params 187 func (o *ListProjectsParams) WithHTTPClient(client *http.Client) *ListProjectsParams { 188 o.SetHTTPClient(client) 189 return o 190 } 191 192 // SetHTTPClient adds the HTTPClient to the list projects params 193 func (o *ListProjectsParams) SetHTTPClient(client *http.Client) { 194 o.HTTPClient = client 195 } 196 197 // WithXRequestID adds the xRequestID to the list projects params 198 func (o *ListProjectsParams) WithXRequestID(xRequestID *string) *ListProjectsParams { 199 o.SetXRequestID(xRequestID) 200 return o 201 } 202 203 // SetXRequestID adds the xRequestId to the list projects params 204 func (o *ListProjectsParams) SetXRequestID(xRequestID *string) { 205 o.XRequestID = xRequestID 206 } 207 208 // WithName adds the name to the list projects params 209 func (o *ListProjectsParams) WithName(name *string) *ListProjectsParams { 210 o.SetName(name) 211 return o 212 } 213 214 // SetName adds the name to the list projects params 215 func (o *ListProjectsParams) SetName(name *string) { 216 o.Name = name 217 } 218 219 // WithOwner adds the owner to the list projects params 220 func (o *ListProjectsParams) WithOwner(owner *string) *ListProjectsParams { 221 o.SetOwner(owner) 222 return o 223 } 224 225 // SetOwner adds the owner to the list projects params 226 func (o *ListProjectsParams) SetOwner(owner *string) { 227 o.Owner = owner 228 } 229 230 // WithPage adds the page to the list projects params 231 func (o *ListProjectsParams) WithPage(page *int64) *ListProjectsParams { 232 o.SetPage(page) 233 return o 234 } 235 236 // SetPage adds the page to the list projects params 237 func (o *ListProjectsParams) SetPage(page *int64) { 238 o.Page = page 239 } 240 241 // WithPageSize adds the pageSize to the list projects params 242 func (o *ListProjectsParams) WithPageSize(pageSize *int64) *ListProjectsParams { 243 o.SetPageSize(pageSize) 244 return o 245 } 246 247 // SetPageSize adds the pageSize to the list projects params 248 func (o *ListProjectsParams) SetPageSize(pageSize *int64) { 249 o.PageSize = pageSize 250 } 251 252 // WithPublic adds the public to the list projects params 253 func (o *ListProjectsParams) WithPublic(public *bool) *ListProjectsParams { 254 o.SetPublic(public) 255 return o 256 } 257 258 // SetPublic adds the public to the list projects params 259 func (o *ListProjectsParams) SetPublic(public *bool) { 260 o.Public = public 261 } 262 263 // WithQ adds the q to the list projects params 264 func (o *ListProjectsParams) WithQ(q *string) *ListProjectsParams { 265 o.SetQ(q) 266 return o 267 } 268 269 // SetQ adds the q to the list projects params 270 func (o *ListProjectsParams) SetQ(q *string) { 271 o.Q = q 272 } 273 274 // WithSort adds the sort to the list projects params 275 func (o *ListProjectsParams) WithSort(sort *string) *ListProjectsParams { 276 o.SetSort(sort) 277 return o 278 } 279 280 // SetSort adds the sort to the list projects params 281 func (o *ListProjectsParams) SetSort(sort *string) { 282 o.Sort = sort 283 } 284 285 // WithWithDetail adds the withDetail to the list projects params 286 func (o *ListProjectsParams) WithWithDetail(withDetail *bool) *ListProjectsParams { 287 o.SetWithDetail(withDetail) 288 return o 289 } 290 291 // SetWithDetail adds the withDetail to the list projects params 292 func (o *ListProjectsParams) SetWithDetail(withDetail *bool) { 293 o.WithDetail = withDetail 294 } 295 296 // WriteToRequest writes these params to a swagger request 297 func (o *ListProjectsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { 298 299 if err := r.SetTimeout(o.timeout); err != nil { 300 return err 301 } 302 var res []error 303 304 if o.XRequestID != nil { 305 306 // header param X-Request-Id 307 if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { 308 return err 309 } 310 } 311 312 if o.Name != nil { 313 314 // query param name 315 var qrName string 316 317 if o.Name != nil { 318 qrName = *o.Name 319 } 320 qName := qrName 321 if qName != "" { 322 323 if err := r.SetQueryParam("name", qName); err != nil { 324 return err 325 } 326 } 327 } 328 329 if o.Owner != nil { 330 331 // query param owner 332 var qrOwner string 333 334 if o.Owner != nil { 335 qrOwner = *o.Owner 336 } 337 qOwner := qrOwner 338 if qOwner != "" { 339 340 if err := r.SetQueryParam("owner", qOwner); err != nil { 341 return err 342 } 343 } 344 } 345 346 if o.Page != nil { 347 348 // query param page 349 var qrPage int64 350 351 if o.Page != nil { 352 qrPage = *o.Page 353 } 354 qPage := swag.FormatInt64(qrPage) 355 if qPage != "" { 356 357 if err := r.SetQueryParam("page", qPage); err != nil { 358 return err 359 } 360 } 361 } 362 363 if o.PageSize != nil { 364 365 // query param page_size 366 var qrPageSize int64 367 368 if o.PageSize != nil { 369 qrPageSize = *o.PageSize 370 } 371 qPageSize := swag.FormatInt64(qrPageSize) 372 if qPageSize != "" { 373 374 if err := r.SetQueryParam("page_size", qPageSize); err != nil { 375 return err 376 } 377 } 378 } 379 380 if o.Public != nil { 381 382 // query param public 383 var qrPublic bool 384 385 if o.Public != nil { 386 qrPublic = *o.Public 387 } 388 qPublic := swag.FormatBool(qrPublic) 389 if qPublic != "" { 390 391 if err := r.SetQueryParam("public", qPublic); err != nil { 392 return err 393 } 394 } 395 } 396 397 if o.Q != nil { 398 399 // query param q 400 var qrQ string 401 402 if o.Q != nil { 403 qrQ = *o.Q 404 } 405 qQ := qrQ 406 if qQ != "" { 407 408 if err := r.SetQueryParam("q", qQ); err != nil { 409 return err 410 } 411 } 412 } 413 414 if o.Sort != nil { 415 416 // query param sort 417 var qrSort string 418 419 if o.Sort != nil { 420 qrSort = *o.Sort 421 } 422 qSort := qrSort 423 if qSort != "" { 424 425 if err := r.SetQueryParam("sort", qSort); err != nil { 426 return err 427 } 428 } 429 } 430 431 if o.WithDetail != nil { 432 433 // query param with_detail 434 var qrWithDetail bool 435 436 if o.WithDetail != nil { 437 qrWithDetail = *o.WithDetail 438 } 439 qWithDetail := swag.FormatBool(qrWithDetail) 440 if qWithDetail != "" { 441 442 if err := r.SetQueryParam("with_detail", qWithDetail); err != nil { 443 return err 444 } 445 } 446 } 447 448 if len(res) > 0 { 449 return errors.CompositeValidationError(res...) 450 } 451 return nil 452 }