Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
f7b8348a
Commit
f7b8348a
authored
Oct 28, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1st commit
parent
935a2048
Changes
33
Show whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
1974 additions
and
0 deletions
+1974
-0
.dockerignore
sure_tosca-flask-server/.dockerignore
+72
-0
.gitignore
sure_tosca-flask-server/.gitignore
+64
-0
.gitignore
sure_tosca-flask-server/.idea/.gitignore
+3
-0
profiles_settings.xml
...ask-server/.idea/inspectionProfiles/profiles_settings.xml
+7
-0
misc.xml
sure_tosca-flask-server/.idea/misc.xml
+10
-0
modules.xml
sure_tosca-flask-server/.idea/modules.xml
+8
-0
sure_tosca-flask-server.iml
sure_tosca-flask-server/.idea/sure_tosca-flask-server.iml
+11
-0
vcs.xml
sure_tosca-flask-server/.idea/vcs.xml
+6
-0
.requirements.txt.kate-swp
sure_tosca-flask-server/.requirements.txt.kate-swp
+0
-0
.swagger-codegen-ignore
sure_tosca-flask-server/.swagger-codegen-ignore
+23
-0
VERSION
sure_tosca-flask-server/.swagger-codegen/VERSION
+1
-0
.travis.yml
sure_tosca-flask-server/.travis.yml
+14
-0
Dockerfile
sure_tosca-flask-server/Dockerfile
+16
-0
README.md
sure_tosca-flask-server/README.md
+49
-0
git_push.sh
sure_tosca-flask-server/git_push.sh
+52
-0
requirements.txt
sure_tosca-flask-server/requirements.txt
+4
-0
setup.py
sure_tosca-flask-server/setup.py
+35
-0
__init__.py
sure_tosca-flask-server/sure_tosca/__init__.py
+0
-0
__main__.py
sure_tosca-flask-server/sure_tosca/__main__.py
+16
-0
__init__.py
sure_tosca-flask-server/sure_tosca/controllers/__init__.py
+0
-0
default_controller.py
...flask-server/sure_tosca/controllers/default_controller.py
+272
-0
encoder.py
sure_tosca-flask-server/sure_tosca/encoder.py
+20
-0
__init__.py
sure_tosca-flask-server/sure_tosca/models/__init__.py
+8
-0
base_model_.py
sure_tosca-flask-server/sure_tosca/models/base_model_.py
+66
-0
node_template.py
sure_tosca-flask-server/sure_tosca/models/node_template.py
+90
-0
topology_template.py
...tosca-flask-server/sure_tosca/models/topology_template.py
+90
-0
tosca_template.py
sure_tosca-flask-server/sure_tosca/models/tosca_template.py
+90
-0
swagger.yaml
sure_tosca-flask-server/sure_tosca/swagger/swagger.yaml
+527
-0
__init__.py
sure_tosca-flask-server/sure_tosca/test/__init__.py
+16
-0
test_default_controller.py
...a-flask-server/sure_tosca/test/test_default_controller.py
+247
-0
util.py
sure_tosca-flask-server/sure_tosca/util.py
+141
-0
test-requirements.txt
sure_tosca-flask-server/test-requirements.txt
+6
-0
tox.ini
sure_tosca-flask-server/tox.ini
+10
-0
No files found.
sure_tosca-flask-server/.dockerignore
0 → 100644
View file @
f7b8348a
.travis.yaml
.swagger-codegen-ignore
README.md
tox.ini
git_push.sh
test-requirements.txt
setup.py
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# 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
.hypothesis/
venv/
.python-version
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
#Ipython Notebook
.ipynb_checkpoints
sure_tosca-flask-server/.gitignore
0 → 100644
View file @
f7b8348a
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# 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
.hypothesis/
venv/
.python-version
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
#Ipython Notebook
.ipynb_checkpoints
sure_tosca-flask-server/.idea/.gitignore
0 → 100644
View file @
f7b8348a
# Default ignored files
/workspace.xml
\ No newline at end of file
sure_tosca-flask-server/.idea/inspectionProfiles/profiles_settings.xml
0 → 100644
View file @
f7b8348a
<component
name=
"InspectionProjectProfileManager"
>
<settings>
<option
name=
"PROJECT_PROFILE"
value=
"Default"
/>
<option
name=
"USE_PROJECT_PROFILE"
value=
"false"
/>
<version
value=
"1.0"
/>
</settings>
</component>
\ No newline at end of file
sure_tosca-flask-server/.idea/misc.xml
0 → 100644
View file @
f7b8348a
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ProjectRootManager"
version=
"2"
project-jdk-name=
"Python 3.6 (sure_tosca-flask-server)"
project-jdk-type=
"Python SDK"
/>
<component
name=
"PyCharmProfessionalAdvertiser"
>
<option
name=
"shown"
value=
"true"
/>
</component>
<component
name=
"PythonCompatibilityInspectionAdvertiser"
>
<option
name=
"version"
value=
"3"
/>
</component>
</project>
\ No newline at end of file
sure_tosca-flask-server/.idea/modules.xml
0 → 100644
View file @
f7b8348a
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ProjectModuleManager"
>
<modules>
<module
fileurl=
"file://$PROJECT_DIR$/.idea/sure_tosca-flask-server.iml"
filepath=
"$PROJECT_DIR$/.idea/sure_tosca-flask-server.iml"
/>
</modules>
</component>
</project>
\ No newline at end of file
sure_tosca-flask-server/.idea/sure_tosca-flask-server.iml
0 → 100644
View file @
f7b8348a
<?xml version="1.0" encoding="UTF-8"?>
<module
type=
"PYTHON_MODULE"
version=
"4"
>
<component
name=
"NewModuleRootManager"
>
<content
url=
"file://$MODULE_DIR$"
/>
<orderEntry
type=
"jdk"
jdkName=
"Python 3.6 (sure_tosca-flask-server)"
jdkType=
"Python SDK"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
<component
name=
"TestRunnerService"
>
<option
name=
"PROJECT_TEST_RUNNER"
value=
"Unittests"
/>
</component>
</module>
\ No newline at end of file
sure_tosca-flask-server/.idea/vcs.xml
0 → 100644
View file @
f7b8348a
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
"$PROJECT_DIR$/.."
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
sure_tosca-flask-server/.requirements.txt.kate-swp
0 → 100644
View file @
f7b8348a
File added
sure_tosca-flask-server/.swagger-codegen-ignore
0 → 100644
View file @
f7b8348a
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
sure_tosca-flask-server/.swagger-codegen/VERSION
0 → 100644
View file @
f7b8348a
2.4.8
\ No newline at end of file
sure_tosca-flask-server/.travis.yml
0 → 100644
View file @
f7b8348a
# ref: https://docs.travis-ci.com/user/languages/python
language
:
python
python
:
-
"
2.7"
-
"
3.2"
-
"
3.3"
-
"
3.4"
-
"
3.5"
#- "3.5-dev" # 3.5 development branch
#- "nightly" # points to the latest development branch e.g. 3.6-dev
# command to install dependencies
install
:
"
pip
install
-r
requirements.txt"
# command to run tests
script
:
nosetests
sure_tosca-flask-server/Dockerfile
0 → 100644
View file @
f7b8348a
FROM
python:2-alpine
RUN
mkdir
-p
/usr/src/app
WORKDIR
/usr/src/app
COPY
requirements.txt /usr/src/app/
RUN
pip
install
--no-cache-dir
-r
requirements.txt
COPY
. /usr/src/app
EXPOSE
8081
ENTRYPOINT
["python"]
CMD
["-m", "sure_tosca"]
\ No newline at end of file
sure_tosca-flask-server/README.md
0 → 100644
View file @
f7b8348a
# Swagger generated server
## Overview
This server was generated by the
[
swagger-codegen
](
https://github.com/swagger-api/swagger-codegen
)
project. By using the
[
OpenAPI-Spec
](
https://github.com/swagger-api/swagger-core/wiki
)
from a remote server, you can easily generate a server stub. This
is an example of building a swagger-enabled Flask server.
This example uses the
[
Connexion
](
https://github.com/zalando/connexion
)
library on top of Flask.
## Requirements
Python 2.7+
## Usage
To run the server, please execute the following from the root directory:
```
pip install -r requirements.txt
python -m sure_tosca
```
and open your browser to here:
```
http://localhost:8081/tosca-sure/1.0.0/ui/
```
Your Swagger definition lives here:
```
http://localhost:8081/tosca-sure/1.0.0/swagger.json
```
To launch the integration tests, use tox:
```
sudo pip install tox
tox
```
## Running with Docker
To run the server on a Docker container, please execute the following from the root directory:
```
bash
# building the image
docker build
-t
sure_tosca
.
# starting up a container
docker run
-p
8081:8081 sure_tosca
```
\ No newline at end of file
sure_tosca-flask-server/git_push.sh
0 → 100644
View file @
f7b8348a
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
git_user_id
=
$1
git_repo_id
=
$2
release_note
=
$3
if
[
"
$git_user_id
"
=
""
]
;
then
git_user_id
=
""
echo
"[INFO] No command line input provided. Set
\$
git_user_id to
$git_user_id
"
fi
if
[
"
$git_repo_id
"
=
""
]
;
then
git_repo_id
=
""
echo
"[INFO] No command line input provided. Set
\$
git_repo_id to
$git_repo_id
"
fi
if
[
"
$release_note
"
=
""
]
;
then
release_note
=
""
echo
"[INFO] No command line input provided. Set
\$
release_note to
$release_note
"
fi
# Initialize the local directory as a Git repository
git init
# Adds the files in the local repository and stages them for commit.
git add
.
# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit
-m
"
$release_note
"
# Sets the new remote
git_remote
=
`
git remote
`
if
[
"
$git_remote
"
=
""
]
;
then
# git remote not defined
if
[
"
$GIT_TOKEN
"
=
""
]
;
then
echo
"[INFO]
\$
GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/
${
git_user_id
}
/
${
git_repo_id
}
.git
else
git remote add origin https://
${
git_user_id
}
:
${
GIT_TOKEN
}
@github.com/
${
git_user_id
}
/
${
git_repo_id
}
.git
fi
fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
echo
"Git pushing to https://github.com/
${
git_user_id
}
/
${
git_repo_id
}
.git"
git push origin master 2>&1 |
grep
-v
'To https'
sure_tosca-flask-server/requirements.txt
0 → 100644
View file @
f7b8348a
connexion == 2.4.0
python-dateutil == 2.8.0
typing == 3.7.4.1
swagger-ui-bundle == 0.0.5
\ No newline at end of file
sure_tosca-flask-server/setup.py
0 → 100644
View file @
f7b8348a
# coding: utf-8
import
sys
from
setuptools
import
setup
,
find_packages
NAME
=
"sure_tosca"
VERSION
=
"1.0.0"
# To install the library, run the following
#
# python setup.py install
#
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools
REQUIRES
=
[
"connexion"
]
setup
(
name
=
NAME
,
version
=
VERSION
,
description
=
"tosca-sure"
,
author_email
=
"S.Koulouzis@uva.nl"
,
url
=
""
,
keywords
=
[
"Swagger"
,
"tosca-sure"
],
install_requires
=
REQUIRES
,
packages
=
find_packages
(),
package_data
=
{
''
:
[
'swagger/swagger.yaml'
]},
include_package_data
=
True
,
entry_points
=
{
'console_scripts'
:
[
'sure_tosca=sure_tosca.__main__:main'
]},
long_description
=
"""
\
TOSCA Simple qUeRy sErvice (SURE).
"""
)
sure_tosca-flask-server/sure_tosca/__init__.py
0 → 100644
View file @
f7b8348a
sure_tosca-flask-server/sure_tosca/__main__.py
0 → 100644
View file @
f7b8348a
#!/usr/bin/env python
import
connexion
from
sure_tosca
import
encoder
def
main
():
app
=
connexion
.
App
(
__name__
,
specification_dir
=
'./swagger/'
)
app
.
app
.
json_encoder
=
encoder
.
JSONEncoder
app
.
add_api
(
'swagger.yaml'
,
arguments
=
{
'title'
:
'tosca-sure'
})
app
.
run
(
port
=
8081
)
if
__name__
==
'__main__'
:
main
()
sure_tosca-flask-server/sure_tosca/controllers/__init__.py
0 → 100644
View file @
f7b8348a
sure_tosca-flask-server/sure_tosca/controllers/default_controller.py
0 → 100644
View file @
f7b8348a
import
connexion
import
six
from
sure_tosca.models.node_template
import
NodeTemplate
# noqa: E501
from
sure_tosca.models.topology_template
import
TopologyTemplate
# noqa: E501
from
sure_tosca.models.tosca_template
import
ToscaTemplate
# noqa: E501
from
sure_tosca
import
util
def
get_all_ancestor_properties
(
id
,
body
=
None
,
node_name
=
None
):
# noqa: E501
"""
Recursively get all requirements all the way to the ROOT including the input node's # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param body:
:type body: dict | bytes
:param node_name: The node name
:type node_name: str
:rtype: List[Dict[str, object]]
"""
if
connexion
.
request
.
is_json
:
body
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
get_all_ancestor_types
(
id
,
body
=
None
,
node_name
=
None
):
# noqa: E501
"""
Recursively get all requirements all the way to the ROOT including the input node's # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param body:
:type body: dict | bytes
:param node_name: The node name
:type node_name: str
:rtype: List[str]
"""
if
connexion
.
request
.
is_json
:
body
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
get_ancestors_requirements
(
id
,
body
=
None
,
node_name
=
None
):
# noqa: E501
"""
Recursively get all requirements all the way to the ROOT including the input node's # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param body:
:type body: dict | bytes
:param node_name: The node name
:type node_name: str
:rtype: Dict[str, object]
"""
if
connexion
.
request
.
is_json
:
body
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
get_interface_types
(
id
,
body
=
None
,
interface_type
=
None
):
# noqa: E501
"""
s # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param body:
:type body: dict | bytes
:param interface_type: The interface type
:type interface_type: str
:rtype: List[Dict[str, object]]
"""
if
connexion
.
request
.
is_json
:
body
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
get_node_outputs
(
id
,
body
=
None
,
node_name
=
None
):
# noqa: E501
"""
s # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param body:
:type body: dict | bytes
:param node_name: The node name
:type node_name: str
:rtype: Dict[str, object]
"""
if
connexion
.
request
.
is_json
:
body
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
get_node_properties
(
id
,
body
=
None
,
node_name
=
None
):
# noqa: E501
"""
s # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param body:
:type body: dict | bytes
:param node_name: The node name
:type node_name: str
:rtype: Dict[str, object]
"""
if
connexion
.
request
.
is_json
:
body
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
get_node_requirements
(
id
,
body
=
None
,
node_name
=
None
):
# noqa: E501
"""get_node_requirements
Returns the requirements for an input node as described in the template not in the node's definition # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param body:
:type body: dict | bytes
:param node_name: The node name
:type node_name: str
:rtype: Dict[str, object]
"""
if
connexion
.
request
.
is_json
:
body
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
get_node_templates
(
id
,
node_name
=
None
,
node_type
=
None
,
has_interface
=
None
):
# noqa: E501
"""get_node_templates
returns nodes templates in topology # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: filter by node name
:type node_name: str
:param node_type: filter by node type
:type node_type: str
:param has_interface: filter if node has interface
:type has_interface: bool
:rtype: List[NodeTemplate]
"""
return
'do some magic!'
def
get_node_type_name
(
id
,
body
=
None
,
node_name
=
None
):
# noqa: E501
"""
# noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param body:
:type body: dict | bytes
:param node_name: The node name
:type node_name: str
:rtype: str
"""
if
connexion
.
request
.
is_json
:
body
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
get_parent_type_name
(
id
,
body
=
None
,
node_name
=
None
):
# noqa: E501
"""
# noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param body:
:type body: dict | bytes
:param node_name: The node name
:type node_name: str
:rtype: str
"""
if
connexion
.
request
.
is_json
:
body
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
get_related_node
(
id
,
body
=
None
,
node_name
=
None
):
# noqa: E501
"""
s # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param body:
:type body: dict | bytes
:param node_name: The node name
:type node_name: str
:rtype: List[NodeTemplate]
"""
if
connexion
.
request
.
is_json
:
body
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
get_topology_template
(
id
):
# noqa: E501
"""get_topology_template
r # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:rtype: TopologyTemplate
"""
return
'do some magic!'
def
get_tosca_template
(
id
):
# noqa: E501
"""get_tosca_template
# noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:rtype: ToscaTemplate
"""
return
'do some magic!'
def
set_node_properties
(
id
,
properties
,
node_name
):
# noqa: E501
"""
s # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param properties:
:type properties:
:param node_name: The node name
:type node_name: str
:rtype: Dict[str, object]
"""
return
'do some magic!'
def
upload_tosca_template
(
file
):
# noqa: E501
"""upload a tosca template description file
upload and validate a tosca template description file # noqa: E501
:param file: tosca Template description
:type file: werkzeug.datastructures.FileStorage
:rtype: str
"""
return
'do some magic!'
sure_tosca-flask-server/sure_tosca/encoder.py
0 → 100644
View file @
f7b8348a
from
connexion.apps.flask_app
import
FlaskJSONEncoder
import
six
from
sure_tosca.models.base_model_
import
Model
class
JSONEncoder
(
FlaskJSONEncoder
):
include_nulls
=
False
def
default
(
self
,
o
):
if
isinstance
(
o
,
Model
):
dikt
=
{}
for
attr
,
_
in
six
.
iteritems
(
o
.
swagger_types
):
value
=
getattr
(
o
,
attr
)
if
value
is
None
and
not
self
.
include_nulls
:
continue
attr
=
o
.
attribute_map
[
attr
]
dikt
[
attr
]
=
value
return
dikt
return
FlaskJSONEncoder
.
default
(
self
,
o
)
sure_tosca-flask-server/sure_tosca/models/__init__.py
0 → 100644
View file @
f7b8348a
# coding: utf-8
# flake8: noqa
from
__future__
import
absolute_import
# import models into model package
from
sure_tosca.models.node_template
import
NodeTemplate
from
sure_tosca.models.topology_template
import
TopologyTemplate
from
sure_tosca.models.tosca_template
import
ToscaTemplate
sure_tosca-flask-server/sure_tosca/models/base_model_.py
0 → 100644
View file @
f7b8348a
import
pprint
import
six
from
sure_tosca
import
util
class
Model
(
object
):
# swaggerTypes: The key is attribute name and the
# value is attribute type.
swagger_types
=
{}
# attributeMap: The key is attribute name and the
# value is json key in definition.
attribute_map
=
{}
@
classmethod
def
from_dict
(
cls
,
dikt
):
"""Returns the dict as a model"""
return
util
.
deserialize_model
(
dikt
,
cls
)
def
to_dict
(
self
):
"""Returns the model properties as a dict
:rtype: dict
"""
result
=
{}
for
attr
,
_
in
six
.
iteritems
(
self
.
swagger_types
):
value
=
getattr
(
self
,
attr
)
if
isinstance
(
value
,
list
):
result
[
attr
]
=
list
(
map
(
lambda
x
:
x
.
to_dict
()
if
hasattr
(
x
,
"to_dict"
)
else
x
,
value
))
elif
hasattr
(
value
,
"to_dict"
):
result
[
attr
]
=
value
.
to_dict
()
elif
isinstance
(
value
,
dict
):
result
[
attr
]
=
dict
(
map
(
lambda
item
:
(
item
[
0
],
item
[
1
]
.
to_dict
())
if
hasattr
(
item
[
1
],
"to_dict"
)
else
item
,
value
.
items
()
))
else
:
result
[
attr
]
=
value
return
result
def
to_str
(
self
):
"""Returns the string representation of the model
:rtype: str
"""
return
pprint
.
pformat
(
self
.
to_dict
())
def
__repr__
(
self
):
"""For `print` and `pprint`"""
return
self
.
to_str
()
def
__eq__
(
self
,
other
):
"""Returns true if both objects are equal"""
return
self
.
__dict__
==
other
.
__dict__
def
__ne__
(
self
,
other
):
"""Returns true if both objects are not equal"""
return
not
self
==
other
sure_tosca-flask-server/sure_tosca/models/node_template.py
0 → 100644
View file @
f7b8348a
# coding: utf-8
from
__future__
import
absolute_import
from
datetime
import
date
,
datetime
# noqa: F401
from
typing
import
List
,
Dict
# noqa: F401
from
sure_tosca.models.base_model_
import
Model
from
sure_tosca
import
util
class
NodeTemplate
(
Model
):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
def
__init__
(
self
,
items
=
None
,
additional_properties
=
None
):
# noqa: E501
"""NodeTemplate - a model defined in Swagger
:param items: The items of this NodeTemplate. # noqa: E501
:type items: object
:param additional_properties: The additional_properties of this NodeTemplate. # noqa: E501
:type additional_properties: object
"""
self
.
swagger_types
=
{
'items'
:
object
,
'additional_properties'
:
object
}
self
.
attribute_map
=
{
'items'
:
'items'
,
'additional_properties'
:
'additionalProperties'
}
self
.
_items
=
items
self
.
_additional_properties
=
additional_properties
@
classmethod
def
from_dict
(
cls
,
dikt
):
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The NodeTemplate of this NodeTemplate. # noqa: E501
:rtype: NodeTemplate
"""
return
util
.
deserialize_model
(
dikt
,
cls
)
@
property
def
items
(
self
):
"""Gets the items of this NodeTemplate.
:return: The items of this NodeTemplate.
:rtype: object
"""
return
self
.
_items
@
items
.
setter
def
items
(
self
,
items
):
"""Sets the items of this NodeTemplate.
:param items: The items of this NodeTemplate.
:type items: object
"""
self
.
_items
=
items
@
property
def
additional_properties
(
self
):
"""Gets the additional_properties of this NodeTemplate.
:return: The additional_properties of this NodeTemplate.
:rtype: object
"""
return
self
.
_additional_properties
@
additional_properties
.
setter
def
additional_properties
(
self
,
additional_properties
):
"""Sets the additional_properties of this NodeTemplate.
:param additional_properties: The additional_properties of this NodeTemplate.
:type additional_properties: object
"""
self
.
_additional_properties
=
additional_properties
sure_tosca-flask-server/sure_tosca/models/topology_template.py
0 → 100644
View file @
f7b8348a
# coding: utf-8
from
__future__
import
absolute_import
from
datetime
import
date
,
datetime
# noqa: F401
from
typing
import
List
,
Dict
# noqa: F401
from
sure_tosca.models.base_model_
import
Model
from
sure_tosca
import
util
class
TopologyTemplate
(
Model
):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
def
__init__
(
self
,
items
=
None
,
additional_properties
=
None
):
# noqa: E501
"""TopologyTemplate - a model defined in Swagger
:param items: The items of this TopologyTemplate. # noqa: E501
:type items: object
:param additional_properties: The additional_properties of this TopologyTemplate. # noqa: E501
:type additional_properties: object
"""
self
.
swagger_types
=
{
'items'
:
object
,
'additional_properties'
:
object
}
self
.
attribute_map
=
{
'items'
:
'items'
,
'additional_properties'
:
'additionalProperties'
}
self
.
_items
=
items
self
.
_additional_properties
=
additional_properties
@
classmethod
def
from_dict
(
cls
,
dikt
):
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The TopologyTemplate of this TopologyTemplate. # noqa: E501
:rtype: TopologyTemplate
"""
return
util
.
deserialize_model
(
dikt
,
cls
)
@
property
def
items
(
self
):
"""Gets the items of this TopologyTemplate.
:return: The items of this TopologyTemplate.
:rtype: object
"""
return
self
.
_items
@
items
.
setter
def
items
(
self
,
items
):
"""Sets the items of this TopologyTemplate.
:param items: The items of this TopologyTemplate.
:type items: object
"""
self
.
_items
=
items
@
property
def
additional_properties
(
self
):
"""Gets the additional_properties of this TopologyTemplate.
:return: The additional_properties of this TopologyTemplate.
:rtype: object
"""
return
self
.
_additional_properties
@
additional_properties
.
setter
def
additional_properties
(
self
,
additional_properties
):
"""Sets the additional_properties of this TopologyTemplate.
:param additional_properties: The additional_properties of this TopologyTemplate.
:type additional_properties: object
"""
self
.
_additional_properties
=
additional_properties
sure_tosca-flask-server/sure_tosca/models/tosca_template.py
0 → 100644
View file @
f7b8348a
# coding: utf-8
from
__future__
import
absolute_import
from
datetime
import
date
,
datetime
# noqa: F401
from
typing
import
List
,
Dict
# noqa: F401
from
sure_tosca.models.base_model_
import
Model
from
sure_tosca
import
util
class
ToscaTemplate
(
Model
):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
def
__init__
(
self
,
items
=
None
,
additional_properties
=
None
):
# noqa: E501
"""ToscaTemplate - a model defined in Swagger
:param items: The items of this ToscaTemplate. # noqa: E501
:type items: str
:param additional_properties: The additional_properties of this ToscaTemplate. # noqa: E501
:type additional_properties: object
"""
self
.
swagger_types
=
{
'items'
:
str
,
'additional_properties'
:
object
}
self
.
attribute_map
=
{
'items'
:
'items'
,
'additional_properties'
:
'additionalProperties'
}
self
.
_items
=
items
self
.
_additional_properties
=
additional_properties
@
classmethod
def
from_dict
(
cls
,
dikt
):
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The ToscaTemplate of this ToscaTemplate. # noqa: E501
:rtype: ToscaTemplate
"""
return
util
.
deserialize_model
(
dikt
,
cls
)
@
property
def
items
(
self
):
"""Gets the items of this ToscaTemplate.
:return: The items of this ToscaTemplate.
:rtype: str
"""
return
self
.
_items
@
items
.
setter
def
items
(
self
,
items
):
"""Sets the items of this ToscaTemplate.
:param items: The items of this ToscaTemplate.
:type items: str
"""
self
.
_items
=
items
@
property
def
additional_properties
(
self
):
"""Gets the additional_properties of this ToscaTemplate.
:return: The additional_properties of this ToscaTemplate.
:rtype: object
"""
return
self
.
_additional_properties
@
additional_properties
.
setter
def
additional_properties
(
self
,
additional_properties
):
"""Sets the additional_properties of this ToscaTemplate.
:param additional_properties: The additional_properties of this ToscaTemplate.
:type additional_properties: object
"""
self
.
_additional_properties
=
additional_properties
sure_tosca-flask-server/sure_tosca/swagger/swagger.yaml
0 → 100644
View file @
f7b8348a
---
swagger
:
"
2.0"
info
:
description
:
"
TOSCA
Simple
qUeRy
sErvice
(SURE).
"
version
:
"
1.0.0"
title
:
"
tosca-sure"
contact
:
email
:
"
S.Koulouzis@uva.nl"
license
:
name
:
"
Apache
2.0"
url
:
"
http://www.apache.org/licenses/LICENSE-2.0.html"
basePath
:
"
/tosca-sure/1.0.0"
schemes
:
-
"
https"
-
"
http"
paths
:
/tosca_template
:
post
:
summary
:
"
upload
a
tosca
template
description
file"
description
:
"
upload
and
validate
a
tosca
template
description
file"
operationId
:
"
upload_tosca_template"
consumes
:
-
"
multipart/form-data"
parameters
:
-
name
:
"
file"
in
:
"
formData"
description
:
"
tosca
Template
description"
required
:
true
type
:
"
file"
responses
:
200
:
description
:
"
successful
operation"
schema
:
type
:
"
string"
405
:
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}
:
get
:
description
:
"
"
operationId
:
"
get_tosca_template"
produces
:
-
"
application/json"
parameters
:
-
name
:
"
id"
in
:
"
path"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
type
:
"
string"
responses
:
200
:
description
:
"
successful
operation"
schema
:
$ref
:
"
#/definitions/ToscaTemplate"
405
:
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template
:
get
:
description
:
"
r"
operationId
:
"
get_topology_template"
produces
:
-
"
application/json"
parameters
:
-
name
:
"
id"
in
:
"
path"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
type
:
"
string"
responses
:
200
:
description
:
"
successful
operation"
schema
:
$ref
:
"
#/definitions/TopologyTemplate"
405
:
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates
:
get
:
description
:
"
returns
nodes
templates
in
topology"
operationId
:
"
get_node_templates"
produces
:
-
"
application/json"
parameters
:
-
name
:
"
id"
in
:
"
path"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
type
:
"
string"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
filter
by
node
name"
required
:
false
type
:
"
string"
-
name
:
"
node_type"
in
:
"
query"
description
:
"
filter
by
node
type"
required
:
false
type
:
"
string"
-
name
:
"
has_interface"
in
:
"
query"
description
:
"
filter
if
node
has
interface"
required
:
false
type
:
"
boolean"
responses
:
200
:
description
:
"
successful
operation"
schema
:
type
:
"
array"
items
:
$ref
:
"
#/definitions/NodeTemplate"
405
:
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/type_name
:
get
:
summary
:
"
"
description
:
"
"
operationId
:
"
get_node_type_name"
produces
:
-
"
application/json"
parameters
:
-
name
:
"
id"
in
:
"
path"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
type
:
"
string"
-
in
:
"
body"
name
:
"
body"
description
:
"
"
required
:
false
schema
:
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
The
node
name"
required
:
false
type
:
"
string"
responses
:
200
:
description
:
"
successful
operation"
schema
:
type
:
"
string"
405
:
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/requirements
:
get
:
description
:
"
Returns
the
requirements
for
an
input
node
as
described
in
the
\
\
template
not
in
the
node's
definition
"
operationId
:
"
get_node_requirements"
produces
:
-
"
application/json"
parameters
:
-
name
:
"
id"
in
:
"
path"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
type
:
"
string"
-
in
:
"
body"
name
:
"
body"
description
:
"
"
required
:
false
schema
:
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
The
node
name"
required
:
false
type
:
"
string"
responses
:
200
:
description
:
"
successful
operation"
schema
:
type
:
"
object"
additionalProperties
:
type
:
"
object"
properties
:
{}
405
:
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/parent_type_name
:
get
:
summary
:
"
"
description
:
"
"
operationId
:
"
get_parent_type_name"
produces
:
-
"
application/json"
parameters
:
-
name
:
"
id"
in
:
"
path"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
type
:
"
string"
-
in
:
"
body"
name
:
"
body"
description
:
"
"
required
:
false
schema
:
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
The
node
name"
required
:
false
type
:
"
string"
responses
:
200
:
description
:
"
successful
operation"
schema
:
type
:
"
string"
405
:
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/ancestors_requirements
:
get
:
summary
:
"
"
description
:
"
Recursively
get
all
requirements
all
the
way
to
the
ROOT
including
\
\
the
input
node's"
operationId
:
"
get_ancestors_requirements"
produces
:
-
"
application/json"
parameters
:
-
name
:
"
id"
in
:
"
path"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
type
:
"
string"
-
in
:
"
body"
name
:
"
body"
required
:
false
schema
:
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
The
node
name"
required
:
false
type
:
"
string"
responses
:
200
:
description
:
"
successful
operation"
schema
:
type
:
"
object"
additionalProperties
:
type
:
"
object"
properties
:
{}
405
:
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/ancestors_types
:
get
:
summary
:
"
"
description
:
"
Recursively
get
all
requirements
all
the
way
to
the
ROOT
including
\
\
the
input
node's"
operationId
:
"
get_all_ancestor_types"
produces
:
-
"
application/json"
parameters
:
-
name
:
"
id"
in
:
"
path"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
type
:
"
string"
-
in
:
"
body"
name
:
"
body"
required
:
false
schema
:
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
The
node
name"
required
:
false
type
:
"
string"
responses
:
200
:
description
:
"
successful
operation"
schema
:
type
:
"
array"
items
:
type
:
"
string"
405
:
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/ancestors_properties
:
get
:
summary
:
"
"
description
:
"
Recursively
get
all
requirements
all
the
way
to
the
ROOT
including
\
\
the
input
node's"
operationId
:
"
get_all_ancestor_properties"
produces
:
-
"
application/json"
parameters
:
-
name
:
"
id"
in
:
"
path"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
type
:
"
string"
-
in
:
"
body"
name
:
"
body"
required
:
false
schema
:
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
The
node
name"
required
:
false
type
:
"
string"
responses
:
200
:
description
:
"
successful
operation"
schema
:
type
:
"
array"
items
:
type
:
"
object"
additionalProperties
:
type
:
"
object"
properties
:
{}
405
:
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/properties
:
get
:
summary
:
"
"
description
:
"
s"
operationId
:
"
get_node_properties"
produces
:
-
"
application/json"
parameters
:
-
name
:
"
id"
in
:
"
path"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
type
:
"
string"
-
in
:
"
body"
name
:
"
body"
required
:
false
schema
:
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
The
node
name"
required
:
false
type
:
"
string"
responses
:
200
:
description
:
"
successful
operation"
schema
:
type
:
"
object"
additionalProperties
:
type
:
"
object"
properties
:
{}
405
:
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
put
:
summary
:
"
"
description
:
"
s"
operationId
:
"
set_node_properties"
produces
:
-
"
application/json"
parameters
:
-
name
:
"
id"
in
:
"
path"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
type
:
"
string"
-
in
:
"
body"
name
:
"
properties"
required
:
true
schema
:
type
:
"
object"
additionalProperties
:
type
:
"
string"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
The
node
name"
required
:
true
type
:
"
string"
responses
:
200
:
description
:
"
successful
operation"
schema
:
type
:
"
object"
additionalProperties
:
type
:
"
object"
properties
:
{}
405
:
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/outputs
:
get
:
summary
:
"
"
description
:
"
s"
operationId
:
"
get_node_outputs"
produces
:
-
"
application/json"
parameters
:
-
name
:
"
id"
in
:
"
path"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
type
:
"
string"
-
in
:
"
body"
name
:
"
body"
required
:
false
schema
:
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
The
node
name"
required
:
false
type
:
"
string"
responses
:
200
:
description
:
"
successful
operation"
schema
:
type
:
"
object"
additionalProperties
:
type
:
"
object"
properties
:
{}
405
:
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/related
:
get
:
summary
:
"
"
description
:
"
s"
operationId
:
"
get_related_node"
produces
:
-
"
application/json"
parameters
:
-
name
:
"
id"
in
:
"
path"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
type
:
"
string"
-
in
:
"
body"
name
:
"
body"
required
:
false
schema
:
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
The
node
name"
required
:
false
type
:
"
string"
responses
:
200
:
description
:
"
successful
operation"
schema
:
type
:
"
array"
items
:
$ref
:
"
#/definitions/NodeTemplate"
405
:
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/interface_types
:
get
:
summary
:
"
"
description
:
"
s"
operationId
:
"
get_interface_types"
produces
:
-
"
application/json"
parameters
:
-
name
:
"
id"
in
:
"
path"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
type
:
"
string"
-
in
:
"
body"
name
:
"
body"
required
:
false
schema
:
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
interface_type"
in
:
"
query"
description
:
"
The
interface
type"
required
:
false
type
:
"
string"
responses
:
200
:
description
:
"
successful
operation"
schema
:
type
:
"
array"
items
:
type
:
"
object"
additionalProperties
:
type
:
"
object"
properties
:
{}
405
:
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
definitions
:
ToscaTemplate
:
type
:
"
object"
properties
:
items
:
type
:
"
string"
additionalProperties
:
type
:
"
object"
properties
:
{}
example
:
additionalProperties
:
"
{}"
items
:
"
items"
TopologyTemplate
:
type
:
"
object"
properties
:
items
:
type
:
"
object"
properties
:
{}
additionalProperties
:
type
:
"
object"
properties
:
{}
example
:
additionalProperties
:
"
{}"
items
:
"
{}"
NodeTemplate
:
type
:
"
object"
properties
:
items
:
type
:
"
object"
properties
:
{}
additionalProperties
:
type
:
"
object"
properties
:
{}
example
:
additionalProperties
:
"
{}"
items
:
"
{}"
sure_tosca-flask-server/sure_tosca/test/__init__.py
0 → 100644
View file @
f7b8348a
import
logging
import
connexion
from
flask_testing
import
TestCase
from
sure_tosca.encoder
import
JSONEncoder
class
BaseTestCase
(
TestCase
):
def
create_app
(
self
):
logging
.
getLogger
(
'connexion.operation'
)
.
setLevel
(
'ERROR'
)
app
=
connexion
.
App
(
__name__
,
specification_dir
=
'../swagger/'
)
app
.
app
.
json_encoder
=
JSONEncoder
app
.
add_api
(
'swagger.yaml'
)
return
app
.
app
sure_tosca-flask-server/sure_tosca/test/test_default_controller.py
0 → 100644
View file @
f7b8348a
# coding: utf-8
from
__future__
import
absolute_import
from
flask
import
json
from
six
import
BytesIO
from
sure_tosca.models.node_template
import
NodeTemplate
# noqa: E501
from
sure_tosca.models.topology_template
import
TopologyTemplate
# noqa: E501
from
sure_tosca.models.tosca_template
import
ToscaTemplate
# noqa: E501
from
sure_tosca.test
import
BaseTestCase
class
TestDefaultController
(
BaseTestCase
):
"""DefaultController integration test stubs"""
def
test_get_all_ancestor_properties
(
self
):
"""Test case for get_all_ancestor_properties
"""
body
=
NodeTemplate
()
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/ancestors_properties'
.
format
(
id
=
'id_example'
),
method
=
'GET'
,
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_get_all_ancestor_types
(
self
):
"""Test case for get_all_ancestor_types
"""
body
=
NodeTemplate
()
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/ancestors_types'
.
format
(
id
=
'id_example'
),
method
=
'GET'
,
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_get_ancestors_requirements
(
self
):
"""Test case for get_ancestors_requirements
"""
body
=
NodeTemplate
()
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/ancestors_requirements'
.
format
(
id
=
'id_example'
),
method
=
'GET'
,
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_get_interface_types
(
self
):
"""Test case for get_interface_types
"""
body
=
NodeTemplate
()
query_string
=
[(
'interface_type'
,
'interface_type_example'
)]
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/interface_types'
.
format
(
id
=
'id_example'
),
method
=
'GET'
,
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_get_node_outputs
(
self
):
"""Test case for get_node_outputs
"""
body
=
NodeTemplate
()
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/outputs'
.
format
(
id
=
'id_example'
),
method
=
'GET'
,
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_get_node_properties
(
self
):
"""Test case for get_node_properties
"""
body
=
NodeTemplate
()
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/properties'
.
format
(
id
=
'id_example'
),
method
=
'GET'
,
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_get_node_requirements
(
self
):
"""Test case for get_node_requirements
"""
body
=
NodeTemplate
()
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/requirements'
.
format
(
id
=
'id_example'
),
method
=
'GET'
,
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_get_node_templates
(
self
):
"""Test case for get_node_templates
"""
query_string
=
[(
'node_name'
,
'node_name_example'
),
(
'node_type'
,
'node_type_example'
),
(
'has_interface'
,
true
)]
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates'
.
format
(
id
=
'id_example'
),
method
=
'GET'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_get_node_type_name
(
self
):
"""Test case for get_node_type_name
"""
body
=
NodeTemplate
()
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/type_name'
.
format
(
id
=
'id_example'
),
method
=
'GET'
,
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_get_parent_type_name
(
self
):
"""Test case for get_parent_type_name
"""
body
=
NodeTemplate
()
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/parent_type_name'
.
format
(
id
=
'id_example'
),
method
=
'GET'
,
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_get_related_node
(
self
):
"""Test case for get_related_node
"""
body
=
NodeTemplate
()
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/related'
.
format
(
id
=
'id_example'
),
method
=
'GET'
,
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_get_topology_template
(
self
):
"""Test case for get_topology_template
"""
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template'
.
format
(
id
=
'id_example'
),
method
=
'GET'
)
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_get_tosca_template
(
self
):
"""Test case for get_tosca_template
"""
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}'
.
format
(
id
=
'id_example'
),
method
=
'GET'
)
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_set_node_properties
(
self
):
"""Test case for set_node_properties
"""
properties
=
None
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/properties'
.
format
(
id
=
'id_example'
),
method
=
'PUT'
,
data
=
json
.
dumps
(
properties
),
content_type
=
'application/json'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_upload_tosca_template
(
self
):
"""Test case for upload_tosca_template
upload a tosca template description file
"""
data
=
dict
(
file
=
(
BytesIO
(
b
'some file data'
),
'file.txt'
))
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template'
,
method
=
'POST'
,
data
=
data
,
content_type
=
'multipart/form-data'
)
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
if
__name__
==
'__main__'
:
import
unittest
unittest
.
main
()
sure_tosca-flask-server/sure_tosca/util.py
0 → 100644
View file @
f7b8348a
import
datetime
import
six
import
typing
def
_deserialize
(
data
,
klass
):
"""Deserializes dict, list, str into an object.
:param data: dict, list or str.
:param klass: class literal, or string of class name.
:return: object.
"""
if
data
is
None
:
return
None
if
klass
in
six
.
integer_types
or
klass
in
(
float
,
str
,
bool
):
return
_deserialize_primitive
(
data
,
klass
)
elif
klass
==
object
:
return
_deserialize_object
(
data
)
elif
klass
==
datetime
.
date
:
return
deserialize_date
(
data
)
elif
klass
==
datetime
.
datetime
:
return
deserialize_datetime
(
data
)
elif
type
(
klass
)
==
typing
.
GenericMeta
:
if
klass
.
__extra__
==
list
:
return
_deserialize_list
(
data
,
klass
.
__args__
[
0
])
if
klass
.
__extra__
==
dict
:
return
_deserialize_dict
(
data
,
klass
.
__args__
[
1
])
else
:
return
deserialize_model
(
data
,
klass
)
def
_deserialize_primitive
(
data
,
klass
):
"""Deserializes to primitive type.
:param data: data to deserialize.
:param klass: class literal.
:return: int, long, float, str, bool.
:rtype: int | long | float | str | bool
"""
try
:
value
=
klass
(
data
)
except
UnicodeEncodeError
:
value
=
six
.
u
(
data
)
except
TypeError
:
value
=
data
return
value
def
_deserialize_object
(
value
):
"""Return a original value.
:return: object.
"""
return
value
def
deserialize_date
(
string
):
"""Deserializes string to date.
:param string: str.
:type string: str
:return: date.
:rtype: date
"""
try
:
from
dateutil.parser
import
parse
return
parse
(
string
)
.
date
()
except
ImportError
:
return
string
def
deserialize_datetime
(
string
):
"""Deserializes string to datetime.
The string should be in iso8601 datetime format.
:param string: str.
:type string: str
:return: datetime.
:rtype: datetime
"""
try
:
from
dateutil.parser
import
parse
return
parse
(
string
)
except
ImportError
:
return
string
def
deserialize_model
(
data
,
klass
):
"""Deserializes list or dict to model.
:param data: dict, list.
:type data: dict | list
:param klass: class literal.
:return: model object.
"""
instance
=
klass
()
if
not
instance
.
swagger_types
:
return
data
for
attr
,
attr_type
in
six
.
iteritems
(
instance
.
swagger_types
):
if
data
is
not
None
\
and
instance
.
attribute_map
[
attr
]
in
data
\
and
isinstance
(
data
,
(
list
,
dict
)):
value
=
data
[
instance
.
attribute_map
[
attr
]]
setattr
(
instance
,
attr
,
_deserialize
(
value
,
attr_type
))
return
instance
def
_deserialize_list
(
data
,
boxed_type
):
"""Deserializes a list and its elements.
:param data: list to deserialize.
:type data: list
:param boxed_type: class literal.
:return: deserialized list.
:rtype: list
"""
return
[
_deserialize
(
sub_data
,
boxed_type
)
for
sub_data
in
data
]
def
_deserialize_dict
(
data
,
boxed_type
):
"""Deserializes a dict and its elements.
:param data: dict to deserialize.
:type data: dict
:param boxed_type: class literal.
:return: deserialized dict.
:rtype: dict
"""
return
{
k
:
_deserialize
(
v
,
boxed_type
)
for
k
,
v
in
six
.
iteritems
(
data
)}
sure_tosca-flask-server/test-requirements.txt
0 → 100644
View file @
f7b8348a
flask-testing==0.7.1
coverage==4.5.4
nose>=1.3.7
pluggy>=0.13.0
#py>=1.4.31
randomize>=0.14
sure_tosca-flask-server/tox.ini
0 → 100644
View file @
f7b8348a
[tox]
envlist
=
py27, py35
[testenv]
deps
=
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands
=
nosetests
\
[]
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment