feeling it out

This commit is contained in:
Sandy Walsh 2014-06-06 11:35:26 +00:00
parent c825508c4d
commit 94cb40b00c
9 changed files with 157 additions and 0 deletions

View File

@ -22,3 +22,9 @@ the Quince drivers.
The [klugman](https://github.com/StackTach/klugman) library is both a cmdline
tool for accessing `quincy` and a python library for programmatically accessing it.
api
===
.../v1/
.../v1/events/

0
quincy/__init__.py Normal file
View File

36
quincy/api.py Normal file
View File

@ -0,0 +1,36 @@
# Copyright (c) 2014 Dark Secret Software Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import falcon
import v1_api
class V1TestImplementation(object):
def get_events(self, resp):
return []
versions = {1: v1_api.Schema,
2: v2_api.Schema}
enabled_versions = [1, 2]
api = falcon.API()
routes = []
for version in enabled_version:
klass = versions[version]
routes.append(version, klass(api))

19
quincy/common.py Normal file
View File

@ -0,0 +1,19 @@
# Copyright (c) 2014 Dark Secret Software Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class FalconBase(object):
def __init__(self, impl):
self.impl = impl

43
quincy/v1_api.py Normal file
View File

@ -0,0 +1,43 @@
# Copyright (c) 2014 Dark Secret Software Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
import common
class EventCollection(common.FalconBase):
def on_get(self, req, resp):
events = self.impl.get_events(resp)
resp.body = json.dumps(event)
class EventItem(common.FalconBase):
pass
class Schema(object):
def _v(self):
return "/v%d" % self.version
def __init__(self, version, api):
self.api = api
self.impl = Impl()
self.event_collection = EventCollection(impl)
self.event_item = EventItem(impl)
self.version = version
self.api.add_route('%s/events' % self._v(), self.event_collection)
self.api.add_route('%s/events/{event_id}' % self._v(), self.event_item)

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
falcon
simport >= 0.0.dev0

28
setup.cfg Normal file
View File

@ -0,0 +1,28 @@
[metadata]
name = quincy
version = 0.1
author = Dark Secret Software Inc.
author-email = admin@darksecretsoftware.com
summary = StackTach.v3 REST API (no implementation)
description-file = README.md
license = Apache-2
classifier =
Development Status :: 3 - Alpha
Environment :: Console
Intended Audience :: Developers
Intended Audience :: Information Technology
License :: OSI Approved :: Apache Software License
Operating System :: OS Independent
Programming Language :: Python
Topic :: Software Development :: Libraries :: Python Modules
home-page = https://github.com/StackTach/quincy
keywords =
stacktach
rest
api
klugman
quince
openstack
[files]
packages =
quincy

8
setup.py Normal file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env python
from setuptools import setup
setup(
setup_requires=['pbr'],
pbr=True,
)

15
tox.ini Normal file
View File

@ -0,0 +1,15 @@
[tox]
envlist = py26,py27
[testenv]
deps =
coverage
nose
mock
notigen
notification_utils
pyrax
python-dateutil
simport
commands = nosetests -d -v --with-coverage --cover-inclusive --cover-package shoebox []