github.com/openshift-online/ocm-sdk-go@v0.1.473/clustersmgmt/v1/awssts_account_roles_inquiry_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 30 "github.com/openshift-online/ocm-sdk-go/errors" 31 "github.com/openshift-online/ocm-sdk-go/helpers" 32 ) 33 34 // AWSSTSAccountRolesInquiryClient is the client of the 'AWSSTS_account_roles_inquiry' resource. 35 // 36 // Manages STS Roles 37 type AWSSTSAccountRolesInquiryClient struct { 38 transport http.RoundTripper 39 path string 40 } 41 42 // NewAWSSTSAccountRolesInquiryClient creates a new client for the 'AWSSTS_account_roles_inquiry' 43 // resource using the given transport to send the requests and receive the 44 // responses. 45 func NewAWSSTSAccountRolesInquiryClient(transport http.RoundTripper, path string) *AWSSTSAccountRolesInquiryClient { 46 return &AWSSTSAccountRolesInquiryClient{ 47 transport: transport, 48 path: path, 49 } 50 } 51 52 // Search creates a request for the 'search' method. 53 func (c *AWSSTSAccountRolesInquiryClient) Search() *AWSSTSAccountRolesInquirySearchRequest { 54 return &AWSSTSAccountRolesInquirySearchRequest{ 55 transport: c.transport, 56 path: c.path, 57 } 58 } 59 60 // AWSSTSAccountRolesInquirySearchRequest is the request for the 'search' method. 61 type AWSSTSAccountRolesInquirySearchRequest struct { 62 transport http.RoundTripper 63 path string 64 query url.Values 65 header http.Header 66 body *AWS 67 page *int 68 size *int 69 } 70 71 // Parameter adds a query parameter. 72 func (r *AWSSTSAccountRolesInquirySearchRequest) Parameter(name string, value interface{}) *AWSSTSAccountRolesInquirySearchRequest { 73 helpers.AddValue(&r.query, name, value) 74 return r 75 } 76 77 // Header adds a request header. 78 func (r *AWSSTSAccountRolesInquirySearchRequest) Header(name string, value interface{}) *AWSSTSAccountRolesInquirySearchRequest { 79 helpers.AddHeader(&r.header, name, value) 80 return r 81 } 82 83 // Impersonate wraps requests on behalf of another user. 84 // Note: Services that do not support this feature may silently ignore this call. 85 func (r *AWSSTSAccountRolesInquirySearchRequest) Impersonate(user string) *AWSSTSAccountRolesInquirySearchRequest { 86 helpers.AddImpersonationHeader(&r.header, user) 87 return r 88 } 89 90 // Body sets the value of the 'body' parameter. 91 // 92 // AWS Account Details required for the inquiry 93 func (r *AWSSTSAccountRolesInquirySearchRequest) Body(value *AWS) *AWSSTSAccountRolesInquirySearchRequest { 94 r.body = value 95 return r 96 } 97 98 // Page sets the value of the 'page' parameter. 99 // 100 // Index of the returned page, where one corresponds to the first page. As this 101 // collection doesn't support paging the result will always be `1`. 102 func (r *AWSSTSAccountRolesInquirySearchRequest) Page(value int) *AWSSTSAccountRolesInquirySearchRequest { 103 r.page = &value 104 return r 105 } 106 107 // Size sets the value of the 'size' parameter. 108 // 109 // Number of items that will be contained in the returned page. As this collection 110 // doesn't support paging or searching the result will always be the total number of 111 // be the total number of STS account roles. 112 func (r *AWSSTSAccountRolesInquirySearchRequest) Size(value int) *AWSSTSAccountRolesInquirySearchRequest { 113 r.size = &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 *AWSSTSAccountRolesInquirySearchRequest) Send() (result *AWSSTSAccountRolesInquirySearchResponse, 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 *AWSSTSAccountRolesInquirySearchRequest) SendContext(ctx context.Context) (result *AWSSTSAccountRolesInquirySearchResponse, err error) { 127 query := helpers.CopyQuery(r.query) 128 if r.page != nil { 129 helpers.AddValue(&query, "page", *r.page) 130 } 131 if r.size != nil { 132 helpers.AddValue(&query, "size", *r.size) 133 } 134 header := helpers.CopyHeader(r.header) 135 buffer := &bytes.Buffer{} 136 err = writeAWSSTSAccountRolesInquirySearchRequest(r, buffer) 137 if err != nil { 138 return 139 } 140 uri := &url.URL{ 141 Path: r.path, 142 RawQuery: query.Encode(), 143 } 144 request := &http.Request{ 145 Method: "POST", 146 URL: uri, 147 Header: header, 148 Body: io.NopCloser(buffer), 149 } 150 if ctx != nil { 151 request = request.WithContext(ctx) 152 } 153 response, err := r.transport.RoundTrip(request) 154 if err != nil { 155 return 156 } 157 defer response.Body.Close() 158 result = &AWSSTSAccountRolesInquirySearchResponse{} 159 result.status = response.StatusCode 160 result.header = response.Header 161 reader := bufio.NewReader(response.Body) 162 _, err = reader.Peek(1) 163 if err == io.EOF { 164 err = nil 165 return 166 } 167 if result.status >= 400 { 168 result.err, err = errors.UnmarshalErrorStatus(reader, result.status) 169 if err != nil { 170 return 171 } 172 err = result.err 173 return 174 } 175 err = readAWSSTSAccountRolesInquirySearchResponse(result, reader) 176 if err != nil { 177 return 178 } 179 return 180 } 181 182 // AWSSTSAccountRolesInquirySearchResponse is the response for the 'search' method. 183 type AWSSTSAccountRolesInquirySearchResponse struct { 184 status int 185 header http.Header 186 err *errors.Error 187 awsAccountId *string 188 items *AWSSTSAccountRoleList 189 page *int 190 size *int 191 total *int 192 } 193 194 // Status returns the response status code. 195 func (r *AWSSTSAccountRolesInquirySearchResponse) Status() int { 196 if r == nil { 197 return 0 198 } 199 return r.status 200 } 201 202 // Header returns header of the response. 203 func (r *AWSSTSAccountRolesInquirySearchResponse) Header() http.Header { 204 if r == nil { 205 return nil 206 } 207 return r.header 208 } 209 210 // Error returns the response error. 211 func (r *AWSSTSAccountRolesInquirySearchResponse) Error() *errors.Error { 212 if r == nil { 213 return nil 214 } 215 return r.err 216 } 217 218 // AwsAccountId returns the value of the 'aws_account_id' parameter. 219 // 220 // The AWS Account Id for the STS Account Roles 221 func (r *AWSSTSAccountRolesInquirySearchResponse) AwsAccountId() string { 222 if r != nil && r.awsAccountId != nil { 223 return *r.awsAccountId 224 } 225 return "" 226 } 227 228 // GetAwsAccountId returns the value of the 'aws_account_id' parameter and 229 // a flag indicating if the parameter has a value. 230 // 231 // The AWS Account Id for the STS Account Roles 232 func (r *AWSSTSAccountRolesInquirySearchResponse) GetAwsAccountId() (value string, ok bool) { 233 ok = r != nil && r.awsAccountId != nil 234 if ok { 235 value = *r.awsAccountId 236 } 237 return 238 } 239 240 // Items returns the value of the 'items' parameter. 241 // 242 // Retrieved list of STS Account Roles 243 func (r *AWSSTSAccountRolesInquirySearchResponse) Items() *AWSSTSAccountRoleList { 244 if r == nil { 245 return nil 246 } 247 return r.items 248 } 249 250 // GetItems returns the value of the 'items' parameter and 251 // a flag indicating if the parameter has a value. 252 // 253 // Retrieved list of STS Account Roles 254 func (r *AWSSTSAccountRolesInquirySearchResponse) GetItems() (value *AWSSTSAccountRoleList, ok bool) { 255 ok = r != nil && r.items != nil 256 if ok { 257 value = r.items 258 } 259 return 260 } 261 262 // Page returns the value of the 'page' parameter. 263 // 264 // Index of the returned page, where one corresponds to the first page. As this 265 // collection doesn't support paging the result will always be `1`. 266 func (r *AWSSTSAccountRolesInquirySearchResponse) Page() int { 267 if r != nil && r.page != nil { 268 return *r.page 269 } 270 return 0 271 } 272 273 // GetPage returns the value of the 'page' parameter and 274 // a flag indicating if the parameter has a value. 275 // 276 // Index of the returned page, where one corresponds to the first page. As this 277 // collection doesn't support paging the result will always be `1`. 278 func (r *AWSSTSAccountRolesInquirySearchResponse) GetPage() (value int, ok bool) { 279 ok = r != nil && r.page != nil 280 if ok { 281 value = *r.page 282 } 283 return 284 } 285 286 // Size returns the value of the 'size' parameter. 287 // 288 // Number of items that will be contained in the returned page. As this collection 289 // doesn't support paging or searching the result will always be the total number of 290 // be the total number of STS account roles. 291 func (r *AWSSTSAccountRolesInquirySearchResponse) Size() int { 292 if r != nil && r.size != nil { 293 return *r.size 294 } 295 return 0 296 } 297 298 // GetSize returns the value of the 'size' parameter and 299 // a flag indicating if the parameter has a value. 300 // 301 // Number of items that will be contained in the returned page. As this collection 302 // doesn't support paging or searching the result will always be the total number of 303 // be the total number of STS account roles. 304 func (r *AWSSTSAccountRolesInquirySearchResponse) GetSize() (value int, ok bool) { 305 ok = r != nil && r.size != nil 306 if ok { 307 value = *r.size 308 } 309 return 310 } 311 312 // Total returns the value of the 'total' parameter. 313 // 314 // Total number of items of the collection that match the search criteria, 315 // regardless of the size of the page. As this collection doesn't support paging or 316 // searching the result will always be the total number of STS account roles 317 func (r *AWSSTSAccountRolesInquirySearchResponse) Total() int { 318 if r != nil && r.total != nil { 319 return *r.total 320 } 321 return 0 322 } 323 324 // GetTotal returns the value of the 'total' parameter and 325 // a flag indicating if the parameter has a value. 326 // 327 // Total number of items of the collection that match the search criteria, 328 // regardless of the size of the page. As this collection doesn't support paging or 329 // searching the result will always be the total number of STS account roles 330 func (r *AWSSTSAccountRolesInquirySearchResponse) GetTotal() (value int, ok bool) { 331 ok = r != nil && r.total != nil 332 if ok { 333 value = *r.total 334 } 335 return 336 }