aboutsummaryrefslogtreecommitdiffstats
path: root/functest/api/resources
diff options
context:
space:
mode:
Diffstat (limited to 'functest/api/resources')
-rw-r--r--functest/api/resources/v1/creds.py13
-rw-r--r--functest/api/resources/v1/envs.py14
-rw-r--r--functest/api/resources/v1/tasks.py6
-rw-r--r--functest/api/resources/v1/testcases.py16
-rw-r--r--functest/api/resources/v1/tiers.py8
5 files changed, 57 insertions, 0 deletions
diff --git a/functest/api/resources/v1/creds.py b/functest/api/resources/v1/creds.py
index 45e4559f..f445017d 100644
--- a/functest/api/resources/v1/creds.py
+++ b/functest/api/resources/v1/creds.py
@@ -13,8 +13,11 @@ Resources to handle openstack related requests
import collections
import logging
+import pkg_resources
+import socket
from flask import jsonify
+from flasgger.utils import swag_from
from functest.api.base import ApiResource
from functest.api.common import api_utils
@@ -24,16 +27,26 @@ from functest.utils.constants import CONST
LOGGER = logging.getLogger(__name__)
+ADDRESS = socket.gethostbyname(socket.gethostname())
+ENDPOINT_CREDS = ('http://{}:5000/api/v1/functest/openstack'.format(ADDRESS))
+
class V1Creds(ApiResource):
""" V1Creds Resource class"""
+ @swag_from(
+ pkg_resources.resource_filename('functest', 'api/swagger/creds.yaml'),
+ endpoint='{0}/credentials'.format(ENDPOINT_CREDS))
def get(self): # pylint: disable=no-self-use
""" Get credentials """
os_utils.source_credentials(CONST.__getattribute__('openstack_creds'))
credentials_show = OpenStack.show_credentials()
return jsonify(credentials_show)
+ @swag_from(
+ pkg_resources.resource_filename('functest',
+ 'api/swagger/creds_action.yaml'),
+ endpoint='{0}/action'.format(ENDPOINT_CREDS))
def post(self):
""" Used to handle post request """
return self._dispatch_post()
diff --git a/functest/api/resources/v1/envs.py b/functest/api/resources/v1/envs.py
index 8020544f..65e61c4b 100644
--- a/functest/api/resources/v1/envs.py
+++ b/functest/api/resources/v1/envs.py
@@ -10,23 +10,37 @@
Resources to handle environment related requests
"""
+import pkg_resources
+import socket
+
import IPy
from flask import jsonify
+from flasgger.utils import swag_from
from functest.api.base import ApiResource
from functest.api.common import api_utils
from functest.cli.commands.cli_env import Env
import functest.utils.functest_utils as ft_utils
+ADDRESS = socket.gethostbyname(socket.gethostname())
+ENDPOINT_ENVS = ('http://{}:5000/api/v1/functest/envs'.format(ADDRESS))
+
class V1Envs(ApiResource):
""" V1Envs Resource class"""
+ @swag_from(
+ pkg_resources.resource_filename('functest', 'api/swagger/envs.yaml'),
+ endpoint=ENDPOINT_ENVS)
def get(self): # pylint: disable=no-self-use
""" Get environment """
environment_show = Env().show()
return jsonify(environment_show)
+ @swag_from(
+ pkg_resources.resource_filename('functest',
+ 'api/swagger/envs_action.yaml'),
+ endpoint='{0}/action'.format(ENDPOINT_ENVS))
def post(self):
""" Used to handle post request """
return self._dispatch_post()
diff --git a/functest/api/resources/v1/tasks.py b/functest/api/resources/v1/tasks.py
index 49214124..6bf625a8 100644
--- a/functest/api/resources/v1/tasks.py
+++ b/functest/api/resources/v1/tasks.py
@@ -15,9 +15,11 @@ import errno
import json
import logging
import os
+import pkg_resources
import uuid
from flask import jsonify
+from flasgger.utils import swag_from
from functest.api.base import ApiResource
from functest.api.common import api_utils
@@ -31,6 +33,8 @@ LOGGER = logging.getLogger(__name__)
class V1Task(ApiResource):
""" V1Task Resource class"""
+ @swag_from(pkg_resources.resource_filename(
+ 'functest', 'api/swagger/task.yaml'))
def get(self, task_id): # pylint: disable=no-self-use
""" GET the result of the task id """
try:
@@ -66,6 +70,8 @@ class V1Task(ApiResource):
class V1TaskLog(ApiResource):
""" V1TaskLog Resource class"""
+ @swag_from(pkg_resources.resource_filename(
+ 'functest', 'api/swagger/task_log.yaml'))
def get(self, task_id): # pylint: disable=no-self-use
""" GET the log of the task id """
try:
diff --git a/functest/api/resources/v1/testcases.py b/functest/api/resources/v1/testcases.py
index cc2d4e19..b6733137 100644
--- a/functest/api/resources/v1/testcases.py
+++ b/functest/api/resources/v1/testcases.py
@@ -14,10 +14,12 @@ Resources to handle testcase related requests
import logging
import os
import pkg_resources
+import socket
import uuid
import ConfigParser
from flask import jsonify
+from flasgger.utils import swag_from
from functest.api.base import ApiResource
from functest.api.common import api_utils, thread
@@ -28,10 +30,16 @@ import functest.utils.functest_utils as ft_utils
LOGGER = logging.getLogger(__name__)
+ADDRESS = socket.gethostbyname(socket.gethostname())
+ENDPOINT_TESTCASES = ('http://{}:5000/api/v1/functest/testcases'
+ .format(ADDRESS))
+
class V1Testcases(ApiResource):
""" V1Testcases Resource class"""
+ @swag_from(pkg_resources.resource_filename(
+ 'functest', 'api/swagger/testcases.yaml'))
def get(self): # pylint: disable=no-self-use
""" GET all testcases """
testcases_list = Testcase().list()
@@ -42,6 +50,10 @@ class V1Testcases(ApiResource):
class V1Testcase(ApiResource):
""" V1Testcase Resource class"""
+ @swag_from(
+ pkg_resources.resource_filename('functest',
+ 'api/swagger/testcase.yaml'),
+ endpoint='{0}/<testcase_name>'.format(ENDPOINT_TESTCASES))
def get(self, testcase_name): # pylint: disable=no-self-use
""" GET the info of one testcase"""
testcase = Testcase().show(testcase_name)
@@ -61,6 +73,10 @@ class V1Testcase(ApiResource):
result.update({'dependency': dependency_dict})
return jsonify(result)
+ @swag_from(
+ pkg_resources.resource_filename('functest',
+ 'api/swagger/testcase_run.yaml'),
+ endpoint='{0}/action'.format(ENDPOINT_TESTCASES))
def post(self):
""" Used to handle post request """
return self._dispatch_post()
diff --git a/functest/api/resources/v1/tiers.py b/functest/api/resources/v1/tiers.py
index b58ab205..523df130 100644
--- a/functest/api/resources/v1/tiers.py
+++ b/functest/api/resources/v1/tiers.py
@@ -11,9 +11,11 @@
Resources to handle tier related requests
"""
+import pkg_resources
import re
from flask import jsonify
+from flasgger.utils import swag_from
from functest.api.base import ApiResource
from functest.api.common import api_utils
@@ -23,6 +25,8 @@ from functest.cli.commands.cli_tier import Tier
class V1Tiers(ApiResource):
""" V1Tiers Resource class """
+ @swag_from(pkg_resources.resource_filename(
+ 'functest', 'api/swagger/tiers.yaml'))
def get(self):
# pylint: disable=no-self-use
""" GET all tiers """
@@ -43,6 +47,8 @@ class V1Tiers(ApiResource):
class V1Tier(ApiResource):
""" V1Tier Resource class """
+ @swag_from(pkg_resources.resource_filename(
+ 'functest', 'api/swagger/tier.yaml'))
def get(self, tier_name): # pylint: disable=no-self-use
""" GET the info of one tier """
tier_info = Tier().show(tier_name)
@@ -62,6 +68,8 @@ class V1Tier(ApiResource):
class V1TestcasesinTier(ApiResource):
""" V1TestcasesinTier Resource class """
+ @swag_from(pkg_resources.resource_filename(
+ 'functest', 'api/swagger/testcases_in_tier.yaml'))
def get(self, tier_name): # pylint: disable=no-self-use
""" GET all testcases within given tier """
tier_info = Tier().show(tier_name)