RE: Question about IriTemplateMapping

Thanks Karol, for now I can go with using 'identifier' then.

I was also interested in what you said regarding putting the possible values into a comma separated list.

> For multiple values, you could just provide all available values as the comma separated value of the variable

I'm not sure I'm understanding that point fully, would you be able to illustrate how that might look? It sounds quite attractive, as long as there aren't lots of possible values.

For example, in the sample response I shared the user has two profiles, EmailAgentProfile and TelephonyAgentProfile. Is there any way for me to have the server include those two values in the mapping description?

Thanks,
Scott


-----Original Message-----
From: Karol Szczepański <karol.szczepanski@gmail.com>
Sent: 30 March 2020 16:34
To: Mackie, Scott <Scott.Mackie@verint.com>
Cc: public-hydra@w3.org
Subject: Re: Question about IriTemplateMapping

Hi Scott

Thank you for reaching us out! I believe this is the correct place to ask that kind of questions.

> The part I’m struggling with is how to tell the client that they need to pick one of the profiles from the hasProfiles list.

The spec does not specify where the mapped variable's value should come from. The IriTemplate's mappings are just hints that the server is using these Iri template variables as pointed with hydra:property predicates, but it does not say anything on how these values are used and where these values should come from. One approach would be to use a user resource (as in your case) to feed for IriTemplate resolution.
This is the default behavior a Heracles.ts [1] and Heracles.net [2] when resolving IriTemplate based links and operations.

As for your mapping example, I think the correct one should look like this:

{
    …the same content as the first example, followed by
    “findPermissions”: {
        “@type”: “hydra:IriTemplate”,
        “hydra:template”:
“http://localhost:8280/agent-service/default/agents/scottm/permissions{?profile}”,

        “hydra:mapping”: [ {
            “@type”: “IriTemplateMapping”,
            “hydra:variable”: “profile”,
            “hydra:property”: “identifier”,
            “hydra:required”: true
        }
    }
}

I think it's the identifier predicate that should be used to feed the template's value. Otherwise you'd need to find a way of serializing whole "Profile" resource as the variable's representation (which is still doable).
For multiple values, you could just provide all available values as the comma separated value of the variable or put the same query string key multiple times - whichever suits you better.

There were some discussions on how to provide hints on where to get a list of values for variables - maybe we should return to this topic to find a suitable resolution.

Hope it helps. Feel free to dig this topic deeper.

Karol Szczepanski

[1] https://github.com/HydraCG/Heracles.ts

[2] https://github.com/HydraCG/Heracles.net


pon., 30 mar 2020 o 15:23 Mackie, Scott <Scott.Mackie@verint.com> napisał(a):
>
> Hi all,
>
>
>
> I’ve got a question about Hydra’s IriTemplateMappings that I was hoping the group could answer. Is this the best place to ask questions? I’m happy to raise it elsewhere if required.
>
>
>
> I’m modelling users, called agents in the API. Each agent can have several profiles assigned to them, for example:
>
>
>
> {
>
>     “@type” : “Agent”,
>
>     …
>
>     “username” : “scottm”,
>
>     “hasProfiles” : [
>
>         {
>
>             “@type” : “Profile”,
>
>             “identifier” : “EmailAgentProfile”
>
>         },
>
>         {
>
>             “@type” : “Profile”,
>
>             “identifier” : “TelephonyAgentProfile”
>
>         }
>
>     ],
>
> }
>
>
>
> Each user has a set of permissions which are computed based on their profile. If I want to load an agent’s permissions I need to include the identifier of one of their profiles.
>
>
>
> We’ve represented this using an IriTemplate on the agent resource. The part I’m struggling with is how to tell the client that they need to pick one of the profiles from the hasProfiles list. At the moment I’ve got:
>
>
>
> {
>
>     …the same content as the first example, followed by
>
>     “findPermissions” : {
>
>         “@type” : “hydra:IriTemplate”,
>
>         “hydra:template” :
> “http://localhost:8280/agent-service/default/agents/scottm/permissions

> {?profile}”,
>
>         “hydra:mapping” : [ {
>
>             “@type”          : “IriTemplateMapping”,
>
>             “hydra:variable” : “profile”,
>
>             “hydra:property” : “hasProfiles”,
>
>             “hydra:required” : true
>
>         }
>
>     }
>
> }
>
>
>
> But hasProfiles is a list of profiles, not the identifier for a specific one. The API is expecting an IRI that looks something like http://localhost:8280/agent-service/default/agents/scottm/permissions?profile=EmailAgentProfile.

>
>
>
> The only other option I can see is to set hydra:property in the mapping to “identifier”, since that is the property on the profile that we want to actually use in the IRI. The downside to that is it doesn’t tell the client where to get that identifier from the resource they have to hand.
>
>
>
> Any suggestions?
>
>
>
> Thanks,
>
> Scott
>
>
>
>
>
> This electronic message may contain proprietary and confidential information of Verint Systems Inc., its affiliates and/or subsidiaries. The information is intended to be for the use of the individual(s) or entity(ies) named above. If you are not the intended recipient (or authorized to receive this e-mail for the intended recipient), you may not use, copy, disclose or distribute to anyone this message or any information contained in this message. If you have received this electronic message in error, please notify us by replying to this e-mail.


This electronic message may contain proprietary and confidential information of Verint Systems Inc., its affiliates and/or subsidiaries. The information is intended to be for the use of the individual(s) or entity(ies) named above. If you are not the intended recipient (or authorized to receive this e-mail for the intended recipient), you may not use, copy, disclose or distribute to anyone this message or any information contained in this message. If you have received this electronic message in error, please notify us by replying to this e-mail.

Received on Monday, 30 March 2020 16:09:27 UTC