zaqar/doc/source/api.rst
Flavio Percoco 36e63c9a45 Rename Marconi to Zaqar
This patch renames every package, file, match of Marconi in the codebase
to Zaqar *except* for the .gitreview file, which will have to be updated
*after* I8e587af588d9be0b5ebbab4b0f729b106a2ae537 lands.

Implements blueprint: project-rename

Change-Id: I63cf2c680cead4641f3e430af379452058bce5b3
2014-08-04 10:36:50 +02:00

2.0 KiB

Using Zaqar's Public APIs

Zaqar fully implements version 1.0 of the OpenStack Messaging API by now. Generally, you can use any HTTP client to talk with Zaqar public REST API, though Zaqar client is the recommended approach.

Zaqar Client

We can easily access the Zaqar REST API via Zaqar client. Below is an example to create a queue, post messages to it and finally delete it:

from zaqarclient.queues.v1 import client

URL = 'http://localhost:8888'
messages = [{'body': {'id': idx}, 'ttl': 360} for idx in range(20)]

cli = client.Client(URL)
queue = cli.queue('myqueue')
queue.post(messages)

for msg in queue.messages(echo=True):
    print(msg.body)
    msg.delete()

queue.delete()

curl

Define these variables:

# USERNAME=my identity username
# APIKEY=my-long-api-key
# ENDPOINT=test-queue.mydomain.com < keystone endpoint >
# QUEUE=test-queue
# CLIENTID=c5a6114a-523c-4085-84fb-533c5ac40789
# HTTP=http
# PORT=80
# TOKEN=9abb6d47de3143bf80c9208d37db58cf < your token here >

Create the queue:

# curl -i -X PUT $HTTP://$ENDPOINT:$PORT/v1/queues/$QUEUE -H "X-Auth-Token: $TOKEN" -H "Client-ID: $CLIENTID"
HTTP/1.1 201 Created
content-length: 0
location: /v1/queues/test-queue

HTTP/1.1 201 Created response proves that service is functioning properly.