gNMI Service¶
-
class
ydk::gNMIService¶ Supports gNMI Set/Get/Subscribe operations on model API entities. It also allows to get gNMI server capabilities.
-
gNMIService()¶ Constructs an instance of gNMIService.
-
bool
set(gNMIServiceProvider &provider, Entity &entity)¶ Create, update, or delete single entity in the server configuration.
Parameters: - provider – (
gNMIServiceProvider) gNMI service provider instance. - entity –
(
Entity) instance, which represents single container in device supported model. The Entity instance must be annotated withYFilter, which defines set operation:- YFilter::replace - add new configuration or replace the whole configuration tree
- YFilter::update - update or create configuration in existing tree
- YFilter::delete_ - delete part or entire configuration tree
Returns: (
bool)trueif operation is successful,falseotherwise.Raises: YServiceError if an error has occurred.
- provider – (
-
bool
set(gNMIServiceProvider &provider, std::vector<Entity *> entities)¶ Create, update, or delete multiple entities in the server configuration.
Parameters: - provider – (
gNMIServiceProvider) gNMI service provider instance. - entities –
(std::vector<ydk::Entity*>) multiple containers of the
Entityinstances encapsulated intostd::vector<ydk::Entity*>. Each Entity instance must be annotated withYFilter, which defines set operation:- YFilter::replace - add new configuration or replace the whole configuration tree
- YFilter::update - update or create configuration in existing tree
- YFilter::delete_ - delete part or entire configuration tree
Returns: (
bool)true, if operation is successful,falseotherwise.Raises: YServiceError if an error has occurred.
- provider – (
-
std::shared_ptr<Entity>
get(gNMIServiceProvider &provider, Entity &read_filter, const std::string &read_mode)¶ Read single entity from the server configuration.
Parameters: - provider – (
gNMIServiceProvider) gNMI service provider instance. - read_filter – (
Entity) instance, which represents single container in device supported model. - read_mode – (
std::string) One of the values:CONFIG,STATE,OPERATIONAL, orALL.
Returns: (std::shared_ptr<ydk::Entity>) An instance of
Entityas identified by the read_filter ornullptr, if operation fails.Raises: YServiceError if an error has occurred.
- provider – (
-
std::vector<std::shared_ptr<Entity>>
get(gNMIServiceProvider &provider, std::vector<Entity *> read_filters, const std::string &read_mode)¶ Read multiple entities from the server configuration.
Parameters: - provider – (
gNMIServiceProvider) gNMI service provider instance. - read_filters – (std::vector<ydk::Entity*>) multiple containers of the
Entityinstances encapsulated intostd::vector<ydk::Entity*>. - read_mode – (
std::string) One of the values:CONFIG,STATE,OPERATIONAL, orALL.
Returns: The requested data encapsulated into std::vector<std::shared_ptr<Entity>> instance; if request fails - empty std::vector.
Raises: YServiceError if an error has occurred.
- provider – (
-
subscribe(gNMIServiceProvider &provider, gNMISubscription &subscription, uint qos, std::string &mode, std::string &encoding, callback)¶ Subscribe to telemetry updates.
Parameters: - provider – (
gNMIServiceProvider) gNMI service provider instance. - subscription – (
gNMISubscription) An instance of structure, which represent the subscription. - qos – (
uint) QOS indicating the packet marking. - mode – (
std::string) Subscription mode: one ofSTREAM,ONCEorPOLL. - encoding – (
std::string) Encoding method for the output: one ofJSON,BYTES,PROTO,ASCII, orJSON_IETF. - callback – (
void*(const char*)) Callback function, which is used to process the subscription data. The subscription data returned to the user as a string representation of protobufSubscribeResponsemessage.
Raises: YServiceError if an error has occurred.
- provider – (
-
subscribe(gNMIServiceProvider &provider, std::vector<ydk::gNMISubscription *> &subscription, uint qos, std::string &mode, std::string &encoding, callback)¶ Subscribe to telemetry updates.
Parameters: - provider – (
gNMIServiceProvider) gNMI service provider instance. - subscription – Set of (
gNMISubscription) instances incapsulated intostd::vector, which represent the subscription. - qos – (
uint) QOS indicating the packet marking. - mode – (
std::string) Subscription mode: one ofSTREAM,ONCEorPOLL. - encoding – (
std::string) Encoding method for the output: one ofJSON,BYTES,PROTO,ASCII, orJSON_IETF. - callback – (
void*(const char*)) Callback function, which is used to process the subscription data. The subscription data returned to the user as a string representation of protobufSubscribeResponsemessage.
Raises: YServiceError if an error has occurred.
- provider – (
-
std::string
capabilities(ydk::gNMIServiceProvider &provider)¶ Get gNMI server capabilities
Parameters: provider – ( gNMIServiceProvider) gNMI service provider instance.Returns: ( std::string) JSON encoded string, which represents gNMI server capabilities.Raises: YServiceError if an error has occurred.
-
-
class
ydk::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. - subscription_mode: (
std::string) Expected one of the following string values:TARGET_DEFINED,ON_CHANGE, orSAMPLE; default value isON_CHANGE. - sample_interval: (
longlong) Time interval in nanoseconds between samples inSTREAMmode; default value is 60000000000 (1 minute). - suppress_redundant: (
bool) Indicates whether values that not changed should be sent in aSTREAMsubscription; default value isfalse - heartbeat_interval: (
longlong) 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.
- entity: (