Services¶
import "github.com/CiscoDevNet/ydk-go/ydk/services"
CRUD¶
-
struct
ydk/services/
CrudService
¶ Supports CRUD operations on entities.
-
(c *CrudService) Create(provider ServiceProvider, entity Entity)
Create the configuration
Parameters: - provider – An instance of ServiceProvider
- entity – An instance of Entity or EntityCollection
Returns: true
if the operation was successful,false
- otherwiseReturn type: bool
-
(c *CrudService) Update(provider ServiceProvider, entity Entity)
Update the configuration
Parameters: - provider – An instance of ServiceProvider
- entity – An instance of Entity or EntityCollection
Returns: true
if the operation was successful,false
- otherwiseReturn type: bool
-
(c *CrudService) Delete(provider ServiceProvider, entity Entity)
Delete the configuration
Parameters: - provider – An instance of ServiceProvider
- entity – An instance of Entity or EntityCollection
Returns: true
if the operation was successful,false
- otherwiseReturn type: bool
-
(c *CrudService) Read(provider ServiceProvider, filter Entity)
Read the configuration and state data
Parameters: - provider – An instance of ServiceProvider
- entity – An instance of Entity or EntityCollection
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:
-
(c *CrudService) ReadConfig(provider ServiceProvider, filter Entity)
Read only configuration data
Parameters: - provider – An instance of ServiceProvider
- entity – An instance of Entity or EntityCollection
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: 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: - provider – An instance of
CodecServiceProvider
- entity – An instance of Entity or EntityCollection
Returns: encoded payload; only one entity from entity collection can be encoded to JSON payload
Return type: A Go
string
- provider – An instance of
-
(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: - provider – An instance
-
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 occurredPossible 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: - provider – An instance of
NetconfServiceProvider
- persistID – An
int
Returns: true
if the operation was successful,false
- otherwiseReturn type: bool
Raises: YError
, if error has occurred- provider – An instance of
-
(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
- otherwiseReturn 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
- otherwiseReturn type: bool
Raises: YError
, if error has occurred- provider – An instance of
-
(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
- otherwiseReturn type: bool
Raises: YError
, if error has occurred- provider – An instance of
-
(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
- otherwiseReturn type: bool
Raises: YError
, if error has occurred- provider – An instance of
-
(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
- otherwiseReturn 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 frommerge
to eithermerge
,replace
, ornone
- testOp – A
string
that can be set totest-then-set
,set
, ortest-only
if the device advertises the :validate:1.1 capability - errOp – A
string
that can be set tostop-on-error
,continue-on-error
, orrollback-on-error
Returns: true
if the operation was successful,false
- otherwiseReturn type: bool
Raises: YError
, if error has occurred- provider – An instance of
-
(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: Raises: YError
, if error has occurred- provider – An instance of
-
(ns *NetconfService) Get(provider ServiceProvider, filter Entity)
Retrieve running configuration and device state information.
Parameters: - provider – An instance of
NetconfServiceProvider
- filter – An instance of Entity or EntityCollection 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 and state
Return type: Raises: YError
, if error has occurredNote: 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.
- provider – An instance of
-
(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
- otherwiseReturn type: bool
Raises: YError
, if error has occurred- provider – An instance of
-
(ns *NetconfService) Lock(provider ServiceProvider, target DataStore)
Allows the client to lock the entire configuration datastore system of a device.
Parameters: - provider – An instance of
NetconfServiceProvider
- target – An instance of DataStore representing the configuration to lock
Returns: true
if the operation was successful,false
- otherwiseReturn type: bool
Raises: YError
, if error has occurred- provider – An instance of
-
(ns *NetconfService) Unlock(provider ServiceProvider, target DataStore)
Used to release a configuration lock, previously obtained with the LOCK operation.
Parameters: - provider – An instance of
NetconfServiceProvider
- target – An instance of DataStore representing the configuration to unlock
Returns: true
if the operation was successful,false
- otherwiseReturn type: bool
Raises: YError
, if error has occurred- provider – An instance of
-
(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
- otherwiseReturn type: bool
Raises: YError
, if error has occurred- provider – An instance of
-
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
- otherwiseReturn 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.
- operation –
string
, which represents operation type; expected values:CONFIG
,STATE
,OPERATIONAL
, andALL
.
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: - provider – An instance of
GnmiServiceProvider
.
Returns: JSON encoded
string
, which contains gNMI server capabilitiesRaises: 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 - qos –
int
QOS indicating the packet marking. - mode – Subscription mode: one of
STREAM
,ONCE
orPOLL
. - encode –
string
, which represents how the subscription data should be encoded: one ofJSON
,BYTES
,PROTO
,ASCII
, orJSON_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
, orSAMPLE
; default value isON_CHANGE
. - SampleInterval: (
uint64
) Time interval in nanoseconds between samples inSTREAM
mode; default value is 60000000000 (1 minute). - SuppressRedundant: (
bool
) Indicates whether values that not changed should be sent in aSTREAM
subscription; default value isfalse
- 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.