github.com/openshift-online/ocm-sdk-go@v0.1.473/clustersmgmt/v1/addon_inquiries_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 "context" 25 "io" 26 "net/http" 27 "net/url" 28 "path" 29 30 "github.com/openshift-online/ocm-sdk-go/errors" 31 "github.com/openshift-online/ocm-sdk-go/helpers" 32 ) 33 34 // AddonInquiriesClient is the client of the 'addon_inquiries' resource. 35 // 36 // Manages add-on inquiries, inquiries perform validation of add-on(s) on a per cluster basis 37 // based on add-on conditions and requirements. 38 type AddonInquiriesClient struct { 39 transport http.RoundTripper 40 path string 41 } 42 43 // NewAddonInquiriesClient creates a new client for the 'addon_inquiries' 44 // resource using the given transport to send the requests and receive the 45 // responses. 46 func NewAddonInquiriesClient(transport http.RoundTripper, path string) *AddonInquiriesClient { 47 return &AddonInquiriesClient{ 48 transport: transport, 49 path: path, 50 } 51 } 52 53 // List creates a request for the 'list' method. 54 func (c *AddonInquiriesClient) List() *AddonInquiriesListRequest { 55 return &AddonInquiriesListRequest{ 56 transport: c.transport, 57 path: c.path, 58 } 59 } 60 61 // AddonInquiry returns the target 'addon_inquiry' resource for the given identifier. 62 func (c *AddonInquiriesClient) AddonInquiry(id string) *AddonInquiryClient { 63 return NewAddonInquiryClient( 64 c.transport, 65 path.Join(c.path, id), 66 ) 67 } 68 69 // AddonInquiriesListRequest is the request for the 'list' method. 70 type AddonInquiriesListRequest struct { 71 transport http.RoundTripper 72 path string 73 query url.Values 74 header http.Header 75 order *string 76 page *int 77 search *string 78 size *int 79 } 80 81 // Parameter adds a query parameter. 82 func (r *AddonInquiriesListRequest) Parameter(name string, value interface{}) *AddonInquiriesListRequest { 83 helpers.AddValue(&r.query, name, value) 84 return r 85 } 86 87 // Header adds a request header. 88 func (r *AddonInquiriesListRequest) Header(name string, value interface{}) *AddonInquiriesListRequest { 89 helpers.AddHeader(&r.header, name, value) 90 return r 91 } 92 93 // Impersonate wraps requests on behalf of another user. 94 // Note: Services that do not support this feature may silently ignore this call. 95 func (r *AddonInquiriesListRequest) Impersonate(user string) *AddonInquiriesListRequest { 96 helpers.AddImpersonationHeader(&r.header, user) 97 return r 98 } 99 100 // Order sets the value of the 'order' parameter. 101 // 102 // Order criteria. 103 // 104 // The syntax of this parameter is similar to the syntax of the _order by_ clause of 105 // a SQL statement, but using the names of the attributes of the add-on instead of 106 // the names of the columns of a table. For example, in order to sort the add-ons 107 // descending by name the value should be: 108 // 109 // ```sql 110 // name desc 111 // ``` 112 // 113 // If the parameter isn't provided, or if the value is empty, then the order of the 114 // results is undefined. 115 func (r *AddonInquiriesListRequest) Order(value string) *AddonInquiriesListRequest { 116 r.order = &value 117 return r 118 } 119 120 // Page sets the value of the 'page' parameter. 121 // 122 // Index of the requested page, where one corresponds to the first page. 123 func (r *AddonInquiriesListRequest) Page(value int) *AddonInquiriesListRequest { 124 r.page = &value 125 return r 126 } 127 128 // Search sets the value of the 'search' parameter. 129 // 130 // Search criteria. 131 // 132 // The syntax of this parameter is similar to the syntax of the _where_ clause of an 133 // SQL statement, but using the names of the attributes of the add-on instead of 134 // the names of the columns of a table. For example, in order to retrieve all the 135 // add-ons with a name starting with `my` the value should be: 136 // 137 // ```sql 138 // name like 'my%' 139 // ``` 140 // 141 // If the parameter isn't provided, or if the value is empty, then all the add-ons 142 // that the user has permission to see will be returned. 143 func (r *AddonInquiriesListRequest) Search(value string) *AddonInquiriesListRequest { 144 r.search = &value 145 return r 146 } 147 148 // Size sets the value of the 'size' parameter. 149 // 150 // Maximum number of items that will be contained in the returned page. 151 func (r *AddonInquiriesListRequest) Size(value int) *AddonInquiriesListRequest { 152 r.size = &value 153 return r 154 } 155 156 // Send sends this request, waits for the response, and returns it. 157 // 158 // This is a potentially lengthy operation, as it requires network communication. 159 // Consider using a context and the SendContext method. 160 func (r *AddonInquiriesListRequest) Send() (result *AddonInquiriesListResponse, err error) { 161 return r.SendContext(context.Background()) 162 } 163 164 // SendContext sends this request, waits for the response, and returns it. 165 func (r *AddonInquiriesListRequest) SendContext(ctx context.Context) (result *AddonInquiriesListResponse, err error) { 166 query := helpers.CopyQuery(r.query) 167 if r.order != nil { 168 helpers.AddValue(&query, "order", *r.order) 169 } 170 if r.page != nil { 171 helpers.AddValue(&query, "page", *r.page) 172 } 173 if r.search != nil { 174 helpers.AddValue(&query, "search", *r.search) 175 } 176 if r.size != nil { 177 helpers.AddValue(&query, "size", *r.size) 178 } 179 header := helpers.CopyHeader(r.header) 180 uri := &url.URL{ 181 Path: r.path, 182 RawQuery: query.Encode(), 183 } 184 request := &http.Request{ 185 Method: "GET", 186 URL: uri, 187 Header: header, 188 } 189 if ctx != nil { 190 request = request.WithContext(ctx) 191 } 192 response, err := r.transport.RoundTrip(request) 193 if err != nil { 194 return 195 } 196 defer response.Body.Close() 197 result = &AddonInquiriesListResponse{} 198 result.status = response.StatusCode 199 result.header = response.Header 200 reader := bufio.NewReader(response.Body) 201 _, err = reader.Peek(1) 202 if err == io.EOF { 203 err = nil 204 return 205 } 206 if result.status >= 400 { 207 result.err, err = errors.UnmarshalErrorStatus(reader, result.status) 208 if err != nil { 209 return 210 } 211 err = result.err 212 return 213 } 214 err = readAddonInquiriesListResponse(result, reader) 215 if err != nil { 216 return 217 } 218 return 219 } 220 221 // AddonInquiriesListResponse is the response for the 'list' method. 222 type AddonInquiriesListResponse struct { 223 status int 224 header http.Header 225 err *errors.Error 226 items *AddOnList 227 page *int 228 size *int 229 total *int 230 } 231 232 // Status returns the response status code. 233 func (r *AddonInquiriesListResponse) Status() int { 234 if r == nil { 235 return 0 236 } 237 return r.status 238 } 239 240 // Header returns header of the response. 241 func (r *AddonInquiriesListResponse) Header() http.Header { 242 if r == nil { 243 return nil 244 } 245 return r.header 246 } 247 248 // Error returns the response error. 249 func (r *AddonInquiriesListResponse) Error() *errors.Error { 250 if r == nil { 251 return nil 252 } 253 return r.err 254 } 255 256 // Items returns the value of the 'items' parameter. 257 // 258 // Retrieved list of add-ons. 259 func (r *AddonInquiriesListResponse) Items() *AddOnList { 260 if r == nil { 261 return nil 262 } 263 return r.items 264 } 265 266 // GetItems returns the value of the 'items' parameter and 267 // a flag indicating if the parameter has a value. 268 // 269 // Retrieved list of add-ons. 270 func (r *AddonInquiriesListResponse) GetItems() (value *AddOnList, ok bool) { 271 ok = r != nil && r.items != nil 272 if ok { 273 value = r.items 274 } 275 return 276 } 277 278 // Page returns the value of the 'page' parameter. 279 // 280 // Index of the requested page, where one corresponds to the first page. 281 func (r *AddonInquiriesListResponse) Page() int { 282 if r != nil && r.page != nil { 283 return *r.page 284 } 285 return 0 286 } 287 288 // GetPage returns the value of the 'page' parameter and 289 // a flag indicating if the parameter has a value. 290 // 291 // Index of the requested page, where one corresponds to the first page. 292 func (r *AddonInquiriesListResponse) GetPage() (value int, ok bool) { 293 ok = r != nil && r.page != nil 294 if ok { 295 value = *r.page 296 } 297 return 298 } 299 300 // Size returns the value of the 'size' parameter. 301 // 302 // Maximum number of items that will be contained in the returned page. 303 func (r *AddonInquiriesListResponse) Size() int { 304 if r != nil && r.size != nil { 305 return *r.size 306 } 307 return 0 308 } 309 310 // GetSize returns the value of the 'size' parameter and 311 // a flag indicating if the parameter has a value. 312 // 313 // Maximum number of items that will be contained in the returned page. 314 func (r *AddonInquiriesListResponse) GetSize() (value int, ok bool) { 315 ok = r != nil && r.size != nil 316 if ok { 317 value = *r.size 318 } 319 return 320 } 321 322 // Total returns the value of the 'total' parameter. 323 // 324 // Total number of items of the collection that match the search criteria, 325 // regardless of the size of the page. 326 func (r *AddonInquiriesListResponse) Total() int { 327 if r != nil && r.total != nil { 328 return *r.total 329 } 330 return 0 331 } 332 333 // GetTotal returns the value of the 'total' parameter and 334 // a flag indicating if the parameter has a value. 335 // 336 // Total number of items of the collection that match the search criteria, 337 // regardless of the size of the page. 338 func (r *AddonInquiriesListResponse) GetTotal() (value int, ok bool) { 339 ok = r != nil && r.total != nil 340 if ok { 341 value = *r.total 342 } 343 return 344 }