Merge "Clean up remamining logic for v1.1 API"
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
9
releasenotes/notes/remove-v1-1-a6f3a7fefd70cc5a.yaml
Normal file
9
releasenotes/notes/remove-v1-1-a6f3a7fefd70cc5a.yaml
Normal file
@@ -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.
|
||||
@@ -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,
|
||||
},
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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']
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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):
|
||||
|
||||
@@ -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.')
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
debug = False
|
||||
verbose = False
|
||||
admin_mode = False
|
||||
enable_deprecated_api_versions = 1.1
|
||||
|
||||
[drivers]
|
||||
transport = wsgi
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
[DEFAULT]
|
||||
debug = False
|
||||
verbose = False
|
||||
enable_deprecated_api_versions = 1.1
|
||||
|
||||
[drivers]
|
||||
transport = invalid
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
[DEFAULT]
|
||||
# run_tests = True
|
||||
unreliable = True
|
||||
enable_deprecated_api_versions = 1.1
|
||||
|
||||
[zaqar]
|
||||
# url = http://0.0.0.0:8888
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -3,7 +3,6 @@ auth_strategy = keystone
|
||||
|
||||
debug = False
|
||||
verbose = False
|
||||
enable_deprecated_api_versions = 1.1
|
||||
|
||||
[drivers]
|
||||
transport = wsgi
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
[DEFAULT]
|
||||
unreliable = True
|
||||
enable_deprecated_api_versions = 1.1
|
||||
|
||||
[drivers]
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
[DEFAULT]
|
||||
auth_strategy = keystone
|
||||
enable_deprecated_api_versions = 1.1
|
||||
|
||||
[drivers]
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
[DEFAULT]
|
||||
unreliable = True
|
||||
enable_deprecated_api_versions = 1.1
|
||||
|
||||
[drivers]
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
[DEFAULT]
|
||||
debug = False
|
||||
verbose = False
|
||||
enable_deprecated_api_versions = 1.1
|
||||
|
||||
[drivers]
|
||||
transport = wsgi
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
debug = False
|
||||
verbose = False
|
||||
unreliable = True
|
||||
enable_deprecated_api_versions = 1.1
|
||||
|
||||
[drivers]
|
||||
transport = wsgi
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
debug = False
|
||||
verbose = False
|
||||
unreliable = True
|
||||
enable_deprecated_api_versions = 1.1
|
||||
|
||||
[drivers]
|
||||
transport = wsgi
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
[DEFAULT]
|
||||
enable_deprecated_api_versions = 1.1
|
||||
|
||||
[drivers]
|
||||
transport = wsgi
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
pooling = True
|
||||
admin_mode = True
|
||||
unreliable = True
|
||||
enable_deprecated_api_versions = 1.1
|
||||
|
||||
[drivers]
|
||||
transport = wsgi
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
pooling = True
|
||||
admin_mode = True
|
||||
unreliable = True
|
||||
enable_deprecated_api_versions = 1.1
|
||||
|
||||
[drivers]
|
||||
transport = wsgi
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
[DEFAULT]
|
||||
enable_deprecated_api_versions = 1.1
|
||||
|
||||
[drivers]
|
||||
transport = wsgi
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
[DEFAULT]
|
||||
debug = False
|
||||
verbose = False
|
||||
enable_deprecated_api_versions = 1.1
|
||||
|
||||
[drivers]
|
||||
transport = wsgi
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
[DEFAULT]
|
||||
pooling = True
|
||||
enable_deprecated_api_versions = 1.1
|
||||
|
||||
[drivers]
|
||||
transport = wsgi
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
debug = False
|
||||
verbose = False
|
||||
admin_mode = False
|
||||
enable_deprecated_api_versions = 1.1
|
||||
|
||||
[drivers]
|
||||
transport = wsgi
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
[DEFAULT]
|
||||
pooling = True
|
||||
admin_mode = True
|
||||
enable_deprecated_api_versions = 1.1
|
||||
|
||||
[drivers]
|
||||
transport = wsgi
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
[DEFAULT]
|
||||
debug = False
|
||||
verbose = False
|
||||
enable_deprecated_api_versions = 1.1
|
||||
|
||||
[drivers]
|
||||
transport = wsgi
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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'],
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user