github.com/cilium/cilium@v1.16.2/api/v1/operator/client/metrics/metrics_client.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 // Copyright Authors of Cilium 4 // SPDX-License-Identifier: Apache-2.0 5 6 package metrics 7 8 // This file was generated by the swagger tool. 9 // Editing this file might prove futile when you re-run the swagger generate command 10 11 import ( 12 "fmt" 13 14 "github.com/go-openapi/runtime" 15 "github.com/go-openapi/strfmt" 16 ) 17 18 // New creates a new metrics API client. 19 func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { 20 return &Client{transport: transport, formats: formats} 21 } 22 23 /* 24 Client for metrics API 25 */ 26 type Client struct { 27 transport runtime.ClientTransport 28 formats strfmt.Registry 29 } 30 31 // ClientOption is the option for Client methods 32 type ClientOption func(*runtime.ClientOperation) 33 34 // ClientService is the interface for Client methods 35 type ClientService interface { 36 GetMetrics(params *GetMetricsParams, opts ...ClientOption) (*GetMetricsOK, error) 37 38 SetTransport(transport runtime.ClientTransport) 39 } 40 41 /* 42 GetMetrics retrieves cilium operator metrics 43 44 Returns the metrics exposed by the Cilium operator. 45 */ 46 func (a *Client) GetMetrics(params *GetMetricsParams, opts ...ClientOption) (*GetMetricsOK, error) { 47 // TODO: Validate the params before sending 48 if params == nil { 49 params = NewGetMetricsParams() 50 } 51 op := &runtime.ClientOperation{ 52 ID: "GetMetrics", 53 Method: "GET", 54 PathPattern: "/metrics/", 55 ProducesMediaTypes: []string{"application/json"}, 56 ConsumesMediaTypes: []string{"application/json"}, 57 Schemes: []string{"http"}, 58 Params: params, 59 Reader: &GetMetricsReader{formats: a.formats}, 60 Context: params.Context, 61 Client: params.HTTPClient, 62 } 63 for _, opt := range opts { 64 opt(op) 65 } 66 67 result, err := a.transport.Submit(op) 68 if err != nil { 69 return nil, err 70 } 71 success, ok := result.(*GetMetricsOK) 72 if ok { 73 return success, nil 74 } 75 // unexpected success response 76 // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue 77 msg := fmt.Sprintf("unexpected success response for GetMetrics: API contract not enforced by server. Client expected to get an error, but got: %T", result) 78 panic(msg) 79 } 80 81 // SetTransport changes the transport on the client 82 func (a *Client) SetTransport(transport runtime.ClientTransport) { 83 a.transport = transport 84 }