From 94cb40b00caf98caf5929addb3d112f17f7e542b Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Fri, 6 Jun 2014 11:35:26 +0000 Subject: [PATCH] feeling it out --- README.md | 6 ++++++ quincy/__init__.py | 0 quincy/api.py | 36 ++++++++++++++++++++++++++++++++++++ quincy/common.py | 19 +++++++++++++++++++ quincy/v1_api.py | 43 +++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 2 ++ setup.cfg | 28 ++++++++++++++++++++++++++++ setup.py | 8 ++++++++ tox.ini | 15 +++++++++++++++ 9 files changed, 157 insertions(+) create mode 100644 quincy/__init__.py create mode 100644 quincy/api.py create mode 100644 quincy/common.py create mode 100644 quincy/v1_api.py create mode 100644 requirements.txt create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 tox.ini diff --git a/README.md b/README.md index 6cc8277..f6477b3 100644 --- a/README.md +++ b/README.md @@ -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/ diff --git a/quincy/__init__.py b/quincy/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/quincy/api.py b/quincy/api.py new file mode 100644 index 0000000..59f63c4 --- /dev/null +++ b/quincy/api.py @@ -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)) diff --git a/quincy/common.py b/quincy/common.py new file mode 100644 index 0000000..719a94f --- /dev/null +++ b/quincy/common.py @@ -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 diff --git a/quincy/v1_api.py b/quincy/v1_api.py new file mode 100644 index 0000000..3ee6d63 --- /dev/null +++ b/quincy/v1_api.py @@ -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) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..b3e647d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +falcon +simport >= 0.0.dev0 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..5b123b7 --- /dev/null +++ b/setup.cfg @@ -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 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..aa2d8a0 --- /dev/null +++ b/setup.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python + +from setuptools import setup + +setup( + setup_requires=['pbr'], + pbr=True, +) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..ca0ec80 --- /dev/null +++ b/tox.ini @@ -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 []