Skip to content

Feature Request | RESTCONF like PATH expressions #1622

Open

Description

@wisotzky

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.

Activity

  1. michalvasko commented on Jun 17, 2021

    @michalvasko
    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.

  2. wisotzky commented on Jun 17, 2021

    @wisotzky
    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.

  3. michalvasko commented on Jun 21, 2021

    @michalvasko
    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.

  4. wisotzky commented on Jun 21, 2021

    @wisotzky
    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.

  5. michalvasko commented on Jun 21, 2021

    @michalvasko
    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.

  6. wisotzky commented on Jun 21, 2021

    @wisotzky
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    is:enhancementRequest for adding new feature or enahncing functionality.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions