github.com/openshift-online/ocm-sdk-go@v0.1.473/clustersmgmt/v1/ht_passwd_users_client.go (about) 1 /* 2 Copyright (c) 2020 Red Hat, Inc. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 // IMPORTANT: This file has been generated automatically, refrain from modifying it manually as all 18 // your changes will be lost when the file is generated again. 19 20 package v1 // github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1 21 22 import ( 23 "bufio" 24 "bytes" 25 "context" 26 "io" 27 "net/http" 28 "net/url" 29 "path" 30 31 "github.com/openshift-online/ocm-sdk-go/errors" 32 "github.com/openshift-online/ocm-sdk-go/helpers" 33 ) 34 35 // HTPasswdUsersClient is the client of the 'HT_passwd_users' resource. 36 // 37 // Manages the collection of users in an _HTPasswd_ IDP of a cluster. 38 type HTPasswdUsersClient struct { 39 transport http.RoundTripper 40 path string 41 } 42 43 // NewHTPasswdUsersClient creates a new client for the 'HT_passwd_users' 44 // resource using the given transport to send the requests and receive the 45 // responses. 46 func NewHTPasswdUsersClient(transport http.RoundTripper, path string) *HTPasswdUsersClient { 47 return &HTPasswdUsersClient{ 48 transport: transport, 49 path: path, 50 } 51 } 52 53 // Add creates a request for the 'add' method. 54 // 55 // Adds a new user to the _HTPasswd_ file. 56 func (c *HTPasswdUsersClient) Add() *HTPasswdUsersAddRequest { 57 return &HTPasswdUsersAddRequest{ 58 transport: c.transport, 59 path: c.path, 60 } 61 } 62 63 // Import creates a request for the 'import' method. 64 // 65 // Adds multiple new users to the _HTPasswd_ file. 66 func (c *HTPasswdUsersClient) Import() *HTPasswdUsersImportRequest { 67 return &HTPasswdUsersImportRequest{ 68 transport: c.transport, 69 path: path.Join(c.path, "import"), 70 } 71 } 72 73 // List creates a request for the 'list' method. 74 // 75 // Retrieves the list of _HTPasswd_ IDP users. 76 func (c *HTPasswdUsersClient) List() *HTPasswdUsersListRequest { 77 return &HTPasswdUsersListRequest{ 78 transport: c.transport, 79 path: c.path, 80 } 81 } 82 83 // HtpasswdUser returns the target 'HT_passwd_user' resource for the given identifier. 84 // 85 // Reference to the service that manages a specific _HTPasswd_ user. 86 func (c *HTPasswdUsersClient) HtpasswdUser(id string) *HTPasswdUserClient { 87 return NewHTPasswdUserClient( 88 c.transport, 89 path.Join(c.path, id), 90 ) 91 } 92 93 // HTPasswdUsersAddRequest is the request for the 'add' method. 94 type HTPasswdUsersAddRequest struct { 95 transport http.RoundTripper 96 path string 97 query url.Values 98 header http.Header 99 body *HTPasswdUser 100 } 101 102 // Parameter adds a query parameter. 103 func (r *HTPasswdUsersAddRequest) Parameter(name string, value interface{}) *HTPasswdUsersAddRequest { 104 helpers.AddValue(&r.query, name, value) 105 return r 106 } 107 108 // Header adds a request header. 109 func (r *HTPasswdUsersAddRequest) Header(name string, value interface{}) *HTPasswdUsersAddRequest { 110 helpers.AddHeader(&r.header, name, value) 111 return r 112 } 113 114 // Impersonate wraps requests on behalf of another user. 115 // Note: Services that do not support this feature may silently ignore this call. 116 func (r *HTPasswdUsersAddRequest) Impersonate(user string) *HTPasswdUsersAddRequest { 117 helpers.AddImpersonationHeader(&r.header, user) 118 return r 119 } 120 121 // Body sets the value of the 'body' parameter. 122 // 123 // New user to be added 124 func (r *HTPasswdUsersAddRequest) Body(value *HTPasswdUser) *HTPasswdUsersAddRequest { 125 r.body = value 126 return r 127 } 128 129 // Send sends this request, waits for the response, and returns it. 130 // 131 // This is a potentially lengthy operation, as it requires network communication. 132 // Consider using a context and the SendContext method. 133 func (r *HTPasswdUsersAddRequest) Send() (result *HTPasswdUsersAddResponse, err error) { 134 return r.SendContext(context.Background()) 135 } 136 137 // SendContext sends this request, waits for the response, and returns it. 138 func (r *HTPasswdUsersAddRequest) SendContext(ctx context.Context) (result *HTPasswdUsersAddResponse, err error) { 139 query := helpers.CopyQuery(r.query) 140 header := helpers.CopyHeader(r.header) 141 buffer := &bytes.Buffer{} 142 err = writeHTPasswdUsersAddRequest(r, buffer) 143 if err != nil { 144 return 145 } 146 uri := &url.URL{ 147 Path: r.path, 148 RawQuery: query.Encode(), 149 } 150 request := &http.Request{ 151 Method: "POST", 152 URL: uri, 153 Header: header, 154 Body: io.NopCloser(buffer), 155 } 156 if ctx != nil { 157 request = request.WithContext(ctx) 158 } 159 response, err := r.transport.RoundTrip(request) 160 if err != nil { 161 return 162 } 163 defer response.Body.Close() 164 result = &HTPasswdUsersAddResponse{} 165 result.status = response.StatusCode 166 result.header = response.Header 167 reader := bufio.NewReader(response.Body) 168 _, err = reader.Peek(1) 169 if err == io.EOF { 170 err = nil 171 return 172 } 173 if result.status >= 400 { 174 result.err, err = errors.UnmarshalErrorStatus(reader, result.status) 175 if err != nil { 176 return 177 } 178 err = result.err 179 return 180 } 181 err = readHTPasswdUsersAddResponse(result, reader) 182 if err != nil { 183 return 184 } 185 return 186 } 187 188 // HTPasswdUsersAddResponse is the response for the 'add' method. 189 type HTPasswdUsersAddResponse struct { 190 status int 191 header http.Header 192 err *errors.Error 193 body *HTPasswdUser 194 } 195 196 // Status returns the response status code. 197 func (r *HTPasswdUsersAddResponse) Status() int { 198 if r == nil { 199 return 0 200 } 201 return r.status 202 } 203 204 // Header returns header of the response. 205 func (r *HTPasswdUsersAddResponse) Header() http.Header { 206 if r == nil { 207 return nil 208 } 209 return r.header 210 } 211 212 // Error returns the response error. 213 func (r *HTPasswdUsersAddResponse) Error() *errors.Error { 214 if r == nil { 215 return nil 216 } 217 return r.err 218 } 219 220 // Body returns the value of the 'body' parameter. 221 // 222 // New user to be added 223 func (r *HTPasswdUsersAddResponse) Body() *HTPasswdUser { 224 if r == nil { 225 return nil 226 } 227 return r.body 228 } 229 230 // GetBody returns the value of the 'body' parameter and 231 // a flag indicating if the parameter has a value. 232 // 233 // New user to be added 234 func (r *HTPasswdUsersAddResponse) GetBody() (value *HTPasswdUser, ok bool) { 235 ok = r != nil && r.body != nil 236 if ok { 237 value = r.body 238 } 239 return 240 } 241 242 // HTPasswdUsersImportRequest is the request for the 'import' method. 243 type HTPasswdUsersImportRequest struct { 244 transport http.RoundTripper 245 path string 246 query url.Values 247 header http.Header 248 items []*HTPasswdUser 249 page *int 250 size *int 251 } 252 253 // Parameter adds a query parameter. 254 func (r *HTPasswdUsersImportRequest) Parameter(name string, value interface{}) *HTPasswdUsersImportRequest { 255 helpers.AddValue(&r.query, name, value) 256 return r 257 } 258 259 // Header adds a request header. 260 func (r *HTPasswdUsersImportRequest) Header(name string, value interface{}) *HTPasswdUsersImportRequest { 261 helpers.AddHeader(&r.header, name, value) 262 return r 263 } 264 265 // Impersonate wraps requests on behalf of another user. 266 // Note: Services that do not support this feature may silently ignore this call. 267 func (r *HTPasswdUsersImportRequest) Impersonate(user string) *HTPasswdUsersImportRequest { 268 helpers.AddImpersonationHeader(&r.header, user) 269 return r 270 } 271 272 // Items sets the value of the 'items' parameter. 273 // 274 // List of users to add to the IDP. 275 func (r *HTPasswdUsersImportRequest) Items(value []*HTPasswdUser) *HTPasswdUsersImportRequest { 276 r.items = value 277 return r 278 } 279 280 // Page sets the value of the 'page' parameter. 281 // 282 // Index of the requested page, where one corresponds to the first page. 283 func (r *HTPasswdUsersImportRequest) Page(value int) *HTPasswdUsersImportRequest { 284 r.page = &value 285 return r 286 } 287 288 // Size sets the value of the 'size' parameter. 289 // 290 // Number of items contained in the returned page. 291 func (r *HTPasswdUsersImportRequest) Size(value int) *HTPasswdUsersImportRequest { 292 r.size = &value 293 return r 294 } 295 296 // Send sends this request, waits for the response, and returns it. 297 // 298 // This is a potentially lengthy operation, as it requires network communication. 299 // Consider using a context and the SendContext method. 300 func (r *HTPasswdUsersImportRequest) Send() (result *HTPasswdUsersImportResponse, err error) { 301 return r.SendContext(context.Background()) 302 } 303 304 // SendContext sends this request, waits for the response, and returns it. 305 func (r *HTPasswdUsersImportRequest) SendContext(ctx context.Context) (result *HTPasswdUsersImportResponse, err error) { 306 query := helpers.CopyQuery(r.query) 307 header := helpers.CopyHeader(r.header) 308 buffer := &bytes.Buffer{} 309 err = writeHTPasswdUsersImportRequest(r, buffer) 310 if err != nil { 311 return 312 } 313 uri := &url.URL{ 314 Path: r.path, 315 RawQuery: query.Encode(), 316 } 317 request := &http.Request{ 318 Method: "POST", 319 URL: uri, 320 Header: header, 321 Body: io.NopCloser(buffer), 322 } 323 if ctx != nil { 324 request = request.WithContext(ctx) 325 } 326 response, err := r.transport.RoundTrip(request) 327 if err != nil { 328 return 329 } 330 defer response.Body.Close() 331 result = &HTPasswdUsersImportResponse{} 332 result.status = response.StatusCode 333 result.header = response.Header 334 reader := bufio.NewReader(response.Body) 335 _, err = reader.Peek(1) 336 if err == io.EOF { 337 err = nil 338 return 339 } 340 if result.status >= 400 { 341 result.err, err = errors.UnmarshalErrorStatus(reader, result.status) 342 if err != nil { 343 return 344 } 345 err = result.err 346 return 347 } 348 err = readHTPasswdUsersImportResponse(result, reader) 349 if err != nil { 350 return 351 } 352 return 353 } 354 355 // HTPasswdUsersImportResponse is the response for the 'import' method. 356 type HTPasswdUsersImportResponse struct { 357 status int 358 header http.Header 359 err *errors.Error 360 items []*HTPasswdUser 361 page *int 362 size *int 363 total *int 364 } 365 366 // Status returns the response status code. 367 func (r *HTPasswdUsersImportResponse) Status() int { 368 if r == nil { 369 return 0 370 } 371 return r.status 372 } 373 374 // Header returns header of the response. 375 func (r *HTPasswdUsersImportResponse) Header() http.Header { 376 if r == nil { 377 return nil 378 } 379 return r.header 380 } 381 382 // Error returns the response error. 383 func (r *HTPasswdUsersImportResponse) Error() *errors.Error { 384 if r == nil { 385 return nil 386 } 387 return r.err 388 } 389 390 // Items returns the value of the 'items' parameter. 391 // 392 // Updated list of users of the IDP. 393 func (r *HTPasswdUsersImportResponse) Items() []*HTPasswdUser { 394 if r == nil { 395 return nil 396 } 397 return r.items 398 } 399 400 // GetItems returns the value of the 'items' parameter and 401 // a flag indicating if the parameter has a value. 402 // 403 // Updated list of users of the IDP. 404 func (r *HTPasswdUsersImportResponse) GetItems() (value []*HTPasswdUser, ok bool) { 405 ok = r != nil && r.items != nil 406 if ok { 407 value = r.items 408 } 409 return 410 } 411 412 // Page returns the value of the 'page' parameter. 413 // 414 // Index of the requested page, where one corresponds to the first page. 415 func (r *HTPasswdUsersImportResponse) Page() int { 416 if r != nil && r.page != nil { 417 return *r.page 418 } 419 return 0 420 } 421 422 // GetPage returns the value of the 'page' parameter and 423 // a flag indicating if the parameter has a value. 424 // 425 // Index of the requested page, where one corresponds to the first page. 426 func (r *HTPasswdUsersImportResponse) GetPage() (value int, ok bool) { 427 ok = r != nil && r.page != nil 428 if ok { 429 value = *r.page 430 } 431 return 432 } 433 434 // Size returns the value of the 'size' parameter. 435 // 436 // Number of items contained in the returned page. 437 func (r *HTPasswdUsersImportResponse) Size() int { 438 if r != nil && r.size != nil { 439 return *r.size 440 } 441 return 0 442 } 443 444 // GetSize returns the value of the 'size' parameter and 445 // a flag indicating if the parameter has a value. 446 // 447 // Number of items contained in the returned page. 448 func (r *HTPasswdUsersImportResponse) GetSize() (value int, ok bool) { 449 ok = r != nil && r.size != nil 450 if ok { 451 value = *r.size 452 } 453 return 454 } 455 456 // Total returns the value of the 'total' parameter. 457 // 458 // Total number of items of the collection. 459 func (r *HTPasswdUsersImportResponse) Total() int { 460 if r != nil && r.total != nil { 461 return *r.total 462 } 463 return 0 464 } 465 466 // GetTotal returns the value of the 'total' parameter and 467 // a flag indicating if the parameter has a value. 468 // 469 // Total number of items of the collection. 470 func (r *HTPasswdUsersImportResponse) GetTotal() (value int, ok bool) { 471 ok = r != nil && r.total != nil 472 if ok { 473 value = *r.total 474 } 475 return 476 } 477 478 // HTPasswdUsersListRequest is the request for the 'list' method. 479 type HTPasswdUsersListRequest struct { 480 transport http.RoundTripper 481 path string 482 query url.Values 483 header http.Header 484 page *int 485 size *int 486 } 487 488 // Parameter adds a query parameter. 489 func (r *HTPasswdUsersListRequest) Parameter(name string, value interface{}) *HTPasswdUsersListRequest { 490 helpers.AddValue(&r.query, name, value) 491 return r 492 } 493 494 // Header adds a request header. 495 func (r *HTPasswdUsersListRequest) Header(name string, value interface{}) *HTPasswdUsersListRequest { 496 helpers.AddHeader(&r.header, name, value) 497 return r 498 } 499 500 // Impersonate wraps requests on behalf of another user. 501 // Note: Services that do not support this feature may silently ignore this call. 502 func (r *HTPasswdUsersListRequest) Impersonate(user string) *HTPasswdUsersListRequest { 503 helpers.AddImpersonationHeader(&r.header, user) 504 return r 505 } 506 507 // Page sets the value of the 'page' parameter. 508 // 509 // Index of the requested page, where one corresponds to the first page. 510 func (r *HTPasswdUsersListRequest) Page(value int) *HTPasswdUsersListRequest { 511 r.page = &value 512 return r 513 } 514 515 // Size sets the value of the 'size' parameter. 516 // 517 // Number of items contained in the returned page. 518 func (r *HTPasswdUsersListRequest) Size(value int) *HTPasswdUsersListRequest { 519 r.size = &value 520 return r 521 } 522 523 // Send sends this request, waits for the response, and returns it. 524 // 525 // This is a potentially lengthy operation, as it requires network communication. 526 // Consider using a context and the SendContext method. 527 func (r *HTPasswdUsersListRequest) Send() (result *HTPasswdUsersListResponse, err error) { 528 return r.SendContext(context.Background()) 529 } 530 531 // SendContext sends this request, waits for the response, and returns it. 532 func (r *HTPasswdUsersListRequest) SendContext(ctx context.Context) (result *HTPasswdUsersListResponse, err error) { 533 query := helpers.CopyQuery(r.query) 534 if r.page != nil { 535 helpers.AddValue(&query, "page", *r.page) 536 } 537 if r.size != nil { 538 helpers.AddValue(&query, "size", *r.size) 539 } 540 header := helpers.CopyHeader(r.header) 541 uri := &url.URL{ 542 Path: r.path, 543 RawQuery: query.Encode(), 544 } 545 request := &http.Request{ 546 Method: "GET", 547 URL: uri, 548 Header: header, 549 } 550 if ctx != nil { 551 request = request.WithContext(ctx) 552 } 553 response, err := r.transport.RoundTrip(request) 554 if err != nil { 555 return 556 } 557 defer response.Body.Close() 558 result = &HTPasswdUsersListResponse{} 559 result.status = response.StatusCode 560 result.header = response.Header 561 reader := bufio.NewReader(response.Body) 562 _, err = reader.Peek(1) 563 if err == io.EOF { 564 err = nil 565 return 566 } 567 if result.status >= 400 { 568 result.err, err = errors.UnmarshalErrorStatus(reader, result.status) 569 if err != nil { 570 return 571 } 572 err = result.err 573 return 574 } 575 err = readHTPasswdUsersListResponse(result, reader) 576 if err != nil { 577 return 578 } 579 return 580 } 581 582 // HTPasswdUsersListResponse is the response for the 'list' method. 583 type HTPasswdUsersListResponse struct { 584 status int 585 header http.Header 586 err *errors.Error 587 items *HTPasswdUserList 588 page *int 589 size *int 590 total *int 591 } 592 593 // Status returns the response status code. 594 func (r *HTPasswdUsersListResponse) Status() int { 595 if r == nil { 596 return 0 597 } 598 return r.status 599 } 600 601 // Header returns header of the response. 602 func (r *HTPasswdUsersListResponse) Header() http.Header { 603 if r == nil { 604 return nil 605 } 606 return r.header 607 } 608 609 // Error returns the response error. 610 func (r *HTPasswdUsersListResponse) Error() *errors.Error { 611 if r == nil { 612 return nil 613 } 614 return r.err 615 } 616 617 // Items returns the value of the 'items' parameter. 618 // 619 // Retrieved list of users of the IDP. 620 func (r *HTPasswdUsersListResponse) Items() *HTPasswdUserList { 621 if r == nil { 622 return nil 623 } 624 return r.items 625 } 626 627 // GetItems returns the value of the 'items' parameter and 628 // a flag indicating if the parameter has a value. 629 // 630 // Retrieved list of users of the IDP. 631 func (r *HTPasswdUsersListResponse) GetItems() (value *HTPasswdUserList, ok bool) { 632 ok = r != nil && r.items != nil 633 if ok { 634 value = r.items 635 } 636 return 637 } 638 639 // Page returns the value of the 'page' parameter. 640 // 641 // Index of the requested page, where one corresponds to the first page. 642 func (r *HTPasswdUsersListResponse) Page() int { 643 if r != nil && r.page != nil { 644 return *r.page 645 } 646 return 0 647 } 648 649 // GetPage returns the value of the 'page' parameter and 650 // a flag indicating if the parameter has a value. 651 // 652 // Index of the requested page, where one corresponds to the first page. 653 func (r *HTPasswdUsersListResponse) GetPage() (value int, ok bool) { 654 ok = r != nil && r.page != nil 655 if ok { 656 value = *r.page 657 } 658 return 659 } 660 661 // Size returns the value of the 'size' parameter. 662 // 663 // Number of items contained in the returned page. 664 func (r *HTPasswdUsersListResponse) Size() int { 665 if r != nil && r.size != nil { 666 return *r.size 667 } 668 return 0 669 } 670 671 // GetSize returns the value of the 'size' parameter and 672 // a flag indicating if the parameter has a value. 673 // 674 // Number of items contained in the returned page. 675 func (r *HTPasswdUsersListResponse) GetSize() (value int, ok bool) { 676 ok = r != nil && r.size != nil 677 if ok { 678 value = *r.size 679 } 680 return 681 } 682 683 // Total returns the value of the 'total' parameter. 684 // 685 // Total number of items of the collection. 686 func (r *HTPasswdUsersListResponse) Total() int { 687 if r != nil && r.total != nil { 688 return *r.total 689 } 690 return 0 691 } 692 693 // GetTotal returns the value of the 'total' parameter and 694 // a flag indicating if the parameter has a value. 695 // 696 // Total number of items of the collection. 697 func (r *HTPasswdUsersListResponse) GetTotal() (value int, ok bool) { 698 ok = r != nil && r.total != nil 699 if ok { 700 value = *r.total 701 } 702 return 703 }