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