Multiple Identifiers for an http label #1967
Replies: 1 comment
-
I think there might be some confusion about what it means for a resource to have multiple identifiers. It isn't that the resource has two separate identifiers that can each uniquely identify the resource. Rather, it means that the resource can only be uniquely identified if all of its identifier shapes are filled out. Consider the following example: resource ObjectResource {
identifiers: {
bucket: String
path: String
}
} Both With that out of the way, if you want to have an operation where either can be missing, you just need to bind them somewhere else. If you want them in the URI, then binding them to the path is an option, like so: @readonly
@http(method: "GET", uri: "/objects", code: 200)
operation SearchObjects {
input := {
@httpQuery("bucket")
bucket: String
@httpQuery("path")
path: String
}
output := {
objects: ObjectList
}
}
list ObjectResource {
member: Object
} This is called a collection operation because rather than operating on a single resource, you're operating on the collection of all instances of that resource. Hence, the uri is |
Beta Was this translation helpful? Give feedback.
-
I have tried looking into the docs to solve this but maybe I have overlooked it but it would be great if someone could clarify how to handles this scenario.
If we have a resource with two or more identifiers like the one below.
And then want to define a Get operation
Alongside with the input
The problem starts becoming a bit apparent, how do we handle using the same label (in this case id) for both identifiers (id & id2)? I have tried quite a few different ways such as using the greedy label but that cannot be used twice to point to different identifiers it seems. Don't believe we can either define a new operation which is identical except referencing id2 and then using mixins would work? But either way I've struggled a bit with this and was wondering if there is some sort of "or" operation that could be used or something along those lines. If someone could clarify how to handle this properly that'd be great.
Beta Was this translation helpful? Give feedback.
All reactions