zaqar/doc/source/api.rst
Ozgur Akan bf09f09d0d Marconi Operations Document
Adding developer/operation documents including:
1. Glossary
2. Install and configure
3. Deploy Marconi in a minimal HA env
4. Access API with Marconi client

Co-Authored-By: Fei Long Wang <flwang@cn.ibm.com>

Implements: blueprint docs

Change-Id: I2549995fb0754c7f3c8ce718639e1299e2805795
2014-03-18 14:49:25 -04:00

2.0 KiB

Using Marconi's Public APIs

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

Marconi Client

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

from marconiclient.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.