github.com/openshift-online/ocm-sdk-go@v0.1.473/clustersmgmt/v1/load_balancer_quota_values_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 29 "github.com/openshift-online/ocm-sdk-go/errors" 30 "github.com/openshift-online/ocm-sdk-go/helpers" 31 ) 32 33 // LoadBalancerQuotaValuesClient is the client of the 'load_balancer_quota_values' resource. 34 // 35 // Manages load balancer quota values. 36 type LoadBalancerQuotaValuesClient struct { 37 transport http.RoundTripper 38 path string 39 } 40 41 // NewLoadBalancerQuotaValuesClient creates a new client for the 'load_balancer_quota_values' 42 // resource using the given transport to send the requests and receive the 43 // responses. 44 func NewLoadBalancerQuotaValuesClient(transport http.RoundTripper, path string) *LoadBalancerQuotaValuesClient { 45 return &LoadBalancerQuotaValuesClient{ 46 transport: transport, 47 path: path, 48 } 49 } 50 51 // List creates a request for the 'list' method. 52 // 53 // Retrieves the list of Load Balancer Quota Values. 54 func (c *LoadBalancerQuotaValuesClient) List() *LoadBalancerQuotaValuesListRequest { 55 return &LoadBalancerQuotaValuesListRequest{ 56 transport: c.transport, 57 path: c.path, 58 } 59 } 60 61 // LoadBalancerQuotaValuesListRequest is the request for the 'list' method. 62 type LoadBalancerQuotaValuesListRequest struct { 63 transport http.RoundTripper 64 path string 65 query url.Values 66 header http.Header 67 page *int 68 size *int 69 } 70 71 // Parameter adds a query parameter. 72 func (r *LoadBalancerQuotaValuesListRequest) Parameter(name string, value interface{}) *LoadBalancerQuotaValuesListRequest { 73 helpers.AddValue(&r.query, name, value) 74 return r 75 } 76 77 // Header adds a request header. 78 func (r *LoadBalancerQuotaValuesListRequest) Header(name string, value interface{}) *LoadBalancerQuotaValuesListRequest { 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 *LoadBalancerQuotaValuesListRequest) Impersonate(user string) *LoadBalancerQuotaValuesListRequest { 86 helpers.AddImpersonationHeader(&r.header, user) 87 return r 88 } 89 90 // Page sets the value of the 'page' parameter. 91 // 92 // Index of the requested page, where one corresponds to the first page. 93 func (r *LoadBalancerQuotaValuesListRequest) Page(value int) *LoadBalancerQuotaValuesListRequest { 94 r.page = &value 95 return r 96 } 97 98 // Size sets the value of the 'size' parameter. 99 // 100 // Number of items contained in the returned page. 101 func (r *LoadBalancerQuotaValuesListRequest) Size(value int) *LoadBalancerQuotaValuesListRequest { 102 r.size = &value 103 return r 104 } 105 106 // Send sends this request, waits for the response, and returns it. 107 // 108 // This is a potentially lengthy operation, as it requires network communication. 109 // Consider using a context and the SendContext method. 110 func (r *LoadBalancerQuotaValuesListRequest) Send() (result *LoadBalancerQuotaValuesListResponse, err error) { 111 return r.SendContext(context.Background()) 112 } 113 114 // SendContext sends this request, waits for the response, and returns it. 115 func (r *LoadBalancerQuotaValuesListRequest) SendContext(ctx context.Context) (result *LoadBalancerQuotaValuesListResponse, err error) { 116 query := helpers.CopyQuery(r.query) 117 if r.page != nil { 118 helpers.AddValue(&query, "page", *r.page) 119 } 120 if r.size != nil { 121 helpers.AddValue(&query, "size", *r.size) 122 } 123 header := helpers.CopyHeader(r.header) 124 uri := &url.URL{ 125 Path: r.path, 126 RawQuery: query.Encode(), 127 } 128 request := &http.Request{ 129 Method: "GET", 130 URL: uri, 131 Header: header, 132 } 133 if ctx != nil { 134 request = request.WithContext(ctx) 135 } 136 response, err := r.transport.RoundTrip(request) 137 if err != nil { 138 return 139 } 140 defer response.Body.Close() 141 result = &LoadBalancerQuotaValuesListResponse{} 142 result.status = response.StatusCode 143 result.header = response.Header 144 reader := bufio.NewReader(response.Body) 145 _, err = reader.Peek(1) 146 if err == io.EOF { 147 err = nil 148 return 149 } 150 if result.status >= 400 { 151 result.err, err = errors.UnmarshalErrorStatus(reader, result.status) 152 if err != nil { 153 return 154 } 155 err = result.err 156 return 157 } 158 err = readLoadBalancerQuotaValuesListResponse(result, reader) 159 if err != nil { 160 return 161 } 162 return 163 } 164 165 // LoadBalancerQuotaValuesListResponse is the response for the 'list' method. 166 type LoadBalancerQuotaValuesListResponse struct { 167 status int 168 header http.Header 169 err *errors.Error 170 items []int 171 page *int 172 size *int 173 total *int 174 } 175 176 // Status returns the response status code. 177 func (r *LoadBalancerQuotaValuesListResponse) Status() int { 178 if r == nil { 179 return 0 180 } 181 return r.status 182 } 183 184 // Header returns header of the response. 185 func (r *LoadBalancerQuotaValuesListResponse) Header() http.Header { 186 if r == nil { 187 return nil 188 } 189 return r.header 190 } 191 192 // Error returns the response error. 193 func (r *LoadBalancerQuotaValuesListResponse) Error() *errors.Error { 194 if r == nil { 195 return nil 196 } 197 return r.err 198 } 199 200 // Items returns the value of the 'items' parameter. 201 // 202 // Retrieved list of values. 203 func (r *LoadBalancerQuotaValuesListResponse) Items() []int { 204 if r == nil { 205 return nil 206 } 207 return r.items 208 } 209 210 // GetItems returns the value of the 'items' parameter and 211 // a flag indicating if the parameter has a value. 212 // 213 // Retrieved list of values. 214 func (r *LoadBalancerQuotaValuesListResponse) GetItems() (value []int, ok bool) { 215 ok = r != nil && r.items != nil 216 if ok { 217 value = r.items 218 } 219 return 220 } 221 222 // Page returns the value of the 'page' parameter. 223 // 224 // Index of the requested page, where one corresponds to the first page. 225 func (r *LoadBalancerQuotaValuesListResponse) Page() int { 226 if r != nil && r.page != nil { 227 return *r.page 228 } 229 return 0 230 } 231 232 // GetPage returns the value of the 'page' parameter and 233 // a flag indicating if the parameter has a value. 234 // 235 // Index of the requested page, where one corresponds to the first page. 236 func (r *LoadBalancerQuotaValuesListResponse) GetPage() (value int, ok bool) { 237 ok = r != nil && r.page != nil 238 if ok { 239 value = *r.page 240 } 241 return 242 } 243 244 // Size returns the value of the 'size' parameter. 245 // 246 // Number of items contained in the returned page. 247 func (r *LoadBalancerQuotaValuesListResponse) Size() int { 248 if r != nil && r.size != nil { 249 return *r.size 250 } 251 return 0 252 } 253 254 // GetSize returns the value of the 'size' parameter and 255 // a flag indicating if the parameter has a value. 256 // 257 // Number of items contained in the returned page. 258 func (r *LoadBalancerQuotaValuesListResponse) GetSize() (value int, ok bool) { 259 ok = r != nil && r.size != nil 260 if ok { 261 value = *r.size 262 } 263 return 264 } 265 266 // Total returns the value of the 'total' parameter. 267 // 268 // Total number of items of the collection. 269 func (r *LoadBalancerQuotaValuesListResponse) Total() int { 270 if r != nil && r.total != nil { 271 return *r.total 272 } 273 return 0 274 } 275 276 // GetTotal returns the value of the 'total' parameter and 277 // a flag indicating if the parameter has a value. 278 // 279 // Total number of items of the collection. 280 func (r *LoadBalancerQuotaValuesListResponse) GetTotal() (value int, ok bool) { 281 ok = r != nil && r.total != nil 282 if ok { 283 value = *r.total 284 } 285 return 286 }