-
The purpose of this application is to build a simple REST API (using Sinatra) which reads/writes records from a sql backend and presents the data as either an editable JSON object for the management front-end or as a read-only XML document for a Polycom SoundPoint IP telephone set to consume.
-
I doubt this project will be of any real interest to anyone but myself, however if you have any comments, tips, tricks or best practices to offer, I'm all ears.
- You will need to setup an rvm environment running ruby-2.0.0-p247.
- You will also need to create a gemset called
polycom-directory-api
-
note: make sure you remember to issue
rvm use ruby-2.0.0-p247@polycom-directory-api --create
from the command line. -
remember to create a .ruby-version and .ruby-gemset file:
.ruby-version:
ruby-2.0.0-p247
.ruby-gemset:
polycom-directory-api
-
- You will also need to create a gemset called
- Clone the Repo: Run
git clone [email protected]:sqlbyme/polycom-directory-api.git
- Install the dependencies
- Run
gem install bundler
- Run
bundle install
- Run
bundle exec rackup -s thin -p 8000
- Run
RACK_ENV=test bundle exec rake spec
-
This doc and APIs are a work in progress. The APIs signatures and responses should not be considered final in any form. See the section on versioning for details on currently supported versions.
-
All calls will use HTTP endpoints.
-
All requests are in text format and must include a valid URI string.
-
All responses will be in either JSON or XML format.
-
GET requests must include a valid telephone extension in order for a directory to be generated.
200 - OK
404 - Bad request - we return a custom message
500 - Server Error
While working for Songbird I learned (from folks much wiser than I) that it really is a good idea to include some type of health_check function within an application. It offers users an easy way to just check and see that your app is up and running. Also, since my background is more on the Systems Admin side I can tell you that it makes writing Nagios checks a whole lot nicer.
Example:
curl http://localhost:8000/health_check -v
Valid Response:
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET /health_check HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8x zlib/1.2.5
> Host: localhost:8000
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/html;charset=utf-8
< Content-Length: 15
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< Connection: keep-alive
< Server: thin 1.5.1 codename Straight Razor
<
* Connection #0 to host localhost left intact
All Systems Go!* Closing connection #0
"All Systems Go!" means exactly that. The health_check shows an API consumer that the service is online and responding to requests correctly.
-
Staging - http://
-
Production - http://
-
Development = http://localhost:8000/
This repo consists of one branch, currently it is:
- checkin
To push to each app you'll need to do the following:
git remote add origin [email protected]:sqlbyme/polycom-directory-api.git
git push origin checkin
This application is released under the MIT license:
The MIT License (MIT)
Copyright (c) 2014 Michael Edwards - sqlby.me
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.