Services

import "github.com/CiscoDevNet/ydk-go/ydk/services"

Table of Contents

CRUD

struct ydk/services/CrudService

Supports CRUD operations on entities.

(c *CrudService) Create(provider ServiceProvider, entity Entity)

Create the configuration

Parameters:
Returns:

true if the operation was successful, false - otherwise

Return type:

bool

(c *CrudService) Update(provider ServiceProvider, entity Entity)

Update the configuration

Parameters:
Returns:

true if the operation was successful, false - otherwise

Return type:

bool

(c *CrudService) Delete(provider ServiceProvider, entity Entity)

Delete the configuration

Parameters:
Returns:

true if the operation was successful, false - otherwise

Return type:

bool

(c *CrudService) Read(provider ServiceProvider, filter Entity)

Read the configuration and state data

Parameters:
Returns:

the entity or entity collection as identified by the filter. If empty collection is specified in filter, the data returned is an EntityCollection containing entire device running configuration and state

Return type:

Entity

(c *CrudService) ReadConfig(provider ServiceProvider, filter Entity)

Read only configuration data

Parameters:
Returns:

the entity or entity collection as identified by the filter. If empty collection is specified in filter, the data returned is an EntityCollection containing entire device running configuration

Return type:

Entity

Note:

When entire device configuration is requested (filter is an empty entity collection), the resulting data will include only those entities that were imported to the application. If an entity was not included, an error message is developed and logged (the logger must be enabled); example:

[ydk] [error] [Go] Entity ‘ietf-netconf-acm:nacm’ is not registered. Please import corresponding package to your application.

Codec

struct ydk/services/CodecService

Supports encoding and decoding Go model API objects of type Entity

(c *CodecService) Encode(provider CodecServiceProvider, entity Entity)

Encode converts entity object to XML/JSON payload

Parameters:
Returns:

encoded payload; only one entity from entity collection can be encoded to JSON payload

Return type:

A Go string

(c *CodecService) Decode(provider CodecServiceProvider, payload string)

Decode converts XML/JSON object to entity object

Parameters:
  • provider – An instance CodecServiceProvider
  • payload – A Go string representing an encoded payload to decode
Returns:

the decoded entity object; if XML payload represents multiple entities, the method returns entity collection

Return type:

Entity

Executor

struct ydk/services/ExecutorService
Provides the functionality to execute RPCs
(es *ExecutorService) ExecuteRpc (provider ServiceProvider, rpcEntity, topEntity Entity)

Create the entity

Parameters:
  • provider – An instance of ServiceProvider
  • rpcEntity – An instance of Entity representing an RPC entity
  • topEntity – Provide an instance of Entity only when expecting data to be returned
Returns:

Any data the resulting from the operation when provided topEntity parameter

Return type:

Entity or nil

Raises:

YError, if error has occurred

Possible Errors: * a server side error * there isn’t enough information in the entity to prepare the message (eg. missing keys)

Netconf

struct ydk/services/NetconfService
Implements the NETCONF Protocol Operations: https://tools.ietf.org/html/rfc6241.
(ns *NetconfService) CancelCommit(provider ServiceProvider, persistID int)

Cancels an ongoing confirmed commit. If the persistID < 1, the operation MUST be issued on the same session that issued the confirmed commit.

Parameters:
Returns:

true if the operation was successful, false - otherwise

Return type:

bool

Raises:

YError, if error has occurred

(ns *NetconfService) CloseSession(provider ServiceProvider)

Request graceful termination of a NETCONF session

Parameters:provider – An instance of NetconfServiceProvider
Returns:true if the operation was successful, false - otherwise
Return type:bool
Raises:YError, if error has occurred
(ns *NetconfService) Commit(
provider ServiceProvider, confirmed bool, confirmTimeOut, persist, persistID int)

Instructs the device to implement the configuration data contained in the candidate configuration.

Parameters:
  • provider – An instance of NetconfServiceProvider
  • confirmed – A bool that signals a confirmed commit operation
  • comfirmTimeOut – An int representing the timeout interval for a confirmed commit
  • persist – An int that makes the confirmed commit persistent
  • persistID – An int that is given in order to commit a persistent confirmed commit
Returns:

true if the operation was successful, false - otherwise

Return type:

bool

Raises:

YError, if error has occurred

(ns *NetconfService) CopyConfig(
provider ServiceProvider, target, sourceDS DataStore, sourceEntity Entity, url string)

Create or replace an entire configuration DataStore with the contents of another complete configuration DataStore. If the target DataStore exists, it is overwritten. Otherwise, a new one is created, if allowed. sourceEntity should be nil OR sourceDS should be nil, but not neither or both. The url is ignored unless target/sourceDS is set to Url.

Parameters:
  • provider – An instance of NetconfServiceProvider
  • target – An instance of DataStore representing the configuration being used as the destination
  • sourceDS – An instance of DataStore representing the configuration being used as the source
  • sourceEntity – An instance of Entity or EntityCollection representing the configuration being used as the source
  • url – A string representing the configuration url
Returns:

true if the operation was successful, false - otherwise

Return type:

bool

Raises:

YError, if error has occurred

(ns *NetconfService) DeleteConfig(provider ServiceProvider, target DataStore, url string)

Delete a configuration DataStore. The RUNNING configuration DataStore cannot be deleted.

Parameters:
  • provider – An instance of NetconfServiceProvider
  • target – An instance of DataStore representing the configuration being used as the destination
  • url – A string representing the configuration url
Returns:

true if the operation was successful, false - otherwise

Return type:

bool

Raises:

YError, if error has occurred

(ns *NetconfService) DiscardChanges(provider ServiceProvider)

Used to revert the candidate configuration to the current running configuration.

Parameters:provider – An instance of NetconfServiceProvider
Returns:true if the operation was successful, false - otherwise
Return type:bool
Raises:YError, if error has occurred
(ns *NetconfService) EditConfig(
provider ServiceProvider, target DataStore, config Entity, defaultOper, testOp, errorOp string)

Loads all or part of a specified configuration to the specified target configuration datastore. Allows the new configuration to be expressed using a local file, a remote file, or inline. If the target configuration datastore does not exist, it will be created.

Parameters:
  • provider – An instance of NetconfServiceProvider
  • target – An instance of DataStore representing the configuration being used as the destination
  • config – An instance of Entity or EntityCollection that is a hierarchy configuration of data as defined by one of the device’s data models
  • defaultOper – A string that changes the default from merge to either merge, replace, or none
  • testOp – A string that can be set to test-then-set, set, or test-only if the device advertises the :validate:1.1 capability
  • errOp – A string that can be set to stop-on-error, continue-on-error, or rollback-on-error
Returns:

true if the operation was successful, false - otherwise

Return type:

bool

Raises:

YError, if error has occurred

(ns *NetconfService) GetConfig(provider ServiceProvider, source DataStore, filter Entity)

Retrieve all or part of a specified configuration datastore

Parameters:
  • provider – An instance of NetconfServiceProvider
  • source – An instance of DataStore representing the configuration being used as the source
  • filter – An instance of Entity which specifies the portion of the system configuration and state data to retrieve
Returns:

The requested data as defined by filter. If empty collection is specified in filter, the data returned is an EntityCollection containing entire device running configuration

Return type:

Entity

Raises:

YError, if error has occurred

(ns *NetconfService) Get(provider ServiceProvider, filter Entity)

Retrieve running configuration and device state information.

Parameters:
Returns:

The requested data as defined by filter. If empty collection is specified in filter, the data returned is an EntityCollection containing entire device running configuration and state

Return type:

Entity

Raises:

YError, if error has occurred

Note:

When entire device configuration is requested (filter is an empty entity collection), the resulting data will include only those entities that were imported to the application. If an entity was not included, an error message is developed and logged (the logger must be enabled); example:

[ydk] [error] [Go] Entity ‘ietf-netconf-acm:nacm’ is not registered. Please import corresponding package to your application.

(ns *NetconfService) KillSession(provider ServiceProvider, sessionID int)

Force the termination of a NETCONF session.

Parameters:
  • provider – An instance of NetconfServiceProvider
  • sessionID – An int that is the session identifier of the NETCONF session to be terminated
Returns:

true if the operation was successful, false - otherwise

Return type:

bool

Raises:

YError, if error has occurred

(ns *NetconfService) Lock(provider ServiceProvider, target DataStore)

Allows the client to lock the entire configuration datastore system of a device.

Parameters:
Returns:

true if the operation was successful, false - otherwise

Return type:

bool

Raises:

YError, if error has occurred

(ns *NetconfService) Unlock(provider ServiceProvider, target DataStore)

Used to release a configuration lock, previously obtained with the LOCK operation.

Parameters:
Returns:

true if the operation was successful, false - otherwise

Return type:

bool

Raises:

YError, if error has occurred

(ns *NetconfService) Validate(
provider ServiceProvider, sourceDS DataStore, sourceEntity Entity, url string)

Validates the contents of the specified configuration. sourceEntity should be nil OR sourceDS should be nil, but not neither or both. url is ignored unless target/sourceDS is set to Url.

Parameters:
  • provider – An instance of NetconfServiceProvider
  • sourceEntity – An instance of Entity or EntityCollection representing the configuration being used as the source
  • sourceDS – An instance of DataStore representing the configuration being used as the source
  • url – A string representing the configuration url
Returns:

true if the operation was successful, false - otherwise

Return type:

bool

Raises:

YError, if error has occurred

gNMI

struct ydk/services/GnmiService

Implements the gNMI Protocol Operations

(gs *GnmiService) Set(provider *providers.GnmiServiceProvider, entity types.Entity) bool

Perform set operation using SetRequest gRPC

Parameters:
  • provider – An instance of GnmiServiceProvider.
  • entity – An instance of Entity or EntityCollection that is a hierarchy configuration of data as defined by one of the device’s data models. Each instance should have settting of YFilter, which defines set operation. Expected filter values: yfilter.Replace, yfilter.Update, or yfilter.Delete.
Returns:

true if the operation was successful, false - otherwise

Return type:

bool

Raises:

YError, if error has occurred

(gs *GnmiService) Get(provider *providers.GnmiServiceProvider, filter types.Entity, operation string) types.Entity

Perform get operation using GetRequest gRPC

Parameters:
  • provider – An instance of GnmiServiceProvider.
  • filter – An instance of Entity or EntityCollection that is a hierarchy configuration of data as defined by one of the device’s data models.
  • operationstring, which represents operation type; expected values: CONFIG, STATE, OPERATIONAL, and ALL.
Returns:

An instance of Entity or EntityCollection according to the filter type, which represent gRPC message GetResponse.

Raises:

YError, if error has occurred

(gs *GnmiService) Capabilities(provider *providers.GnmiServiceProvider) string

Sends to the gNMI server the GetCapabilities request message

Parameters:
Returns:

JSON encoded string, which contains gNMI server capabilities

Raises:

YError, if error has occurred

(gs *GnmiService) Subscribe(provider *providers.GnmiServiceProvider, subscriptionList []GnmiSubscription, qos uint32, mode string, encode string)

Executed subscribe operation on the gNMI server

Parameters:
  • provider – An instance of GnmiServiceProvider.
  • subscriptionList – Go slice of GnmiSubscription instances
  • qosint QOS indicating the packet marking.
  • mode – Subscription mode: one of STREAM, ONCE or POLL.
  • encodestring, which represents how the subscription data should be encoded: one of JSON, BYTES, PROTO, ASCII, or JSON_IETF.
Returns:

None

Raises:

YError, if error has occurred

struct ydk/services/GnmiSubscription

Instance of this structure defines subscription for a single entity. Members of the structure are:

  • Entity: (Entity) Instance of the subscription entity. This parameter must be set by the user.
  • SubscriptionMode: (string) Expected one of the following string values: TARGET_DEFINED, ON_CHANGE, or SAMPLE; default value is ON_CHANGE.
  • SampleInterval: (uint64) Time interval in nanoseconds between samples in STREAM mode; default value is 60000000000 (1 minute).
  • SuppressRedundant: (bool) Indicates whether values that not changed should be sent in a STREAM subscription; default value is false
  • HeartbeatInterval: (uint64) Specifies the maximum allowable silent period in nanoseconds when suppress_redundant is True. If not specified, the heartbeat_interval is set to 360000000000 (10 minutes) or sample_interval whatever is bigger.