github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/client/label/list_labels_parameters.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package label 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 // NewListLabelsParams creates a new ListLabelsParams 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 NewListLabelsParams() *ListLabelsParams { 27 return &ListLabelsParams{ 28 timeout: cr.DefaultTimeout, 29 } 30 } 31 32 // NewListLabelsParamsWithTimeout creates a new ListLabelsParams object 33 // with the ability to set a timeout on a request. 34 func NewListLabelsParamsWithTimeout(timeout time.Duration) *ListLabelsParams { 35 return &ListLabelsParams{ 36 timeout: timeout, 37 } 38 } 39 40 // NewListLabelsParamsWithContext creates a new ListLabelsParams object 41 // with the ability to set a context for a request. 42 func NewListLabelsParamsWithContext(ctx context.Context) *ListLabelsParams { 43 return &ListLabelsParams{ 44 Context: ctx, 45 } 46 } 47 48 // NewListLabelsParamsWithHTTPClient creates a new ListLabelsParams object 49 // with the ability to set a custom HTTPClient for a request. 50 func NewListLabelsParamsWithHTTPClient(client *http.Client) *ListLabelsParams { 51 return &ListLabelsParams{ 52 HTTPClient: client, 53 } 54 } 55 56 /* 57 ListLabelsParams contains all the parameters to send to the API endpoint 58 59 for the list labels operation. 60 61 Typically these are written to a http.Request. 62 */ 63 type ListLabelsParams struct { 64 65 /* XRequestID. 66 67 An unique ID for the request 68 */ 69 XRequestID *string 70 71 /* Name. 72 73 The label name. 74 */ 75 Name *string 76 77 /* Page. 78 79 The page number 80 81 Format: int64 82 Default: 1 83 */ 84 Page *int64 85 86 /* PageSize. 87 88 The size of per page 89 90 Format: int64 91 Default: 10 92 */ 93 PageSize *int64 94 95 /* ProjectID. 96 97 Relevant project ID, required when scope is p. 98 99 Format: int64 100 */ 101 ProjectID *int64 102 103 /* Q. 104 105 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] 106 */ 107 Q *string 108 109 /* Scope. 110 111 The label scope. Valid values are g and p. g for global labels and p for project labels. 112 */ 113 Scope *string 114 115 /* Sort. 116 117 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" 118 */ 119 Sort *string 120 121 timeout time.Duration 122 Context context.Context 123 HTTPClient *http.Client 124 } 125 126 // WithDefaults hydrates default values in the list labels params (not the query body). 127 // 128 // All values with no default are reset to their zero value. 129 func (o *ListLabelsParams) WithDefaults() *ListLabelsParams { 130 o.SetDefaults() 131 return o 132 } 133 134 // SetDefaults hydrates default values in the list labels params (not the query body). 135 // 136 // All values with no default are reset to their zero value. 137 func (o *ListLabelsParams) SetDefaults() { 138 var ( 139 pageDefault = int64(1) 140 141 pageSizeDefault = int64(10) 142 ) 143 144 val := ListLabelsParams{ 145 Page: &pageDefault, 146 PageSize: &pageSizeDefault, 147 } 148 149 val.timeout = o.timeout 150 val.Context = o.Context 151 val.HTTPClient = o.HTTPClient 152 *o = val 153 } 154 155 // WithTimeout adds the timeout to the list labels params 156 func (o *ListLabelsParams) WithTimeout(timeout time.Duration) *ListLabelsParams { 157 o.SetTimeout(timeout) 158 return o 159 } 160 161 // SetTimeout adds the timeout to the list labels params 162 func (o *ListLabelsParams) SetTimeout(timeout time.Duration) { 163 o.timeout = timeout 164 } 165 166 // WithContext adds the context to the list labels params 167 func (o *ListLabelsParams) WithContext(ctx context.Context) *ListLabelsParams { 168 o.SetContext(ctx) 169 return o 170 } 171 172 // SetContext adds the context to the list labels params 173 func (o *ListLabelsParams) SetContext(ctx context.Context) { 174 o.Context = ctx 175 } 176 177 // WithHTTPClient adds the HTTPClient to the list labels params 178 func (o *ListLabelsParams) WithHTTPClient(client *http.Client) *ListLabelsParams { 179 o.SetHTTPClient(client) 180 return o 181 } 182 183 // SetHTTPClient adds the HTTPClient to the list labels params 184 func (o *ListLabelsParams) SetHTTPClient(client *http.Client) { 185 o.HTTPClient = client 186 } 187 188 // WithXRequestID adds the xRequestID to the list labels params 189 func (o *ListLabelsParams) WithXRequestID(xRequestID *string) *ListLabelsParams { 190 o.SetXRequestID(xRequestID) 191 return o 192 } 193 194 // SetXRequestID adds the xRequestId to the list labels params 195 func (o *ListLabelsParams) SetXRequestID(xRequestID *string) { 196 o.XRequestID = xRequestID 197 } 198 199 // WithName adds the name to the list labels params 200 func (o *ListLabelsParams) WithName(name *string) *ListLabelsParams { 201 o.SetName(name) 202 return o 203 } 204 205 // SetName adds the name to the list labels params 206 func (o *ListLabelsParams) SetName(name *string) { 207 o.Name = name 208 } 209 210 // WithPage adds the page to the list labels params 211 func (o *ListLabelsParams) WithPage(page *int64) *ListLabelsParams { 212 o.SetPage(page) 213 return o 214 } 215 216 // SetPage adds the page to the list labels params 217 func (o *ListLabelsParams) SetPage(page *int64) { 218 o.Page = page 219 } 220 221 // WithPageSize adds the pageSize to the list labels params 222 func (o *ListLabelsParams) WithPageSize(pageSize *int64) *ListLabelsParams { 223 o.SetPageSize(pageSize) 224 return o 225 } 226 227 // SetPageSize adds the pageSize to the list labels params 228 func (o *ListLabelsParams) SetPageSize(pageSize *int64) { 229 o.PageSize = pageSize 230 } 231 232 // WithProjectID adds the projectID to the list labels params 233 func (o *ListLabelsParams) WithProjectID(projectID *int64) *ListLabelsParams { 234 o.SetProjectID(projectID) 235 return o 236 } 237 238 // SetProjectID adds the projectId to the list labels params 239 func (o *ListLabelsParams) SetProjectID(projectID *int64) { 240 o.ProjectID = projectID 241 } 242 243 // WithQ adds the q to the list labels params 244 func (o *ListLabelsParams) WithQ(q *string) *ListLabelsParams { 245 o.SetQ(q) 246 return o 247 } 248 249 // SetQ adds the q to the list labels params 250 func (o *ListLabelsParams) SetQ(q *string) { 251 o.Q = q 252 } 253 254 // WithScope adds the scope to the list labels params 255 func (o *ListLabelsParams) WithScope(scope *string) *ListLabelsParams { 256 o.SetScope(scope) 257 return o 258 } 259 260 // SetScope adds the scope to the list labels params 261 func (o *ListLabelsParams) SetScope(scope *string) { 262 o.Scope = scope 263 } 264 265 // WithSort adds the sort to the list labels params 266 func (o *ListLabelsParams) WithSort(sort *string) *ListLabelsParams { 267 o.SetSort(sort) 268 return o 269 } 270 271 // SetSort adds the sort to the list labels params 272 func (o *ListLabelsParams) SetSort(sort *string) { 273 o.Sort = sort 274 } 275 276 // WriteToRequest writes these params to a swagger request 277 func (o *ListLabelsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { 278 279 if err := r.SetTimeout(o.timeout); err != nil { 280 return err 281 } 282 var res []error 283 284 if o.XRequestID != nil { 285 286 // header param X-Request-Id 287 if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { 288 return err 289 } 290 } 291 292 if o.Name != nil { 293 294 // query param name 295 var qrName string 296 297 if o.Name != nil { 298 qrName = *o.Name 299 } 300 qName := qrName 301 if qName != "" { 302 303 if err := r.SetQueryParam("name", qName); err != nil { 304 return err 305 } 306 } 307 } 308 309 if o.Page != nil { 310 311 // query param page 312 var qrPage int64 313 314 if o.Page != nil { 315 qrPage = *o.Page 316 } 317 qPage := swag.FormatInt64(qrPage) 318 if qPage != "" { 319 320 if err := r.SetQueryParam("page", qPage); err != nil { 321 return err 322 } 323 } 324 } 325 326 if o.PageSize != nil { 327 328 // query param page_size 329 var qrPageSize int64 330 331 if o.PageSize != nil { 332 qrPageSize = *o.PageSize 333 } 334 qPageSize := swag.FormatInt64(qrPageSize) 335 if qPageSize != "" { 336 337 if err := r.SetQueryParam("page_size", qPageSize); err != nil { 338 return err 339 } 340 } 341 } 342 343 if o.ProjectID != nil { 344 345 // query param project_id 346 var qrProjectID int64 347 348 if o.ProjectID != nil { 349 qrProjectID = *o.ProjectID 350 } 351 qProjectID := swag.FormatInt64(qrProjectID) 352 if qProjectID != "" { 353 354 if err := r.SetQueryParam("project_id", qProjectID); err != nil { 355 return err 356 } 357 } 358 } 359 360 if o.Q != nil { 361 362 // query param q 363 var qrQ string 364 365 if o.Q != nil { 366 qrQ = *o.Q 367 } 368 qQ := qrQ 369 if qQ != "" { 370 371 if err := r.SetQueryParam("q", qQ); err != nil { 372 return err 373 } 374 } 375 } 376 377 if o.Scope != nil { 378 379 // query param scope 380 var qrScope string 381 382 if o.Scope != nil { 383 qrScope = *o.Scope 384 } 385 qScope := qrScope 386 if qScope != "" { 387 388 if err := r.SetQueryParam("scope", qScope); err != nil { 389 return err 390 } 391 } 392 } 393 394 if o.Sort != nil { 395 396 // query param sort 397 var qrSort string 398 399 if o.Sort != nil { 400 qrSort = *o.Sort 401 } 402 qSort := qrSort 403 if qSort != "" { 404 405 if err := r.SetQueryParam("sort", qSort); err != nil { 406 return err 407 } 408 } 409 } 410 411 if len(res) > 0 { 412 return errors.CompositeValidationError(res...) 413 } 414 return nil 415 }