github.com/cilium/cilium@v1.16.2/api/v1/health/client/connectivity/connectivity_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 connectivity
     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 connectivity 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 connectivity 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  	GetStatus(params *GetStatusParams, opts ...ClientOption) (*GetStatusOK, error)
    37  
    38  	PutStatusProbe(params *PutStatusProbeParams, opts ...ClientOption) (*PutStatusProbeOK, error)
    39  
    40  	SetTransport(transport runtime.ClientTransport)
    41  }
    42  
    43  /*
    44  	GetStatus gets connectivity status of the cilium cluster
    45  
    46  	Returns the connectivity status to all other cilium-health instances
    47  
    48  using interval-based probing.
    49  */
    50  func (a *Client) GetStatus(params *GetStatusParams, opts ...ClientOption) (*GetStatusOK, error) {
    51  	// TODO: Validate the params before sending
    52  	if params == nil {
    53  		params = NewGetStatusParams()
    54  	}
    55  	op := &runtime.ClientOperation{
    56  		ID:                 "GetStatus",
    57  		Method:             "GET",
    58  		PathPattern:        "/status",
    59  		ProducesMediaTypes: []string{"application/json"},
    60  		ConsumesMediaTypes: []string{"application/json"},
    61  		Schemes:            []string{"http"},
    62  		Params:             params,
    63  		Reader:             &GetStatusReader{formats: a.formats},
    64  		Context:            params.Context,
    65  		Client:             params.HTTPClient,
    66  	}
    67  	for _, opt := range opts {
    68  		opt(op)
    69  	}
    70  
    71  	result, err := a.transport.Submit(op)
    72  	if err != nil {
    73  		return nil, err
    74  	}
    75  	success, ok := result.(*GetStatusOK)
    76  	if ok {
    77  		return success, nil
    78  	}
    79  	// unexpected success response
    80  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
    81  	msg := fmt.Sprintf("unexpected success response for GetStatus: API contract not enforced by server. Client expected to get an error, but got: %T", result)
    82  	panic(msg)
    83  }
    84  
    85  /*
    86  	PutStatusProbe runs synchronous connectivity probe to determine status of the cilium cluster
    87  
    88  	Runs a synchronous probe to all other cilium-health instances and
    89  
    90  returns the connectivity status.
    91  */
    92  func (a *Client) PutStatusProbe(params *PutStatusProbeParams, opts ...ClientOption) (*PutStatusProbeOK, error) {
    93  	// TODO: Validate the params before sending
    94  	if params == nil {
    95  		params = NewPutStatusProbeParams()
    96  	}
    97  	op := &runtime.ClientOperation{
    98  		ID:                 "PutStatusProbe",
    99  		Method:             "PUT",
   100  		PathPattern:        "/status/probe",
   101  		ProducesMediaTypes: []string{"application/json"},
   102  		ConsumesMediaTypes: []string{"application/json"},
   103  		Schemes:            []string{"http"},
   104  		Params:             params,
   105  		Reader:             &PutStatusProbeReader{formats: a.formats},
   106  		Context:            params.Context,
   107  		Client:             params.HTTPClient,
   108  	}
   109  	for _, opt := range opts {
   110  		opt(op)
   111  	}
   112  
   113  	result, err := a.transport.Submit(op)
   114  	if err != nil {
   115  		return nil, err
   116  	}
   117  	success, ok := result.(*PutStatusProbeOK)
   118  	if ok {
   119  		return success, nil
   120  	}
   121  	// unexpected success response
   122  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   123  	msg := fmt.Sprintf("unexpected success response for PutStatusProbe: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   124  	panic(msg)
   125  }
   126  
   127  // SetTransport changes the transport on the client
   128  func (a *Client) SetTransport(transport runtime.ClientTransport) {
   129  	a.transport = transport
   130  }