From 5272be3127c8ee08f5d9becdb6d8f783f34813ea Mon Sep 17 00:00:00 2001 From: David Shea Date: Mon, 6 Aug 2018 15:01:27 -0400 Subject: [PATCH] Add filter arguments to /compose/status This adds the following optional arguments to the /compose/status route: - type, matches the compose_type field - status, matches the queue_status field - blueprint, matches the blueprint field (cherry picked from commit 40f23f093dde01cf631ae2ee5d1245556ae9e4fa) --- src/pylorax/api/v0.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/pylorax/api/v0.py b/src/pylorax/api/v0.py index bbcd8465..e233dfdb 100644 --- a/src/pylorax/api/v0.py +++ b/src/pylorax/api/v0.py @@ -801,8 +801,8 @@ POST `/api/v0/compose` ] } -`/api/v0/compose/status/` -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +`/api/v0/compose/status/[?blueprint=&status=&type=]` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Return the details for each of the comma-separated list of uuids. @@ -1822,14 +1822,29 @@ def v0_api(api): if VALID_API_STRING.match(uuids) is None: return jsonify(status=False, errors=[{"id": INVALID_CHARS, "msg": "Invalid characters in API path"}]), 400 + blueprint = request.args.get("blueprint", None) + status = request.args.get("status", None) + compose_type = request.args.get("type", None) + results = [] errors = [] for uuid in [n.strip().lower() for n in uuids.split(",")]: details = uuid_status(api.config["COMPOSER_CFG"], uuid) - if details is not None: - results.append(details) - else: + + if details is None: errors.append({"id": UNKNOWN_UUID, "msg": "%s is not a valid build uuid" % uuid}) + continue + + if blueprint is not None and details['blueprint'] != blueprint: + continue + + if status is not None and details['queue_status'] != status: + continue + + if compose_type is not None and details['compose_type'] != compose_type: + continue + + results.append(details) return jsonify(uuids=results, errors=errors)