diff --git a/cli/http.go b/cli/http.go index 1dc35dd178006d65a8813a8e92bfb95d0d216f79..5c1e9e2e2d7086c23c9c42af330ca979152e2f2d 100644 --- a/cli/http.go +++ b/cli/http.go @@ -40,9 +40,8 @@ func HttpGet(apiEndpoint, f string, args ...string) error { viper.Set("CLI_PND", pnd) viper.Set("CLI_SBI", sbi) return viper.WriteConfig() - } else { - fmt.Println(string(bytes)) } + fmt.Println(string(bytes)) case http.StatusCreated: defer resp.Body.Close() bytes, err := ioutil.ReadAll(resp.Body) diff --git a/nucleus/errors.go b/nucleus/errors.go index 1578ecb1615404a37a7c06021e35a6141280e3bb..8bd01fe67150cba93b9c6f2cb5710ae63383b11c 100644 --- a/nucleus/errors.go +++ b/nucleus/errors.go @@ -5,6 +5,7 @@ import ( "reflect" ) +// ErrNilClient implements the Error interface and is called if a GNMI Client is nil. type ErrNilClient struct { } @@ -12,6 +13,7 @@ func (e *ErrNilClient) Error() string { return fmt.Sprintf("client cannot be nil") } +// ErrNil implements the Error interface and is called if a struct is nil. type ErrNil struct { } @@ -19,6 +21,8 @@ func (e *ErrNil) Error() string { return fmt.Sprintf("struct cannot be nil") } +// ErrNotFound implements the Error interface and is called if a specific ID +// of a storable item could not be found. type ErrNotFound struct { id interface{} } @@ -27,6 +31,8 @@ func (e *ErrNotFound) Error() string { return fmt.Sprintf("%v not found", e.id) } +// ErrAlreadyExists implements the Error interface and is called if a specific ID +// of a storable item already exists. type ErrAlreadyExists struct { item interface{} } @@ -35,6 +41,8 @@ func (e *ErrAlreadyExists) Error() string { return fmt.Sprintf("%v already exists", e.item) } +// ErrInvalidTypeAssertion implements the Error interface and is called if the +// type of a storable item does not correspond to the expected type. type ErrInvalidTypeAssertion struct { v interface{} t interface{} @@ -44,6 +52,8 @@ func (e ErrInvalidTypeAssertion) Error() string { return fmt.Sprintf("%v does not implement %v", e.v, e.t) } +// ErrUnsupportedPath implements the Error interface and is called if the +// given path is not supported. type ErrUnsupportedPath struct { p interface{} } @@ -52,12 +62,16 @@ func (e ErrUnsupportedPath) Error() string { return fmt.Sprintf("path %v is not supported", e.p) } +// ErrNotYetImplemented implements the Error interface and is called if a function +// is not implemented yet. type ErrNotYetImplemented struct{} func (e ErrNotYetImplemented) Error() string { return fmt.Sprintf("function not yet implemented") } +// ErrInvalidParameters implements the Error interface and is called if the wrong +// or no parameters have been provided. type ErrInvalidParameters struct { f interface{} r interface{} @@ -67,6 +81,8 @@ func (e ErrInvalidParameters) Error() string { return fmt.Sprintf("invalid parameters for %v: %v", e.f, e.r) } +// ErrInvalidTransportOptions implements the Error interface and is called if the +// wrong TransportOptions have been provided. type ErrInvalidTransportOptions struct { t interface{} } diff --git a/nucleus/gnmi_transport.go b/nucleus/gnmi_transport.go index 0f56e38c0c14f2fe12f78fa387e8862f4d8dfa53..7fb02919e1785530d789bc58cf333b3d32ad2480 100644 --- a/nucleus/gnmi_transport.go +++ b/nucleus/gnmi_transport.go @@ -49,8 +49,7 @@ func (g *Gnmi) GetOptions() interface{} { return g.Options } -// Get takes a slice of gnmi paths, splits them and calls a GNMI get for -//each one of them. +// Get takes a slice of gnmi paths, splits them and calls get for each one of them. func (g *Gnmi) Get(ctx context.Context, params ...string) (interface{}, error) { if g.client == nil { return nil, &ErrNilClient{} @@ -102,6 +101,7 @@ func (g *Gnmi) Set(ctx context.Context, args ...interface{}) (interface{}, error return g.set(ctx, ops, exts...) } +//Subscribe subscribes to a gNMI target func (g *Gnmi) Subscribe(ctx context.Context, params ...string) error { if g.client == nil { return &ErrNilClient{} @@ -243,7 +243,7 @@ func (g *Gnmi) Close() error { // GnmiTransportOptions implements the TransportOptions interface. // GnmiTransportOptions contains all needed information to setup a Gnmi -// Transport and therefore inherits gnmi.Config. +// transport and therefore inherits gnmi.Config. type GnmiTransportOptions struct { // all needed gnmi transport parameters gnmi.Config diff --git a/nucleus/restconf_transport.go b/nucleus/restconf_transport.go index 606f818ff0301bdc5d2e37d6a4273f7851c5b6e1..c4fc343d419256c9a872ebe5d9e1084e81acbb3b 100644 --- a/nucleus/restconf_transport.go +++ b/nucleus/restconf_transport.go @@ -8,22 +8,27 @@ import ( type Restconf struct { } +//Get not implemented yet func (r Restconf) Get(ctx context.Context, params ...string) (interface{}, error) { return nil, &ErrNotYetImplemented{} } +//Set not implemented yet func (r Restconf) Set(ctx context.Context, params ...string) (interface{}, error) { return nil, &ErrNotYetImplemented{} } +// Subscribe not implemented yet func (r Restconf) Subscribe(ctx context.Context, params ...string) error { return &ErrNotYetImplemented{} } +// Type returns the RESTCONF transport type func (r Restconf) Type() string { return "restconf" } +// ProcessResponse not implemented yet func (r Restconf) ProcessResponse(resp interface{}, root interface{}, models *ytypes.Schema) error { return &ErrNotYetImplemented{} }