github.com/cilium/cilium@v1.16.2/api/v1/client/bgp/bgp_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 bgp
     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 bgp 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 bgp 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  	GetBgpPeers(params *GetBgpPeersParams, opts ...ClientOption) (*GetBgpPeersOK, error)
    37  
    38  	GetBgpRoutePolicies(params *GetBgpRoutePoliciesParams, opts ...ClientOption) (*GetBgpRoutePoliciesOK, error)
    39  
    40  	GetBgpRoutes(params *GetBgpRoutesParams, opts ...ClientOption) (*GetBgpRoutesOK, error)
    41  
    42  	SetTransport(transport runtime.ClientTransport)
    43  }
    44  
    45  /*
    46  	GetBgpPeers lists operational state of b g p peers
    47  
    48  	Retrieves current operational state of BGP peers created by
    49  
    50  Cilium BGP virtual router. This includes session state, uptime,
    51  information per address family, etc.
    52  */
    53  func (a *Client) GetBgpPeers(params *GetBgpPeersParams, opts ...ClientOption) (*GetBgpPeersOK, error) {
    54  	// TODO: Validate the params before sending
    55  	if params == nil {
    56  		params = NewGetBgpPeersParams()
    57  	}
    58  	op := &runtime.ClientOperation{
    59  		ID:                 "GetBgpPeers",
    60  		Method:             "GET",
    61  		PathPattern:        "/bgp/peers",
    62  		ProducesMediaTypes: []string{"application/json"},
    63  		ConsumesMediaTypes: []string{"application/json"},
    64  		Schemes:            []string{"http"},
    65  		Params:             params,
    66  		Reader:             &GetBgpPeersReader{formats: a.formats},
    67  		Context:            params.Context,
    68  		Client:             params.HTTPClient,
    69  	}
    70  	for _, opt := range opts {
    71  		opt(op)
    72  	}
    73  
    74  	result, err := a.transport.Submit(op)
    75  	if err != nil {
    76  		return nil, err
    77  	}
    78  	success, ok := result.(*GetBgpPeersOK)
    79  	if ok {
    80  		return success, nil
    81  	}
    82  	// unexpected success response
    83  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
    84  	msg := fmt.Sprintf("unexpected success response for GetBgpPeers: API contract not enforced by server. Client expected to get an error, but got: %T", result)
    85  	panic(msg)
    86  }
    87  
    88  /*
    89  GetBgpRoutePolicies lists b g p route policies configured in b g p control plane
    90  
    91  Retrieves route policies from BGP Control Plane.
    92  */
    93  func (a *Client) GetBgpRoutePolicies(params *GetBgpRoutePoliciesParams, opts ...ClientOption) (*GetBgpRoutePoliciesOK, error) {
    94  	// TODO: Validate the params before sending
    95  	if params == nil {
    96  		params = NewGetBgpRoutePoliciesParams()
    97  	}
    98  	op := &runtime.ClientOperation{
    99  		ID:                 "GetBgpRoutePolicies",
   100  		Method:             "GET",
   101  		PathPattern:        "/bgp/route-policies",
   102  		ProducesMediaTypes: []string{"application/json"},
   103  		ConsumesMediaTypes: []string{"application/json"},
   104  		Schemes:            []string{"http"},
   105  		Params:             params,
   106  		Reader:             &GetBgpRoutePoliciesReader{formats: a.formats},
   107  		Context:            params.Context,
   108  		Client:             params.HTTPClient,
   109  	}
   110  	for _, opt := range opts {
   111  		opt(op)
   112  	}
   113  
   114  	result, err := a.transport.Submit(op)
   115  	if err != nil {
   116  		return nil, err
   117  	}
   118  	success, ok := result.(*GetBgpRoutePoliciesOK)
   119  	if ok {
   120  		return success, nil
   121  	}
   122  	// unexpected success response
   123  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   124  	msg := fmt.Sprintf("unexpected success response for GetBgpRoutePolicies: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   125  	panic(msg)
   126  }
   127  
   128  /*
   129  GetBgpRoutes lists b g p routes from b g p control plane r i b
   130  
   131  Retrieves routes from BGP Control Plane RIB filtered by parameters you specify
   132  */
   133  func (a *Client) GetBgpRoutes(params *GetBgpRoutesParams, opts ...ClientOption) (*GetBgpRoutesOK, error) {
   134  	// TODO: Validate the params before sending
   135  	if params == nil {
   136  		params = NewGetBgpRoutesParams()
   137  	}
   138  	op := &runtime.ClientOperation{
   139  		ID:                 "GetBgpRoutes",
   140  		Method:             "GET",
   141  		PathPattern:        "/bgp/routes",
   142  		ProducesMediaTypes: []string{"application/json"},
   143  		ConsumesMediaTypes: []string{"application/json"},
   144  		Schemes:            []string{"http"},
   145  		Params:             params,
   146  		Reader:             &GetBgpRoutesReader{formats: a.formats},
   147  		Context:            params.Context,
   148  		Client:             params.HTTPClient,
   149  	}
   150  	for _, opt := range opts {
   151  		opt(op)
   152  	}
   153  
   154  	result, err := a.transport.Submit(op)
   155  	if err != nil {
   156  		return nil, err
   157  	}
   158  	success, ok := result.(*GetBgpRoutesOK)
   159  	if ok {
   160  		return success, nil
   161  	}
   162  	// unexpected success response
   163  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   164  	msg := fmt.Sprintf("unexpected success response for GetBgpRoutes: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   165  	panic(msg)
   166  }
   167  
   168  // SetTransport changes the transport on the client
   169  func (a *Client) SetTransport(transport runtime.ClientTransport) {
   170  	a.transport = transport
   171  }