diff options
author | Koren Lev <korenlev@gmail.com> | 2017-10-02 12:11:30 +0300 |
---|---|---|
committer | Yaron Yogev <yaronyogev@gmail.com> | 2017-10-03 10:14:04 +0000 |
commit | 1789adab406bc38499ef69fdb61bbb573578ebec (patch) | |
tree | 3a145aa11c8b009a9e52c1e5354f51aeec64dd98 /app/api/responders/resource | |
parent | 929a33a1cf8854e06d13e5ef352a48759c9ba2d5 (diff) |
fix api scheme for scan requests
Change-Id: I26a732073fa577f5eb9165d808a32b96e4b62f7f
Signed-off-by: Koren Lev <korenlev@gmail.com>
(cherry picked from commit 16960c3ca325b33c5884f8f67ec2369453bc498f)
Diffstat (limited to 'app/api/responders/resource')
-rw-r--r-- | app/api/responders/resource/scans.py | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/app/api/responders/resource/scans.py b/app/api/responders/resource/scans.py index c9ad2e2..7f2a947 100644 --- a/app/api/responders/resource/scans.py +++ b/app/api/responders/resource/scans.py @@ -21,22 +21,24 @@ class Scans(ResponderBase): self.PROJECTION = { self.ID: True, "environment": True, - "status": True, - "scan_completed": True + "status": True } def on_get(self, req, resp): self.log.debug("Getting scans") filters = self.parse_query_params(req) - scan_statuses = self.get_constants_by_name("scan_statuses") + scan_statuses = self.get_constants_by_name("scans_statuses") filters_requirements = { "env_name": self.require(str, mandatory=True), - "id": self.require(ObjectId, True), + "id": self.require(ObjectId, convert_to_type=True), "base_object": self.require(str), - "status": self.require(str, False, DataValidate.LIST, scan_statuses), - "page": self.require(int, True), - "page_size": self.require(int, True) + "status": self.require(str, + convert_to_type=False, + validate=DataValidate.LIST, + requirement=scan_statuses), + "page": self.require(int, convert_to_type=True), + "page_size": self.require(int, convert_to_type=True) } self.validate_query_data(filters, filters_requirements) @@ -58,21 +60,21 @@ class Scans(ResponderBase): if error: self.bad_request(error) - scan_statuses = self.get_constants_by_name("scan_statuses") + scan_statuses = self.get_constants_by_name("scans_statuses") log_levels = self.get_constants_by_name("log_levels") scan_requirements = { "status": self.require(str, + mandatory=True, validate=DataValidate.LIST, - requirement=scan_statuses, - mandatory=True), + requirement=scan_statuses), "log_level": self.require(str, validate=DataValidate.LIST, requirement=log_levels), - "clear": self.require(bool, True), - "scan_only_inventory": self.require(bool, True), - "scan_only_links": self.require(bool, True), - "scan_only_cliques": self.require(bool, True), + "clear": self.require(bool, convert_to_type=True), + "scan_only_inventory": self.require(bool, convert_to_type=True), + "scan_only_links": self.require(bool, convert_to_type=True), + "scan_only_cliques": self.require(bool, convert_to_type=True), "environment": self.require(str, mandatory=True), "inventory": self.require(str), "object_id": self.require(str) @@ -86,9 +88,8 @@ class Scans(ResponderBase): env_name = scan["environment"] if not self.check_environment_name(env_name): - self.bad_request("unkown environment: " + env_name) + self.bad_request("unknown environment: " + env_name) - scan["scan_completed"] = False scan["submit_timestamp"] = datetime.now() self.write(scan, self.COLLECTION) self.set_successful_response(resp, |