github.com/openshift-online/ocm-sdk-go@v0.1.473/clustersmgmt/v1/oidc_configs_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 // OidcConfigsClient is the client of the 'oidc_configs' resource. 36 // 37 // Manages the collection of oidc configurations. 38 type OidcConfigsClient struct { 39 transport http.RoundTripper 40 path string 41 } 42 43 // NewOidcConfigsClient creates a new client for the 'oidc_configs' 44 // resource using the given transport to send the requests and receive the 45 // responses. 46 func NewOidcConfigsClient(transport http.RoundTripper, path string) *OidcConfigsClient { 47 return &OidcConfigsClient{ 48 transport: transport, 49 path: path, 50 } 51 } 52 53 // Add creates a request for the 'add' method. 54 // 55 // Creates a hosting under Red Hat's S3 bucket for byo oidc configuration. 56 func (c *OidcConfigsClient) Add() *OidcConfigsAddRequest { 57 return &OidcConfigsAddRequest{ 58 transport: c.transport, 59 path: c.path, 60 } 61 } 62 63 // List creates a request for the 'list' method. 64 // 65 // Retrieves the list of oidc configs. 66 func (c *OidcConfigsClient) List() *OidcConfigsListRequest { 67 return &OidcConfigsListRequest{ 68 transport: c.transport, 69 path: c.path, 70 } 71 } 72 73 // OidcConfig returns the target 'oidc_config' resource for the given identifier. 74 // 75 // Reference to the service that manages an specific identity provider. 76 func (c *OidcConfigsClient) OidcConfig(id string) *OidcConfigClient { 77 return NewOidcConfigClient( 78 c.transport, 79 path.Join(c.path, id), 80 ) 81 } 82 83 // OidcConfigsAddRequest is the request for the 'add' method. 84 type OidcConfigsAddRequest struct { 85 transport http.RoundTripper 86 path string 87 query url.Values 88 header http.Header 89 body *OidcConfig 90 } 91 92 // Parameter adds a query parameter. 93 func (r *OidcConfigsAddRequest) Parameter(name string, value interface{}) *OidcConfigsAddRequest { 94 helpers.AddValue(&r.query, name, value) 95 return r 96 } 97 98 // Header adds a request header. 99 func (r *OidcConfigsAddRequest) Header(name string, value interface{}) *OidcConfigsAddRequest { 100 helpers.AddHeader(&r.header, name, value) 101 return r 102 } 103 104 // Impersonate wraps requests on behalf of another user. 105 // Note: Services that do not support this feature may silently ignore this call. 106 func (r *OidcConfigsAddRequest) Impersonate(user string) *OidcConfigsAddRequest { 107 helpers.AddImpersonationHeader(&r.header, user) 108 return r 109 } 110 111 // Body sets the value of the 'body' parameter. 112 func (r *OidcConfigsAddRequest) Body(value *OidcConfig) *OidcConfigsAddRequest { 113 r.body = value 114 return r 115 } 116 117 // Send sends this request, waits for the response, and returns it. 118 // 119 // This is a potentially lengthy operation, as it requires network communication. 120 // Consider using a context and the SendContext method. 121 func (r *OidcConfigsAddRequest) Send() (result *OidcConfigsAddResponse, err error) { 122 return r.SendContext(context.Background()) 123 } 124 125 // SendContext sends this request, waits for the response, and returns it. 126 func (r *OidcConfigsAddRequest) SendContext(ctx context.Context) (result *OidcConfigsAddResponse, err error) { 127 query := helpers.CopyQuery(r.query) 128 header := helpers.CopyHeader(r.header) 129 buffer := &bytes.Buffer{} 130 err = writeOidcConfigsAddRequest(r, buffer) 131 if err != nil { 132 return 133 } 134 uri := &url.URL{ 135 Path: r.path, 136 RawQuery: query.Encode(), 137 } 138 request := &http.Request{ 139 Method: "POST", 140 URL: uri, 141 Header: header, 142 Body: io.NopCloser(buffer), 143 } 144 if ctx != nil { 145 request = request.WithContext(ctx) 146 } 147 response, err := r.transport.RoundTrip(request) 148 if err != nil { 149 return 150 } 151 defer response.Body.Close() 152 result = &OidcConfigsAddResponse{} 153 result.status = response.StatusCode 154 result.header = response.Header 155 reader := bufio.NewReader(response.Body) 156 _, err = reader.Peek(1) 157 if err == io.EOF { 158 err = nil 159 return 160 } 161 if result.status >= 400 { 162 result.err, err = errors.UnmarshalErrorStatus(reader, result.status) 163 if err != nil { 164 return 165 } 166 err = result.err 167 return 168 } 169 err = readOidcConfigsAddResponse(result, reader) 170 if err != nil { 171 return 172 } 173 return 174 } 175 176 // OidcConfigsAddResponse is the response for the 'add' method. 177 type OidcConfigsAddResponse struct { 178 status int 179 header http.Header 180 err *errors.Error 181 body *OidcConfig 182 } 183 184 // Status returns the response status code. 185 func (r *OidcConfigsAddResponse) Status() int { 186 if r == nil { 187 return 0 188 } 189 return r.status 190 } 191 192 // Header returns header of the response. 193 func (r *OidcConfigsAddResponse) Header() http.Header { 194 if r == nil { 195 return nil 196 } 197 return r.header 198 } 199 200 // Error returns the response error. 201 func (r *OidcConfigsAddResponse) Error() *errors.Error { 202 if r == nil { 203 return nil 204 } 205 return r.err 206 } 207 208 // Body returns the value of the 'body' parameter. 209 func (r *OidcConfigsAddResponse) Body() *OidcConfig { 210 if r == nil { 211 return nil 212 } 213 return r.body 214 } 215 216 // GetBody returns the value of the 'body' parameter and 217 // a flag indicating if the parameter has a value. 218 func (r *OidcConfigsAddResponse) GetBody() (value *OidcConfig, ok bool) { 219 ok = r != nil && r.body != nil 220 if ok { 221 value = r.body 222 } 223 return 224 } 225 226 // OidcConfigsListRequest is the request for the 'list' method. 227 type OidcConfigsListRequest struct { 228 transport http.RoundTripper 229 path string 230 query url.Values 231 header http.Header 232 page *int 233 size *int 234 } 235 236 // Parameter adds a query parameter. 237 func (r *OidcConfigsListRequest) Parameter(name string, value interface{}) *OidcConfigsListRequest { 238 helpers.AddValue(&r.query, name, value) 239 return r 240 } 241 242 // Header adds a request header. 243 func (r *OidcConfigsListRequest) Header(name string, value interface{}) *OidcConfigsListRequest { 244 helpers.AddHeader(&r.header, name, value) 245 return r 246 } 247 248 // Impersonate wraps requests on behalf of another user. 249 // Note: Services that do not support this feature may silently ignore this call. 250 func (r *OidcConfigsListRequest) Impersonate(user string) *OidcConfigsListRequest { 251 helpers.AddImpersonationHeader(&r.header, user) 252 return r 253 } 254 255 // Page sets the value of the 'page' parameter. 256 // 257 // Index of the requested page, where one corresponds to the first page. 258 func (r *OidcConfigsListRequest) Page(value int) *OidcConfigsListRequest { 259 r.page = &value 260 return r 261 } 262 263 // Size sets the value of the 'size' parameter. 264 // 265 // Number of items contained in the returned page. 266 func (r *OidcConfigsListRequest) Size(value int) *OidcConfigsListRequest { 267 r.size = &value 268 return r 269 } 270 271 // Send sends this request, waits for the response, and returns it. 272 // 273 // This is a potentially lengthy operation, as it requires network communication. 274 // Consider using a context and the SendContext method. 275 func (r *OidcConfigsListRequest) Send() (result *OidcConfigsListResponse, err error) { 276 return r.SendContext(context.Background()) 277 } 278 279 // SendContext sends this request, waits for the response, and returns it. 280 func (r *OidcConfigsListRequest) SendContext(ctx context.Context) (result *OidcConfigsListResponse, err error) { 281 query := helpers.CopyQuery(r.query) 282 if r.page != nil { 283 helpers.AddValue(&query, "page", *r.page) 284 } 285 if r.size != nil { 286 helpers.AddValue(&query, "size", *r.size) 287 } 288 header := helpers.CopyHeader(r.header) 289 uri := &url.URL{ 290 Path: r.path, 291 RawQuery: query.Encode(), 292 } 293 request := &http.Request{ 294 Method: "GET", 295 URL: uri, 296 Header: header, 297 } 298 if ctx != nil { 299 request = request.WithContext(ctx) 300 } 301 response, err := r.transport.RoundTrip(request) 302 if err != nil { 303 return 304 } 305 defer response.Body.Close() 306 result = &OidcConfigsListResponse{} 307 result.status = response.StatusCode 308 result.header = response.Header 309 reader := bufio.NewReader(response.Body) 310 _, err = reader.Peek(1) 311 if err == io.EOF { 312 err = nil 313 return 314 } 315 if result.status >= 400 { 316 result.err, err = errors.UnmarshalErrorStatus(reader, result.status) 317 if err != nil { 318 return 319 } 320 err = result.err 321 return 322 } 323 err = readOidcConfigsListResponse(result, reader) 324 if err != nil { 325 return 326 } 327 return 328 } 329 330 // OidcConfigsListResponse is the response for the 'list' method. 331 type OidcConfigsListResponse struct { 332 status int 333 header http.Header 334 err *errors.Error 335 items *OidcConfigList 336 page *int 337 size *int 338 total *int 339 } 340 341 // Status returns the response status code. 342 func (r *OidcConfigsListResponse) Status() int { 343 if r == nil { 344 return 0 345 } 346 return r.status 347 } 348 349 // Header returns header of the response. 350 func (r *OidcConfigsListResponse) Header() http.Header { 351 if r == nil { 352 return nil 353 } 354 return r.header 355 } 356 357 // Error returns the response error. 358 func (r *OidcConfigsListResponse) Error() *errors.Error { 359 if r == nil { 360 return nil 361 } 362 return r.err 363 } 364 365 // Items returns the value of the 'items' parameter. 366 // 367 // Retrieved list of identity providers. 368 func (r *OidcConfigsListResponse) Items() *OidcConfigList { 369 if r == nil { 370 return nil 371 } 372 return r.items 373 } 374 375 // GetItems returns the value of the 'items' parameter and 376 // a flag indicating if the parameter has a value. 377 // 378 // Retrieved list of identity providers. 379 func (r *OidcConfigsListResponse) GetItems() (value *OidcConfigList, ok bool) { 380 ok = r != nil && r.items != nil 381 if ok { 382 value = r.items 383 } 384 return 385 } 386 387 // Page returns the value of the 'page' parameter. 388 // 389 // Index of the requested page, where one corresponds to the first page. 390 func (r *OidcConfigsListResponse) Page() int { 391 if r != nil && r.page != nil { 392 return *r.page 393 } 394 return 0 395 } 396 397 // GetPage returns the value of the 'page' parameter and 398 // a flag indicating if the parameter has a value. 399 // 400 // Index of the requested page, where one corresponds to the first page. 401 func (r *OidcConfigsListResponse) GetPage() (value int, ok bool) { 402 ok = r != nil && r.page != nil 403 if ok { 404 value = *r.page 405 } 406 return 407 } 408 409 // Size returns the value of the 'size' parameter. 410 // 411 // Number of items contained in the returned page. 412 func (r *OidcConfigsListResponse) Size() int { 413 if r != nil && r.size != nil { 414 return *r.size 415 } 416 return 0 417 } 418 419 // GetSize returns the value of the 'size' parameter and 420 // a flag indicating if the parameter has a value. 421 // 422 // Number of items contained in the returned page. 423 func (r *OidcConfigsListResponse) GetSize() (value int, ok bool) { 424 ok = r != nil && r.size != nil 425 if ok { 426 value = *r.size 427 } 428 return 429 } 430 431 // Total returns the value of the 'total' parameter. 432 // 433 // Total number of items of the collection. 434 func (r *OidcConfigsListResponse) Total() int { 435 if r != nil && r.total != nil { 436 return *r.total 437 } 438 return 0 439 } 440 441 // GetTotal returns the value of the 'total' parameter and 442 // a flag indicating if the parameter has a value. 443 // 444 // Total number of items of the collection. 445 func (r *OidcConfigsListResponse) GetTotal() (value int, ok bool) { 446 ok = r != nil && r.total != nil 447 if ok { 448 value = *r.total 449 } 450 return 451 }