blob: 4ac411241dedcd021be56625455d660414c3705b [file] [log] [blame]
Ken'ichi Ohmichi4adae2f2017-03-15 15:47:44 -07001# 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
Doug Schveninger152f1052019-09-06 19:53:02 -050015from six.moves.urllib.parse import urljoin
16
Ken'ichi Ohmichi4adae2f2017-03-15 15:47:44 -070017from oslo_serialization import jsonutils as json
18
19from tempest.lib.api_schema.response.volume import versions as schema
20from tempest.lib.common import rest_client
zhufl02736522017-06-19 13:57:28 +080021from tempest.lib.services.volume import base_client
Ken'ichi Ohmichi4adae2f2017-03-15 15:47:44 -070022
23
24class VersionsClient(base_client.BaseClient):
Ken'ichi Ohmichi4adae2f2017-03-15 15:47:44 -070025
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 Jaegerbf30ae72019-07-22 19:22:57 +020031 https://docs.openstack.org/api-ref/block-storage/v3/#list-all-api-versions
Ken'ichi Ohmichi4adae2f2017-03-15 15:47:44 -070032 """
33 version_url = self._get_base_version_url()
34
Ken'ichi Ohmichi4adae2f2017-03-15 15:47:44 -070035 resp, body = self.raw_request(version_url, 'GET')
Ken'ichi Ohmichi4adae2f2017-03-15 15:47:44 -070036 # NOTE: We need a raw_request() here instead of request() call because
37 # "list API versions" API doesn't require an authentication and we can
38 # skip it with raw_request() call.
Ken'ichi Ohmichi4adae2f2017-03-15 15:47:44 -070039 self._error_checker(resp, body)
40
41 body = json.loads(body)
42 self.validate_response(schema.list_versions, resp, body)
43 return rest_client.ResponseBody(resp, body)
wangzhiguangdb10fb02019-07-29 18:05:10 +080044
45 def show_version(self, version):
46 """Show API version details
47
Doug Schveninger152f1052019-09-06 19:53:02 -050048 Use raw_request in order to have access to the endpoints minus
49 version and project in order to add version only back.
50
wangzhiguangdb10fb02019-07-29 18:05:10 +080051 For a full list of available parameters, please refer to the official
52 API reference:
53 https://docs.openstack.org/api-ref/block-storage/v3/#show-api-v3-details
54 """
55
Doug Schveninger152f1052019-09-06 19:53:02 -050056 version_url = urljoin(self._get_base_version_url(), version + '/')
Gayathri Devi Kathirife7a9832020-07-13 15:22:13 +000057 headers = self.get_headers()
58 headers['X-Auth-Token'] = self.token
59 resp, body = self.raw_request(version_url, 'GET', headers=headers)
Doug Schveninger152f1052019-09-06 19:53:02 -050060 self._error_checker(resp, body)
wangzhiguangdb10fb02019-07-29 18:05:10 +080061 body = json.loads(body)
62 self.validate_response(schema.volume_api_version_details, resp, body)
63 return rest_client.ResponseBody(resp, body)