Hi Shakila,
If your connector is addressing each endpoint separately (as separate
methods), it doesn't matter whether you call them all using a single proxy
or multiple proxies.
Check the proxy configurations used by the Integration Tests for previous
connectors. These use a single configuration to call all methods in the
connector.
Thanks.
On Thu, Nov 27, 2014 at 2:37 PM, Shakila Sivagnanarajah [via WSO2 Oxygen
Tank] <[email protected]> wrote:
> Hi All,
>
> I am developing connector for Nest API. Nest Thermostat API is organized
> in a single data object and every data element is addressable by a URL
> called data location.
>
> *Data model:*
>
> {
> "devices": {
>
> "thermostats": {
> "peyiJNo0IldT2YlIVtYaGQ": {
> "device_id": "peyiJNo0IldT2YlIVtYaGQ" ,
> "locale": "en-US" ,
> "software_version": "4.0" ,
> "structure_id": "VqFabWH21nwVyd4RWgJgNb292wa7hG_dUwo2i2SG7j3-BOLY0BA4sw" ,
> "name": "Hallway (upstairs)" ,
> "name_long": "Hallway Thermostat (upstairs)" ,
> "last_connection": "2014-10-31T23:59:59.000Z" ,
> "is_online": true ,
> "can_cool": true ,
> "can_heat": true ,
> "is_using_emergency_heat": true ,
> "has_fan": true ,
> "fan_timer_active": true ,
> "fan_timer_timeout": "2014-10-31T23:59:59.000Z" ,
> "has_leaf": true ,
> "temperature_scale": "C" ,
> "target_temperature_f": 72 ,
> "target_temperature_c": 21.5 ,
> "target_temperature_high_f": 72 ,
> "target_temperature_high_c": 21.5 ,
> "target_temperature_low_f": 64 ,
> "target_temperature_low_c": 17.5 ,
> "away_temperature_high_f": 72 ,
> "away_temperature_high_c": 21.5 ,
> "away_temperature_low_f": 64 ,
> "away_temperature_low_c": 17.5 ,
> "hvac_mode": "heat" ,
> "ambient_temperature_f": 72 ,
> "ambient_temperature_c": 21.5 ,
> "humidity": 40
> }
> }
> ,
> "smoke_co_alarms": {
> "RTMTKxsQTCxzVcsySOHPxKoF4OyCifrs": {
> "device_id": "RTMTKxsQTCxzVcsySOHPxKoF4OyCifrs" ,
> "locale": "en-US" ,
> "software_version": "1.01" ,
> "structure_id": "VqFabWH21nwVyd4RWgJgNb292wa7hG_dUwo2i2SG7j3-BOLY0BA4sw" ,
> "name": "Hallway (upstairs)" ,
> "name_long": "Hallway Protect (upstairs)" ,
> "last_connection": "2014-10-31T23:59:59.000Z" ,
> "is_online": true ,
> "battery_health": "ok" ,
> "co_alarm_state": "ok" ,
> "smoke_alarm_state": "ok" ,
> "is_manual_test_active": true ,
> "last_manual_test_time": "2014-10-31T23:59:59.000Z" ,
> "ui_color_state": "gray"
> }
> }
>
> } ,
> "structures": {
> "VqFabWH21nwVyd4RWgJgNb292wa7hG_dUwo2i2SG7j3-BOLY0BA4sw": {
> "structure_id": "VqFabWH21nwVyd4RWgJgNb292wa7hG_dUwo2i2SG7j3-BOLY0BA4sw" ,
> "thermostats": [ "peyiJNo0IldT2YlIVtYaGQ", ... ] ,
> "smoke_co_alarms": [ "RTMTKxsQTCxzVcsySOHPxKoF4OyCifrs", ... ] ,
> "away": "home" ,
> "name": "Home" ,
> "country_code": "US" ,
> "postal_code": "94304" ,
> "peak_period_start_time": "2014-10-31T23:59:59.000Z" ,
> "peak_period_end_time": "2014-10-31T23:59:59.000Z" ,
> "time_zone": "America/Los_Angeles" ,
> "eta": {
> "trip_id": "myTripHome1024" ,
> "estimated_arrival_window_begin": "2014-10-31T22:42:59.000Z" ,
> "estimated_arrival_window_end": "2014-10-31T23:59:59.000Z"
> }
> }
> }
> }
>
> *Endpoints:*
> To get whole object: https://developer-api.nest.com?auth=<token>
> To get all device objects: https://developer-api.nest.com/devices?auth=
> <token>
> To get all thermostat device objects:
> https://developer-api.nest.com/devices/thermostats?auth=<token>
> To get a particular thermostat device object:
> https://developer-api.nest.com/devices/thermostats/<device
> id>?auth=<token>
> To get target temperature value of a particular thermostat device:
> https://developer-api.nest.com/devices/thermostats/<device
> id>/target_temperature_f?auth=<token>
>
>
> To view whole structure object (all devices in home, away status etc):
> https://developer-api.nest.com/structures?auth=<token>
> To view a list of thermostat devices in home:
> https://developer-api.nest.com/structures/<structure
> id>/thermostats?auth=<token>
>
> So I am planning to do this using switch mediator in a single
> configuration as written below. In the proxy service, I have to define all
> parameters. Is this a correct way or do I want to write each methods
> separately?
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <template name="getServices" xmlns="http://ws.apache.org/ns/synapse">
>
> <parameter name="category" description="Category" />
>
>
> <!-- For devices -->
> <parameter name="device" description="Type of device" />
> <parameter name="deviceId" description="Id of device" />
>
> <!-- For structures -->
> <parameter name="structureId" description="Id of structure" />
>
> <!-- For both devices and structures -->
> <parameter name="field" description="Field of a thermostat" /> <!--
> It can be last_connection, is_online, can_cool, can_heat etc for devices
> and thermostats, smoke_co_alarms, away, country_code for structures -->
>
> <sequence>
> <property name="uri.var.category" expression="$func:category" />
> <property name="uri.var.device" expression="$func:device" />
> <property name="uri.var.deviceId" expression="$func:deviceId" />
> <property name="uri.var.structureId"
> expression="$func:structureId" />
> <property name="uri.var.field" expression="$func:field" />
>
> <switch source="get-property('uri.var.category')">
> <case regex="devices">
> <property name="uri.var.param" value="devices"/>
>
> <filter xpath="(not(get-property('uri.var.deviceId') = ''
> or (not(string(get-property('uri.var.deviceId'))))))">
> <then>
> <property name="uri.var.param"
>
> expression="fn:concat(get-property('uri.var.param'),'/thermostats/',get-property('uri.var.deviceId'))"/>
>
> <filter xpath="(not(get-property('uri.var.field')
> = '' or (not(string(get-property('uri.var.field'))))))">
> <then>
>
> <switch
> source="get-property('uri.var.field')">
> <case
> regex="humidity|last_connection|is_online|can_cool|can_heat">
> <property name="uri.var.param"
>
> expression="fn:concat(get-property('uri.var.param'),'/',get-property('uri.var.field'))"/>
> </case>
> <default/>
> </switch>
>
> </then>
> </filter>
>
> </then>
> </filter>
>
> </case>
> <case regex="structures">
> <property name="uri.var.param" value="structures"/>
> </case>
> <default/>
> </switch>
>
> <property name="Content-Type" value="application/json"/>
>
> <call>
> <endpoint>
> <http method="get"
>
> uri-template="{uri.var.apiUrl}/{uri.var.param}?auth={uri.var.token}" />
> </endpoint>
> </call>
> </sequence>
> </template>
>
> I appreciate the thoughts on performance implications.
>
> Thank you.
> --
> Shakila Sivagnanarajah
> Associate Software Engineer
> Mobile :+94 (0) 770 760240
> [hidden email] <http://user/SendEmail.jtp?type=node&node=107945&i=0>
>
> _______________________________________________
> Dev mailing list
> [hidden email] <http://user/SendEmail.jtp?type=node&node=107945&i=1>
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://wso2-oxygen-tank.10903.n7.nabble.com/Requesting-guidance-for-Nest-ESB-connector-tp107945.html
> To start a new topic under WSO2 Development, email
> [email protected]
> To unsubscribe from WSO2 Development, click here
> <http://wso2-oxygen-tank.10903.n7.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3&code=cmFzYWRlODhAZ21haWwuY29tfDN8LTEwNDAzODU2MTk=>
> .
> NAML
> <http://wso2-oxygen-tank.10903.n7.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
Au revoir!
Ramindu Deshapriya.
Member - Sahana Software Foundation http://sahanafoundation.org
http://rdeshapriya.com
<http://www.facebook.com/rdeshapriya> <http://twitter.com/#%21/rami_lota>
<https://plus.google.com/113801459480978566130>
<http://www.linkedin.com/profile/view?id=84017607&trk=tab_pro>
<http://rdeshapriya.com> <http://lmakuthan.blogspot.com>
--
View this message in context:
http://wso2-oxygen-tank.10903.n7.nabble.com/Requesting-guidance-for-Nest-ESB-connector-tp107945p107948.html
Sent from the WSO2 Development mailing list archive at Nabble.com._______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev