github.com/cilium/cilium@v1.16.2/api/v1/kvstoremesh/client/cluster/cluster_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 cluster
     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 cluster 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 cluster 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  	GetCluster(params *GetClusterParams, opts ...ClientOption) (*GetClusterOK, error)
    37  
    38  	SetTransport(transport runtime.ClientTransport)
    39  }
    40  
    41  /*
    42  GetCluster retrieves the list of remote clusters and their status
    43  */
    44  func (a *Client) GetCluster(params *GetClusterParams, opts ...ClientOption) (*GetClusterOK, error) {
    45  	// TODO: Validate the params before sending
    46  	if params == nil {
    47  		params = NewGetClusterParams()
    48  	}
    49  	op := &runtime.ClientOperation{
    50  		ID:                 "GetCluster",
    51  		Method:             "GET",
    52  		PathPattern:        "/cluster",
    53  		ProducesMediaTypes: []string{"application/json"},
    54  		ConsumesMediaTypes: []string{"application/json"},
    55  		Schemes:            []string{"http"},
    56  		Params:             params,
    57  		Reader:             &GetClusterReader{formats: a.formats},
    58  		Context:            params.Context,
    59  		Client:             params.HTTPClient,
    60  	}
    61  	for _, opt := range opts {
    62  		opt(op)
    63  	}
    64  
    65  	result, err := a.transport.Submit(op)
    66  	if err != nil {
    67  		return nil, err
    68  	}
    69  	success, ok := result.(*GetClusterOK)
    70  	if ok {
    71  		return success, nil
    72  	}
    73  	// unexpected success response
    74  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
    75  	msg := fmt.Sprintf("unexpected success response for GetCluster: API contract not enforced by server. Client expected to get an error, but got: %T", result)
    76  	panic(msg)
    77  }
    78  
    79  // SetTransport changes the transport on the client
    80  func (a *Client) SetTransport(transport runtime.ClientTransport) {
    81  	a.transport = transport
    82  }