diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2017-12-06 09:00:41 +0800 |
---|---|---|
committer | SerenaFeng <feng.xiaowei@zte.com.cn> | 2017-12-06 09:02:42 +0800 |
commit | 72bdba31cae034843333470ea6ca523e488ea27f (patch) | |
tree | a1adcd726a63612e327d1dc8d45c75ef9adc7ca6 /testapi/opnfv_testapi | |
parent | 41ff15069d96ea1040cb457b39f909967dabb8bc (diff) |
add querying pods by name(part & case insentitive)
Change-Id: Ie7f14588864c79d6ed87adec3e6901dfbabbb1a6
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'testapi/opnfv_testapi')
-rw-r--r-- | testapi/opnfv_testapi/handlers/pod_handlers.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/testapi/opnfv_testapi/handlers/pod_handlers.py b/testapi/opnfv_testapi/handlers/pod_handlers.py index 9e52ca0..06a8b17 100644 --- a/testapi/opnfv_testapi/handlers/pod_handlers.py +++ b/testapi/opnfv_testapi/handlers/pod_handlers.py @@ -6,6 +6,8 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +import re + from opnfv_testapi.handlers import base_handlers from opnfv_testapi.models import pod_models from opnfv_testapi.tornado_swagger import swagger @@ -17,6 +19,14 @@ class GenericPodHandler(base_handlers.GenericApiHandler): self.table = 'pods' self.table_cls = pod_models.Pod + def set_query(self): + query = dict() + for k in self.request.query_arguments.keys(): + v = self.get_query_argument(k) + if k == 'name': + query['name'] = re.compile(v, re.IGNORECASE) + return query + class PodCLHandler(GenericPodHandler): @swagger.operation(nickname='listAllPods') @@ -25,8 +35,12 @@ class PodCLHandler(GenericPodHandler): @description: list all pods @return 200: list all pods, empty list is no pod exist @rtype: L{Pods} + @param name: pod name + @type name: L{string} + @in name: query + @required name: False """ - self._list() + self._list(query=self.set_query()) @swagger.operation(nickname='createPod') def post(self): |