Subject: Re: [Netconf] RESTCONF URL for a list with an instance-identifier as a key

From: "Beauville, Yves (Nokia - BE/Antwerp)" <[email-masked]>
Date: Fri, 14 Sep 2018 16:00:28 +0200

Hello all,

I am looking at how to encode a data resource identifiers in RESTCONF 
request URI.

I am looking at the specific case of a YANG list, with an 
instance-identifier as a key.

RFC8040, section 3.5.3, specifies the following:

    If a data node in the path expression is a YANG list node, then the
    key values for the list (if any) MUST be encoded according to the
    following rules:
...
    o  The key value is specified as a string,_using the canonical _       _representation for the YANG data type_.  Any reserved characters
       MUST be percent-encoded, according to Sections2.1 <https://tools.ietf.org/html/rfc8040#section-2.1>  and2.5 <https://tools.ietf.org/html/rfc8040#section-2.5>  of
       [RFC3986 <https://tools.ietf.org/html/rfc3986>].  The comma (",") character MUST be percent-encoded if
       it is present in the key value.

For an instance-identifier, RFC7950, section 9.13.3, specifies that:

    Since the lexical form depends on the XML context in which the value
    occurs,_this type does not have a canonical form_.

In the example provided below, I have used RFC7951, section 6.11, that  
defines how
an "instance-identifier" value is encoded a string.

Is this a correct approach? Can anyone confirm?

Best Regards
Yves

On 28-08-18 15:02, Beauville, Yves (Nokia - BE/Antwerp) wrote:
>
> Hi All,
>
>  Given the following list in a dummy module called "disable-alarms":
>
>      list disable-alarm {          key "resource";          leaf 
> resource {              type instance-identifier;          }          
> leaf disable {              type boolean;          }      }
>
> And assuming that an entry exists in that list for a resource 
> referring to an interface named 'port' in the "ietf-interfaces" module 
> of RFC-7332.
>
> How do I build a RESTCONF GET request for that entry?
>
> Will it be:
>
>        GET /restconf/data/disable-alarms:disable-alarm=/ietf-interfaces:interfaces/interface[name='port'] HTTP/1.1
>        Host: example.com
>        Accept: application/yang-data+xml
> I have not encoded the URL above for readability. I understand that it 
> should be something like:
> 	/restconf/data/disable-alarms:disable-alarm=%2Fietf-interfaces%3Ainterfaces%2Finterface[name%3D'port']
> If this is not correct, what should be provided in the URL?
>
> Yves
>
>
> _______________________________________________
> Netconf mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netconf

---

From: Qin Wu <[email-masked]>
Date: Sat, 15 Sep 2018 01:44:57 +0000

I don’t think RESTCONF can translate resource into port instance defined in ietf-interfaces automatically.
The correct RESTCONF request is:

GET /restconf/data/disable-alarms:disable-alarm/resource=xxx  HTTP/1.1

      Host: example.com

If you link resource with port interface defined in ietf-interfaces modules, xxx should probably be replaced by

the path to the port interface, e.g., something like /if:interfaces/if:interface[name='port']/ if:ifInOctets
probably both modules namespace should be declared somewhere.

-Qin
发件人: Netconf [mailto:[email-masked]] 代表 Beauville, Yves (Nokia - BE/Antwerp)
发送时间: 2018年9月14日 22:00
收件人: [email-masked]
主题: Re: [Netconf] RESTCONF URL for a list with an instance-identifier as a key

Hello all,

I am looking at how to encode a data resource identifiers in RESTCONF request URI.

I am looking at the specific case of a YANG list, with an instance-identifier as a key.

   following rules:

....

   o  The key value is specified as a string, using the canonical

      representation for the YANG data type.  Any reserved characters

      MUST be percent-encoded, according to Sections 2.1<https://tools.ietf.org/html/rfc8040#section-2.1> and 2.5<https://tools.ietf.org/html/rfc8040#section-2.5> of

      [RFC3986<https://tools.ietf.org/html/rfc3986>].  The comma (",") character MUST be percent-encoded if

   occurs, this type does not have a canonical form.
In the example provided below, I have used RFC7951, section 6.11, that  defines how
an "instance-identifier" value is encoded a string.

Best Regards
Yves

Hi All,

     list disable-alarm {

         key "resource";

         leaf resource {

             type instance-identifier;

         }

         leaf disable {

             type boolean;

         }

     }

And assuming that an entry exists in that list for a resource referring to an interface named 'port' in the "ietf-interfaces" module of RFC-7332.

Will it be:

      Host: example.com

      Accept: application/yang-data+xml
I have not encoded the URL above for readability. I understand that it should be something like:

Yves

Netconf mailing list

[email-masked]<mailto:[email-masked]>