Documentation ¶
Index ¶
- Constants
- func ArbitrationExt(s string) (*gnmi_ext.Extension, error)
- func DecimalToFloat(dec *pb.Decimal64) float64
- func Dial(cfg *Config) (pb.GNMIClient, error)
- func DialContext(ctx context.Context, cfg *Config) (pb.GNMIClient, error)
- func ExtractValue(update *pb.Update) (interface{}, error)
- func Get(ctx context.Context, client pb.GNMIClient, paths [][]string, origin string) error
- func GetWithRequest(ctx context.Context, client pb.GNMIClient, req *pb.GetRequest) error
- func JoinPaths(paths ...*pb.Path) *pb.Path
- func LogSubscribeResponse(response *pb.SubscribeResponse) error
- func NewContext(ctx context.Context, cfg *Config) context.Context
- func NewGetRequest(ctx context.Context, paths [][]string, origin string) (*pb.GetRequest, error)
- func NewSubscribeRequest(subscribeOptions *SubscribeOptions) (*pb.SubscribeRequest, error)
- func NotificationToMap(notif *gnmi.Notification) (map[string]interface{}, error)
- func ParseGNMIElements(elms []string) (*pb.Path, error)
- func ParseHostnames(list string) ([]string, error)
- func Set(ctx context.Context, client pb.GNMIClient, setOps []*Operation, ...) (*pb.SetResponse, error)
- func SplitPath(path string) []string
- func SplitPaths(paths []string) [][]string
- func StrPath(path *pb.Path) string
- func StrUpdateVal(u *pb.Update) string
- func StrVal(val *pb.TypedValue) string
- func Subscribe(ctx context.Context, client pb.GNMIClient, subscribeOptions *SubscribeOptions, ...)
- func SubscribeErr(ctx context.Context, client pb.GNMIClient, subscribeOptions *SubscribeOptions, ...) error
- func TypedValue(val interface{}) *pb.TypedValue
- type Config
- type Operation
- type PublishFunc
- type SubscribeOptions
Constants ¶
const (
// HostnameArg is the value to be replaced by the actual hostname
HostnameArg = "HOSTNAME"
)
Variables ¶
This section is empty.
Functions ¶
func ArbitrationExt ¶
ArbitrationExt takes a string representation of a master arbitration value (e.g. "23", "role:42") and return a *gnmi_ext.Extension.
func DecimalToFloat ¶
DecimalToFloat converts a gNMI Decimal64 to a float64
func Dial ¶
func Dial(cfg *Config) (pb.GNMIClient, error)
Dial connects to a gnmi service and returns a client
func DialContext ¶
DialContext connects to a gnmi service and returns a client
func ExtractValue ¶
ExtractValue pulls a value out of a gNMI Update, parsing JSON if present. Possible return types:
string int64 uint64 bool []byte float32 *gnmi.Decimal64 json.Number *any.Any []interface{} map[string]interface{}
func GetWithRequest ¶
func GetWithRequest(ctx context.Context, client pb.GNMIClient, req *pb.GetRequest) error
GetWithRequest takes a fully formed GetRequest, performs the Get, and displays any response.
func LogSubscribeResponse ¶
func LogSubscribeResponse(response *pb.SubscribeResponse) error
LogSubscribeResponse logs update responses to stderr.
func NewContext ¶
NewContext returns a new context with username and password metadata if they are set in cfg.
func NewGetRequest ¶
NewGetRequest returns a GetRequest for the given paths
func NewSubscribeRequest ¶
func NewSubscribeRequest(subscribeOptions *SubscribeOptions) (*pb.SubscribeRequest, error)
NewSubscribeRequest returns a SubscribeRequest for the given paths
func NotificationToMap ¶
func NotificationToMap(notif *gnmi.Notification) (map[string]interface{}, error)
NotificationToMap converts a Notification into a map[string]interface{}
func ParseGNMIElements ¶
ParseGNMIElements builds up a gnmi path, from user-supplied text
func ParseHostnames ¶
ParseHostnames parses a comma-separated list of names and replaces HOSTNAME with the current hostname in it
func Set ¶
func Set(ctx context.Context, client pb.GNMIClient, setOps []*Operation, exts ...*gnmi_ext.Extension) (*pb.SetResponse, error)
Set sends a SetRequest to the given client.
func SplitPath ¶
SplitPath splits a gnmi path according to the spec. See https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-path-conventions.md No validation is done. Behavior is undefined if path is an invalid gnmi path. TODO: Do validation?
func StrUpdateVal ¶
StrUpdateVal will return a string representing the value within the supplied update
func StrVal ¶
func StrVal(val *pb.TypedValue) string
StrVal will return a string representing the supplied value
func Subscribe ¶
func Subscribe(ctx context.Context, client pb.GNMIClient, subscribeOptions *SubscribeOptions, respChan chan<- *pb.SubscribeResponse, errChan chan<- error)
Subscribe sends a SubscribeRequest to the given client. Deprecated: Use SubscribeErr instead.
func SubscribeErr ¶
func SubscribeErr(ctx context.Context, client pb.GNMIClient, subscribeOptions *SubscribeOptions, respChan chan<- *pb.SubscribeResponse) error
SubscribeErr makes a gNMI.Subscribe call and writes the responses to the respChan. Before returning respChan will be closed.
func TypedValue ¶
func TypedValue(val interface{}) *pb.TypedValue
TypedValue marshals an interface into a gNMI TypedValue value
Types ¶
type Config ¶
type Config struct { Addr string CAFile string CertFile string KeyFile string Password string Username string TLS bool Compression string DialOptions []grpc.DialOption Token string Encoding pb.Encoding }
Config is the gnmi.Client config
type PublishFunc ¶
PublishFunc is the method to publish responses