go.ligato.io/vpp-agent/v3@v3.5.0/cmd/agentctl/client/api.go (about) 1 package client 2 3 import ( 4 "context" 5 "net/http" 6 7 govppapi "go.fd.io/govpp/api" 8 "go.ligato.io/cn-infra/v2/db/keyval" 9 "go.ligato.io/cn-infra/v2/health/probe" 10 "google.golang.org/grpc" 11 12 "go.ligato.io/vpp-agent/v3/client" 13 "go.ligato.io/vpp-agent/v3/cmd/agentctl/api/types" 14 "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/api" 15 "go.ligato.io/vpp-agent/v3/proto/ligato/configurator" 16 "go.ligato.io/vpp-agent/v3/proto/ligato/generic" 17 "go.ligato.io/vpp-agent/v3/proto/ligato/kvscheduler" 18 ) 19 20 // APIClient is an interface that clients that talk with a agent server must implement. 21 type APIClient interface { 22 InfraAPIClient 23 ModelAPIClient 24 SchedulerAPIClient 25 VppAPIClient 26 MetricsAPIClient 27 28 GenericClient() (client.GenericClient, error) 29 ConfiguratorClient() (configurator.ConfiguratorServiceClient, error) 30 MetaServiceClient() (generic.MetaServiceClient, error) 31 32 AgentHost() string 33 Version() string 34 KVDBClient() (KVDBAPIClient, error) 35 GRPCConn() (*grpc.ClientConn, error) 36 HTTPClient() *http.Client 37 AgentVersion(ctx context.Context) (*types.Version, error) 38 NegotiateAPIVersion(ctx context.Context) 39 NegotiateAPIVersionPing(version *types.Version) 40 Close() error 41 } 42 43 // InfraAPIClient defines API client methods for the system 44 type InfraAPIClient interface { 45 Status(ctx context.Context) (*probe.ExposedStatus, error) 46 LoggerList(ctx context.Context) ([]types.Logger, error) 47 LoggerSet(ctx context.Context, logger, level string) error 48 } 49 50 // ModelAPIClient defines API client methods for the models 51 type ModelAPIClient interface { 52 ModelList(ctx context.Context, opts types.ModelListOptions) ([]types.Model, error) 53 } 54 55 // SchedulerAPIClient defines API client methods for the scheduler 56 type SchedulerAPIClient interface { 57 SchedulerDump(ctx context.Context, opts types.SchedulerDumpOptions) ([]api.RecordedKVWithMetadata, error) 58 SchedulerValues(ctx context.Context, opts types.SchedulerValuesOptions) ([]*kvscheduler.BaseValueStatus, error) 59 SchedulerResync(ctx context.Context, opts types.SchedulerResyncOptions) (*api.RecordedTxn, error) 60 SchedulerHistory(ctx context.Context, opts types.SchedulerHistoryOptions) (api.RecordedTxns, error) 61 } 62 63 // VppAPIClient defines API client methods for the VPP 64 type VppAPIClient interface { 65 VppStatsAPIClient 66 VppRunCli(ctx context.Context, cmd string) (reply string, err error) 67 } 68 69 // VppStatsAPIClient defines stats API client methods for the VPP 70 type VppStatsAPIClient interface { 71 VppGetStats(ctx context.Context, typ string) error 72 VppGetBufferStats() (*govppapi.BufferStats, error) 73 VppGetNodeStats() (*govppapi.NodeStats, error) 74 VppGetSystemStats() (*govppapi.SystemStats, error) 75 VppGetErrorStats() (*govppapi.ErrorStats, error) 76 VppGetInterfaceStats() (*govppapi.InterfaceStats, error) 77 } 78 79 type MetricsAPIClient interface { 80 GetMetricData(ctx context.Context, metricName string) (map[string]interface{}, error) 81 } 82 83 type KVDBAPIClient interface { 84 keyval.CoreBrokerWatcher 85 ProtoBroker() keyval.ProtoBroker 86 CompleteFullKey(key string) (string, error) 87 }