RestApi
Restfull Api to Freedomotic. This plugin is needed to exchange Freedomotic data like environment topology and related objects with external clients.
This plugin enables Freedomotic to expose part of it data as a RESTFull representation in a web server, this way any Client that wants to intercomunicate with Freedomotic is capable of retrieve the same data that is used in the core.
The plugin starts a little web server in the machine in wich is running.
URL Mapping
Version 5.5
IMPORTANT: on version 5.5 the api has changed. If you are still using the version 5.4 Please go to the 5.4 section
The resources are accesible throught url in the web server, the root url of all resources is the following:
http://xxx.xxx.xxx.xxx:8111/v2 where xxx.xxx.xxx.xxx is the IP address of the machine in wich the restapi is running.
In the following table is resumed the resources specific url part that must be attached to the root to be capable of retrieve each resource:
| url | Parameter | REST METHODS | Freedomotic Java Object | XML |
|---|---|---|---|---|
/environments/ | N/A | GET | ArrayList<Enviroment> | XStream conversion |
/environments/{env} | env: numeric index of the env to retrieve | GET | Enviroment | XStream conversion |
| /environments/{env}/zones/ | env: numeric index of the env to retrieve | GET | ArrayList<Zone> | Xstream Conversion |
| /environments/{env}/zones/{index} | env: numeric index of the env to retrieve index: numeric index of the zone to retrieve | GET | Zone | Xstream Conversion |
| /objects/ | N/A | GET | ArrayList<EnvObject> | Xstream Conversion |
| /objects/{name} | name: text the name of the object to retrieve | GET | EnvObject | Xstream Conversion |
| /plugins/ | N/A | GET | N/A | Xstream Conversion |
| /commands/hardware/ | N/A | GET | N/A | Xstream Conversion |
| /commands/user/ | N/A | GET | N/A | Xstream Conversion |
| /triggers/ | N/A | GET | N/A | Xstream Conversion |
| /resources/{filename} | The name of the File | GET | N/A | N/A |
NOTE: The values betwen {} are parameters that should be changed by the correct value
For example, if the RestApi is running in a machine with an IP:192.168.1.20 to retrieve the object xml representation with name: "TV" we should use the following url:
http://192.168.1.20:8111/v2/objects/TV
We could test the RestApi using any rest client, for example a web browser like Chrome or Firefox.
Also in the path /resources/{filename} are served as static files all resources in the freedom resources directory.
Version 5.4
The resources are accesible throught url in the web server, the root url of all resources is the following:
http://xxx.xxx.xxx.xxx:8111/v1 where xxx.xxx.xxx.xxx is the IP address of the machine in wich the restapi is running.
In the following table is resumed the resources specific url part that must be attached to the root to be capable of retrieve each resource:
| url | Parameter | REST METHODS | Freedomotic Java Object | XML |
|---|---|---|---|---|
| /environment/ | N/A | GET | Enviroment | XStream conversion |
| /environment/zones/ | N/A | GET | ArrayList<Zone> | Xstream Conversion |
| /environment/zones/{index} | index: numeric index of the zone to retrieve | GET | Zone | Xstream Conversion |
| /environment/objects/ | N/A | GET | ArrayList<EnvObject> | Xstream Conversion |
| /environment/objects/{name} | name: text the name of the object to retrieve | GET | EnvObject | Xstream Conversion |
| /environment/plugins/ | N/A | GET | N/A | Xstream Conversion |
| /environment/commands/hardware/ | N/A | GET | N/A | Xstream Conversion |
| /environment/commands/user/ | N/A | GET | N/A | Xstream Conversion |
| /environment/triggers/ | N/A | GET | N/A | Xstream Conversion |
| /resources/{filename} | The name of the File | GET | N/A | N/A |
NOTE: The values betwen {} are parameters that should be changed by the correct value
For example, if the RestApi is running in a machine with an IP:192.168.1.20 to retrieve the object xml representation with name: "TV" we should use the following url:
http://192.168.1.20:8111/v1/environment/objects/TV
We could test the RestApi using any rest client, for example a web browser like Chrome or Firefox.
Also in the path /resources/{filename} are served as static files all resources in the freedom resources directory.
