cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
570
Views
0
Helpful
1
Replies

maapi to restconf

yale.prince
Level 1
Level 1

hi all i can do this via maapi, but how can i do the same via restconf

import ncs
with ncs.maapi.Maapi() as maapi:
with ncs.maapi.Session(maapi, 'admin', 'system'):
with maapi.start_write_trans() as trans:
root = ncs.maagic.get_root(trans)
print(root.alarms.alarm_list.alarm['ncs', 'al:package-load-failure', "/ncs:packages/ncs:package[ncs:name='tailf-hcc']", ""])
print(root.alarms.alarm_list.alarm['ncs', 'al:package-load-failure', "/ncs:packages/ncs:package[ncs:name='tailf-hcc']", ""].is_cleared)

 

this get will show me all the https://nso:cisco1234@10.10.1.1:8888/restconf/data/tailf-ncs-alarms:alarms/alarm-list/tailf-ncs-alarms:alarm

 

but i want to filter on just the single one

 

eg somthing like 

 

https://nso:cisco1234@10.10.1.1:8888/restconf/data/tailf-ncs-alarms:alarms/alarm-list/tailf-ncs-alarms:alarm

 

https://nso:cisco1234@10.10.1.1:8888/restconf/data/tailf-ncs-alarms:alarms/alarm-list/tailf-ncs-alarms:alarm{"device":"ncs","type":"tailf-ncs-alarms:package-load-failure","managed-object":"/tailf-ncs:packages/package[name='tailf-hcc']","specific-prob...

 

Thanks

Regards

Yale

 

 

1 Reply 1

perander
Cisco Employee
Cisco Employee

You are referencing the list /alarms/alarm-list/alarm which has a multi leaf key,
the values are separated by comma. For further details see
RFC 8040 Section 3.5.3. Encoding Data Resource Identifiers in the Request URI.

+--rw alarms
   +--ro alarm-list
      +--ro alarm* [device type managed-object specific-problem]

You should be able to get the same results with something like the following
RESTCONF requests (note that there are four, 4, leaf values in the key)

https://nso:cisco1234@10.10.1.1:8888/restconf/data/tailf-ncs-alarms:alarms/alarm-list/alarm=ncs,al:package-load-failure,/ncs:packages/ncs:package[ncs:name='tailf-hcc'],

You probably need to urlencode the values, omitted that here for brevity.

EDIT: A coworker pointed out to me that it might not work to supply
"managed-object" with prefixes, e.g.

/ncs:packages/ncs:package[ncs:name='tailf-hcc']

But instead supplying the value without prefixes might work

/packages/package[name='tailf-hcc']

We filed an issue for it and will investigate this further.