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

Are URI fragments supported? #119

Open
dchanman opened this issue Oct 15, 2019 · 7 comments
Open

Are URI fragments supported? #119

dchanman opened this issue Oct 15, 2019 · 7 comments

Comments

@dchanman
Copy link
Contributor

No description provided.

@dchanman
Copy link
Contributor Author

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?

@pboyd04
Copy link
Contributor

pboyd04 commented Nov 4, 2019

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.

@pboyd04
Copy link
Contributor

pboyd04 commented Nov 4, 2019

If you pass the fragment to getPayloadForPathString as the string value then it should return only the fragment you are interested in.

@dchanman
Copy link
Contributor Author

dchanman commented Nov 4, 2019

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.

@pboyd04
Copy link
Contributor

pboyd04 commented Nov 4, 2019

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

@dchanman
Copy link
Contributor Author

dchanman commented Nov 4, 2019

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.

@dchanman
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants