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
f8f59806
Commit
f8f59806
authored
Oct 29, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemeted node template query
parent
a3185654
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
261 additions
and
108 deletions
+261
-108
default_controller.py
...flask-server/sure_tosca/controllers/default_controller.py
+75
-89
base_model_.py
sure_tosca-flask-server/sure_tosca/models/base_model_.py
+9
-0
node_template.py
sure_tosca-flask-server/sure_tosca/models/node_template.py
+2
-1
topology_template.py
...tosca-flask-server/sure_tosca/models/topology_template.py
+5
-0
tosca_template.py
sure_tosca-flask-server/sure_tosca/models/tosca_template.py
+10
-1
__init__.py
sure_tosca-flask-server/sure_tosca/service/__init__.py
+0
-0
tosca_template_service.py
...flask-server/sure_tosca/service/tosca_template_service.py
+120
-0
swagger.yaml
sure_tosca-flask-server/sure_tosca/swagger/swagger.yaml
+40
-17
No files found.
sure_tosca-flask-server/sure_tosca/controllers/default_controller.py
View file @
f8f59806
import
os
from
toscaparser.topology_template
import
TopologyTemplate
import
uuid
from
toscaparser.tosca_template
import
ToscaTemplate
from
sure_tosca.service
import
tosca_template_service
from
sure_tosca.service.tosca_template_service
import
*
import
connexion
import
connexion
import
six
import
six
import
yaml
from
sure_tosca.models.node_template
import
NodeTemplate
as
NodeTemplateModel
from
sure_tosca.models.node_template
import
NodeTemplate
# noqa: E501
from
sure_tosca.models.topology_template
import
TopologyTemplate
as
TopologyTemplateModel
from
sure_tosca.models.topology_template
import
TopologyTemplate
# noqa: E501
from
sure_tosca.models.tosca_template
import
ToscaTemplate
as
ToscaTemplateModel
from
sure_tosca.models.tosca_template
import
ToscaTemplate
# noqa: E501
from
sure_tosca
import
util
from
sure_tosca
import
util
from
tinydb
import
TinyDB
,
Query
import
tempfile
from
toscaparser.nodetemplate
import
NodeTemplate
from
toscaparser.tosca_template
import
ToscaTemplate
from
toscaparser.topology_template
import
TopologyTemplate
db_dir_path
=
tempfile
.
gettempdir
()
db_file_path
=
os
.
path
.
join
(
db_dir_path
,
"db.json"
)
db
=
TinyDB
(
db_file_path
)
# db.insert({'type': 'EFY', 'count': 800})
def
get_all_ancestor_properties
(
id
,
body
=
None
,
node_name
=
None
):
# noqa: E501
def
get_all_ancestor_properties
(
id
,
body
=
None
,
node_name
=
None
):
# noqa: E501
...
@@ -57,7 +47,7 @@ def get_all_ancestor_types(id, body=None, node_name=None): # noqa: E501
...
@@ -57,7 +47,7 @@ def get_all_ancestor_types(id, body=None, node_name=None): # noqa: E501
:rtype: List[str]
:rtype: List[str]
"""
"""
if
connexion
.
request
.
is_json
:
if
connexion
.
request
.
is_json
:
body
=
NodeTemplate
Model
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
body
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
return
'do some magic!'
...
@@ -76,45 +66,26 @@ def get_ancestors_requirements(id, body=None, node_name=None): # noqa: E501
...
@@ -76,45 +66,26 @@ def get_ancestors_requirements(id, body=None, node_name=None): # noqa: E501
:rtype: Dict[str, object]
:rtype: Dict[str, object]
"""
"""
if
connexion
.
request
.
is_json
:
if
connexion
.
request
.
is_json
:
body
=
NodeTemplateModel
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
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
=
NodeTemplateModel
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
return
'do some magic!'
def
get_node_outputs
(
id
,
body
=
None
,
node_name
=
None
):
# noqa: E501
def
get_node_outputs
(
id
,
nodeTemplate
=
None
,
node_name
=
None
):
# noqa: E501
"""
"""
s # noqa: E501
s # noqa: E501
:param id: ID of topolog template uplodaed
:param id: ID of topolog template uplodaed
:type id: str
:type id: str
:param
body
:
:param
nodeTemplate
:
:type
body
: dict | bytes
:type
nodeTemplate
: dict | bytes
:param node_name: The node name
:param node_name: The node name
:type node_name: str
:type node_name: str
:rtype: Dict[str, object]
:rtype: Dict[str, object]
"""
"""
if
connexion
.
request
.
is_json
:
if
connexion
.
request
.
is_json
:
body
=
NodeTemplateModel
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
nodeTemplate
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
return
'do some magic!'
...
@@ -133,7 +104,7 @@ def get_node_properties(id, body=None, node_name=None): # noqa: E501
...
@@ -133,7 +104,7 @@ def get_node_properties(id, body=None, node_name=None): # noqa: E501
:rtype: Dict[str, object]
:rtype: Dict[str, object]
"""
"""
if
connexion
.
request
.
is_json
:
if
connexion
.
request
.
is_json
:
body
=
NodeTemplate
Model
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
body
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
return
'do some magic!'
...
@@ -152,7 +123,7 @@ def get_node_requirements(id, body=None, node_name=None): # noqa: E501
...
@@ -152,7 +123,7 @@ def get_node_requirements(id, body=None, node_name=None): # noqa: E501
:rtype: Dict[str, object]
:rtype: Dict[str, object]
"""
"""
if
connexion
.
request
.
is_json
:
if
connexion
.
request
.
is_json
:
body
=
NodeTemplate
Model
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
body
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
return
'do some magic!'
...
@@ -172,29 +143,29 @@ def get_node_templates(id, node_name=None, node_type=None, has_interface=None):
...
@@ -172,29 +143,29 @@ def get_node_templates(id, node_name=None, node_type=None, has_interface=None):
:rtype: List[NodeTemplate]
:rtype: List[NodeTemplate]
"""
"""
return
'do some magic!'
return
tosca_template_service
.
get_node_templates
(
id
,
name
=
node_name
,
node_type
=
node_type
,
has_interface
=
has_interface
)
def
get_node_type_name
(
id
,
body
=
None
,
node_name
=
None
):
# noqa: E501
def
get_node_type_name
(
id
,
nodeTemplate
=
None
,
node_name
=
None
):
# noqa: E501
"""
"""
# noqa: E501
# noqa: E501
:param id: ID of topolog template uplodaed
:param id: ID of topolog template uplodaed
:type id: str
:type id: str
:param
body:
:param
nodeTemplate: the NodeTemplate
:type
body
: dict | bytes
:type
nodeTemplate
: dict | bytes
:param node_name: The node name
:param node_name: The node name
:type node_name: str
:type node_name: str
:rtype: str
:rtype: str
"""
"""
if
connexion
.
request
.
is_json
:
if
connexion
.
request
.
is_json
:
body
=
NodeTemplateModel
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
nodeTemplate
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
return
'do some magic!'
def
get_parent_type_name
(
id
,
body
=
None
,
node_name
=
None
):
# noqa: E501
def
get_parent_type_name
(
id
,
nodeTemplate
=
None
,
node_name
=
None
):
# noqa: E501
"""
"""
# noqa: E501
# noqa: E501
...
@@ -209,26 +180,26 @@ def get_parent_type_name(id, body=None, node_name=None): # noqa: E501
...
@@ -209,26 +180,26 @@ def get_parent_type_name(id, body=None, node_name=None): # noqa: E501
:rtype: str
:rtype: str
"""
"""
if
connexion
.
request
.
is_json
:
if
connexion
.
request
.
is_json
:
body
=
NodeTemplateModel
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
nodeTemplate
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
return
'do some magic!'
def
get_related_node
(
id
,
body
=
None
,
node_name
=
None
):
# noqa: E501
def
get_related_node
(
id
,
nodeTemplate
=
None
,
node_name
=
None
):
# noqa: E501
"""
"""
s # noqa: E501
s # noqa: E501
:param id: ID of topolog template uplodaed
:param id: ID of topolog template uplodaed
:type id: str
:type id: str
:param
body
:
:param
nodeTemplate
:
:type
body
: dict | bytes
:type
nodeTemplate
: dict | bytes
:param node_name: The node name
:param node_name: The node name
:type node_name: str
:type node_name: str
:rtype: List[NodeTemplate
Model
]
:rtype: List[NodeTemplate]
"""
"""
if
connexion
.
request
.
is_json
:
if
connexion
.
request
.
is_json
:
body
=
NodeTemplateModel
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
nodeTemplate
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
return
'do some magic!'
...
@@ -239,8 +210,8 @@ def set_node_properties(id, properties, node_name): # noqa: E501
...
@@ -239,8 +210,8 @@ def set_node_properties(id, properties, node_name): # noqa: E501
:param id: ID of topolog template uplodaed
:param id: ID of topolog template uplodaed
:type id: str
:type id: str
:param properties:
:param properties:
:type properties:
:type properties:
:param node_name: The node name
:param node_name: The node name
:type node_name: str
:type node_name: str
...
@@ -249,27 +220,17 @@ def set_node_properties(id, properties, node_name): # noqa: E501
...
@@ -249,27 +220,17 @@ def set_node_properties(id, properties, node_name): # noqa: E501
return
'do some magic!'
return
'do some magic!'
def
upload_tosca_template
(
file
):
# noqa: E501
def
get_topology_template
(
id
):
# noqa: E501
"""
upload a tosca template description fil
e
"""
get_topology_templat
e
upload and validate a tosca template description file
# noqa: E501
r
# noqa: E501
:param
file: tosca Template description
:param
id: ID of topolog template uplodaed
:type
file: werkzeug.datastructures.FileStorage
:type
id: str
:rtype:
str
:rtype:
TopologyTemplate
"""
"""
tosca_template_file_path
=
os
.
path
.
join
(
db_dir_path
,
file
.
filename
)
return
tosca_template_service
.
get_tosca_template_model_by_id
(
id
)
.
topology_template
tosca_template_dict
=
yaml
.
safe_load
(
file
.
stream
)
tosca_template_model
=
ToscaTemplateModel
.
from_dict
(
tosca_template_dict
)
tosca_template
=
ToscaTemplate
(
yaml_dict_tpl
=
tosca_template_dict
)
doc_id
=
str
(
uuid
.
uuid4
())
tosca_template_dict_with_id
=
{
"id"
:
doc_id
}
tosca_template_dict_with_id
.
update
(
tosca_template_model
.
to_dict
())
db
.
insert
(
tosca_template_dict_with_id
)
return
doc_id
def
get_tosca_template
(
id
):
# noqa: E501
def
get_tosca_template
(
id
):
# noqa: E501
...
@@ -282,26 +243,51 @@ def get_tosca_template(id): # noqa: E501
...
@@ -282,26 +243,51 @@ def get_tosca_template(id): # noqa: E501
:rtype: ToscaTemplate
:rtype: ToscaTemplate
"""
"""
return
get_ToscaTemplateM
odel_by_id
(
id
)
return
tosca_template_service
.
get_tosca_template_m
odel_by_id
(
id
)
def
get_topology_template
(
id
):
# noqa: E501
def
upload_tosca_template
(
file
):
# noqa: E501
"""
get_topology_templat
e
"""
upload a tosca template description fil
e
r # noqa: E501
upload and validate a tosca template description file # noqa: E501
:param file: tosca Template description
:type file: werkzeug.datastructures.FileStorage
:rtype: str
"""
return
tosca_template_service
.
save
(
file
)
def
get_related_nodes
(
id
,
nodeTemplate
=
None
,
node_name
=
None
):
# noqa: E501
"""
s # noqa: E501
:param id: ID of topolog template uplodaed
:param id: ID of topolog template uplodaed
:type id: str
:type id: str
:param nodeTemplate:
:type nodeTemplate: dict | bytes
:param node_name: The node name
:type node_name: str
:rtype:
TopologyTemplate
:rtype:
List[NodeTemplate]
"""
"""
return
get_ToscaTemplateModel_by_id
(
id
)
.
topology_template
if
connexion
.
request
.
is_json
:
nodeTemplate
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
get_ToscaTemplateModel_by_id
(
id
):
def
get_interface_types
(
id
,
interface_type
=
None
):
# noqa: E501
query
=
Query
()
"""
tosca_template_list_dict
=
db
.
search
(
query
.
id
==
id
)
tosca_template_dict
=
tosca_template_list_dict
[
0
]
returns the interface types # noqa: E501
tosca_template_dict
.
pop
(
"id"
)
tosca_template
=
ToscaTemplate
(
yaml_dict_tpl
=
tosca_template_dict
)
:param id: ID of topolog template uplodaed
return
ToscaTemplateModel
.
from_dict
(
tosca_template_dict
)
:type id: str
:param interface_type: The interface type
:type interface_type: str
:rtype: List[Dict[str, object]]
"""
return
tosca_template_service
.
get_interface_types
(
id
,
interface_type
=
interface_type
)
sure_tosca-flask-server/sure_tosca/models/base_model_.py
View file @
f8f59806
...
@@ -64,3 +64,12 @@ class Model(object):
...
@@ -64,3 +64,12 @@ class Model(object):
def
__ne__
(
self
,
other
):
def
__ne__
(
self
,
other
):
"""Returns true if both objects are not equal"""
"""Returns true if both objects are not equal"""
return
not
self
==
other
return
not
self
==
other
# def __hash__(self):
# return hash(self.__dict__.keys())
def
__key
(
self
):
return
tuple
(
sorted
(
self
.
to_dict
()))
def
__hash__
(
self
):
return
hash
(
self
.
__key
())
\ No newline at end of file
sure_tosca-flask-server/sure_tosca/models/node_template.py
View file @
f8f59806
...
@@ -15,7 +15,8 @@ class NodeTemplate(Model):
...
@@ -15,7 +15,8 @@ class NodeTemplate(Model):
Do not edit the class manually.
Do not edit the class manually.
"""
"""
def
__init__
(
self
,
derived_from
=
None
,
properties
=
None
,
requirements
=
None
,
interfaces
=
None
,
capabilities
=
None
,
type
=
None
,
description
=
None
,
directives
=
None
,
attributes
=
None
,
artifacts
=
None
):
# noqa: E501
def
__init__
(
self
,
derived_from
=
None
,
properties
=
None
,
requirements
=
None
,
interfaces
=
None
,
capabilities
=
None
,
type
=
None
,
description
=
None
,
directives
=
None
,
attributes
=
None
,
artifacts
=
None
):
# noqa: E501
"""NodeTemplate - a model defined in Swagger
"""NodeTemplate - a model defined in Swagger
:param derived_from: The derived_from of this NodeTemplate. # noqa: E501
:param derived_from: The derived_from of this NodeTemplate. # noqa: E501
...
...
sure_tosca-flask-server/sure_tosca/models/topology_template.py
View file @
f8f59806
...
@@ -245,3 +245,8 @@ class TopologyTemplate(Model):
...
@@ -245,3 +245,8 @@ class TopologyTemplate(Model):
"""
"""
self
.
_policies
=
policies
self
.
_policies
=
policies
def
__eq__
(
self
,
other
):
if
isinstance
(
other
,
TopologyTemplate
):
return
self
.
__key
()
==
other
.
__key
()
return
NotImplemented
\ No newline at end of file
sure_tosca-flask-server/sure_tosca/models/tosca_template.py
View file @
f8f59806
...
@@ -16,7 +16,11 @@ class ToscaTemplate(Model):
...
@@ -16,7 +16,11 @@ class ToscaTemplate(Model):
Do not edit the class manually.
Do not edit the class manually.
"""
"""
def
__init__
(
self
,
tosca_definitions_version
=
None
,
tosca_default_namespace
=
None
,
template_name
=
None
,
topology_template
=
None
,
template_author
=
None
,
template_version
=
None
,
description
=
None
,
imports
=
None
,
dsl_definitions
=
None
,
node_types
=
None
,
relationship_types
=
None
,
relationship_templates
=
None
,
capability_types
=
None
,
artifact_types
=
None
,
data_types
=
None
,
interface_types
=
None
,
policy_types
=
None
,
group_types
=
None
,
repositories
=
None
):
# noqa: E501
def
__init__
(
self
,
tosca_definitions_version
=
None
,
tosca_default_namespace
=
None
,
template_name
=
None
,
topology_template
=
None
,
template_author
=
None
,
template_version
=
None
,
description
=
None
,
imports
=
None
,
dsl_definitions
=
None
,
node_types
=
None
,
relationship_types
=
None
,
relationship_templates
=
None
,
capability_types
=
None
,
artifact_types
=
None
,
data_types
=
None
,
interface_types
=
None
,
policy_types
=
None
,
group_types
=
None
,
repositories
=
None
):
# noqa: E501
"""ToscaTemplate - a model defined in Swagger
"""ToscaTemplate - a model defined in Swagger
:param tosca_definitions_version: The tosca_definitions_version of this ToscaTemplate. # noqa: E501
:param tosca_definitions_version: The tosca_definitions_version of this ToscaTemplate. # noqa: E501
...
@@ -531,3 +535,8 @@ class ToscaTemplate(Model):
...
@@ -531,3 +535,8 @@ class ToscaTemplate(Model):
"""
"""
self
.
_repositories
=
repositories
self
.
_repositories
=
repositories
def
__eq__
(
self
,
other
):
if
isinstance
(
other
,
ToscaTemplate
):
return
self
.
__key
()
==
other
.
__key
()
return
NotImplemented
sure_tosca-flask-server/sure_tosca/service/__init__.py
0 → 100644
View file @
f8f59806
sure_tosca-flask-server/sure_tosca/service/tosca_template_service.py
0 → 100644
View file @
f8f59806
import
os
import
uuid
import
connexion
import
six
import
yaml
from
tinydb.middlewares
import
CachingMiddleware
from
sure_tosca.models.node_template
import
NodeTemplate
as
NodeTemplateModel
from
sure_tosca.models.topology_template
import
TopologyTemplate
as
TopologyTemplateModel
from
sure_tosca.models.tosca_template
import
ToscaTemplate
as
ToscaTemplateModel
from
sure_tosca
import
util
from
tinydb
import
TinyDB
,
Query
import
tempfile
from
toscaparser.nodetemplate
import
NodeTemplate
from
toscaparser.tosca_template
import
ToscaTemplate
from
toscaparser.topology_template
import
TopologyTemplate
from
tinydb.storages
import
MemoryStorage
from
operator
import
and_
,
or_
from
functools
import
reduce
from
tinydb
import
where
# db = TinyDB(storage=CachingMiddleware(MemoryStorage))
db_dir_path
=
tempfile
.
gettempdir
()
tosca_templates_db_file_path
=
os
.
path
.
join
(
db_dir_path
,
"tosca_templates.json"
)
tosca_templates_db
=
TinyDB
(
tosca_templates_db_file_path
,
cache_size
=
30
)
node_templates_db
=
TinyDB
(
storage
=
CachingMiddleware
(
MemoryStorage
))
model_id_names
=
[
'id'
]
def
get_tosca_template_model_by_id
(
id
):
tosca_template_dict
=
get_tosca_template_dict_by_id
(
id
)
if
tosca_template_dict
:
get_tosca_template_by_id
(
tosca_template_dict
)
return
ToscaTemplateModel
.
from_dict
(
tosca_template_dict
)
return
'Not Found'
,
404
def
get_tosca_template_by_id
(
tosca_template_dict
):
return
ToscaTemplate
(
yaml_dict_tpl
=
tosca_template_dict
)
def
get_tosca_template_dict_by_id
(
id
):
query
=
Query
()
tosca_template_list_dict
=
tosca_templates_db
.
search
(
query
.
id
==
id
)
if
tosca_template_list_dict
:
tosca_template_dict
=
tosca_template_list_dict
[
0
]
for
id_name
in
model_id_names
:
if
id_name
in
tosca_template_dict
:
tosca_template_dict
.
pop
(
id_name
)
break
return
tosca_template_dict
return
'Not Found'
,
404
def
save
(
file
):
tosca_template_file_path
=
os
.
path
.
join
(
db_dir_path
,
file
.
filename
)
tosca_template_dict
=
yaml
.
safe_load
(
file
.
stream
)
tosca_template_model
=
ToscaTemplateModel
.
from_dict
(
tosca_template_dict
)
tosca_template
=
ToscaTemplate
(
yaml_dict_tpl
=
tosca_template_dict
)
doc_id
=
str
(
uuid
.
uuid4
())
tosca_template_dict_with_id
=
{
model_id_names
[
0
]:
doc_id
}
tosca_template_dict_with_id
.
update
(
tosca_template_model
.
to_dict
())
tosca_templates_db
.
insert
(
tosca_template_dict_with_id
)
# tosca_templates_db.close()
return
doc_id
def
get_interface_types
(
id
,
interface_type
=
None
):
interface_types
=
get_tosca_template_model_by_id
(
id
)
.
interface_types
if
interface_types
:
if
interface_type
:
filtered_interface_types
=
[]
for
interface
in
interface_types
:
type_name
=
next
(
iter
(
interface
))
if
type_name
==
interface_type
:
filtered_interface_types
.
append
({
type_name
:
interface
})
return
filtered_interface_types
return
'Not Found'
,
404
def
get_node_templates
(
id
,
name
=
None
,
node_type
=
None
,
has_interface
=
None
):
node_templates_db
.
purge
()
node_templates
=
get_tosca_template_model_by_id
(
id
)
.
topology_template
.
node_templates
if
node_templates
:
for
node_template_name
in
node_templates
:
node
=
{
'name'
:
node_template_name
}
node
.
update
(
node_templates
[
node_template_name
]
.
to_dict
())
node_templates_db
.
insert
(
node
)
queries
=
[]
if
name
:
query
=
Query
()
queries
.
append
(
query
.
name
==
name
)
if
node_type
:
query
=
Query
()
queries
.
append
(
query
.
type
==
node_type
)
if
has_interface
:
query
=
Query
()
interface
=
None
queries
.
append
(
query
.
interfaces
!=
interface
)
query
=
reduce
(
lambda
a
,
b
:
a
&
b
,
queries
)
query_results
=
node_templates_db
.
search
(
query
)
if
not
query_results
:
return
'Not Found'
,
404
results
=
[]
for
res
in
query_results
:
name
=
res
.
pop
(
'name'
)
node
=
{
name
:
res
}
if
has_interface
and
'interfaces'
in
res
and
res
[
'interfaces'
]
is
not
None
:
results
.
append
(
node
)
elif
not
has_interface
:
results
.
append
(
node
)
return
results
return
'Not Found'
,
404
sure_tosca-flask-server/sure_tosca/swagger/swagger.yaml
View file @
f8f59806
...
@@ -52,6 +52,8 @@ paths:
...
@@ -52,6 +52,8 @@ paths:
description
:
"
successful
operation"
description
:
"
successful
operation"
schema
:
schema
:
$ref
:
"
#/definitions/ToscaTemplate"
$ref
:
"
#/definitions/ToscaTemplate"
404
:
description
:
"
Not
found"
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
...
@@ -72,6 +74,8 @@ paths:
...
@@ -72,6 +74,8 @@ paths:
description
:
"
successful
operation"
description
:
"
successful
operation"
schema
:
schema
:
$ref
:
"
#/definitions/TopologyTemplate"
$ref
:
"
#/definitions/TopologyTemplate"
404
:
description
:
"
Not
found"
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
...
@@ -109,6 +113,8 @@ paths:
...
@@ -109,6 +113,8 @@ paths:
type
:
"
array"
type
:
"
array"
items
:
items
:
$ref
:
"
#/definitions/NodeTemplate"
$ref
:
"
#/definitions/NodeTemplate"
404
:
description
:
"
Not
found"
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
...
@@ -126,8 +132,8 @@ paths:
...
@@ -126,8 +132,8 @@ paths:
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
"
body"
-
in
:
"
body"
name
:
"
body
"
name
:
"
nodeTemplate
"
description
:
"
"
description
:
"
the
NodeTemplate
"
required
:
false
required
:
false
schema
:
schema
:
$ref
:
"
#/definitions/NodeTemplate"
$ref
:
"
#/definitions/NodeTemplate"
...
@@ -141,6 +147,8 @@ paths:
...
@@ -141,6 +147,8 @@ paths:
description
:
"
successful
operation"
description
:
"
successful
operation"
schema
:
schema
:
type
:
"
string"
type
:
"
string"
404
:
description
:
"
Not
found"
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
...
@@ -158,7 +166,7 @@ paths:
...
@@ -158,7 +166,7 @@ paths:
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
"
body"
-
in
:
"
body"
name
:
"
body
"
name
:
"
nodeTemplate
"
description
:
"
"
description
:
"
"
required
:
false
required
:
false
schema
:
schema
:
...
@@ -176,6 +184,8 @@ paths:
...
@@ -176,6 +184,8 @@ paths:
additionalProperties
:
additionalProperties
:
type
:
"
object"
type
:
"
object"
properties
:
{}
properties
:
{}
404
:
description
:
"
Not
found"
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
...
@@ -193,7 +203,7 @@ paths:
...
@@ -193,7 +203,7 @@ paths:
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
"
body"
-
in
:
"
body"
name
:
"
body
"
name
:
"
nodeTemplate
"
description
:
"
"
description
:
"
"
required
:
false
required
:
false
schema
:
schema
:
...
@@ -208,6 +218,8 @@ paths:
...
@@ -208,6 +218,8 @@ paths:
description
:
"
successful
operation"
description
:
"
successful
operation"
schema
:
schema
:
type
:
"
string"
type
:
"
string"
404
:
description
:
"
Not
found"
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
...
@@ -226,7 +238,7 @@ paths:
...
@@ -226,7 +238,7 @@ paths:
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
"
body"
-
in
:
"
body"
name
:
"
body
"
name
:
"
nodeTemplate
"
required
:
false
required
:
false
schema
:
schema
:
$ref
:
"
#/definitions/NodeTemplate"
$ref
:
"
#/definitions/NodeTemplate"
...
@@ -243,6 +255,8 @@ paths:
...
@@ -243,6 +255,8 @@ paths:
additionalProperties
:
additionalProperties
:
type
:
"
object"
type
:
"
object"
properties
:
{}
properties
:
{}
404
:
description
:
"
Not
found"
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
...
@@ -261,7 +275,7 @@ paths:
...
@@ -261,7 +275,7 @@ paths:
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
"
body"
-
in
:
"
body"
name
:
"
body
"
name
:
"
nodeTemplate
"
required
:
false
required
:
false
schema
:
schema
:
$ref
:
"
#/definitions/NodeTemplate"
$ref
:
"
#/definitions/NodeTemplate"
...
@@ -277,6 +291,8 @@ paths:
...
@@ -277,6 +291,8 @@ paths:
type
:
"
array"
type
:
"
array"
items
:
items
:
type
:
"
string"
type
:
"
string"
404
:
description
:
"
Not
found"
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
...
@@ -295,7 +311,7 @@ paths:
...
@@ -295,7 +311,7 @@ paths:
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
"
body"
-
in
:
"
body"
name
:
"
body
"
name
:
"
nodeTemplate
"
required
:
false
required
:
false
schema
:
schema
:
$ref
:
"
#/definitions/NodeTemplate"
$ref
:
"
#/definitions/NodeTemplate"
...
@@ -314,6 +330,8 @@ paths:
...
@@ -314,6 +330,8 @@ paths:
additionalProperties
:
additionalProperties
:
type
:
"
object"
type
:
"
object"
properties
:
{}
properties
:
{}
404
:
description
:
"
Not
found"
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
...
@@ -331,7 +349,7 @@ paths:
...
@@ -331,7 +349,7 @@ paths:
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
"
body"
-
in
:
"
body"
name
:
"
body
"
name
:
"
nodeTemplate
"
required
:
false
required
:
false
schema
:
schema
:
$ref
:
"
#/definitions/NodeTemplate"
$ref
:
"
#/definitions/NodeTemplate"
...
@@ -348,6 +366,8 @@ paths:
...
@@ -348,6 +366,8 @@ paths:
additionalProperties
:
additionalProperties
:
type
:
"
object"
type
:
"
object"
properties
:
{}
properties
:
{}
404
:
description
:
"
Not
found"
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
...
@@ -383,6 +403,8 @@ paths:
...
@@ -383,6 +403,8 @@ paths:
additionalProperties
:
additionalProperties
:
type
:
"
object"
type
:
"
object"
properties
:
{}
properties
:
{}
404
:
description
:
"
Not
found"
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
...
@@ -400,7 +422,7 @@ paths:
...
@@ -400,7 +422,7 @@ paths:
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
"
body"
-
in
:
"
body"
name
:
"
body
"
name
:
"
nodeTemplate
"
required
:
false
required
:
false
schema
:
schema
:
$ref
:
"
#/definitions/NodeTemplate"
$ref
:
"
#/definitions/NodeTemplate"
...
@@ -417,6 +439,8 @@ paths:
...
@@ -417,6 +439,8 @@ paths:
additionalProperties
:
additionalProperties
:
type
:
"
object"
type
:
"
object"
properties
:
{}
properties
:
{}
404
:
description
:
"
Not
found"
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
...
@@ -424,7 +448,7 @@ paths:
...
@@ -424,7 +448,7 @@ paths:
get
:
get
:
summary
:
"
"
summary
:
"
"
description
:
"
s"
description
:
"
s"
operationId
:
"
get_related_node"
operationId
:
"
get_related_node
s
"
produces
:
produces
:
-
"
application/json"
-
"
application/json"
parameters
:
parameters
:
...
@@ -434,7 +458,7 @@ paths:
...
@@ -434,7 +458,7 @@ paths:
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
"
body"
-
in
:
"
body"
name
:
"
body
"
name
:
"
nodeTemplate
"
required
:
false
required
:
false
schema
:
schema
:
$ref
:
"
#/definitions/NodeTemplate"
$ref
:
"
#/definitions/NodeTemplate"
...
@@ -450,13 +474,15 @@ paths:
...
@@ -450,13 +474,15 @@ paths:
type
:
"
array"
type
:
"
array"
items
:
items
:
$ref
:
"
#/definitions/NodeTemplate"
$ref
:
"
#/definitions/NodeTemplate"
404
:
description
:
"
Not
found"
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/interface_types
:
/tosca_template/{id}/interface_types
:
get
:
get
:
summary
:
"
"
summary
:
"
"
description
:
"
s"
description
:
"
returns
the
interface
type
s"
operationId
:
"
get_interface_types"
operationId
:
"
get_interface_types"
produces
:
produces
:
-
"
application/json"
-
"
application/json"
...
@@ -466,11 +492,6 @@ paths:
...
@@ -466,11 +492,6 @@ paths:
description
:
"
ID
of
topolog
template
uplodaed"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
"
body"
name
:
"
body"
required
:
false
schema
:
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
interface_type"
-
name
:
"
interface_type"
in
:
"
query"
in
:
"
query"
description
:
"
The
interface
type"
description
:
"
The
interface
type"
...
@@ -486,6 +507,8 @@ paths:
...
@@ -486,6 +507,8 @@ paths:
additionalProperties
:
additionalProperties
:
type
:
"
object"
type
:
"
object"
properties
:
{}
properties
:
{}
404
:
description
:
"
Not
found"
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
...
...
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