Editing API
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 15: | Line 15: | ||
For instance, to open the door using curl: | For instance, to open the door using curl: | ||
<source lang="bash"> | <source lang="bash"> curl -X POST -d open=True http://api.noisebridge.net/gate/</source> | ||
</source> | |||
=== GET /hello/[name] === | === GET /hello/[name] === | ||
Line 32: | Line 26: | ||
=== GET /gate/ === | === GET /gate/ === | ||
Gets interesting | Gets interesting stats about the gate. Currently: | ||
<pre class="json"> { | <pre class="json"> { | ||
Line 38: | Line 32: | ||
}</pre> | }</pre> | ||
Where 'ringing' is true if the gate buzzer is ringing at that moment, or in the last few seconds, as users may push the button for a very short time. The amount of time that this state is cached is totally up to the Gateman daemon that runs to interact with the gate hardware. | Where 'ringing' is true if the gate buzzer is ringing at that moment, or in the last few seconds, as users may push the button for a very short time. The amount of time that this state is cached is totally up to the Gateman daemon that runs to interact with the gate hardware. | ||
=== POST /gate/ === | === POST /gate/ === | ||
Line 56: | Line 48: | ||
With create=True and an existing, valid doorcode, redirects to a URL of the form /gate/key/[newdoorcode] which gives a valid new doorcode to open the door. | With create=True and an existing, valid doorcode, redirects to a URL of the form /gate/key/[newdoorcode] which gives a valid new doorcode to open the door. | ||
With preferred=[number] you can suggest a doorcode you'd like to use. It's not guaranteed that the preferred option will be returned. | With preferred=[number] you can suggest a doorcode you'd like to use. It's not guaranteed that the preferred option will be returned. | ||
Suppose you have a doorcode 8499146, and you'd like to give a friend a new doorcode. She asks if she can have the number '7895473' | |||
curl -v -X POST -d create=True -d preferred=7895473 http://localhost:8080/gate/key/8499146 | |||
would return something like this: | |||
POST /gate/key/8499146 HTTP/1.1 > | |||
HTTP/1.0 303 See Other < | |||
Date: Mon, 05 Nov 2012 05:07:29 GMT < | |||
Server: WSGIServer/0.1 Python/2.7.3rc2 < | |||
Content-Length: 0 < Content-Type: text/html; charset=UTF-8 < | |||
Location: http://localhost:8080/gate/key/7895473 < | |||
The Location header contains the new doorcode. | The Location header contains the new doorcode. | ||
Line 114: | Line 85: | ||
You'll need sudo powers on minotaur. Check out the code using git: | You'll need sudo powers on minotaur. Check out the code using git: | ||
git clone git@github.com:noisebridge/noise-api.git | git clone git@github.com:noisebridge/noise-api.git | ||
Make your changes, and test them locally using | Make your changes, and test them locally using | ||
python api.py --debug | python api.py --debug | ||
When you're ready to deploy, change the Debian changelog in debian/changelog | When you're ready to deploy, change the Debian changelog in debian/changelog , and commit the code to the github repository.. | ||
Log onto minotaur, clone the git repository, and make a Debian package. Install it using dpkg -i | Log onto minotaur, clone the git repository, and make a Debian package. Install it using dpkg -i | ||
git clone git://github.com/noisebridge/noise-api.git | git clone git://github.com/noisebridge/noise-api.git | ||
cd noise-api | cd noise-api | ||
make package | make package | ||
sudo dpkg -i ../noisebridge-api_0[whatever the version number is]*.deb | sudo dpkg -i ../noisebridge-api_0[whatever the version number is]*.deb | ||