3232
3333class XEClient (Client ):
3434 """IOS XE-specific wrapper for gNMI functionality.
35+ Assumes IOS XE 16.12+
3536
3637 Returns direct responses from base Client methods.
3738
@@ -62,17 +63,17 @@ class XEClient(Client):
6263 >>> capabilities = client.capabilities()
6364 >>> print(capabilities)
6465 ...
65- >>> get_response = client.get_xpaths('interfaces/interface')
66+ >>> get_response = client.get_xpaths('/ interfaces/interface')
6667 >>> print(get_response)
6768 ...
68- >>> subscribe_response = client.subscribe_xpaths('interfaces/interface')
69+ >>> subscribe_response = client.subscribe_xpaths('/ interfaces/interface')
6970 >>> for message in subscribe_response: print(message)
7071 ...
71- >>> config = '{"Cisco-IOS-XR-shellutil-cfg:host-names ": [{"host-name ": "gnmi_test"}] }'
72+ >>> config = '{"Cisco-IOS-XE-native:native ": {"hostname ": "gnmi_test"}}'
7273 >>> set_response = client.set_json(config)
7374 >>> print(set_response)
7475 ...
75- >>> delete_response = client.delete_xpaths('Cisco-IOS-XR-shellutil-cfg:host-names/host-name ')
76+ >>> delete_response = client.delete_xpaths('/ Cisco-IOS-XE-native:native/hostname ')
7677 """
7778
7879 def delete_xpaths (self , xpaths , prefix = None ):
@@ -200,12 +201,20 @@ def get_xpaths(self, xpaths, data_type="ALL", encoding="JSON_IETF"):
200201 [ALL, CONFIG, STATE, OPERATIONAL]
201202 encoding : proto.gnmi_pb2.GetRequest.Encoding, optional
202203 A direct value or key from the Encoding enum
203- [JSON, BYTES, PROTO, ASCII, JSON_IETF]
204+ [JSON, JSON_IETF]
204205
205206 Returns
206207 -------
207208 get()
208209 """
210+ supported_encodings = ["JSON" , "JSON_IETF" ]
211+ encoding = util .validate_proto_enum (
212+ "encoding" ,
213+ encoding ,
214+ "Encoding" ,
215+ proto .gnmi_pb2 .Encoding ,
216+ supported_encodings ,
217+ )
209218 gnmi_path = None
210219 if isinstance (xpaths , (list , set )):
211220 gnmi_path = map (self .parse_xpath_to_gnmi_path , set (xpaths ))
@@ -220,11 +229,8 @@ def get_xpaths(self, xpaths, data_type="ALL", encoding="JSON_IETF"):
220229 def subscribe_xpaths (
221230 self ,
222231 xpath_subscriptions ,
223- request_mode = "STREAM" ,
224- sub_mode = "SAMPLE" ,
225232 encoding = "JSON_IETF" ,
226233 sample_interval = Client ._NS_IN_S * 10 ,
227- suppress_redundant = False ,
228234 heartbeat_interval = None ,
229235 ):
230236 """A convenience wrapper of subscribe() which aids in building of SubscriptionRequest
@@ -242,29 +248,12 @@ def subscribe_xpaths(
242248 to SubscriptionRequest. Strings are parsed as XPaths and defaulted with the default arguments,
243249 dictionaries are treated as dicts of args to pass to the Subscribe init, and Subscription is
244250 treated as simply a pre-made Subscription.
245- request_mode : proto.gnmi_pb2.SubscriptionList.Mode, optional
246- Indicates whether STREAM to stream from target,
247- ONCE to stream once (like a get),
248- POLL to respond to POLL.
249- [STREAM]
250- sub_mode : proto.gnmi_pb2.SubscriptionMode, optional
251- The default SubscriptionMode on a per Subscription basis in the SubscriptionList.
252- TARGET_DEFINED indicates that the target (like device/destination) should stream
253- information however it knows best. This instructs the target to decide between ON_CHANGE
254- or SAMPLE - e.g. the device gNMI server may understand that we only need RIB updates
255- as an ON_CHANGE basis as opposed to SAMPLE, and we don't have to explicitly state our
256- desired behavior.
257- ON_CHANGE only streams updates when changes occur.
258- SAMPLE will stream the subscription at a regular cadence/interval.
259- [SAMPLE]
260251 encoding : proto.gnmi_pb2.Encoding, optional
261252 A member of the proto.gnmi_pb2.Encoding enum specifying desired encoding of returned data
262253 [JSON, JSON_IETF]
263254 sample_interval : int, optional
264255 Default nanoseconds for sample to occur.
265256 Defaults to 10 seconds.
266- suppress_redundant : bool, optional
267- Indicates whether values that have not changed should be sent in a SAMPLE subscription.
268257 heartbeat_interval : int, optional
269258 Specifies the maximum allowable silent period in nanoseconds when
270259 suppress_redundant is in use. The target should send a value at least once
@@ -274,9 +263,9 @@ def subscribe_xpaths(
274263 -------
275264 subscribe()
276265 """
277- supported_request_modes = [ "STREAM" ]
266+ request_mode = "STREAM"
278267 supported_encodings = ["JSON" , "JSON_IETF" ]
279- supported_sub_modes = [ "SAMPLE" ]
268+ sub_mode = "SAMPLE"
280269 subscription_list = proto .gnmi_pb2 .SubscriptionList ()
281270 subscription_list .mode = util .validate_proto_enum (
282271 "mode" ,
0 commit comments