github.com/cilium/cilium@v1.16.2/api/v1/health/client/restapi/restapi_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 restapi 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 restapi 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 restapi 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 GetHealthz(params *GetHealthzParams, opts ...ClientOption) (*GetHealthzOK, error) 37 38 SetTransport(transport runtime.ClientTransport) 39 } 40 41 /* 42 GetHealthz gets health of cilium node 43 44 Returns health and status information of the local node including 45 46 load and uptime, as well as the status of related components including 47 the Cilium daemon. 48 */ 49 func (a *Client) GetHealthz(params *GetHealthzParams, opts ...ClientOption) (*GetHealthzOK, error) { 50 // TODO: Validate the params before sending 51 if params == nil { 52 params = NewGetHealthzParams() 53 } 54 op := &runtime.ClientOperation{ 55 ID: "GetHealthz", 56 Method: "GET", 57 PathPattern: "/healthz", 58 ProducesMediaTypes: []string{"application/json"}, 59 ConsumesMediaTypes: []string{"application/json"}, 60 Schemes: []string{"http"}, 61 Params: params, 62 Reader: &GetHealthzReader{formats: a.formats}, 63 Context: params.Context, 64 Client: params.HTTPClient, 65 } 66 for _, opt := range opts { 67 opt(op) 68 } 69 70 result, err := a.transport.Submit(op) 71 if err != nil { 72 return nil, err 73 } 74 success, ok := result.(*GetHealthzOK) 75 if ok { 76 return success, nil 77 } 78 // unexpected success response 79 // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue 80 msg := fmt.Sprintf("unexpected success response for GetHealthz: API contract not enforced by server. Client expected to get an error, but got: %T", result) 81 panic(msg) 82 } 83 84 // SetTransport changes the transport on the client 85 func (a *Client) SetTransport(transport runtime.ClientTransport) { 86 a.transport = transport 87 }