03-03-2019 05:45 PM
I can form simple Restconf query from simple Yang models like below.
I know 'augment' is for extended data models.
Can someone explain how can I create a restconf query for below data model ?
03-17-2019 04:22 PM
Hey there!
There is nothing specific you need to do to retrieve details based on the augmentation model. Assuming the device supports the augmentation, when you send a query to the device, you'll retrieve details on the base model and any augmentations that are relevant.
For example in this request I'm asking for details on the ietf-interfaces model, which is augmented by the ietf-ip model to provide IP details.
curl -k -u 'root:D_Vay!_10&' \ > https://ios-xe-mgmt.cisco.com:9443/restconf/data/ietf-interfaces:interfaces/interface=GigabitEthernet2 <interface xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces" xmlns:if="urn:ietf:params:xml:ns:yang:ietf-interfaces"> <name>GigabitEthernet2</name> <description>Configured by RESTCONF</description> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> <enabled>true</enabled> <ipv4 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip"> <address> <ip>10.255.255.3</ip> <netmask>255.255.255.0</netmask> </address> </ipv4> <ipv6 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip"> </ipv6> </interface>
In your question, you're inquiring about a model that augments the Cisco-IOS-XE-native model, so you'd just make a request targeting the path from the Native model. Something like this:
curl -k -u 'root:D_Vay!_10&' \ > https://ios-xe-mgmt.cisco.com:9443/restconf/data/Cisco-IOS-XE-native:native/dot1x
I don't have a device with dot1x configured handy so can't show the sample response, but the request path should be accurate.
Hope that helps!
Hank
06-26-2020 04:23 PM
Hi I´m trying to do the same with BGP module, but not able to get reply. I know that using the native I can get it, but I would like to know if its possible to use the specific BGP module. I don´t know if my URI is correct.. According to documentations the URI is like that as shown in the picture,the only diff is the augment. Please any help should be very thankfull.
02-26-2021 04:53 PM
Hi Rafael , did you solve this issue? , I have the same problem but i don't find any solution
03-01-2021 06:35 AM
Hi, @rober1986 no one replied me back. =/
01-30-2022 01:36 AM
Hello @rafael_wilbert , @rober1986
have you guys solve the problem?
08-28-2020 04:50 PM
I have a similar query. All the examples on Web etc, take the basic ietf-interface example. What if I wish to use VRRP module for example which has a requirement of: '/ios:native/ios:interface/ios:FastEthernet:'.
(py3-venv) AMANDES4-M-465J:1693 amandes4$ pyang -f tree Cisco-IOS-XE-vrrp.yang
module: Cisco-IOS-XE-vrrp
augment /ios:native/ios:interface/ios:FastEthernet:
+--rw vrrp
+--rw vrrp-group* [group-id]
| +--rw group-id uint8
How do I fit into the REST GET request? Following fails.
/ios:native/ios:interface/ios:FastEthernet:
Regards
Aman
07-27-2021 03:56 AM
Like the name says... this yang model only augments / extends another yang model.
So my assumption is, you're using the incorrect yang model for dot1x queries.
The Cisco-IOS-XE-dot1x module is linked to ios-native. So I would search in the "Cisco-IOS-XE-native" model.
There's a container for dot1x (which is augmented by Cisco-IOS-XE-dot1x)
08-11-2021 11:27 PM
Thought I would add my reply since this topic didn't answer the question and found out by trial and error...
Reading the original question its asking how do you use the augment to build a restconf query.
Based on this
augment "/ios:native/ios:dot1x"
your restconf query would be
/restconf/data/native/dot1x
Please rate as helpful and answered
01-29-2022 01:06 PM
Hello @Wayne Knight
I have tried this, but for different example:
pyang output:
my querry looks like this:
/restconf/data/native/ip/access-list
but the host returns 204 even though, some acls already exists. Solution to this, is if you examine this querry /restconf/data/native/ip/ i.e in postman, output shows, there is no container called "access list". Therefore your solution, in my opinion is wrong. Please feel free to correct me, if im wrong (I am trying to solve it too).
Regards,
Lukasz
07-25-2024 08:50 AM
Hi Lukasz,
I don't know if it's still active, but you forgot to use cisco native namespace `Cisco-IOS-XE-native` in your URI
In [106]: uri = 'https://devnetsandboxiosxe.cisco.com/restconf/data/Cisco-IOS-XE-native:native/ip/access-list/'
In [107]: response = requests.get(
...: url=uri,
...: headers=headers,
...: auth=(username, password),
...: verify=False)
In [108]: print(json.dumps(response.json(), indent=2))
{
"Cisco-IOS-XE-native:access-list": {
"Cisco-IOS-XE-acl:standard": [
{
"name": 10,
"access-list-seq-rule": [
{
"sequence": "10",
"permit": {
"std-ace": {
"ipv4-address-prefix": "1.1.1.1",
"ipv4-prefix": "1.1.1.1"
}
}
},
{
"sequence": "20",
"permit": {
"std-ace": {
"ipv4-address-prefix": "2.2.2.2",
"ipv4-prefix": "2.2.2.2"
}
}
}
]
}
],
"Cisco-IOS-XE-acl:extended": [
{
"name": "NAT-ACL",
"access-list-seq-rule": [
{
"sequence": "10",
"ace-rule": {
"action": "permit",
"protocol": "ip",
"ipv4-address": "192.168.1.0",
"mask": "0.0.0.255",
"dst-any": [
null
]
}
}
]
},
{
"name": "Test",
"access-list-seq-rule": [
{
"sequence": "10",
"ace-rule": {
"action": "permit",
"protocol": "ip",
"any": [
null
],
"dst-host-address": "1.1.1.1",
"dst-host": "1.1.1.1"
}
},
{
"sequence": "20",
"ace-rule": {
"action": "permit",
"protocol": "ip",
"host-address": "2.2.2.2",
"host": "2.2.2.2",
"dst-any": [
null
]
}
}
]
}
]
}
}
In [120]: uri = 'https://devnetsandboxiosxe.cisco.com/restconf/data/Cisco-IOS-XE-native:native/ip/access-list/extended=Test'
In [121]: response = requests.get(
...: url=uri,
...: headers=headers,
...: auth=(username, password),
...: verify=False)
In [122]: print(json.dumps(response.json(), indent=2))
{
"Cisco-IOS-XE-acl:extended": [
{
"name": "Test",
"access-list-seq-rule": [
{
"sequence": "10",
"ace-rule": {
"action": "permit",
"protocol": "ip",
"any": [
null
],
"dst-host-address": "1.1.1.1",
"dst-host": "1.1.1.1"
}
},
{
"sequence": "20",
"ace-rule": {
"action": "permit",
"protocol": "ip",
"host-address": "2.2.2.2",
"host": "2.2.2.2",
"dst-any": [
null
]
}
}
]
}
]
}
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide