Support PATCH of queue metadata
This patch adds support to the v1.1 and v2 API for PATCH to update queue metadata. Depends on server support for PATCH waiting to be merged here https://review.openstack.org/#/c/280941/ Change-Id: I9dec8ab8b3f99d48b4a42fde6244d38038e4662f Depends-On: Iba6d7a0ca5cf7a755c20d9af69d5c52687142dff
This commit is contained in:
parent
3c83b4a6c6
commit
3152321c7a
@ -294,6 +294,15 @@ V1_1.schema.update({
|
||||
}
|
||||
},
|
||||
|
||||
'queue_update': {
|
||||
'ref': 'queues/{queue_name}',
|
||||
'method': 'PATCH',
|
||||
'required': ['queue_name'],
|
||||
'properties': {
|
||||
'queue_name': {'type': 'string'}
|
||||
}
|
||||
},
|
||||
|
||||
'message_pop': {
|
||||
'ref': 'queues/{queue_name}/messages',
|
||||
'method': 'DELETE',
|
||||
|
@ -80,6 +80,31 @@ def queue_create(transport, request, name,
|
||||
return resp.deserialized_content
|
||||
|
||||
|
||||
def queue_update(transport, request, name, metadata, callback=None):
|
||||
"""Updates a queue's metadata using PATCH. API v1.1+ only
|
||||
|
||||
:param transport: Transport instance to use
|
||||
:type transport: `transport.base.Transport`
|
||||
:param request: Request instance ready to be sent.
|
||||
:type request: `transport.request.Request`
|
||||
:param name: Queue reference name.
|
||||
:type name: `six.text_type`
|
||||
:param metadata: Queue's metadata object. (>=v1.1)
|
||||
:type metadata: `dict`
|
||||
:param callback: Optional callable to use as callback.
|
||||
If specified, this request will be sent asynchronously.
|
||||
(IGNORED UNTIL ASYNC SUPPORT IS COMPLETE)
|
||||
:type callback: Callable object.
|
||||
"""
|
||||
|
||||
request.operation = 'queue_update'
|
||||
request.params['queue_name'] = name
|
||||
request.content = json.dumps(metadata)
|
||||
|
||||
resp = transport.send(request)
|
||||
return resp.deserialized_content
|
||||
|
||||
|
||||
def queue_exists(transport, request, name, callback=None):
|
||||
"""Checks if the queue exists."""
|
||||
try:
|
||||
|
@ -97,8 +97,11 @@ class Queue(object):
|
||||
if new_meta is not None:
|
||||
if self.client.api_version < 1.1:
|
||||
core.queue_set_metadata(trans, req, self._name, new_meta)
|
||||
else:
|
||||
elif not len(new_meta):
|
||||
# if metadata is empty dict, clear existing metadata
|
||||
core.queue_create(trans, req, self._name, metadata=new_meta)
|
||||
else:
|
||||
core.queue_update(trans, req, self._name, metadata=new_meta)
|
||||
self._metadata = new_meta
|
||||
|
||||
# TODO(flaper87): Cache with timeout
|
||||
|
Loading…
Reference in New Issue
Block a user