summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apigateway/.gitignore62
-rw-r--r--apigateway/.testr.conf7
-rw-r--r--apigateway/LICENSE175
-rw-r--r--apigateway/MANIFEST.in9
-rw-r--r--apigateway/README.rst25
-rw-r--r--apigateway/apigateway/__init__.py0
-rw-r--r--apigateway/apigateway/api/__init__.py0
-rw-r--r--apigateway/apigateway/api/app.py37
-rw-r--r--apigateway/apigateway/api/config.py18
-rw-r--r--apigateway/apigateway/api/controllers/__init__.py0
-rw-r--r--apigateway/apigateway/api/controllers/root.py26
-rw-r--r--apigateway/apigateway/api/controllers/v1/__init__.py0
-rw-r--r--apigateway/apigateway/api/controllers/v1/controller.py26
-rw-r--r--apigateway/apigateway/api/controllers/v1/users.py81
-rw-r--r--apigateway/apigateway/api/expose.py22
-rw-r--r--apigateway/apigateway/api/hooks.py23
-rw-r--r--apigateway/apigateway/cmd/api.py30
-rw-r--r--apigateway/apigateway/db/__init__.py0
-rw-r--r--apigateway/apigateway/db/api.py77
-rw-r--r--apigateway/apigateway/db/models.py32
-rw-r--r--apigateway/apigateway/db/sqlalchemy/alembic.ini69
-rw-r--r--apigateway/apigateway/db/sqlalchemy/alembic/README1
-rw-r--r--apigateway/apigateway/db/sqlalchemy/alembic/env.py83
-rw-r--r--apigateway/apigateway/db/sqlalchemy/alembic/script.py.mako24
-rw-r--r--apigateway/apigateway/db/sqlalchemy/alembic/versions/6acdba136829_create_user_table.py43
-rw-r--r--apigateway/apigateway/grpc/__init__.py0
-rw-r--r--apigateway/apigateway/grpc/tosca2heat/__init__.py0
-rw-r--r--apigateway/apigateway/grpc/tosca2heat/model.py15
-rw-r--r--apigateway/apigateway/grpc/verigraph/__init__.py0
-rw-r--r--apigateway/apigateway/grpc/verigraph/model.py15
-rw-r--r--apigateway/apigateway/testes/__init__.py0
-rw-r--r--apigateway/bindep.txt7
-rw-r--r--apigateway/requirements.txt10
-rw-r--r--apigateway/setup.cfg54
-rw-r--r--apigateway/setup.py29
-rw-r--r--apigateway/test-requirements.txt22
-rwxr-xr-xapigateway/tools/build.sh21
-rwxr-xr-xapigateway/tools/install_proto3.sh40
-rwxr-xr-xapigateway/tools/tox_install_python.sh16
-rw-r--r--apigateway/tox.ini38
40 files changed, 1137 insertions, 0 deletions
diff --git a/apigateway/.gitignore b/apigateway/.gitignore
new file mode 100644
index 0000000..253f547
--- /dev/null
+++ b/apigateway/.gitignore
@@ -0,0 +1,62 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+env/
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+*.egg-info/
+.installed.cfg
+*.egg
+
+# PyInstaller
+# Usually these files are written by a python script from a template
+# before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*,cover
+.testrepository/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# misc files
+AUTHORS
+ChangeLog
diff --git a/apigateway/.testr.conf b/apigateway/.testr.conf
new file mode 100644
index 0000000..fb62267
--- /dev/null
+++ b/apigateway/.testr.conf
@@ -0,0 +1,7 @@
+[DEFAULT]
+test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
+ OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
+ OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
+ ${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION
+test_id_option=--load-list $IDFILE
+test_list_option=--list \ No newline at end of file
diff --git a/apigateway/LICENSE b/apigateway/LICENSE
new file mode 100644
index 0000000..67db858
--- /dev/null
+++ b/apigateway/LICENSE
@@ -0,0 +1,175 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
diff --git a/apigateway/MANIFEST.in b/apigateway/MANIFEST.in
new file mode 100644
index 0000000..7963b5f
--- /dev/null
+++ b/apigateway/MANIFEST.in
@@ -0,0 +1,9 @@
+include AUTHORS
+include ChangeLog
+include apigateway/gRPC/tosca2heat/*pb2.py
+include apigateway/gRPC/verigraph/*pb2.py
+exclude .gitignore
+exclude .gitreview
+
+global-exclude *.pyc
+global-exclude *.go
diff --git a/apigateway/README.rst b/apigateway/README.rst
new file mode 100644
index 0000000..48eba40
--- /dev/null
+++ b/apigateway/README.rst
@@ -0,0 +1,25 @@
+
+Apigateway
+==========
+A apigateway of web application for parser sub-projects, such as tosca2heat and policy2tosca.
+
+Building
+--------
+
+First you need some dependencies:
+
+.. code-block:: bash
+
+ pip install bindep
+ apt-get install $(bindep -b)
+ pip install -f requirements.txt
+ pip install grpcio-tools
+ go get -u github.com/golang/protobuf/protoc-gen-go
+
+Then you can build the code:
+
+.. code-block:: bash
+
+ autoreconf -fi
+ ./configure
+ make \ No newline at end of file
diff --git a/apigateway/apigateway/__init__.py b/apigateway/apigateway/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/apigateway/apigateway/__init__.py
diff --git a/apigateway/apigateway/api/__init__.py b/apigateway/apigateway/api/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/apigateway/apigateway/api/__init__.py
diff --git a/apigateway/apigateway/api/app.py b/apigateway/apigateway/api/app.py
new file mode 100644
index 0000000..a8af22e
--- /dev/null
+++ b/apigateway/apigateway/api/app.py
@@ -0,0 +1,37 @@
+#
+# 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 pecan
+
+from apigateway.api import config as api_config
+from apigateway.api import hooks
+
+
+def get_pecan_config():
+ filename = api_config.__file__.replace('.pyc', '.py')
+ return pecan.configuration.conf_from_file(filename)
+
+
+def setup_app():
+ config = get_pecan_config()
+
+ app_hooks = [hooks.DBHook()]
+ app_conf = dict(config.app)
+ app = pecan.make_app(
+ app_conf.pop('root'),
+ logging=getattr(config, 'logging', {}),
+ hooks=app_hooks,
+ **app_conf
+ )
+
+ return app
diff --git a/apigateway/apigateway/api/config.py b/apigateway/apigateway/api/config.py
new file mode 100644
index 0000000..b76e681
--- /dev/null
+++ b/apigateway/apigateway/api/config.py
@@ -0,0 +1,18 @@
+#
+# 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.
+
+app = {
+ 'root': 'apigateway.api.controllers.root.RootController',
+ 'modules': ['apigateway.api'],
+ 'debug': False,
+}
diff --git a/apigateway/apigateway/api/controllers/__init__.py b/apigateway/apigateway/api/controllers/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/apigateway/apigateway/api/controllers/__init__.py
diff --git a/apigateway/apigateway/api/controllers/root.py b/apigateway/apigateway/api/controllers/root.py
new file mode 100644
index 0000000..941b895
--- /dev/null
+++ b/apigateway/apigateway/api/controllers/root.py
@@ -0,0 +1,26 @@
+#
+# 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.
+
+from pecan import rest
+from wsme import types as wtypes
+
+from apigateway.api.controllers.v1 import controller as v1_controller
+from apigateway.api import expose
+
+
+class RootController(rest.RestController):
+ v1 = v1_controller.V1Controller()
+
+ @expose.expose(wtypes.text)
+ def get(self):
+ return "apigateway"
diff --git a/apigateway/apigateway/api/controllers/v1/__init__.py b/apigateway/apigateway/api/controllers/v1/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/apigateway/apigateway/api/controllers/v1/__init__.py
diff --git a/apigateway/apigateway/api/controllers/v1/controller.py b/apigateway/apigateway/api/controllers/v1/controller.py
new file mode 100644
index 0000000..79b529b
--- /dev/null
+++ b/apigateway/apigateway/api/controllers/v1/controller.py
@@ -0,0 +1,26 @@
+#
+# 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.
+
+from pecan import rest
+from wsme import types as wtypes
+
+from apigateway.api.controllers.v1 import users as v1_users
+from apigateway.api import expose
+
+
+class V1Controller(rest.RestController):
+ users = v1_users.UsersController()
+
+ @expose.expose(wtypes.text)
+ def get(self):
+ return 'apigateway v1controller'
diff --git a/apigateway/apigateway/api/controllers/v1/users.py b/apigateway/apigateway/api/controllers/v1/users.py
new file mode 100644
index 0000000..8cd2345
--- /dev/null
+++ b/apigateway/apigateway/api/controllers/v1/users.py
@@ -0,0 +1,81 @@
+#
+# 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 pecan
+from pecan import request
+from pecan import rest
+from wsme import types as wtypes
+
+from apigateway.api import expose
+
+
+class User(wtypes.Base):
+ id = int
+ user_id = wtypes.text
+ name = wtypes.text
+ email = wtypes.text
+
+
+class Users(wtypes.Base):
+ users = [User]
+
+
+class UserController(rest.RestController):
+
+ def __init__(self, user_id):
+ self.user_id = int(user_id)
+
+ @expose.expose(User)
+ def get(self):
+ user_info = {
+ 'id': self.user_id,
+ 'name': 'parser',
+ }
+ return User(**user_info)
+
+ @expose.expose(User, body=User)
+ def put(self, user):
+ user_info = {
+ 'id': self.user_id,
+ 'name': user.name,
+ }
+ return User(**user_info)
+
+ @expose.expose()
+ def delete(self):
+ print('Delete user_id: %s' % self.user_id)
+
+
+class UsersController(rest.RestController):
+
+ @pecan.expose()
+ def _lookup(self, user_id, *remainder):
+ return UserController(user_id), remainder
+
+ @expose.expose(Users)
+ def get(self):
+ db_conn = request.db_conn
+ users = db_conn.list_users()
+ users_list = []
+ for user in users:
+ u = User()
+ u.id = user.id
+ u.user_id = user.user_id
+ u.name = user.name
+ u.email = user.email
+ users_list.append(u)
+ return Users(users=users_list)
+
+ @expose.expose(None, body=User, status_code=201)
+ def post(self, user):
+ print(user)
diff --git a/apigateway/apigateway/api/expose.py b/apigateway/apigateway/api/expose.py
new file mode 100644
index 0000000..db30569
--- /dev/null
+++ b/apigateway/apigateway/api/expose.py
@@ -0,0 +1,22 @@
+#
+# 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 wsmeext.pecan as wsme_pecan
+
+
+def expose(*args, **kwargs):
+ """Ensure that only JSON, and not XML, is supported."""
+ if 'rest_content_types' not in kwargs:
+ kwargs['rest_content_types'] = ('json',)
+
+ return wsme_pecan.wsexpose(*args, **kwargs)
diff --git a/apigateway/apigateway/api/hooks.py b/apigateway/apigateway/api/hooks.py
new file mode 100644
index 0000000..03cbd9e
--- /dev/null
+++ b/apigateway/apigateway/api/hooks.py
@@ -0,0 +1,23 @@
+#
+# 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.
+
+from pecan import hooks
+
+from apigateway.db import api as db_api
+
+
+class DBHook(hooks.PecanHook):
+ """Create a db connection instance before a request handle."""
+
+ def before(self, state):
+ state.request.db_conn = db_api.Connection()
diff --git a/apigateway/apigateway/cmd/api.py b/apigateway/apigateway/cmd/api.py
new file mode 100644
index 0000000..dfdc1dc
--- /dev/null
+++ b/apigateway/apigateway/cmd/api.py
@@ -0,0 +1,30 @@
+#
+# 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.
+
+from wsgiref import simple_server
+
+from apigateway.api import app
+
+
+def main():
+ host = '0.0.0.0'
+ port = 8080
+
+ application = app.setup_app()
+ srv = simple_server.make_server(host, port, application)
+
+ srv.serve_forever()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/apigateway/apigateway/db/__init__.py b/apigateway/apigateway/db/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/apigateway/apigateway/db/__init__.py
diff --git a/apigateway/apigateway/db/api.py b/apigateway/apigateway/db/api.py
new file mode 100644
index 0000000..908a99b
--- /dev/null
+++ b/apigateway/apigateway/db/api.py
@@ -0,0 +1,77 @@
+#
+# 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.
+
+from sqlalchemy import create_engine
+import sqlalchemy.orm
+from sqlalchemy.orm import exc
+
+from apigateway.db import models as db_models
+
+
+_ENGINE = None
+_SESSION_MAKER = None
+
+
+def get_engine():
+ global _ENGINE
+ if _ENGINE is not None:
+ return _ENGINE
+
+ _ENGINE = create_engine('sqlite:///webdemo.db')
+ return _ENGINE
+
+
+def get_session_maker(engine):
+ global _SESSION_MAKER
+ if _SESSION_MAKER is not None:
+ return _SESSION_MAKER
+
+ _SESSION_MAKER = sqlalchemy.orm.sessionmaker(bind=engine)
+ return _SESSION_MAKER
+
+
+def get_session():
+ engine = get_engine()
+ maker = get_session_maker(engine)
+ session = maker()
+
+ return session
+
+
+class Connection(object):
+
+ def __init__(self):
+ pass
+
+ def get_user(self, user_id):
+ query = get_session().query(db_models.User).filter_by(user_id=user_id)
+ try:
+ user = query.one()
+ except exc.NoResultFound:
+ # TODO(developer): process this situation
+ pass
+
+ return user
+
+ def list_users(self):
+ session = get_session()
+ query = session.query(db_models.User)
+ users = query.all()
+
+ return users
+
+ def update_user(self, user):
+ pass
+
+ def delete_user(self, user):
+ pass
diff --git a/apigateway/apigateway/db/models.py b/apigateway/apigateway/db/models.py
new file mode 100644
index 0000000..96fba77
--- /dev/null
+++ b/apigateway/apigateway/db/models.py
@@ -0,0 +1,32 @@
+#
+# 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.
+
+from sqlalchemy import Column, Integer, String
+from sqlalchemy.ext import declarative
+from sqlalchemy import Index
+
+
+Base = declarative.declarative_base()
+
+
+class User(Base):
+ """User table"""
+
+ __tablename__ = 'user'
+ __table_args__ = (
+ Index('ix_user_user_id', 'user_id'),
+ )
+ id = Column(Integer, primary_key=True)
+ user_id = Column(String(255), nullable=False)
+ name = Column(String(64), nullable=False, unique=True)
+ email = Column(String(255))
diff --git a/apigateway/apigateway/db/sqlalchemy/alembic.ini b/apigateway/apigateway/db/sqlalchemy/alembic.ini
new file mode 100644
index 0000000..63fd682
--- /dev/null
+++ b/apigateway/apigateway/db/sqlalchemy/alembic.ini
@@ -0,0 +1,69 @@
+# A generic, single database configuration.
+
+[alembic]
+# path to migration scripts
+script_location = alembic
+
+# template used to generate migration files
+# file_template = %%(rev)s_%%(slug)s
+
+# max length of characters to apply to the
+# "slug" field
+#truncate_slug_length = 40
+
+# set to 'true' to run the environment during
+# the 'revision' command, regardless of autogenerate
+# revision_environment = false
+
+# set to 'true' to allow .pyc and .pyo files without
+# a source .py file to be detected as revisions in the
+# versions/ directory
+# sourceless = false
+
+# version location specification; this defaults
+# to alembic/versions. When using multiple version
+# directories, initial revisions must be specified with --version-path
+# version_locations = %(here)s/bar %(here)s/bat alembic/versions
+
+# the output encoding used when revision files
+# are written from script.py.mako
+# output_encoding = utf-8
+
+# sqlalchemy.url = driver://user:pass@localhost/dbname
+sqlalchemy.url = sqlite:///../../../parser.db
+
+
+# Logging configuration
+[loggers]
+keys = root,sqlalchemy,alembic
+
+[handlers]
+keys = console
+
+[formatters]
+keys = generic
+
+[logger_root]
+level = WARN
+handlers = console
+qualname =
+
+[logger_sqlalchemy]
+level = WARN
+handlers =
+qualname = sqlalchemy.engine
+
+[logger_alembic]
+level = INFO
+handlers =
+qualname = alembic
+
+[handler_console]
+class = StreamHandler
+args = (sys.stderr,)
+level = NOTSET
+formatter = generic
+
+[formatter_generic]
+format = %(levelname)-5.5s [%(name)s] %(message)s
+datefmt = %H:%M:%S
diff --git a/apigateway/apigateway/db/sqlalchemy/alembic/README b/apigateway/apigateway/db/sqlalchemy/alembic/README
new file mode 100644
index 0000000..98e4f9c
--- /dev/null
+++ b/apigateway/apigateway/db/sqlalchemy/alembic/README
@@ -0,0 +1 @@
+Generic single-database configuration. \ No newline at end of file
diff --git a/apigateway/apigateway/db/sqlalchemy/alembic/env.py b/apigateway/apigateway/db/sqlalchemy/alembic/env.py
new file mode 100644
index 0000000..c1d6706
--- /dev/null
+++ b/apigateway/apigateway/db/sqlalchemy/alembic/env.py
@@ -0,0 +1,83 @@
+#
+# 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.
+
+from __future__ import with_statement
+from alembic import context
+from sqlalchemy import engine_from_config, pool
+from logging.config import fileConfig
+
+# this is the Alembic Config object, which provides
+# access to the values within the .ini file in use.
+config = context.config
+
+# Interpret the config file for Python logging.
+# This line sets up loggers basically.
+fileConfig(config.config_file_name)
+
+# add your model's MetaData object here
+# for 'autogenerate' support
+# from myapp import mymodel
+# target_metadata = mymodel.Base.metadata
+target_metadata = None
+
+# other values from the config, defined by the needs of env.py,
+# can be acquired:
+# my_important_option = config.get_main_option("my_important_option")
+# ... etc.
+
+
+def run_migrations_offline():
+ """Run migrations in 'offline' mode.
+
+ This configures the context with just a URL
+ and not an Engine, though an Engine is acceptable
+ here as well. By skipping the Engine creation
+ we don't even need a DBAPI to be available.
+
+ Calls to context.execute() here emit the given string to the
+ script output.
+
+ """
+ url = config.get_main_option("sqlalchemy.url")
+ context.configure(
+ url=url, target_metadata=target_metadata, literal_binds=True)
+
+ with context.begin_transaction():
+ context.run_migrations()
+
+
+def run_migrations_online():
+ """Run migrations in 'online' mode.
+
+ In this scenario we need to create an Engine
+ and associate a connection with the context.
+
+ """
+ connectable = engine_from_config(
+ config.get_section(config.config_ini_section),
+ prefix='sqlalchemy.',
+ poolclass=pool.NullPool)
+
+ with connectable.connect() as connection:
+ context.configure(
+ connection=connection,
+ target_metadata=target_metadata
+ )
+
+ with context.begin_transaction():
+ context.run_migrations()
+
+if context.is_offline_mode():
+ run_migrations_offline()
+else:
+ run_migrations_online()
diff --git a/apigateway/apigateway/db/sqlalchemy/alembic/script.py.mako b/apigateway/apigateway/db/sqlalchemy/alembic/script.py.mako
new file mode 100644
index 0000000..43c0940
--- /dev/null
+++ b/apigateway/apigateway/db/sqlalchemy/alembic/script.py.mako
@@ -0,0 +1,24 @@
+"""${message}
+
+Revision ID: ${up_revision}
+Revises: ${down_revision | comma,n}
+Create Date: ${create_date}
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = ${repr(up_revision)}
+down_revision = ${repr(down_revision)}
+branch_labels = ${repr(branch_labels)}
+depends_on = ${repr(depends_on)}
+
+from alembic import op
+import sqlalchemy as sa
+${imports if imports else ""}
+
+def upgrade():
+ ${upgrades if upgrades else "pass"}
+
+
+def downgrade():
+ ${downgrades if downgrades else "pass"}
diff --git a/apigateway/apigateway/db/sqlalchemy/alembic/versions/6acdba136829_create_user_table.py b/apigateway/apigateway/db/sqlalchemy/alembic/versions/6acdba136829_create_user_table.py
new file mode 100644
index 0000000..962e76a
--- /dev/null
+++ b/apigateway/apigateway/db/sqlalchemy/alembic/versions/6acdba136829_create_user_table.py
@@ -0,0 +1,43 @@
+#
+# 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.
+
+"""Create user table
+
+Revision ID: 6acdba136829
+Revises:
+Create Date: 2017-01-22 9:18:09.967362
+
+"""
+
+from alembic import op
+import sqlalchemy as sa
+
+# revision identifiers, used by Alembic.
+revision = '6acdba136829'
+down_revision = None
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ op.create_table(
+ 'user',
+ sa.Column('id', sa.Integer, primary_key=True),
+ sa.Column('user_id', sa.String(255), nullable=False),
+ sa.Column('name', sa.String(64), nullable=False, unique=True),
+ sa.Column('email', sa.String(255))
+ )
+
+
+def downgrade():
+ op.drop_table('user')
diff --git a/apigateway/apigateway/grpc/__init__.py b/apigateway/apigateway/grpc/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/apigateway/apigateway/grpc/__init__.py
diff --git a/apigateway/apigateway/grpc/tosca2heat/__init__.py b/apigateway/apigateway/grpc/tosca2heat/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/apigateway/apigateway/grpc/tosca2heat/__init__.py
diff --git a/apigateway/apigateway/grpc/tosca2heat/model.py b/apigateway/apigateway/grpc/tosca2heat/model.py
new file mode 100644
index 0000000..cdf6612
--- /dev/null
+++ b/apigateway/apigateway/grpc/tosca2heat/model.py
@@ -0,0 +1,15 @@
+#
+# 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.
+
+# from apigateway.grpc.tosca2heat.common_pb2 import *
+print(__file__)
diff --git a/apigateway/apigateway/grpc/verigraph/__init__.py b/apigateway/apigateway/grpc/verigraph/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/apigateway/apigateway/grpc/verigraph/__init__.py
diff --git a/apigateway/apigateway/grpc/verigraph/model.py b/apigateway/apigateway/grpc/verigraph/model.py
new file mode 100644
index 0000000..c92c44a
--- /dev/null
+++ b/apigateway/apigateway/grpc/verigraph/model.py
@@ -0,0 +1,15 @@
+#
+# 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.
+
+# from apigateway.grpc.verigraph.common_pb2 import *
+print(__file__)
diff --git a/apigateway/apigateway/testes/__init__.py b/apigateway/apigateway/testes/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/apigateway/apigateway/testes/__init__.py
diff --git a/apigateway/bindep.txt b/apigateway/bindep.txt
new file mode 100644
index 0000000..f436dc0
--- /dev/null
+++ b/apigateway/bindep.txt
@@ -0,0 +1,7 @@
+pkg-config
+build-essential
+autoconf
+automake
+libtool
+golang-go
+curl
diff --git a/apigateway/requirements.txt b/apigateway/requirements.txt
new file mode 100644
index 0000000..f7f8798
--- /dev/null
+++ b/apigateway/requirements.txt
@@ -0,0 +1,10 @@
+# The order of packages is significant, because pip processes them in the order
+# of appearance. Changing the order has an impact on the overall integration
+# process, which may cause wedges in the gate later.
+
+pbr<2.0,>=0.11
+pecan
+WSME
+SQLAlchemy<1.1.0,>=0.9.9
+alembic>=0.8.0
+grpcio
diff --git a/apigateway/setup.cfg b/apigateway/setup.cfg
new file mode 100644
index 0000000..920094a
--- /dev/null
+++ b/apigateway/setup.cfg
@@ -0,0 +1,54 @@
+[metadata]
+name = apigateway
+url = https://opnfv.org/parser
+summary = API Application
+description-file = README.rst
+author = parser
+author-email = openstack-dev@lists.openstack.org
+classifier =
+ Environment :: OPNFV
+ Intended Audience :: Information Technology
+ Intended Audience :: System Administrators
+ License :: OSI Approved :: Apache Software License
+ Operating System :: POSIX :: Linux
+ Operating System :: POSIX :: Linux
+ Programming Language :: Python
+ Programming Language :: Python :: 2
+ Programming Language :: Python :: 2.7
+ Programming Language :: Python :: 3
+ Programming Language :: Python :: 3.4
+ Programming Language :: Python :: 3.5
+
+[global]
+setup-hooks =
+ pbr.hooks.setup_hook
+
+[files]
+packages =
+ apigateway
+
+[entry_points]
+console_scripts =
+ apigateway = apigateway.cmd.api:main
+
+[build_sphinx]
+source-dir = doc/source
+build-dir = doc/build
+all_files = 1
+
+[upload_sphinx]
+upload-dir = doc/build/html
+
+[compile_catalog]
+directory = apigateway/locale
+domain = apigateway
+
+[update_catalog]
+domain = apigateway
+output_dir = apigateway/locale
+input_file = apigateway/locale/apigateway.pot
+
+[extract_messages]
+keywords = _ gettext ngettext l_ lazy_gettext
+mapping_file = babel.cfg
+output_file = apigateway/locale/apigateway.pot \ No newline at end of file
diff --git a/apigateway/setup.py b/apigateway/setup.py
new file mode 100644
index 0000000..79b3a7d
--- /dev/null
+++ b/apigateway/setup.py
@@ -0,0 +1,29 @@
+#
+# 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.
+
+# -*- coding: utf-8 -*-
+
+import setuptools
+
+
+# In python < 2.7.4, a lazy loading of package `pbr` will break
+# setuptools if some other modules registered functions in `atexit`.
+# solution from: http://bugs.python.org/issue15881#msg170215
+try:
+ import multiprocessing # noqa
+except ImportError:
+ pass
+
+
+setuptools.setup(
+ setup_requires=['pbr'], pbr=True)
diff --git a/apigateway/test-requirements.txt b/apigateway/test-requirements.txt
new file mode 100644
index 0000000..043eedc
--- /dev/null
+++ b/apigateway/test-requirements.txt
@@ -0,0 +1,22 @@
+# The order of packages is significant, because pip processes them in the order
+# of appearance. Changing the order has an impact on the overall integration
+# process, which may cause wedges in the gate later.
+
+# Hacking already pins down pep8, pyflakes and flake8
+coverage>=4.0 # Apache-2.0
+flake8<2.6.0,>=2.5.4 # MIT
+hacking<0.11,>=0.10.2
+mock>=2.0 # BSD
+openstackdocstheme>=1.5.0 # Apache-2.0
+oslotest>=1.10.0 # Apache-2.0
+os-testr>=0.8.0 # Apache-2.0
+PyMySQL!=0.7.7,>=0.7.6 # MIT License
+tempest>=12.1.0 # Apache-2.0
+testrepository>=0.0.18 # Apache-2.0/BSD
+testscenarios>=0.4 # Apache-2.0/BSD
+testtools>=1.4.0 # MIT
+
+# Documentation
+os-api-ref>=1.0.0 # Apache-2.0
+oslosphinx>=4.7.0 # Apache-2.0
+sphinx!=1.3b1,<1.4,>=1.2.1 # BSD
diff --git a/apigateway/tools/build.sh b/apigateway/tools/build.sh
new file mode 100755
index 0000000..61af23f
--- /dev/null
+++ b/apigateway/tools/build.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# 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.
+
+if [ ! -f configure ]; then
+ autoreconf -fi
+fi
+if [ ! -f Makefile ]; then
+ ../configure
+fi
+make
diff --git a/apigateway/tools/install_proto3.sh b/apigateway/tools/install_proto3.sh
new file mode 100755
index 0000000..1281209
--- /dev/null
+++ b/apigateway/tools/install_proto3.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+# 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.
+
+if [ -z $GOPATH ]; then
+ echo "oaktreemodel requires a golang environment."
+ echo "Please set GOPATH and make sure GOPATH/bin is in your PATH."
+ exit 1
+fi
+GRPCDIR=$GOPATH/src/github.com/grpc/grpc
+GRPCVER=$(curl -L http://grpc.io/release)
+mkdir -p $(dirname $GRPCDIR)
+git clone -b $GRPCVER https://github.com/grpc/grpc $GRPCDIR
+pushd $GRPCDIR
+
+git submodule update --init
+make
+if [ $(id -u) = '0' ] ; then
+ SUDO=
+else
+ SUDO=sudo
+fi
+$SUDO make install
+cd third_party/protobuf
+$SUDO make install
+
+popd
+
+go get google.golang.org/grpc
+go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
diff --git a/apigateway/tools/tox_install_python.sh b/apigateway/tools/tox_install_python.sh
new file mode 100755
index 0000000..ba9eb5e
--- /dev/null
+++ b/apigateway/tools/tox_install_python.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+# 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.
+
+./build.sh
+pip install -U $*
diff --git a/apigateway/tox.ini b/apigateway/tox.ini
new file mode 100644
index 0000000..71304df
--- /dev/null
+++ b/apigateway/tox.ini
@@ -0,0 +1,38 @@
+[tox]
+minversion = 1.6
+envlist = py27,pep8
+skipsdist = True
+
+[testenv]
+usedevelop = True
+install_command = pip install -U {opts} {packages}
+setenv =
+ VIRTUAL_ENV={envdir}
+deps = -r{toxinidir}/requirements.txt
+ -r{toxinidir}/test-requirements.txt
+commands = python setup.py test --slowest --testr-args='{posargs}'
+whitelist_externals =
+ bash
+[testenv:pep8]
+commands = flake8
+
+[testenv:venv]
+commands = {posargs}
+
+[testenv:cover]
+commands = python setup.py test --coverage --coverage-package-name=translator --testr-args='{posargs}'
+
+[testenv:docs]
+commands = python setup.py build_sphinx
+
+[testenv:debug]
+commands = oslo_debug_helper -t translator/tests {posargs}
+
+[flake8]
+# H803 skipped on purpose per list discussion.
+# E123, E125 skipped as they are invalid PEP-8.
+
+show-source = True
+ignore = E123,E125,H803
+builtins = _
+exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build