Are URI fragments supported?
Sorry, I fat-fingered the submit button too quickly.
From the Redfish specification:
RFC3986-compliant URIs may also contain the query, ?query, and frag, #frag, components. For information about queries, see Query parameters. When a URI includes a fragment (frag) to submit an operation, the server ignores the fragment.
I'm writing a Redfish client with a fragment reference, but I seem to be getting back the full JSON resource and not the properties referenced by the fragment. Does libredfish support extracting fragments right now?
If you use the redpath APIs then yes it does. If you use just the URI based API's then no it does not take the fragment into account.
If you pass the fragment to getPayloadForPathString as the string value then it should return only the fragment you are interested in.
Hmm, we're mostly using getPayloadByNodeName and getPayloadByIndex to retrieve payloads and crawl the resource tree starting from the root. In our use case, we aren't really using any hardcoded URIs.
I have a hackaround in our own fork of libredfish where I've just hacked getUriFromService (which gets called by the two aforementioned getPayloadBy* functions) to resolve and return the fragment referenced in an odata.id. Do you think something like that would be generally useful? Basically the hackaround is calling our own hacked version of getPayloadForPathString in case a fragment is detected.
I can see it being useful. Wouldn't be that hard to have getUriFromService parse the URI pull the fragment out and pass it to getPayloadForPathString
Sounds good, I'll send up a PR with this implementation when I get the chance. It'll just be cleaning up our hacked version to use getPayloadForPathString.
Taking another look at this, does the Redpath API conform to the JSON Pointer standard RFC6901 that is referenced by the Redfish Spec Section 6.1.1. URIs?
If a property in a response is a reference to another property within a resource, the "URI Fragment Identifier Representation" format as specified in RFC6901 shall be used.
The example in the standard is given as:
For example, given the JSON document
{
"foo": ["bar", "baz"],
"": 0,
"a/b": 1,
"c%d": 2,
"e^f": 3,
"g|h": 4,
"i\\j": 5,
"k\"l": 6,
" ": 7,
"m~n": 8
}
The following JSON strings evaluate to the accompanying values:
"" // the whole document
"/foo" ["bar", "baz"]
"/foo/0" "bar"
"/" 0
"/a~1b" 1
"/c%d" 2
"/e^f" 3
"/g|h" 4
"/i\\j" 5
"/k\"l" 6
"/ " 7
"/m~0n" 8
From my understanding of Redpath, I don't think /foo/0 in RFC6901 matches the Redpath /foo[0] notation.
Just wanted to confirm this since I'll probably look to implementing the feature without Redpath if this is the case.