Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request | RESTCONF like PATH expressions #1622

Open
wisotzky opened this issue Jun 14, 2021 · 6 comments
Open

Feature Request | RESTCONF like PATH expressions #1622

wisotzky opened this issue Jun 14, 2021 · 6 comments
Labels
is:enhancement Request for adding new feature or enahncing functionality.

Comments

@wisotzky
Copy link

Today, libyang only supports XPATH expressions. There is a need to alternatively support RESTCONF compliant path expression, as specified in rfc8040.

XPATH expression example:
/nokia-conf:configure/port[port-id=1/1/1]

Corresponding RESTCONF URL syntax
/nokia-conf:configure/port=1%2F1%2F1

Some details:

  • RESTCONF uses URL encoding for key values
  • Only list-key values are provided (no attribute names)
  • For lists with multiple keys, comma is used as separator while key values will follow the same order as in the YANG key statement

Example with multiple keys:

  • In YANG the statement key: "p1 p2 p3 p4" for list mylist occurs. To access an object with p1="bla" and p4="bing" one would use the following URL path statement .../mylist=bla,,,bing/...

Rational:
To convert a RESTCONF URL/PATH to XPATH is rather complex, because one needs to understand the list keys including ordering (aka requires to know the corresponding YANG file). As libyang has the knowledge the recommendation is to support URL style (model-path) out-of-the-box.

@michalvasko
Copy link
Member

You could have at least reference the specification. Should be fairly simple to support but we have no spare time right now for implementing it and have no use-case so we would not know what exactly should the API do. But we accept pull requests so you are free to implement it.

@michalvasko michalvasko added the is:enhancement Request for adding new feature or enahncing functionality. label Jun 17, 2021
@wisotzky
Copy link
Author

@michalvasko, I will start with the specification and use-case definition first. Will check, if we have cycles to add the code for this.

Instead of providing alternative support for mode-path for all available API endpoints that support XPATH today, likely the best API requirement would be to have a function that translates model-path to xpath and vice versa.

@michalvasko
Copy link
Member

have a function that translates model-path to xpath and vice versa.

Not sure that is really possible because that would require there to already be support in libyang for expressions that can be mapped 1:1 to these RESTCONF URIs. It is certainly not XPath, it may be path but that would need careful examination to make sure of it.

@wisotzky
Copy link
Author

Not sure that is really possible because that would require there to already be support in libyang for expressions that can be mapped 1:1 to these RESTCONF URIs.

1:1 mapping shall be possible. Not sure, what libyang2 provides to make this happen...

It is certainly not XPath, it may be path but that would need careful examination to make sure of it.

Well, it's a path expression (FDN style), however it uses XPATH syntax. Indeed, it's not any XPATH expression just the once that are related to object paths - because else translation would not be possible.

@michalvasko
Copy link
Member

Indeed, it's not any XPATH expression just the once that are related to object paths

I think the restrictions are much more severe than that, you cannot have any operators and even no predicates, which are substituted by special syntax that is not valid in any YANG/NETCONF path.

@wisotzky
Copy link
Author

I think the restrictions are much more severe than that, you cannot have any operators and even no predicates, which are substituted by special syntax that is not valid in any YANG/NETCONF path.

Right... The main use-case here is to having tooling on top of RESTCONF agent. To provide any sort of validation and compare on top of RESTCONF transformation this sort of translation is essential an requires knowledge about the YANG module contents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is:enhancement Request for adding new feature or enahncing functionality.
Projects
None yet
Development

No branches or pull requests

2 participants