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 with YFilter, 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, false otherwise.

Raises:

YServiceError if an error has occurred.

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 Entity instances encapsulated into std::vector<ydk::Entity*>. Each Entity instance must be annotated with YFilter, 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, false otherwise.

Raises:

YServiceError if an error has occurred.

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, or ALL.
Returns:

(std::shared_ptr<ydk::Entity>) An instance of Entity as identified by the read_filter or nullptr, if operation fails.

Raises:

YServiceError if an error has occurred.

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 Entity instances encapsulated into std::vector<ydk::Entity*>.
  • read_mode – (std::string) One of the values: CONFIG, STATE, OPERATIONAL, or ALL.
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.

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 of STREAM, ONCE or POLL.
  • encoding – (std::string) Encoding method for the output: one of JSON, BYTES, PROTO, ASCII, or JSON_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 protobuf SubscribeResponse message.
Raises:

YServiceError if an error has occurred.

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 into std::vector, which represent the subscription.
  • qos – (uint) QOS indicating the packet marking.
  • mode – (std::string) Subscription mode: one of STREAM, ONCE or POLL.
  • encoding – (std::string) Encoding method for the output: one of JSON, BYTES, PROTO, ASCII, or JSON_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 protobuf SubscribeResponse message.
Raises:

YServiceError if an error has occurred.

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, or SAMPLE; default value is ON_CHANGE.
  • sample_interval: (longlong) Time interval in nanoseconds between samples in STREAM mode; default value is 60000000000 (1 minute).
  • suppress_redundant: (bool) Indicates whether values that not changed should be sent in a STREAM subscription; default value is false
  • 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.