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

Where to find the REST API for created Things? #373

Open
Martinocom opened this issue Jan 11, 2021 · 8 comments
Open

Where to find the REST API for created Things? #373

Martinocom opened this issue Jan 11, 2021 · 8 comments
Labels
core Issues with the core library enhancement New feature or request

Comments

@Martinocom
Copy link

Hello! I'm doing my best to understand all the stuff about Thing Description and WoT. I choose to test this framework over the "Mozilla" one, since ThingWeb has a native support for multiple context values (or at least, it does not overwrite them and I still can retrieve them when asking for the TD of my Thing).

Now, since my future project will require a raw REST API to use (and not a NodeJs / JavaScript based one), I was trying to find some references to where to find all possible operations I could make on a Thing. I don't want to use the API of this library, but the native REST protocol.

Some background. I have a simple bulb, with status (boolean: true/false) and a toggle action (self-explanatory).

With Postman I tried to make some blind requests, and I found that this combination works:

So, are there some docs about all types of GET/PUT/POST/etc... combinations (or, at least, the most common and useful ones)?
And, is there any standard for passing/returning data? Like the just plain false or true values seems strange for me.

Thank you.

@relu91
Copy link
Member

relu91 commented Jan 11, 2021

Now, since my future project will require a raw REST API to use (and not a NodeJs / JavaScript based one), I was trying to find some references to where to find all possible operations I could make on a Thing.

I am not quite sure about what you're asking, but if you're looking for a list of operation types allowed in a Thing Affordance you could look at the Thing Description document (precisely here see the op vocabulary term). Basically you can:

  • read/write/observe a property
  • invoke an action
  • subscribe/unsubscribe to an event
  • read/write multiple properties

@Martinocom
Copy link
Author

Ok, I partially got it. It depends on "what" I'm trying to achieve with that particular op type. Clear.
But how I can know that op correspond to a _REST_CALL_ on something/to/call?

For example:

  • it's clear that if I have a readproperty on a property, I'll expect to have a GET call on thing/properties/<property>/.
    But the fact I know this is only because I'm aware that REST works in this way, not because I know it from somewhere from docs.

  • it's not so clear if i have a writeproperty: I could make a POST or PUT. And making those, where I must put parameters? In body or a param on URL?
    After making some experiments on Postman I figured out that writeproperty wants a PUT with a body set to application/json, and body must have the value that I want to set (like just true) or an object (like {"status": true}, and I must do it on the same URL as for the GET one (thing/properties/<property>/)

  • it's even more not clear what can I do to subscribeevent: PUT or POST? With what kind of data (if any)?
    I expect like a PUT or POST on thing/events/<event>/ but with "what"?

  • same thing for writeallproperties: must I pass a json with ALL my properties, only those ones that I want to change? Where I need to call it? A PUT or POST in thing/all/properties/?

Maybe I'm the one that didn't fully understand the Thing Description... Maybe it's the Thing Description itself that gives me this info, but I can't figure it out (some default values that I missed?). For this I'm asking a little help: maybe I'm not the only one that didn't find a reference to this.

@egekorkan
Copy link
Member

So what is confusing is actually sadly not clearly documented. Depending on the protocol, different op values will map to different methods or "functions" of the protocol. For HTTP, it is as you have understood and it is "documented" here. The rest of the protocols are documented here. What is confusing you and that should be fixed in node-wot is that the default generated TD does not contain the default values and that is not documented nor there is a way to specify this, i.e. the Thing developer cannot say that these values should be present in the forms.

@Martinocom
Copy link
Author

For HTTP, it is as you have understood and it is "documented" here. The rest of the protocols are documented here.

Awesome. I totally missed this part of the documentation. It clearly says what method uses which type of op.

And you're right, some parts are not well documented, but I think is also part of "our" job: we use it, we got what's good and we open an issue for things that are not good, right?

For the rest, I think I'm going to search most common (or draft-standard) patterns to use, just not to completly "reinvent the wheel".

Thank you.

@egekorkan
Copy link
Member

No problem :)

For the rest, I think I'm going to search most common (or draft-standard) patterns to use, just not to completly "reinvent the wheel".

You don't have to use the default values btw, you can simply say how the request should be constructed and the WoT Consumers should understand it.

@danielpeintner
Copy link
Member

What is confusing you and that should be fixed in node-wot is that the default generated TD does not contain the default values and that is not documented nor there is a way to specify this, i.e. the Thing developer cannot say that these values should be present in the forms.

@egekorkan I take your comment as an open issue we should look into. Right?

@danielpeintner danielpeintner added the enhancement New feature or request label Jan 12, 2021
@egekorkan
Copy link
Member

I think so. I'd say that there should be an option to generate TDs with default or not since there's no option to do it now. The default behaviour could be to generate the defaults since the beginners need more information.

@relu91
Copy link
Member

relu91 commented Aug 4, 2021

I think is linked with #424, once we add canonicalization in practice the generated TD would have the default values. What do you think?

@relu91 relu91 added the core Issues with the core library label Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues with the core library enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants