Local prefixes usually do not have an AS_PATH:
```
vtysh -c "show bgp ipv4 unicast 10.10.10.10 json" | jq '.paths[].aspath'
{
"string": "Local",
"segments": [],
"length": 0
}
```
Set AS0 as a temporary solution when AS_PATH length is zero. This
avoids parser failures for local prefixes, though ideally we should
use the device's actual ASN (see TODO in code).
Signed-off-by: Tan Siewert <tan@siewert.io>
The metric and used fields might not be returned, causing the parser to
fail if they are not present. The absence was observed in FRR 10.4.1
with a multipath IPv6 route that has two next-hops (one GUA, one LL):
```
$ vtysh -c "show bgp ipv6 unicast 2003::/19 json" | jq '.paths[].nexthops'
[
{
"ip": "2a0d:2146:bdff:120::1",
"afi": "ipv6",
"scope": "global",
"linkLocalOnly": false,
"length": 32,
"metric": 0,
"accessible": true
},
{
"ip": "fe80::3e61:408:1e3e:cff0",
"afi": "ipv6",
"scope": "link-local",
"length": 32,
"accessible": true,
"used": true
}
]
[
{
"ip": "2a0d:2146:bdff:120::1",
"afi": "ipv6",
"scope": "global",
"linkLocalOnly": false,
"length": 32,
"metric": 0,
"accessible": true
},
{
"ip": "fe80::3e61:408:1e3e:cff0",
"afi": "ipv6",
"scope": "link-local",
"length": 32,
"accessible": true,
"used": true
}
]
```
Tested: Query a prefix with multiple next-hops where the metric or used
attributes are missing on one of them.
Signed-off-by: Tan Siewert <tan@siewert.io>
The use of `strip_whitespace` in `Field` for the query validation model caused the automatic generation of the API docs to fail with `ValueError: `schema_extra` declares key `strip_whitespace` which does not exist in `Schema` object`. By switching from `Field` to `Annotated` with `StringConstraints`, this avoids this issue allowing API docs to be correctly rendered.
Signed-off-by: Mattie Nickson <mnickson@sidingsmedia.com>
Previously, when processing rules with no condition, an extra RuleWithPattern rule was also added to the rule list causing a validation error. This has been corrected.
Signed-off-by: Mattie Nickson <mnickson@sidingsmedia.com>
Some of the field validator methods for device config used `values` as a dictionary (presumably from an old version of pydantic). This is now passed as a `ValidationInfo` object by pydantic, which caused issues when code attempted to access it. The affected methods have been updated to fix the issue.
Fix #311
Signed-off-by: Mattie Nickson <mnickson@sidingsmedia.com>