Support client of bp support-md5-of-body
Implement blueprint support-md5-of-body Change-Id: Ia0062925e0157e62cc5a5d01fc6b5bbe353b883e
This commit is contained in:
parent
fd7a02588d
commit
82b3022e24
@ -14,7 +14,30 @@
|
||||
# limitations under the License.
|
||||
|
||||
from zaqarclient.queues.v1 import claim
|
||||
from zaqarclient.queues.v1 import iterator as iterate
|
||||
from zaqarclient.queues.v2 import core
|
||||
from zaqarclient.queues.v2 import message
|
||||
|
||||
|
||||
class Claim(claim.Claim):
|
||||
pass
|
||||
|
||||
def _create(self):
|
||||
req, trans = self._queue.client._request_and_transport()
|
||||
msgs = core.claim_create(trans, req,
|
||||
self._queue._name,
|
||||
ttl=self._ttl,
|
||||
grace=self._grace,
|
||||
limit=self._limit)
|
||||
|
||||
# extract the id from the first message
|
||||
if msgs is not None:
|
||||
if self._queue.client.api_version >= 1.1:
|
||||
msgs = msgs['messages']
|
||||
self.id = msgs[0]['href'].split('=')[-1]
|
||||
|
||||
self._message_iter = iterate._Iterator(self._queue.client,
|
||||
msgs or [],
|
||||
'messages',
|
||||
message.create_object(
|
||||
self._queue
|
||||
))
|
||||
|
@ -249,7 +249,7 @@ class ListMessages(command.Lister):
|
||||
else:
|
||||
messages = queue.messages(**kwargs)
|
||||
|
||||
columns = ("ID", "Body", "TTL", "Age", "Claim ID")
|
||||
columns = ("ID", "Body", "TTL", "Age", "Claim ID", "Checksum")
|
||||
return (columns,
|
||||
(utils.get_item_properties(s, columns) for s in messages))
|
||||
|
||||
@ -700,7 +700,25 @@ class OldListSubscriptions(ListSubscriptions):
|
||||
|
||||
class CreateClaim(cli.CreateClaim):
|
||||
"""Create claim and return a list of claimed messages"""
|
||||
pass
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
client = _get_client(self, parsed_args)
|
||||
|
||||
kwargs = {}
|
||||
if parsed_args.ttl is not None:
|
||||
kwargs["ttl"] = parsed_args.ttl
|
||||
if parsed_args.grace is not None:
|
||||
kwargs["grace"] = parsed_args.grace
|
||||
if parsed_args.limit is not None:
|
||||
kwargs["limit"] = parsed_args.limit
|
||||
|
||||
queue = client.queue(parsed_args.queue_name, auto_create=False)
|
||||
keys = ("claim_id", "id", "ttl", "age", 'body', "checksum")
|
||||
columns = ("Claim_ID", "Message_ID", "TTL", "Age", "Messages",
|
||||
"Checksum")
|
||||
data = queue.claim(**kwargs)
|
||||
return (columns,
|
||||
(utils.get_item_properties(s, keys) for s in data))
|
||||
|
||||
|
||||
class OldCreateClaim(cli.OldCreateClaim):
|
||||
|
@ -14,6 +14,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
from zaqarclient.queues.v1 import queues
|
||||
from zaqarclient.queues.v2 import claim as claim_api
|
||||
from zaqarclient.queues.v2 import core
|
||||
from zaqarclient.queues.v2 import message
|
||||
|
||||
@ -88,6 +89,10 @@ class Queue(queues.Queue):
|
||||
core.queue_purge(trans, req, self._name,
|
||||
resource_types=resource_types)
|
||||
|
||||
def claim(self, id=None, ttl=None, grace=None,
|
||||
limit=None):
|
||||
return claim_api.Claim(self, id=id, ttl=ttl, grace=grace, limit=limit)
|
||||
|
||||
|
||||
def create_object(parent):
|
||||
return lambda args: Queue(parent, args["name"], href=args.get("href"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user