Ken'ichi Ohmichi | 4adae2f | 2017-03-15 15:47:44 -0700 | [diff] [blame] | 1 | # Copyright 2017 NEC Corporation. All rights reserved. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # 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, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
| 15 | import time |
| 16 | |
| 17 | from oslo_serialization import jsonutils as json |
| 18 | |
| 19 | from tempest.lib.api_schema.response.volume import versions as schema |
| 20 | from tempest.lib.common import rest_client |
zhufl | 0273652 | 2017-06-19 13:57:28 +0800 | [diff] [blame] | 21 | from tempest.lib.services.volume import base_client |
Ken'ichi Ohmichi | 4adae2f | 2017-03-15 15:47:44 -0700 | [diff] [blame] | 22 | |
| 23 | |
| 24 | class VersionsClient(base_client.BaseClient): |
Ken'ichi Ohmichi | 4adae2f | 2017-03-15 15:47:44 -0700 | [diff] [blame] | 25 | |
| 26 | def list_versions(self): |
| 27 | """List API versions |
| 28 | |
| 29 | For a full list of available parameters, please refer to the official |
| 30 | API reference: |
Andreas Jaeger | bf30ae7 | 2019-07-22 19:22:57 +0200 | [diff] [blame] | 31 | https://docs.openstack.org/api-ref/block-storage/v3/#list-all-api-versions |
Ken'ichi Ohmichi | 4adae2f | 2017-03-15 15:47:44 -0700 | [diff] [blame] | 32 | """ |
| 33 | version_url = self._get_base_version_url() |
| 34 | |
| 35 | start = time.time() |
| 36 | resp, body = self.raw_request(version_url, 'GET') |
| 37 | end = time.time() |
| 38 | # NOTE: We need a raw_request() here instead of request() call because |
| 39 | # "list API versions" API doesn't require an authentication and we can |
| 40 | # skip it with raw_request() call. |
| 41 | self._log_request('GET', version_url, resp, secs=(end - start), |
| 42 | resp_body=body) |
| 43 | self._error_checker(resp, body) |
| 44 | |
| 45 | body = json.loads(body) |
| 46 | self.validate_response(schema.list_versions, resp, body) |
| 47 | return rest_client.ResponseBody(resp, body) |