api

package module
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2024 License: Apache-2.0 Imports: 18 Imported by: 10

Documentation

Index

Constants

View Source
const (
	DefaultGNMIVersion = "0.7.0"
)

Variables

View Source
var DefaultTargetTimeout = 10 * time.Second
View Source
var ErrInvalidMsgType = errors.New("invalid message type")

ErrInvalidMsgType is returned by a GNMIOption in case the Option is supplied an unexpected proto.Message

View Source
var ErrInvalidValue = errors.New("invalid value")

ErrInvalidValue is returned by a GNMIOption in case the Option is supplied an unexpected value.

Functions

func Accept

func Accept(b bool) func(msg proto.Message) error

func AllowAggregation

func AllowAggregation(b bool) func(msg proto.Message) error

AllowAggregation creates a GNMIOption that sets the AllowAggregation field in a *gnmi.SubscribeRequest with RequestType Subscribe.

func Atomic

func Atomic(b bool) func(msg proto.Message) error

Atomic sets the .Atomic field in a gnmi.Notification message

func Close

func Close(b bool) func(msg proto.Message) error

func Data

func Data(d []byte) func(msg proto.Message) error

func DataType

func DataType(datat string) func(msg proto.Message) error

DataType creates a GNMIOption that adds the data type to the supplied proto.Message which must be a *gnmi.GetRequest.

func DataTypeALL

func DataTypeALL() func(msg proto.Message) error

DataTypeALL creates a GNMIOption that sets the gnmi.GetRequest data type to ALL

func DataTypeCONFIG

func DataTypeCONFIG() func(msg proto.Message) error

DataTypeCONFIG creates a GNMIOption that sets the gnmi.GetRequest data type to CONFIG

func DataTypeOPERATIONAL

func DataTypeOPERATIONAL() func(msg proto.Message) error

DataTypeOPERATIONAL creates a GNMIOption that sets the gnmi.GetRequest data type to OPERATIONAL

func DataTypeSTATE

func DataTypeSTATE() func(msg proto.Message) error

DataTypeSTATE creates a GNMIOption that sets the gnmi.GetRequest data type to STATE

func Delete

func Delete(p string) func(msg proto.Message) error

Delete creates a GNMIOption that creates a *gnmi.Path and adds it to the supplied proto.Message. the supplied message must be a *gnmi.SetRequest. The *gnmi.Path is added the .Delete list.

func Encoding

func Encoding(encoding string) func(msg proto.Message) error

Encoding creates a GNMIOption that adds the encoding type to the supplied proto.Message which can be a *gnmi.GetRequest, *gnmi.SetRequest or a *gnmi.SubscribeRequest with RequestType Subscribe.

func EncodingASCII

func EncodingASCII() func(msg proto.Message) error

EncodingASCII creates a GNMIOption that sets the encoding type to ASCII in a gnmi.GetRequest or gnmi.SubscribeRequest.

func EncodingBYTES

func EncodingBYTES() func(msg proto.Message) error

EncodingBYTES creates a GNMIOption that sets the encoding type to BYTES in a gnmi.GetRequest or gnmi.SubscribeRequest.

func EncodingCustom

func EncodingCustom(enc int) func(msg proto.Message) error

EncodingCustom creates a GNMIOption that adds the encoding type to the supplied proto.Message which can be a *gnmi.GetRequest, *gnmi.SetRequest or a *gnmi.SubscribeRequest with RequestType Subscribe. Unlike Encoding, this GNMIOption does not validate if the provided encoding is defined by the gNMI spec.

func EncodingJSON

func EncodingJSON() func(msg proto.Message) error

EncodingJSON creates a GNMIOption that sets the encoding type to JSON in a gnmi.GetRequest or gnmi.SubscribeRequest.

func EncodingJSON_IETF

func EncodingJSON_IETF() func(msg proto.Message) error

EncodingJSON_IETF creates a GNMIOption that sets the encoding type to JSON_IETF in a gnmi.GetRequest or gnmi.SubscribeRequest.

func EncodingPROTO

func EncodingPROTO() func(msg proto.Message) error

EncodingPROTO creates a GNMIOption that sets the encoding type to PROTO in a gnmi.GetRequest or gnmi.SubscribeRequest.

func Error

func Error(e string) func(msg proto.Message) error

func Extension

func Extension(ext *gnmi_ext.Extension) func(msg proto.Message) error

Extension creates a GNMIOption that applies the supplied gnmi_ext.Extension to the provided proto.Message.

func Extension_CommitCancel added in v0.1.8

func Extension_CommitCancel(id string) func(msg proto.Message) error

func Extension_CommitConfirm added in v0.1.8

func Extension_CommitConfirm(id string) func(msg proto.Message) error

func Extension_CommitRequest added in v0.1.8

func Extension_CommitRequest(id string, dur time.Duration) func(msg proto.Message) error

func Extension_CommitSetRollbackDuration added in v0.1.8

func Extension_CommitSetRollbackDuration(id string, dur time.Duration) func(msg proto.Message) error

func Extension_Depth added in v0.1.8

func Extension_Depth(lvl uint32) func(msg proto.Message) error

func Extension_HistoryRange

func Extension_HistoryRange(start, end time.Time) func(msg proto.Message) error

Extension_HistoryRange creates a GNMIOption that adds a gNMI extension of type History TimeRange with the supplied start and end times. the start/end values can be nanoseconds since Unix epoch or a date in RFC3339 format

func Extension_HistorySnapshotTime

func Extension_HistorySnapshotTime(tm time.Time) func(msg proto.Message) error

Extension_HistorySnapshotTime creates a GNMIOption that adds a gNMI extension of type History Snapshot with the supplied snapshot time. the snapshot value can be nanoseconds since Unix epoch or a date in RFC3339 format

func HeartbeatInterval

func HeartbeatInterval(d time.Duration) func(msg proto.Message) error

HeartbeatInterval creates a GNMIOption that sets the HeartbeatInterval in a proto.Message of type *gnmi.Subscription.

func NewCapabilitiesRequest

func NewCapabilitiesRequest(opts ...GNMIOption) (*gnmi.CapabilityRequest, error)

NewCapabilitiesRequest creates a new *gnmi.CapabilityeRequest using the provided GNMIOption list. returns an error in case one of the options is invalid

func NewCapabilitiesResponse

func NewCapabilitiesResponse(opts ...GNMIOption) (*gnmi.CapabilityResponse, error)

NewCapabilitiesResponse creates a new *gnmi.CapabilityResponse using the provided GNMIOption list. returns an error in case one of the options is invalid

func NewData

func NewData(opts ...TunnelOption) (*tpb.Data, error)

func NewGetRequest

func NewGetRequest(opts ...GNMIOption) (*gnmi.GetRequest, error)

NewGetRequest creates a new *gnmi.GetRequest using the provided GNMIOption list. returns an error in case one of the options is invalid

func NewGetResponse

func NewGetResponse(opts ...GNMIOption) (*gnmi.GetResponse, error)

NewGetResponse creates a new *gnmi.GetResponse using the provided GNMIOption list. returns an error in case one of the options is invalid

func NewRegisterOpSession

func NewRegisterOpSession(opts ...TunnelOption) (*tpb.RegisterOp, error)

func NewRegisterOpSubscription

func NewRegisterOpSubscription(opts ...TunnelOption) (*tpb.RegisterOp, error)

func NewRegisterOpTarget

func NewRegisterOpTarget(opts ...TunnelOption) (*tpb.RegisterOp, error)

func NewSetRequest

func NewSetRequest(opts ...GNMIOption) (*gnmi.SetRequest, error)

NewSetRequest creates a new *gnmi.SetRequest using the provided GNMIOption list. returns an error in case one of the options is invalid

func NewSetResponse

func NewSetResponse(opts ...GNMIOption) (*gnmi.SetResponse, error)

NewSetResponse creates a new *gnmi.SetResponse using the provided GNMIOption list. returns an error in case one of the options is invalid

func NewSubscribePollRequest

func NewSubscribePollRequest(opts ...GNMIOption) (*gnmi.SubscribeRequest, error)

NewSubscribePollRequest creates a new *gnmi.SubscribeRequest with request type Poll using the provided GNMIOption list. returns an error in case one of the options is invalid

func NewSubscribeRequest

func NewSubscribeRequest(opts ...GNMIOption) (*gnmi.SubscribeRequest, error)

NewSubscribeRequest creates a new *gnmi.SubscribeRequest using the provided GNMIOption list. returns an error in case one of the options is invalid

func NewSubscribeResponse

func NewSubscribeResponse(opts ...GNMIOption) (*gnmi.SubscribeResponse, error)

NewSubscribeResponse creates a *gnmi.SubscribeResponse with a gnmi.SubscribeResponse_Update as response type.

func NewSubscribeSyncResponse

func NewSubscribeSyncResponse(opts ...GNMIOption) (*gnmi.SubscribeResponse, error)

NewSubscribeResponse creates a *gnmi.SubscribeResponse with a gnmi.SubscribeResponse_SyncResponse as response type.

func NewTarget

func NewTarget(opts ...TargetOption) (*target.Target, error)

func Notification

func Notification(opts ...GNMIOption) func(msg proto.Message) error

Notification creates a GNMIOption that builds a gnmi.Notification from the supplied GNMIOptions and adds it to the supplied proto.Message

func Operation

func Operation(oper string) func(msg proto.Message) error

Operation creates a GNMIOption that sets the gnmi.UpdateResult_Operation value in a gnmi.UpdateResult.

func OperationDELETE

func OperationDELETE() func(msg proto.Message) error

OperationDELETE creates a GNMIOption that sets the gnmi.SetResponse Operation to DELETE

func OperationINVALID

func OperationINVALID() func(msg proto.Message) error

OperationINVALID creates a GNMIOption that sets the gnmi.SetResponse Operation to INVALID

func OperationREPLACE

func OperationREPLACE() func(msg proto.Message) error

OperationREPLACE creates a GNMIOption that sets the gnmi.SetResponse Operation to REPLACE

func OperationUPDATE

func OperationUPDATE() func(msg proto.Message) error

OperationUPDATE creates a GNMIOption that sets the gnmi.SetResponse Operation to UPDATE

func Path

func Path(p string) func(msg proto.Message) error

Path creates a GNMIOption that creates a *gnmi.Path and adds it to the supplied proto.Message which can be a *gnmi.GetRequest, *gnmi.SetRequest or a *gnmi.Subscription.

func Prefix

func Prefix(prefix string) func(msg proto.Message) error

Prefix creates a GNMIOption that creates a *gnmi.Path and adds it to the supplied proto.Message (as a Path Prefix). The proto.Message can be a *gnmi.GetRequest, *gnmi.SetRequest or a *gnmi.SubscribeRequest with RequestType Subscribe.

func Qos

func Qos(qos uint32) func(msg proto.Message) error

Qos creates a GNMIOption that sets the QosMarking field in a *gnmi.SubscribeRequest with RequestType Subscribe.

func Replace

func Replace(opts ...GNMIOption) func(msg proto.Message) error

Replace creates a GNMIOption that creates a *gnmi.Update message and adds it to the supplied proto.Message. the supplied message must be a *gnmi.SetRequest.

func SampleInterval

func SampleInterval(d time.Duration) func(msg proto.Message) error

SampleInterval creates a GNMIOption that sets the SampleInterval in a proto.Message of type *gnmi.Subscription.

func Subscription

func Subscription(opts ...GNMIOption) func(msg proto.Message) error

UpdatesOnly creates a GNMIOption that creates a *gnmi.Subscription based on the supplied GNMIOption(s) and adds it the supplied proto.Mesage which must be of type *gnmi.SubscribeRequest with RequestType Subscribe.

func SubscriptionListMode

func SubscriptionListMode(mode string) func(msg proto.Message) error

SubscriptionListMode creates a GNMIOption that sets the SubscribeRequest Mode. The variable mode must be one of "once", "poll" or "stream". The supplied proto.Message must be a *gnmi.SubscribeRequest with RequestType Subscribe.

func SubscriptionListModeONCE

func SubscriptionListModeONCE() func(msg proto.Message) error

SubscriptionListModeONCE creates a GNMIOption that sets the Subscription List Mode to ONCE

func SubscriptionListModePOLL

func SubscriptionListModePOLL() func(msg proto.Message) error

SubscriptionListModePOLL creates a GNMIOption that sets the Subscription List Mode to POLL

func SubscriptionListModeSTREAM

func SubscriptionListModeSTREAM() func(msg proto.Message) error

SubscriptionListModeSTREAM creates a GNMIOption that sets the Subscription List Mode to STREAM

func SubscriptionMode

func SubscriptionMode(mode string) func(msg proto.Message) error

SubscriptionMode creates a GNMIOption that sets the Subscription mode in a proto.Message of type *gnmi.Subscription.

func SubscriptionModeON_CHANGE

func SubscriptionModeON_CHANGE() func(msg proto.Message) error

SubscriptionModeON_CHANGE creates a GNMIOption that sets the subscription mode to ON_CHANGE

func SubscriptionModeSAMPLE

func SubscriptionModeSAMPLE() func(msg proto.Message) error

SubscriptionModeSAMPLE creates a GNMIOption that sets the subscription mode to SAMPLE

func SubscriptionModeTARGET_DEFINED

func SubscriptionModeTARGET_DEFINED() func(msg proto.Message) error

SubscriptionModeTARGET_DEFINED creates a GNMIOption that sets the subscription mode to TARGET_DEFINED

func SubscriptionOpSubscribe

func SubscriptionOpSubscribe() func(msg proto.Message) error

func SubscriptionOpUnsubscribe

func SubscriptionOpUnsubscribe() func(msg proto.Message) error

func SupportedEncoding

func SupportedEncoding(encodings ...string) func(msg proto.Message) error

SupportedEncoding creates an GNMIOption that sets the provided encodings as supported encodings in a gnmi.CapabilitiesResponse

func SupportedModel

func SupportedModel(name, org, version string) func(msg proto.Message) error

SupportedModel creates an GNMIOption that sets the provided name, org and version as a supported model in a gnmi.CapabilitiesResponse.

func SuppressRedundant

func SuppressRedundant(s bool) func(msg proto.Message) error

SuppressRedundant creates a GNMIOption that sets the SuppressRedundant in a proto.Message of type *gnmi.Subscription.

func Tag

func Tag(t int32) func(msg proto.Message) error

func Target

func Target(target string) func(msg proto.Message) error

Target creates a GNMIOption that set the gnmi Prefix target to the supplied string value. The proto.Message can be a *gnmi.GetRequest, *gnmi.SetRequest or a *gnmi.SubscribeRequest with RequestType Subscribe.

func TargetName

func TargetName(n string) func(msg proto.Message) error

func TargetOpAdd

func TargetOpAdd() func(msg proto.Message) error

func TargetOpRemove

func TargetOpRemove() func(msg proto.Message) error

Common Options

func TargetType

func TargetType(typ string) func(msg proto.Message) error

func Timestamp

func Timestamp(t int64) func(msg proto.Message) error

Timestamp sets the supplied timestamp in a gnmi.Notification message

func TimestampNow

func TimestampNow() func(msg proto.Message) error

TimestampNow is the same as Timestamp(time.Now().UnixNano())

func TunnelSession

func TunnelSession(opts ...TunnelOption) func(msg proto.Message) error

func TunnelSubscription

func TunnelSubscription(opts ...TunnelOption) func(msg proto.Message) error

func TunnelTarget

func TunnelTarget(opts ...TunnelOption) func(msg proto.Message) error

func UnionReplace

func UnionReplace(opts ...GNMIOption) func(msg proto.Message) error

UnionReplace creates a GNMIOption that creates a *gnmi.Update message and adds it to the supplied proto.Message. the supplied message must be a *gnmi.SetRequest.

func Update

func Update(opts ...GNMIOption) func(msg proto.Message) error

Update creates a GNMIOption that creates a *gnmi.Update message and adds it to the supplied proto.Message, the supplied message must be a *gnmi.SetRequest.

func UpdateResult

func UpdateResult(opts ...GNMIOption) func(msg proto.Message) error

UpdateResult creates a GNMIOption that creates a gnmi.UpdateResult and adds it to a proto.Message of type gnmi.SetResponse.

func UpdatesOnly

func UpdatesOnly(b bool) func(msg proto.Message) error

UpdatesOnly creates a GNMIOption that sets the UpdatesOnly field in a *gnmi.SubscribeRequest with RequestType Subscribe.

func UseModel

func UseModel(name, org, version string) func(msg proto.Message) error

UseModel creates a GNMIOption that add a gnmi.DataModel to a gnmi.GetRequest or gnmi.SubscribeRequest based on the name, org and version strings provided.

func Value

func Value(data interface{}, encoding string) func(msg proto.Message) error

Value creates a GNMIOption that creates a *gnmi.TypedValue and adds it to the supplied proto.Message. the supplied message must be a *gnmi.Update. If a map is supplied as `data interface{}` it has to be a map[string]interface{}.

func Version

func Version(v string) func(msg proto.Message) error

Version sets the provided gNMI version string in a gnmi.CapabilityResponse message.

Types

type GNMIOption

type GNMIOption func(proto.Message) error

GNMIOption is a function that acts on the supplied proto.Message. The message is expected to be one of the protobuf defined gNMI messages exchanged by the RPCs or any of the nested messages.

type TargetOption

type TargetOption func(*target.Target) error

func Address

func Address(addr string) TargetOption

Address sets the target address. This Option can be set multiple times.

func Gzip

func Gzip(b bool) TargetOption

Gzip, if set to true, adds gzip compression to the gRPC connection.

func Insecure

func Insecure(i bool) TargetOption

Insecure sets the option to create a gNMI client with an insecure gRPC connection

func LogTLSSecret

func LogTLSSecret(b bool) TargetOption

LogTLSSecret, if set to true, enables logging of the TLS master key.

func Name

func Name(name string) TargetOption

Name sets the target name.

func Password

func Password(password string) TargetOption

Password sets the target Password.

func SkipVerify

func SkipVerify(i bool) TargetOption

SkipVerify sets the option to create a gNMI client with a secure gRPC connection without verifying the target's certificates.

func TLSCA

func TLSCA(tlsca string) TargetOption

TLSCA sets that path towards the TLS certificate authority file.

func TLSCert

func TLSCert(cert string) TargetOption

TLSCert sets that path towards the TLS certificate file.

func TLSConfig added in v0.1.6

func TLSConfig(tlsconfig *tls.Config) TargetOption

TLSConfig

func TLSKey

func TLSKey(key string) TargetOption

TLSKey sets that path towards the TLS key file.

func TLSMaxVersion

func TLSMaxVersion(v string) TargetOption

TLSMaxVersion sets the TLS maximum version used during the TLS handshake.

func TLSMinVersion

func TLSMinVersion(v string) TargetOption

TLSMinVersion sets the TLS minimum version used during the TLS handshake.

func TLSVersion

func TLSVersion(v string) TargetOption

TLSVersion sets the desired TLS version used during the TLS handshake.

func Timeout

func Timeout(timeout time.Duration) TargetOption

Timeout sets the gNMI client creation timeout.

func Token

func Token(token string) TargetOption

Token sets the per RPC credentials for all RPC calls.

func Username

func Username(username string) TargetOption

Username sets the target Username.

type TunnelOption

type TunnelOption func(proto.Message) error

TunnelOption is a function that acts on the supplied proto.Message. The message is expected to be one of the protobuf defined gRPC tunnel messages exchanged by the RPCs or any of the nested messages.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL