Malini Kamalambal | 6e7b3b8 | 2014-02-06 06:49:04 -0500 | [diff] [blame] | 1 | # Copyright (c) 2014 Rackspace, Inc. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 12 | # implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | import json |
| 17 | |
| 18 | from tempest.common import rest_client |
| 19 | from tempest import config |
| 20 | |
| 21 | CONF = config.CONF |
| 22 | |
| 23 | |
| 24 | class QueuingClientJSON(rest_client.RestClient): |
| 25 | |
| 26 | def __init__(self, auth_provider): |
| 27 | super(QueuingClientJSON, self).__init__(auth_provider) |
| 28 | self.service = CONF.queuing.catalog_type |
| 29 | self.version = '1' |
| 30 | self.uri_prefix = 'v{0}'.format(self.version) |
| 31 | |
| 32 | def list_queues(self): |
| 33 | uri = '{0}/queues'.format(self.uri_prefix) |
| 34 | resp, body = self.get(uri) |
| 35 | body = json.loads(body) |
| 36 | return resp, body |
| 37 | |
| 38 | def create_queue(self, queue_name): |
| 39 | uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name) |
| 40 | resp, body = self.put(uri, body=None) |
| 41 | return resp, body |
| 42 | |
| 43 | def get_queue(self, queue_name): |
| 44 | uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name) |
| 45 | resp, body = self.get(uri) |
| 46 | body = json.loads(body) |
| 47 | return resp, body |
| 48 | |
| 49 | def head_queue(self, queue_name): |
| 50 | uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name) |
| 51 | resp, body = self.head(uri) |
| 52 | body = json.loads(body) |
| 53 | return resp, body |
| 54 | |
| 55 | def delete_queue(self, queue_name): |
| 56 | uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name) |
| 57 | resp = self.delete(uri) |
| 58 | return resp |