<commit_before>* Cloud Preferences API

Cloud Preferences provides a RESTful API and is designed to be work with OpenStack and Rackspace Cloud.  It let's you store and manage data associated with tenants, users, devices and more.

** Overview

Cloud Preferences is built with Python and uses Tornado for the web framework providing asynchronous networking and Motor for non-blocking MongoDB support.

** TODO

- Add OpenStack Identity integration for verifying tokens
- Cleanup and optimization
- API documentation
- More error handling
- Create a client for load testing

** Installation

Install the Cloud Preferences API, Supervisor, MongoDB and Memcached:

#+BEGIN_SRC sh
apt-get install supervisor mongodb-server memcached libmemcached-dev zlib1g-dev
pip install https://github.com/treytabner/python-cloudprefs.git
#+END_SRC

** Configuration

Configuration is done at runtime or with the Supervisor configuration file.  Create ~/etc/supervisor/conf.d/cloudprefs.conf~ with the following content:

#+BEGIN_SRC conf
[program:cloudprefs]
command=python -m cloudprefs.server \
    --port=8888 \
    --identity=https://identity.api.rackspacecloud.com/v2.0 \
    --memcached=localhost
stdout_logfile=/var/log/cloudprefs.log
stderr_logfile=/var/log/cloudprefs.log
user=nobody
group=nogroup
numprocs=1
autostart=true
autorestart=true
startsecs=10
stopwaitsecs=10
directory=/tmp
#+END_SRC

** Starting services

Once you have the configuration in place, add it to Supervisor:

#+BEGIN_SRC sh
supervisorctl update
supervisorctl status
#+END_SRC

Or you can start it up manually:

#+BEGIN_SRC sh
python -m cloudprefs.server
#+END_SRC

** Testing & examples

#+BEGIN_SRC sh
pip install httpie
echo '"<PASSWORD>"' | http http://localhost:8888/servers/b36d8906-3b97-4e26-a501-e1f9191b8765/password
http http://localhost:8888/servers/b36d8906-3b97-4<PASSWORD>-a<PASSWORD>-<PASSWORD>/password
#+END_SRC<commit_msg>Update documentation<commit_after>* Cloud Preferences API

Cloud Preferences provides a RESTful API and is designed to be work with OpenStack and Rackspace Cloud.  It let's you store and manage data associated with tenants, users, devices and more.

** Overview

Cloud Preferences is built with Python and uses Tornado for the web framework providing asynchronous networking and Motor for non-blocking MongoDB support.

** Todo

- Add OpenStack Identity integration for verifying tokens
- Cleanup and optimization
- API documentation
- More error handling
- Create a client for load testing

** Installation

Install the Cloud Preferences API, Supervisor, MongoDB and Memcached:

#+BEGIN_SRC sh
apt-get install supervisor mongodb-server memcached libmemcached-dev zlib1g-dev
pip install https://github.com/treytabner/python-cloudprefs.git
#+END_SRC

** Configuration

Configuration is done at runtime or with the Supervisor configuration file.  Create ~/etc/supervisor/conf.d/cloudprefs.conf~ with the following content:

#+BEGIN_SRC conf
[program:cloudprefs]
command=python -m cloudprefs.server \
    --port=8888 \
    --identity=https://identity.api.rackspacecloud.com/v2.0 \
    --memcached=localhost
stdout_logfile=/var/log/cloudprefs.log
stderr_logfile=/var/log/cloudprefs.log
user=nobody
group=nogroup
numprocs=1
autostart=true
autorestart=true
startsecs=10
stopwaitsecs=10
directory=/tmp
#+END_SRC

** Starting services

Once you have the configuration in place, add it to Supervisor:

#+BEGIN_SRC sh
supervisorctl update
supervisorctl status
#+END_SRC

Or you can start it up manually:

#+BEGIN_SRC sh
python -m cloudprefs.server
#+END_SRC

** Testing & examples

#+BEGIN_SRC sh
pip install httpie
echo '"<PASSWORD>"' | http http://localhost:8888/servers/b36d8906-3b97-4e26-a501-e1f9191b8765/password X-Tenant-Id:123456
http http://localhost:8888/servers/b36d8906-3b97-4e26-a501-e1f9191b8765/password X-Tenant-Id:123456
#+END_SRC
{'fraction_non_alphanumeric': 0.0827909398594116, 'fraction_numerical': 0.03488674824264514, 'mean_word_length': 5.137380191693291, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5338433', 'n_tokens_mistral': 1304, 'n_tokens_neox': 1198, 'n_words': 378}