From fbd1d81643dea58f43e8b9be8ed8d2927c0b0c96 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sat, 11 Oct 2025 21:14:04 +0900 Subject: [PATCH] Clean up remamining logic for v1.1 API Change-Id: I97712410d90948976262856842bca35fd77904eb Signed-off-by: Takashi Kajinami --- .../samples/versions-list-response.json | 17 - devstack/plugin.sh | 1 - .../notes/remove-v1-1-a6f3a7fefd70cc5a.yaml | 9 + zaqar/api/v1_1/request.py | 606 ----------------- zaqar/api/v1_1/response.py | 417 ------------ zaqar/api/v2/request.py | 630 +++++++++++++++++- zaqar/bench/helpers.py | 2 - zaqar/common/api/schemas/v1_1/__init__.py | 0 zaqar/common/api/schemas/v1_1/flavors.py | 40 -- zaqar/common/transport/wsgi/helpers.py | 33 +- zaqar/conf/default.py | 2 + zaqar/tests/etc/drivers_storage_invalid.conf | 1 - .../tests/etc/drivers_transport_invalid.conf | 1 - zaqar/tests/etc/functional-tests.conf | 1 - zaqar/tests/etc/functional-zaqar.conf | 2 - zaqar/tests/etc/keystone_auth.conf | 1 - zaqar/tests/etc/websocket_mongodb.conf | 1 - .../etc/websocket_mongodb_keystone_auth.conf | 1 - .../etc/websocket_mongodb_subscriptions.conf | 1 - zaqar/tests/etc/wsgi_faulty.conf | 1 - zaqar/tests/etc/wsgi_fifo_mongodb.conf | 1 - zaqar/tests/etc/wsgi_mongodb.conf | 1 - .../etc/wsgi_mongodb_default_limits.conf | 1 - zaqar/tests/etc/wsgi_mongodb_pooled.conf | 1 - ...i_mongodb_pooled_disable_virtual_pool.conf | 1 - zaqar/tests/etc/wsgi_mongodb_validation.conf | 1 - zaqar/tests/etc/wsgi_redis.conf | 1 - zaqar/tests/etc/wsgi_redis_pooled.conf | 1 - zaqar/tests/etc/wsgi_sqlalchemy.conf | 1 - zaqar/tests/etc/wsgi_sqlalchemy_pooled.conf | 1 - zaqar/tests/etc/wsgi_swift.conf | 1 - zaqar/tests/functional/base.py | 7 - zaqar/tests/functional/helpers.py | 72 -- .../tests/functional/websocket/test_queues.py | 2 +- zaqar/tests/unit/common/test_decorators.py | 18 +- zaqar/transport/wsgi/utils.py | 11 +- zaqar/transport/wsgi/v2_0/claims.py | 5 +- zaqar/transport/wsgi/v2_0/messages.py | 11 +- 38 files changed, 635 insertions(+), 1269 deletions(-) create mode 100644 releasenotes/notes/remove-v1-1-a6f3a7fefd70cc5a.yaml delete mode 100644 zaqar/api/v1_1/request.py delete mode 100644 zaqar/api/v1_1/response.py delete mode 100644 zaqar/common/api/schemas/v1_1/__init__.py delete mode 100644 zaqar/common/api/schemas/v1_1/flavors.py diff --git a/api-ref/source/samples/versions-list-response.json b/api-ref/source/samples/versions-list-response.json index 89f158191..e9b284324 100644 --- a/api-ref/source/samples/versions-list-response.json +++ b/api-ref/source/samples/versions-list-response.json @@ -1,22 +1,5 @@ { "versions":[ - { - "status":"DEPRECATED", - "updated":"2016-7-29T02:22:47Z", - "media-types":[ - { - "base":"application/json", - "type":"application/vnd.openstack.messaging-v1_1+json" - } - ], - "id":"1.1", - "links":[ - { - "href":"/v1.1/", - "rel":"self" - } - ] - }, { "status":"CURRENT", "updated":"2014-9-24T04:06:47Z", diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 1345a3170..8ffdbf3c1 100755 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -81,7 +81,6 @@ function configure_zaqar { iniset $ZAQAR_CONF DEFAULT debug True iniset $ZAQAR_CONF DEFAULT unreliable True iniset $ZAQAR_CONF DEFAULT admin_mode True - iniset $ZAQAR_CONF DEFAULT enable_deprecated_api_versions 1.1 iniset $ZAQAR_CONF signed_url secret_key notreallysecret if is_service_enabled key; then diff --git a/releasenotes/notes/remove-v1-1-a6f3a7fefd70cc5a.yaml b/releasenotes/notes/remove-v1-1-a6f3a7fefd70cc5a.yaml new file mode 100644 index 000000000..5c2fb458b --- /dev/null +++ b/releasenotes/notes/remove-v1-1-a6f3a7fefd70cc5a.yaml @@ -0,0 +1,9 @@ +--- +upgrade: + - | + The deprecated version v1.1 API has been removed. + +deprecations: + - | + The ``[DEFAULT] enable_deprecated_api_versions`` option has been deprecated + due to removal of deprecated APIs. diff --git a/zaqar/api/v1_1/request.py b/zaqar/api/v1_1/request.py deleted file mode 100644 index 71b9b143f..000000000 --- a/zaqar/api/v1_1/request.py +++ /dev/null @@ -1,606 +0,0 @@ -# Copyright (c) 2013 Red Hat, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from zaqar.common.api import api -from zaqar.common import consts - - -class RequestSchema(api.Api): - - headers = { - 'User-Agent': {'type': 'string'}, - 'Date': {'type': 'string'}, - 'Accept': {'type': 'string'}, - 'Client-ID': {'type': 'string'}, - 'X-Project-ID': {'type': 'string'}, - 'X-Auth-Token': {'type': 'string'} - } - - schema = { - - # Base - 'get_home_doc': { - 'properties': { - 'action': {'enum': ['get_home_doc']}, - 'headers': { - 'type': 'object', - 'properties': headers, - } - }, - 'required': ['action', 'headers'], - 'admin': True, - }, - - 'check_node_health': { - 'properties': { - 'action': {'enum': ['check_node_health']}, - 'headers': { - 'type': 'object', - 'properties': headers, - } - }, - 'required': ['action', 'headers'], - 'admin': True, - }, - - 'ping_node': { - 'properties': { - 'action': {'enum': ['ping_node']}, - 'headers': { - 'type': 'object', - 'properties': headers, - } - }, - 'required': ['action', 'headers'], - 'admin': True, - }, - 'authenticate': { - 'properties': { - 'action': {'enum': ['authenticate']}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['X-Project-ID', 'X-Auth-Token'] - } - }, - 'required': ['action', 'headers'], - }, - - # Queues - consts.QUEUE_LIST: { - 'properties': { - 'action': {'enum': [consts.QUEUE_LIST]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'marker': {'type': 'string'}, - 'limit': {'type': 'integer'}, - 'detailed': {'type': 'boolean'} - } - } - }, - 'required': ['action', 'headers'] - }, - - consts.QUEUE_CREATE: { - 'properties': { - 'action': {'enum': [consts.QUEUE_CREATE]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID']}, - 'body': { - 'type': 'object', - 'properties': { - 'queue_name': {'type': 'string'}, - }, - 'required': ['queue_name'], - } - }, - 'required': ['action', 'headers', 'body'] - }, - - consts.QUEUE_DELETE: { - 'properties': { - 'action': {'enum': [consts.QUEUE_DELETE]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'queue_name': {'type': 'string'}, - }, - 'required': ['queue_name'] - } - }, - 'required': ['action', 'headers', 'body'] - }, - - consts.QUEUE_GET: { - 'properties': { - 'action': {'enum': [consts.QUEUE_GET]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'queue_name': {'type': 'string'}, - }, - 'required': ['queue_name'], - } - }, - 'required': ['action', 'headers', 'body'] - }, - - consts.QUEUE_GET_STATS: { - 'properties': { - 'action': {'enum': [consts.QUEUE_GET_STATS]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'queue_name': {'type': 'string'}, - }, - 'required': ['queue_name'], - } - }, - 'required': ['action', 'headers', 'body'], - 'admin': True - }, - - # Messages - consts.MESSAGE_LIST: { - 'properties': { - 'action': {'enum': [consts.MESSAGE_LIST]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'queue_name': {'type': 'string'}, - 'marker': {'type': 'string'}, - 'limit': {'type': 'integer'}, - 'echo': {'type': 'boolean'}, - 'include_claimed': {'type': 'boolean'}, - }, - 'required': ['queue_name'], - } - }, - 'required': ['action', 'headers', 'body'] - }, - - consts.MESSAGE_GET: { - 'properties': { - 'action': {'enum': [consts.MESSAGE_GET]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'queue_name': {'type': 'string'}, - 'message_id': {'type': 'string'}, - }, - 'required': ['queue_name', 'message_id'], - } - }, - 'required': ['action', 'headers', 'body'] - }, - - consts.MESSAGE_GET_MANY: { - 'properties': { - 'action': {'enum': [consts.MESSAGE_GET_MANY]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'queue_name': {'type': 'string'}, - 'message_ids': {'type': 'array'}, - }, - 'required': ['queue_name', 'message_ids'], - } - }, - 'required': ['action', 'headers', 'body'] - }, - - consts.MESSAGE_POST: { - 'properties': { - 'action': {'enum': [consts.MESSAGE_POST]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'queue_name': {'type': 'string'}, - 'messages': {'type': 'array'}, - }, - 'required': ['queue_name', 'messages'], - } - }, - 'required': ['action', 'headers', 'body'] - }, - - consts.MESSAGE_DELETE: { - 'properties': { - 'action': {'enum': [consts.MESSAGE_DELETE]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'queue_name': {'type': 'string'}, - 'message_id': {'type': 'string'}, - 'claim_id': {'type': 'string'} - }, - 'required': ['queue_name', 'message_id'], - } - }, - 'required': ['action', 'headers', 'body'] - }, - - consts.MESSAGE_DELETE_MANY: { - 'properties': { - 'action': {'enum': [consts.MESSAGE_DELETE_MANY]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'queue_name': {'type': 'string'}, - 'message_ids': {'type': 'array'}, - 'claim_ids': {'type': 'array'}, - 'pop': {'type': 'integer'} - }, - 'required': ['queue_name'], - } - }, - 'required': ['action', 'headers', 'body'] - }, - - # Claims - consts.CLAIM_CREATE: { - 'properties': { - 'action': {'enum': [consts.CLAIM_CREATE]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'queue_name': {'type': 'string'}, - 'limit': {'type': 'integer'}, - 'ttl': {'type': 'integer'}, - 'grace': {'type': 'integer'} - }, - 'required': ['queue_name'], - } - }, - 'required': ['action', 'headers', 'body'] - }, - - consts.CLAIM_GET: { - 'properties': { - 'action': {'enum': [consts.CLAIM_GET]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'queue_name': {'type': 'string'}, - 'claim_id': {'type': 'string'} - }, - 'required': ['queue_name', 'claim_id'], - } - }, - 'required': ['action', 'headers', 'body'] - }, - - consts.CLAIM_UPDATE: { - 'properties': { - 'action': {'enum': [consts.CLAIM_UPDATE]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'queue_name': {'type': 'string'}, - 'claim_id': {'type': 'string'}, - 'ttl': {'type': 'integer'} - }, - 'required': ['queue_name', 'claim_id'], - } - }, - 'required': ['action', 'headers', 'body'] - }, - - consts.CLAIM_DELETE: { - 'properties': { - 'action': {'enum': [consts.CLAIM_DELETE]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'queue_name': {'type': 'string'}, - 'claim_id': {'type': 'string'} - }, - 'required': ['queue_name', 'claim_id'], - } - }, - 'required': ['action', 'headers', 'body'] - }, - - # Pools - consts.POOL_LIST: { - 'properties': { - 'action': {'enum': [consts.POOL_LIST]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'pool_name': {'type': 'string'}, - 'limit': {'type': 'integer'}, - 'marker': {'type': 'string'} - }, - 'required': ['pool_name'], - } - }, - 'required': ['action', 'headers', 'body'], - 'admin': True, - }, - - consts.POOL_CREATE: { - 'properties': { - 'action': {'enum': [consts.POOL_CREATE]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'pool_name': {'type': 'string'}, - 'weight': {'type': 'integer'}, - 'uri': {'type': 'string'}, - 'options': {'type': 'object'}, - }, - 'required': ['pool_name'], - } - }, - 'required': ['action', 'headers', 'body'], - 'admin': True, - }, - - consts.POOL_UPDATE: { - 'properties': { - 'action': {'enum': [consts.POOL_UPDATE]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'pool_name': {'type': 'string'}, - 'weight': {'type': 'integer'}, - 'uri': {'type': 'string'}, - 'options': {'type': 'object'}, - }, - 'required': ['pool_name'], - } - }, - 'required': ['action', 'headers', 'body'], - 'admin': True, - }, - - consts.POOL_GET: { - 'properties': { - 'action': {'enum': [consts.POOL_GET]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'pool_name': {'type': 'string'}, - 'detailed': {'type': 'boolean'} - }, - 'required': ['pool_name'], - } - }, - 'required': ['action', 'headers', 'body'], - 'admin': True, - }, - - consts.POOL_DELETE: { - 'properties': { - 'action': {'enum': [consts.POOL_DELETE]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'pool_name': {'type': 'string'} - }, - 'required': ['pool_name'], - } - }, - 'required': ['action', 'headers', 'body'], - 'admin': True, - }, - - # Flavors - consts.FLAVOR_LIST: { - 'properties': { - 'action': {'enum': [consts.FLAVOR_LIST]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'flavor_name': {'type': 'string'}, - 'limit': {'type': 'integer'}, - 'marker': {'type': 'string'} - }, - 'required': ['flavor_name'], - } - }, - 'required': ['action', 'headers', 'body'], - 'admin': True, - }, - - consts.FLAVOR_CREATE: { - 'properties': { - 'action': {'enum': [consts.FLAVOR_CREATE]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'flavor_name': {'type': 'string'}, - 'pool_name': {'type': 'string'}, - 'capabilities': {'type': 'object'}, - }, - 'required': ['flavor_name', 'pool_name'], - } - }, - 'required': ['action', 'headers', 'body'], - 'admin': True, - }, - - consts.FLAVOR_UPDATE: { - 'properties': { - 'action': {'enum': [consts.FLAVOR_UPDATE]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'flavor_name': {'type': 'string'}, - 'pool_name': {'type': 'string'}, - 'capabilities': {'type': 'object'}, - }, - 'required': ['flavor_name'], - } - }, - 'required': ['action', 'headers', 'body'], - 'admin': True, - }, - - consts.FLAVOR_GET: { - 'properties': { - 'action': {'enum': [consts.FLAVOR_GET]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'flavor_name': {'type': 'string'}, - 'detailed': {'type': 'boolean'} - }, - 'required': ['flavor_name'], - } - }, - 'required': ['action', 'headers', 'body'], - 'admin': True, - }, - - consts.FLAVOR_DELETE: { - 'properties': { - 'action': {'enum': [consts.FLAVOR_DELETE]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID'] - }, - 'body': { - 'type': 'object', - 'properties': { - 'flavor_name': {'type': 'string'} - }, - 'required': ['flavor_name'], - } - }, - 'required': ['action', 'headers', 'body'], - 'admin': True, - }, - } diff --git a/zaqar/api/v1_1/response.py b/zaqar/api/v1_1/response.py deleted file mode 100644 index ae1995f41..000000000 --- a/zaqar/api/v1_1/response.py +++ /dev/null @@ -1,417 +0,0 @@ -# Copyright (c) 2013 Rackspace, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from zaqar.common.api import api -from zaqar.common import consts - - -class ResponseSchema(api.Api): - - """Define validation schema for json response.""" - - def __init__(self, limits): - self.limits = limits - - age = { - "type": "number", - "minimum": 0 - } - - message = { - "type": "object", - "properties": { - "id": { - "type": "string", - }, - "href": { - "type": "string", - "pattern": r"^(/v1\.1/queues/[a-zA-Z0-9_-]{1,64}" - r"/messages/[a-zA-Z0-9_-]+)(\?claim_id=[a-zA-Z0-9_-]+)?$" - }, - "age": age, - "ttl": { - "type": "number", - "minimum": 1, - "maximum": self.limits.max_message_ttl - }, - - "body": { - "type": "object" - }, - "checksum": { - "type": "string", - }, - }, - "required": ["href", "ttl", "age", "body", "id"], - "additionalProperties": False, - } - - claim_href = { - "type": "string", - "pattern": r"^(/v1\.1/queues/[a-zA-Z0-9_-]{1,64}" - r"/messages/[a-zA-Z0-9_-]+)" - r"\?claim_id=[a-zA-Z0-9_-]+$" - } - - flavor = { - 'type': 'object', - 'properties': { - 'href': { - 'type': 'string', - 'pattern': r'^/v1\.1/flavors/[a-zA-Z0-9_-]{1,64}$' - }, - 'pool': { - 'type': 'string', - }, - 'project': { - 'type': 'string' - }, - 'capabilities': { - 'type': 'object', - 'additionalProperties': True - } - }, - 'required': ['href', 'pool', 'project'], - 'additionalProperties': False, - } - - self.schema = { - consts.MESSAGE_GET_MANY: { - 'type': 'object', - 'properties': { - 'messages': { - "type": "array", - "items": message, - "minItems": 1, - "maxItems": self.limits.max_messages_per_page - } - }, - 'required': ['messages'], - 'additionalProperties': False, - }, - - consts.QUEUE_LIST: { - 'type': 'object', - 'properties': { - 'links': { - 'type': 'array', - 'items': { - 'type': 'object', - 'properties': { - 'rel': { - 'type': 'string', - 'enum': ['next'], - }, - 'href': { - 'type': 'string', - "pattern": r"^/v1\.1/queues\?", - } - }, - 'required': ['rel', 'href'], - 'additionalProperties': False, - }, - 'minItems': 1, - 'maxItems': 1, - }, - - 'queues': { - 'type': 'array', - 'items': { - 'type': 'object', - 'properties': { - 'name': { - 'type': 'string', - 'pattern': '^[a-zA-Z0-9_-]{1,64}$' - }, - 'href': { - 'type': 'string', - 'pattern': r'^/v1\.1/queues/' - r'[a-zA-Z0-9_-]{1,64}$', - }, - 'metadata': { - 'type': 'object', - } - }, - 'required': ['name', 'href'], - 'additionalProperties': False, - }, - 'minItems': 1, - 'maxItems': self.limits.max_queues_per_page, - } - }, - 'required': ['links', 'queues'], - 'additionalProperties': False, - }, - - consts.QUEUE_GET_STATS: { - 'type': 'object', - 'properties': { - 'messages': { - 'type': 'object', - 'properties': { - 'free': { - 'type': 'number', - 'minimum': 0 - }, - 'claimed': { - 'type': 'number', - 'minimum': 0 - }, - 'total': { - 'type': 'number', - 'minimum': 0 - }, - 'oldest': { - 'type': 'object' - }, - 'newest': { - 'type': 'object' - } - - }, - 'required': ['free', 'claimed', 'total'], - 'additionalProperties': False - } - }, - 'required': ['messages'], - 'additionalProperties': False - }, - - consts.POOL_LIST: { - 'type': 'object', - 'properties': { - 'links': { - 'type': 'array', - 'items': { - 'type': 'object', - 'properties': { - 'rel': { - 'type': 'string' - }, - 'href': { - 'type': 'string', - 'pattern': r'^/v1\.1/pools\?' - } - }, - 'required': ['rel', 'href'], - 'additionalProperties': False - } - }, - 'pools': { - 'type': 'array', - 'items': { - 'type': 'object', - 'properties': { - 'href': { - 'type': 'string', - 'pattern': r'^/v1\.1/' - r'pools/[a-zA-Z0-9_-]{1,64}$' - }, - 'weight': { - 'type': 'number', - 'minimum': -1 - }, - 'name': { - 'type': 'string' - }, - 'uri': { - 'type': 'string' - }, - 'flavor': { - 'type': ['string', 'null'] - }, - 'options': { - 'type': 'object', - 'additionalProperties': True - } - }, - 'required': ['href', 'weight', 'uri'], - 'additionalProperties': False, - }, - } - }, - 'required': ['links', 'pools'], - 'additionalProperties': False - }, - - consts.MESSAGE_LIST: { - 'type': 'object', - 'properties': { - 'links': { - 'type': 'array', - 'items': { - 'type': 'object', - 'properties': { - 'rel': { - 'type': 'string' - }, - 'href': { - 'type': 'string', - 'pattern': r'^/v1\.1/queues/[a-zA-Z0-9_-]+' - r'/messages\?(.)*$' - } - }, - 'required': ['rel', 'href'], - 'additionalProperties': False - } - }, - 'messages': { - "type": "array", - "items": message, - "minItems": 0, - "maxItems": self.limits.max_messages_per_claim_or_pop - } - } - }, - consts.POOL_GET_DETAIL: { - 'type': 'object', - 'properties': { - 'name': { - 'type': 'string' - }, - 'uri': { - 'type': 'string' - }, - 'flavor': { - 'type': ['string', 'null'] - }, - 'weight': { - 'type': 'number', - 'minimum': -1 - }, - 'href': { - 'type': 'string', - 'pattern': r'^/v1\.1/pools/' - r'[a-zA-Z0-9_\-]+$' - }, - 'options': { - 'type': 'object', - 'additionalProperties': True - } - }, - 'required': ['uri', 'weight', 'href'], - 'additionalProperties': False - }, - - consts.CLAIM_CREATE: { - 'type': 'object', - 'properties': { - 'messages': { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "string", - }, - "href": claim_href, - "ttl": { - "type": "number", - "minimum": 1, - "maximum": self.limits.max_message_ttl - }, - "age": age, - "body": { - "type": "object" - }, - "checksum": { - "type": "string", - }, - }, - "required": ["href", "ttl", "age", "body", "id"], - "additionalProperties": False, - }, - "minItems": 1, - "maxItems": self.limits.max_messages_per_page - } - }, - 'required': ['messages'], - 'additionalProperties': False - }, - - consts.CLAIM_GET: { - 'type': 'object', - 'properties': { - 'age': age, - 'ttl': { - 'type': 'number', - 'minimum': 0, - 'maximum': self.limits.max_claim_ttl - }, - 'href': { - 'type': 'string', - 'pattern': r'^/v1\.1/queues/[a-zA-Z0-9_-]+' - r'/claims/[a-zA-Z0-9_-]+$' - }, - 'messages': { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "string", - }, - "href": claim_href, - "ttl": { - "type": "number", - "minimum": 1, - "maximum": self.limits.max_message_ttl - }, - "age": age, - "body": { - "type": "object" - } - }, - "required": ["href", "ttl", "age", "body", "id"], - "additionalProperties": False, - }, - "minItems": 1, - "maxItems": self.limits.max_messages_per_page - } - }, - 'required': ['age', 'ttl', 'messages', 'href'], - 'additionalProperties': False - }, - - consts.FLAVOR_LIST: { - 'type': 'object', - 'properties': { - 'links': { - 'type': 'array', - 'items': { - 'type': 'object', - 'properties': { - 'rel': { - 'type': 'string' - }, - 'href': { - 'type': 'string', - 'pattern': r'^/v1\.1/flavors\?' - } - }, - 'required': ['rel', 'href'], - 'additionalProperties': False - } - }, - 'flavors': { - 'type': 'array', - 'items': flavor, - } - }, - 'required': ['links', 'flavors'], - 'additionalProperties': False - } - - } diff --git a/zaqar/api/v2/request.py b/zaqar/api/v2/request.py index d7525cf2f..84ff5cdf8 100644 --- a/zaqar/api/v2/request.py +++ b/zaqar/api/v2/request.py @@ -13,16 +13,615 @@ # See the License for the specific language governing permissions and # limitations under the License. -from zaqar.api.v1_1 import request as v1_1 +from zaqar.common.api import api from zaqar.common import consts -class RequestSchema(v1_1.RequestSchema): +class RequestSchema(api.Api): - headers = v1_1.RequestSchema.headers - schema = v1_1.RequestSchema.schema + headers = { + 'User-Agent': {'type': 'string'}, + 'Date': {'type': 'string'}, + 'Accept': {'type': 'string'}, + 'Client-ID': {'type': 'string'}, + 'X-Project-ID': {'type': 'string'}, + 'X-Auth-Token': {'type': 'string'} + } - schema.update({ + schema = { + + # Base + 'get_home_doc': { + 'properties': { + 'action': {'enum': ['get_home_doc']}, + 'headers': { + 'type': 'object', + 'properties': headers, + } + }, + 'required': ['action', 'headers'], + 'admin': True, + }, + + 'check_node_health': { + 'properties': { + 'action': {'enum': ['check_node_health']}, + 'headers': { + 'type': 'object', + 'properties': headers, + } + }, + 'required': ['action', 'headers'], + 'admin': True, + }, + + 'ping_node': { + 'properties': { + 'action': {'enum': ['ping_node']}, + 'headers': { + 'type': 'object', + 'properties': headers, + } + }, + 'required': ['action', 'headers'], + 'admin': True, + }, + 'authenticate': { + 'properties': { + 'action': {'enum': ['authenticate']}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['X-Project-ID', 'X-Auth-Token'] + } + }, + 'required': ['action', 'headers'], + }, + + # Queues + consts.QUEUE_LIST: { + 'properties': { + 'action': {'enum': [consts.QUEUE_LIST]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'marker': {'type': 'string'}, + 'limit': {'type': 'integer'}, + 'detailed': {'type': 'boolean'} + } + } + }, + 'required': ['action', 'headers'] + }, + + consts.QUEUE_CREATE: { + 'properties': { + 'action': {'enum': [consts.QUEUE_CREATE]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID']}, + 'body': { + 'type': 'object', + 'properties': { + 'queue_name': {'type': 'string'}, + }, + 'required': ['queue_name'], + } + }, + 'required': ['action', 'headers', 'body'] + }, + + consts.QUEUE_DELETE: { + 'properties': { + 'action': {'enum': [consts.QUEUE_DELETE]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'queue_name': {'type': 'string'}, + }, + 'required': ['queue_name'] + } + }, + 'required': ['action', 'headers', 'body'] + }, + + consts.QUEUE_GET: { + 'properties': { + 'action': {'enum': [consts.QUEUE_GET]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'queue_name': {'type': 'string'}, + }, + 'required': ['queue_name'], + } + }, + 'required': ['action', 'headers', 'body'] + }, + + consts.QUEUE_GET_STATS: { + 'properties': { + 'action': {'enum': [consts.QUEUE_GET_STATS]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'queue_name': {'type': 'string'}, + }, + 'required': ['queue_name'], + } + }, + 'required': ['action', 'headers', 'body'], + 'admin': True + }, + + consts.QUEUE_PURGE: { + 'properties': { + 'action': {'enum': [consts.QUEUE_PURGE]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID']}, + 'body': { + 'type': 'object', + 'properties': { + 'queue_name': {'type': 'string'}, + 'resource_types': {'type': 'array'}, + }, + 'required': ['queue_name'], + } + }, + 'required': ['action', 'headers', 'body'] + }, + + # Messages + consts.MESSAGE_LIST: { + 'properties': { + 'action': {'enum': [consts.MESSAGE_LIST]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'queue_name': {'type': 'string'}, + 'marker': {'type': 'string'}, + 'limit': {'type': 'integer'}, + 'echo': {'type': 'boolean'}, + 'include_claimed': {'type': 'boolean'}, + }, + 'required': ['queue_name'], + } + }, + 'required': ['action', 'headers', 'body'] + }, + + consts.MESSAGE_GET: { + 'properties': { + 'action': {'enum': [consts.MESSAGE_GET]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'queue_name': {'type': 'string'}, + 'message_id': {'type': 'string'}, + }, + 'required': ['queue_name', 'message_id'], + } + }, + 'required': ['action', 'headers', 'body'] + }, + + consts.MESSAGE_GET_MANY: { + 'properties': { + 'action': {'enum': [consts.MESSAGE_GET_MANY]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'queue_name': {'type': 'string'}, + 'message_ids': {'type': 'array'}, + }, + 'required': ['queue_name', 'message_ids'], + } + }, + 'required': ['action', 'headers', 'body'] + }, + + consts.MESSAGE_POST: { + 'properties': { + 'action': {'enum': [consts.MESSAGE_POST]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'queue_name': {'type': 'string'}, + 'messages': {'type': 'array'}, + }, + 'required': ['queue_name', 'messages'], + } + }, + 'required': ['action', 'headers', 'body'] + }, + + consts.MESSAGE_DELETE: { + 'properties': { + 'action': {'enum': [consts.MESSAGE_DELETE]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'queue_name': {'type': 'string'}, + 'message_id': {'type': 'string'}, + 'claim_id': {'type': 'string'} + }, + 'required': ['queue_name', 'message_id'], + } + }, + 'required': ['action', 'headers', 'body'] + }, + + consts.MESSAGE_DELETE_MANY: { + 'properties': { + 'action': {'enum': [consts.MESSAGE_DELETE_MANY]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'queue_name': {'type': 'string'}, + 'message_ids': {'type': 'array'}, + 'claim_ids': {'type': 'array'}, + 'pop': {'type': 'integer'} + }, + 'required': ['queue_name'], + } + }, + 'required': ['action', 'headers', 'body'] + }, + + # Claims + consts.CLAIM_CREATE: { + 'properties': { + 'action': {'enum': [consts.CLAIM_CREATE]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'queue_name': {'type': 'string'}, + 'limit': {'type': 'integer'}, + 'ttl': {'type': 'integer'}, + 'grace': {'type': 'integer'} + }, + 'required': ['queue_name'], + } + }, + 'required': ['action', 'headers', 'body'] + }, + + consts.CLAIM_GET: { + 'properties': { + 'action': {'enum': [consts.CLAIM_GET]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'queue_name': {'type': 'string'}, + 'claim_id': {'type': 'string'} + }, + 'required': ['queue_name', 'claim_id'], + } + }, + 'required': ['action', 'headers', 'body'] + }, + + consts.CLAIM_UPDATE: { + 'properties': { + 'action': {'enum': [consts.CLAIM_UPDATE]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'queue_name': {'type': 'string'}, + 'claim_id': {'type': 'string'}, + 'ttl': {'type': 'integer'} + }, + 'required': ['queue_name', 'claim_id'], + } + }, + 'required': ['action', 'headers', 'body'] + }, + + consts.CLAIM_DELETE: { + 'properties': { + 'action': {'enum': [consts.CLAIM_DELETE]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'queue_name': {'type': 'string'}, + 'claim_id': {'type': 'string'} + }, + 'required': ['queue_name', 'claim_id'], + } + }, + 'required': ['action', 'headers', 'body'] + }, + + # Pools + consts.POOL_LIST: { + 'properties': { + 'action': {'enum': [consts.POOL_LIST]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'pool_name': {'type': 'string'}, + 'limit': {'type': 'integer'}, + 'marker': {'type': 'string'} + }, + 'required': ['pool_name'], + } + }, + 'required': ['action', 'headers', 'body'], + 'admin': True, + }, + + consts.POOL_CREATE: { + 'properties': { + 'action': {'enum': [consts.POOL_CREATE]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'pool_name': {'type': 'string'}, + 'weight': {'type': 'integer'}, + 'uri': {'type': 'string'}, + 'options': {'type': 'object'}, + }, + 'required': ['pool_name'], + } + }, + 'required': ['action', 'headers', 'body'], + 'admin': True, + }, + + consts.POOL_UPDATE: { + 'properties': { + 'action': {'enum': [consts.POOL_UPDATE]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'pool_name': {'type': 'string'}, + 'weight': {'type': 'integer'}, + 'uri': {'type': 'string'}, + 'options': {'type': 'object'}, + }, + 'required': ['pool_name'], + } + }, + 'required': ['action', 'headers', 'body'], + 'admin': True, + }, + + consts.POOL_GET: { + 'properties': { + 'action': {'enum': [consts.POOL_GET]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'pool_name': {'type': 'string'}, + 'detailed': {'type': 'boolean'} + }, + 'required': ['pool_name'], + } + }, + 'required': ['action', 'headers', 'body'], + 'admin': True, + }, + + consts.POOL_DELETE: { + 'properties': { + 'action': {'enum': [consts.POOL_DELETE]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'pool_name': {'type': 'string'} + }, + 'required': ['pool_name'], + } + }, + 'required': ['action', 'headers', 'body'], + 'admin': True, + }, + + # Flavors + consts.FLAVOR_LIST: { + 'properties': { + 'action': {'enum': [consts.FLAVOR_LIST]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'flavor_name': {'type': 'string'}, + 'limit': {'type': 'integer'}, + 'marker': {'type': 'string'} + }, + 'required': ['flavor_name'], + } + }, + 'required': ['action', 'headers', 'body'], + 'admin': True, + }, + + consts.FLAVOR_CREATE: { + 'properties': { + 'action': {'enum': [consts.FLAVOR_CREATE]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'flavor_name': {'type': 'string'}, + 'pool_name': {'type': 'string'}, + 'capabilities': {'type': 'object'}, + }, + 'required': ['flavor_name', 'pool_name'], + } + }, + 'required': ['action', 'headers', 'body'], + 'admin': True, + }, + + consts.FLAVOR_UPDATE: { + 'properties': { + 'action': {'enum': [consts.FLAVOR_UPDATE]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'flavor_name': {'type': 'string'}, + 'pool_name': {'type': 'string'}, + 'capabilities': {'type': 'object'}, + }, + 'required': ['flavor_name'], + } + }, + 'required': ['action', 'headers', 'body'], + 'admin': True, + }, + + consts.FLAVOR_GET: { + 'properties': { + 'action': {'enum': [consts.FLAVOR_GET]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'flavor_name': {'type': 'string'}, + 'detailed': {'type': 'boolean'} + }, + 'required': ['flavor_name'], + } + }, + 'required': ['action', 'headers', 'body'], + 'admin': True, + }, + + consts.FLAVOR_DELETE: { + 'properties': { + 'action': {'enum': [consts.FLAVOR_DELETE]}, + 'headers': { + 'type': 'object', + 'properties': headers, + 'required': ['Client-ID', 'X-Project-ID'] + }, + 'body': { + 'type': 'object', + 'properties': { + 'flavor_name': {'type': 'string'} + }, + 'required': ['flavor_name'], + } + }, + 'required': ['action', 'headers', 'body'], + 'admin': True, + }, # Subscriptions consts.SUBSCRIPTION_LIST: { @@ -104,23 +703,4 @@ class RequestSchema(v1_1.RequestSchema): }, 'required': ['action', 'headers', 'body'] }, - - consts.QUEUE_PURGE: { - 'properties': { - 'action': {'enum': [consts.QUEUE_PURGE]}, - 'headers': { - 'type': 'object', - 'properties': headers, - 'required': ['Client-ID', 'X-Project-ID']}, - 'body': { - 'type': 'object', - 'properties': { - 'queue_name': {'type': 'string'}, - 'resource_types': {'type': 'array'}, - }, - 'required': ['queue_name'], - } - }, - 'required': ['action', 'headers', 'body'] - }, - }) + } diff --git a/zaqar/bench/helpers.py b/zaqar/bench/helpers.py index 6718018bd..2233d5036 100644 --- a/zaqar/bench/helpers.py +++ b/zaqar/bench/helpers.py @@ -110,8 +110,6 @@ class LazyAPIVersion(object): def get(self): if self.api_version is None: conversion_map = { - 1.0: 1, - 1.1: 1.1, 2.0: 2, } try: diff --git a/zaqar/common/api/schemas/v1_1/__init__.py b/zaqar/common/api/schemas/v1_1/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/zaqar/common/api/schemas/v1_1/flavors.py b/zaqar/common/api/schemas/v1_1/flavors.py deleted file mode 100644 index 5505f30f2..000000000 --- a/zaqar/common/api/schemas/v1_1/flavors.py +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (c) 2013 Rackspace Hosting, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""flavors: JSON schema for zaqar-queues flavors resources.""" - -# NOTE(flaper87): capabilities can be anything. These will be unique to -# each storage driver, so we don't perform any further validation at -# the transport layer. -patch_capabilities = { - 'type': 'object', - 'properties': { - 'capabilities': { - 'type': 'object' - } - } -} - -create = { - 'type': 'object', - 'properties': { - 'capabilities': patch_capabilities['properties']['capabilities'] - }, - # NOTE(flaper87): capabilities need not be present. Storage drivers - # must provide reasonable defaults. - # NOTE(wanghao): remove the whole folder when we remove the 1.1 API - # totally. - 'additionalProperties': True -} diff --git a/zaqar/common/transport/wsgi/helpers.py b/zaqar/common/transport/wsgi/helpers.py index a258e017a..b4d52fc13 100644 --- a/zaqar/common/transport/wsgi/helpers.py +++ b/zaqar/common/transport/wsgi/helpers.py @@ -21,7 +21,6 @@ import uuid import falcon from oslo_log import log as logging -from oslo_utils import versionutils from zaqar.common import urls from zaqar import context @@ -101,8 +100,7 @@ def extract_project_id(req, resp, params): description=_('X-PROJECT-ID cannot be an empty string. Specify ' 'the right header X-PROJECT-ID and retry.')) - if not params['project_id'] and versionutils.is_compatible( - 'v1.1', api_version_string, same_major=False): + if not params['project_id']: raise falcon.HTTPBadRequest( title='Project-Id Missing', description=_('The header X-PROJECT-ID was missing')) @@ -124,27 +122,14 @@ def require_client_id(validate, req, resp, params): :rtype: None """ - if req.path.startswith('/v1.1/') or req.path.startswith('/v2/'): - try: - validate(req.get_header('Client-ID', required=True)) - except ValueError: - description = _('Malformed hexadecimal UUID.') - raise falcon.HTTPBadRequest( - title='Wrong UUID value', description=description) - except validation.ValidationFailed as ex: - raise falcon.HTTPBadRequest(title=str(ex)) - else: - # NOTE(wanghao): Since we changed the get_client_uuid to support - # other format of client id, so need to check the uuid here for - # v1 API. - try: - client_id = req.get_header('Client-ID') - if client_id or client_id == '': - uuid.UUID(client_id) - except ValueError: - description = _('Malformed hexadecimal UUID.') - raise falcon.HTTPBadRequest( - title='Wrong UUID value', description=description) + try: + validate(req.get_header('Client-ID', required=True)) + except ValueError: + description = _('Malformed hexadecimal UUID.') + raise falcon.HTTPBadRequest( + title='Wrong UUID value', description=description) + except validation.ValidationFailed as ex: + raise falcon.HTTPBadRequest(title=str(ex)) def validate_queue_identification(validate, req, resp, params): diff --git a/zaqar/conf/default.py b/zaqar/conf/default.py index 6de6b0cf3..31b3757f6 100644 --- a/zaqar/conf/default.py +++ b/zaqar/conf/default.py @@ -36,6 +36,8 @@ unreliable = cfg.BoolOpt( enable_deprecated_api_versions = cfg.ListOpt( 'enable_deprecated_api_versions', default=[], item_type=cfg.types.String(choices=('1.1',)), + deprecated_for_removal=True, + deprecated_reason='Deprecated APIs no longer exist', help='List of deprecated API versions to enable.') diff --git a/zaqar/tests/etc/drivers_storage_invalid.conf b/zaqar/tests/etc/drivers_storage_invalid.conf index dd136b6ce..f289cd591 100644 --- a/zaqar/tests/etc/drivers_storage_invalid.conf +++ b/zaqar/tests/etc/drivers_storage_invalid.conf @@ -2,7 +2,6 @@ debug = False verbose = False admin_mode = False -enable_deprecated_api_versions = 1.1 [drivers] transport = wsgi diff --git a/zaqar/tests/etc/drivers_transport_invalid.conf b/zaqar/tests/etc/drivers_transport_invalid.conf index 98fd3b4bd..575fbf776 100644 --- a/zaqar/tests/etc/drivers_transport_invalid.conf +++ b/zaqar/tests/etc/drivers_transport_invalid.conf @@ -1,7 +1,6 @@ [DEFAULT] debug = False verbose = False -enable_deprecated_api_versions = 1.1 [drivers] transport = invalid diff --git a/zaqar/tests/etc/functional-tests.conf b/zaqar/tests/etc/functional-tests.conf index b4bda480b..38d8dc66b 100644 --- a/zaqar/tests/etc/functional-tests.conf +++ b/zaqar/tests/etc/functional-tests.conf @@ -1,7 +1,6 @@ [DEFAULT] # run_tests = True unreliable = True -enable_deprecated_api_versions = 1.1 [zaqar] # url = http://0.0.0.0:8888 diff --git a/zaqar/tests/etc/functional-zaqar.conf b/zaqar/tests/etc/functional-zaqar.conf index bca78c7ce..04ebbf408 100644 --- a/zaqar/tests/etc/functional-zaqar.conf +++ b/zaqar/tests/etc/functional-zaqar.conf @@ -5,7 +5,6 @@ verbose = True # Show debugging output in logs (sets DEBUG log level output) debug = True -enable_deprecated_api_versions = 1.1 # Log to this file! ; log_file = /var/log/zaqar/server.log @@ -22,7 +21,6 @@ enable_deprecated_api_versions = 1.1 ;syslog_log_facility = LOG_LOCAL0 unreliable = True -enable_deprecated_api_versions = 1.1 [drivers] # Transport driver module (e.g., wsgi) diff --git a/zaqar/tests/etc/keystone_auth.conf b/zaqar/tests/etc/keystone_auth.conf index 152c930aa..647807714 100644 --- a/zaqar/tests/etc/keystone_auth.conf +++ b/zaqar/tests/etc/keystone_auth.conf @@ -3,7 +3,6 @@ auth_strategy = keystone debug = False verbose = False -enable_deprecated_api_versions = 1.1 [drivers] transport = wsgi diff --git a/zaqar/tests/etc/websocket_mongodb.conf b/zaqar/tests/etc/websocket_mongodb.conf index dcee0dfde..81c4f42c0 100644 --- a/zaqar/tests/etc/websocket_mongodb.conf +++ b/zaqar/tests/etc/websocket_mongodb.conf @@ -1,6 +1,5 @@ [DEFAULT] unreliable = True -enable_deprecated_api_versions = 1.1 [drivers] diff --git a/zaqar/tests/etc/websocket_mongodb_keystone_auth.conf b/zaqar/tests/etc/websocket_mongodb_keystone_auth.conf index a153d2b2c..64e98f0f3 100644 --- a/zaqar/tests/etc/websocket_mongodb_keystone_auth.conf +++ b/zaqar/tests/etc/websocket_mongodb_keystone_auth.conf @@ -1,6 +1,5 @@ [DEFAULT] auth_strategy = keystone -enable_deprecated_api_versions = 1.1 [drivers] diff --git a/zaqar/tests/etc/websocket_mongodb_subscriptions.conf b/zaqar/tests/etc/websocket_mongodb_subscriptions.conf index 697dad7bb..56a97899d 100644 --- a/zaqar/tests/etc/websocket_mongodb_subscriptions.conf +++ b/zaqar/tests/etc/websocket_mongodb_subscriptions.conf @@ -1,6 +1,5 @@ [DEFAULT] unreliable = True -enable_deprecated_api_versions = 1.1 [drivers] diff --git a/zaqar/tests/etc/wsgi_faulty.conf b/zaqar/tests/etc/wsgi_faulty.conf index 2a6dfdcdb..c07ebc4ba 100644 --- a/zaqar/tests/etc/wsgi_faulty.conf +++ b/zaqar/tests/etc/wsgi_faulty.conf @@ -1,7 +1,6 @@ [DEFAULT] debug = False verbose = False -enable_deprecated_api_versions = 1.1 [drivers] transport = wsgi diff --git a/zaqar/tests/etc/wsgi_fifo_mongodb.conf b/zaqar/tests/etc/wsgi_fifo_mongodb.conf index 636fdf17e..5b0c8cb65 100644 --- a/zaqar/tests/etc/wsgi_fifo_mongodb.conf +++ b/zaqar/tests/etc/wsgi_fifo_mongodb.conf @@ -2,7 +2,6 @@ debug = False verbose = False unreliable = True -enable_deprecated_api_versions = 1.1 [drivers] transport = wsgi diff --git a/zaqar/tests/etc/wsgi_mongodb.conf b/zaqar/tests/etc/wsgi_mongodb.conf index 91ef6fefe..134ef39e1 100644 --- a/zaqar/tests/etc/wsgi_mongodb.conf +++ b/zaqar/tests/etc/wsgi_mongodb.conf @@ -2,7 +2,6 @@ debug = False verbose = False unreliable = True -enable_deprecated_api_versions = 1.1 [drivers] transport = wsgi diff --git a/zaqar/tests/etc/wsgi_mongodb_default_limits.conf b/zaqar/tests/etc/wsgi_mongodb_default_limits.conf index 209ae048c..f710a7e1f 100644 --- a/zaqar/tests/etc/wsgi_mongodb_default_limits.conf +++ b/zaqar/tests/etc/wsgi_mongodb_default_limits.conf @@ -1,5 +1,4 @@ [DEFAULT] -enable_deprecated_api_versions = 1.1 [drivers] transport = wsgi diff --git a/zaqar/tests/etc/wsgi_mongodb_pooled.conf b/zaqar/tests/etc/wsgi_mongodb_pooled.conf index a2a1ca905..002e207f3 100644 --- a/zaqar/tests/etc/wsgi_mongodb_pooled.conf +++ b/zaqar/tests/etc/wsgi_mongodb_pooled.conf @@ -2,7 +2,6 @@ pooling = True admin_mode = True unreliable = True -enable_deprecated_api_versions = 1.1 [drivers] transport = wsgi diff --git a/zaqar/tests/etc/wsgi_mongodb_pooled_disable_virtual_pool.conf b/zaqar/tests/etc/wsgi_mongodb_pooled_disable_virtual_pool.conf index 919a177eb..6b0fd875e 100644 --- a/zaqar/tests/etc/wsgi_mongodb_pooled_disable_virtual_pool.conf +++ b/zaqar/tests/etc/wsgi_mongodb_pooled_disable_virtual_pool.conf @@ -2,7 +2,6 @@ pooling = True admin_mode = True unreliable = True -enable_deprecated_api_versions = 1.1 [drivers] transport = wsgi diff --git a/zaqar/tests/etc/wsgi_mongodb_validation.conf b/zaqar/tests/etc/wsgi_mongodb_validation.conf index cfdd228ae..e87426e78 100644 --- a/zaqar/tests/etc/wsgi_mongodb_validation.conf +++ b/zaqar/tests/etc/wsgi_mongodb_validation.conf @@ -1,5 +1,4 @@ [DEFAULT] -enable_deprecated_api_versions = 1.1 [drivers] transport = wsgi diff --git a/zaqar/tests/etc/wsgi_redis.conf b/zaqar/tests/etc/wsgi_redis.conf index b15f2840e..a06ea5108 100644 --- a/zaqar/tests/etc/wsgi_redis.conf +++ b/zaqar/tests/etc/wsgi_redis.conf @@ -1,7 +1,6 @@ [DEFAULT] debug = False verbose = False -enable_deprecated_api_versions = 1.1 [drivers] transport = wsgi diff --git a/zaqar/tests/etc/wsgi_redis_pooled.conf b/zaqar/tests/etc/wsgi_redis_pooled.conf index 3805bbb56..8cc01bac4 100644 --- a/zaqar/tests/etc/wsgi_redis_pooled.conf +++ b/zaqar/tests/etc/wsgi_redis_pooled.conf @@ -1,6 +1,5 @@ [DEFAULT] pooling = True -enable_deprecated_api_versions = 1.1 [drivers] transport = wsgi diff --git a/zaqar/tests/etc/wsgi_sqlalchemy.conf b/zaqar/tests/etc/wsgi_sqlalchemy.conf index 44735b94f..d13f7b30e 100644 --- a/zaqar/tests/etc/wsgi_sqlalchemy.conf +++ b/zaqar/tests/etc/wsgi_sqlalchemy.conf @@ -2,7 +2,6 @@ debug = False verbose = False admin_mode = False -enable_deprecated_api_versions = 1.1 [drivers] transport = wsgi diff --git a/zaqar/tests/etc/wsgi_sqlalchemy_pooled.conf b/zaqar/tests/etc/wsgi_sqlalchemy_pooled.conf index 47292c311..0eb3bcd2b 100644 --- a/zaqar/tests/etc/wsgi_sqlalchemy_pooled.conf +++ b/zaqar/tests/etc/wsgi_sqlalchemy_pooled.conf @@ -1,7 +1,6 @@ [DEFAULT] pooling = True admin_mode = True -enable_deprecated_api_versions = 1.1 [drivers] transport = wsgi diff --git a/zaqar/tests/etc/wsgi_swift.conf b/zaqar/tests/etc/wsgi_swift.conf index 2c913e4bc..c4f145331 100644 --- a/zaqar/tests/etc/wsgi_swift.conf +++ b/zaqar/tests/etc/wsgi_swift.conf @@ -1,7 +1,6 @@ [DEFAULT] debug = False verbose = False -enable_deprecated_api_versions = 1.1 [drivers] transport = wsgi diff --git a/zaqar/tests/functional/base.py b/zaqar/tests/functional/base.py index 4271a7eaf..2b4167ac8 100644 --- a/zaqar/tests/functional/base.py +++ b/zaqar/tests/functional/base.py @@ -21,7 +21,6 @@ import os import jsonschema from oslo_utils import timeutils -from zaqar.api.v1_1 import response as response_v1_1 from zaqar.api.v2 import response as response_v2 from zaqar import bootstrap from zaqar.storage import mongodb @@ -386,12 +385,6 @@ class ZaqarAdminServer(Server): return server.run -class V1_1FunctionalTestBase(FunctionalTestBase): - def setUp(self): - super(V1_1FunctionalTestBase, self).setUp() - self.response = response_v1_1.ResponseSchema(self.limits) - - class V2FunctionalTestBase(FunctionalTestBase): def setUp(self): super(V2FunctionalTestBase, self).setUp() diff --git a/zaqar/tests/functional/helpers.py b/zaqar/tests/functional/helpers.py index b357d9f3b..dde578131 100644 --- a/zaqar/tests/functional/helpers.py +++ b/zaqar/tests/functional/helpers.py @@ -31,84 +31,12 @@ def create_zaqar_headers(conf): return headers -def generate_dict(dict_length): - """Returns dictionary of specified length. Key:Value is random data. - - :param dict_length: length of the dictionary - """ - return dict([(generate_random_string(), generate_random_string()) - for _ in range(dict_length)]) - - def generate_random_string(length=10): """Returns an ASCII string of specified length.""" chars = string.ascii_letters + string.digits return ''.join(random.choice(chars) for i in range(length)) -def single_message_body(messagesize=2, default_ttl=False, ttl=None): - """Returns message body for one message. - - :param messagesize: Size of the message body to generate (default 2) - :param default_ttl: Set to True to not set an explicit TTL value in - the message request, in which case the server will use a default - value (default False). Note that default TTL is only supported in - v1.1 of the API. - :param ttl: Number of seconds to provide as the TTL for each - message. If not specified, a random value is chosen in the - range: (60 <= TTL <= 1209600). If `default_ttl` is True, the - `ttl` param is ignored. - """ - - message_body = {} - message_body['body'] = generate_dict(messagesize) - - if not default_ttl: - if ttl is not None: - message_body['ttl'] = ttl - else: - message_body['ttl'] = random.randint(60, 1209600) - - return message_body - - -def create_message_body(messagecount, **kwargs): - """Returns request body for message-posting tests. - - :param messagecount: Number of messages to create - :param **kwargs: Same as for `single_message_body` - """ - - return [single_message_body(**kwargs) - for i in range(messagecount)] - - -def create_message_body_v1_1(messagecount, **kwargs): - """Returns request body for message-posting tests. - - :param messagecount: Number of messages to create - :param **kwargs: Same as for `single_message_body` - """ - - return { - "messages": [single_message_body(**kwargs) - for i in range(messagecount)] - } - - -def create_pool_body(**kwargs): - pool_body = { - 'weight': kwargs['weight'], - 'uri': kwargs['uri'], - 'options': { - 'max_retry_sleep': 1, - 'partitions': 8 - } - } - - return pool_body - - def create_subscription_body(subscriber='http://fake:8080', ttl=600, options_key='funny', options_value='no'): options = {options_key: options_value} diff --git a/zaqar/tests/functional/websocket/test_queues.py b/zaqar/tests/functional/websocket/test_queues.py index c9a9d32c7..a4ccf051a 100644 --- a/zaqar/tests/functional/websocket/test_queues.py +++ b/zaqar/tests/functional/websocket/test_queues.py @@ -22,7 +22,7 @@ import websocket from zaqar.tests.functional import base -class TestQueues(base.V1_1FunctionalTestBase): +class TestQueues(base.V2FunctionalTestBase): config_file = 'websocket_mongodb.conf' server_class = base.ZaqarServer diff --git a/zaqar/tests/unit/common/test_decorators.py b/zaqar/tests/unit/common/test_decorators.py index 61d9ef9ba..88ab05477 100644 --- a/zaqar/tests/unit/common/test_decorators.py +++ b/zaqar/tests/unit/common/test_decorators.py @@ -161,24 +161,8 @@ class TestDecorators(base.TestBase): self.assertTrue(public_endpoint_1(None, self.conf)) - # 2. Test accessing deprecated API version - VERSION = { - 'id': '1.1', - 'status': 'DEPRECATED', - 'updated': 'A long time ago' - } - @decorators.api_version_manager(VERSION) def public_endpoint_2(driver, conf): - self.fail('Deprecated API enabled') - - public_endpoint_2(None, self.conf) - - # 3. Test enabling deprecated API version - self.config(enable_deprecated_api_versions=['1.1']) - - @decorators.api_version_manager(VERSION) - def public_endpoint_3(driver, conf): return True - self.assertTrue(public_endpoint_3(None, self.conf)) + self.assertTrue(public_endpoint_2(None, self.conf)) diff --git a/zaqar/transport/wsgi/utils.py b/zaqar/transport/wsgi/utils.py index e316e015e..8c8818f92 100644 --- a/zaqar/transport/wsgi/utils.py +++ b/zaqar/transport/wsgi/utils.py @@ -222,16 +222,7 @@ def message_url(message, base_path, claim_id=None): return path -def format_message_v1(message, base_path, claim_id=None): - return { - 'href': message_url(message, base_path, claim_id), - 'ttl': message['ttl'], - 'age': message['age'], - 'body': message['body'], - } - - -def format_message_v1_1(message, base_path, claim_id=None): +def format_message(message, base_path, claim_id=None): url = message_url(message, base_path, claim_id) res = { 'id': message['id'], diff --git a/zaqar/transport/wsgi/v2_0/claims.py b/zaqar/transport/wsgi/v2_0/claims.py index 13f0cf8e8..120141460 100644 --- a/zaqar/transport/wsgi/v2_0/claims.py +++ b/zaqar/transport/wsgi/v2_0/claims.py @@ -100,7 +100,7 @@ class CollectionResource(object): # the storage driver returned well-formed messages. if len(resp_msgs) != 0: base_path = req.path.rpartition('/')[0] - resp_msgs = [wsgi_utils.format_message_v1_1(msg, base_path, cid) + resp_msgs = [wsgi_utils.format_message(msg, base_path, cid) for msg in resp_msgs] resp.location = req.path + '/' + cid @@ -148,8 +148,7 @@ class ItemResource(object): # Serialize claimed messages # TODO(kgriffs): Optimize base_path = req.path.rsplit('/', 2)[0] - meta['messages'] = [wsgi_utils.format_message_v1_1(msg, base_path, - claim_id) + meta['messages'] = [wsgi_utils.format_message(msg, base_path, claim_id) for msg in meta['messages']] meta['href'] = req.path diff --git a/zaqar/transport/wsgi/v2_0/messages.py b/zaqar/transport/wsgi/v2_0/messages.py index f606fdf4e..f37c903aa 100644 --- a/zaqar/transport/wsgi/v2_0/messages.py +++ b/zaqar/transport/wsgi/v2_0/messages.py @@ -86,7 +86,7 @@ class CollectionResource(object): if queue_meta and queue_meta.get('_enable_encrypt_messages', False): self._encryptor.message_decrypted(messages) - messages = [wsgi_utils.format_message_v1_1(m, base_path, m['claim_id']) + messages = [wsgi_utils.format_message(m, base_path, m['claim_id']) for m in messages] return {'messages': messages} @@ -156,8 +156,7 @@ class CollectionResource(object): # Found some messages, so prepare the response kwargs['marker'] = next(results) base_path = req.path.rsplit('/', 1)[0] - messages = [wsgi_utils.format_message_v1_1(m, base_path, - m['claim_id']) + messages = [wsgi_utils.format_message(m, base_path, m['claim_id']) for m in messages] links = [] @@ -398,9 +397,9 @@ class ItemResource(object): # Prepare response message['href'] = req.path - message = wsgi_utils.format_message_v1_1(message, - req.path.rsplit('/', 2)[0], - message['claim_id']) + message = wsgi_utils.format_message(message, + req.path.rsplit('/', 2)[0], + message['claim_id']) resp.text = utils.to_json(message) # status defaults to 200