Add show types API to v3 types client library

add show default volume types api to v3 types client

Change-Id: I3053c49a5ce6bac33c91170978bef2d14375d3fa
This commit is contained in:
wanglbj 2020-04-13 16:27:37 +08:00
parent 91f0e00882
commit 5e8f044538
3 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,6 @@
---
features:
- |
Add show type API to v3 types_client library.
* default_volume_type

View File

@ -65,6 +65,19 @@ class TypesClient(rest_client.RestClient):
self.validate_response(schema.show_volume_type, resp, body)
return rest_client.ResponseBody(resp, body)
def show_default_volume_type(self):
"""Returns the details of a single volume type.
For a full list of available parameters, please refer to the official
API reference:
https://docs.openstack.org/api-ref/block-storage/v3/index.html#show-default-volume-type
"""
url = "types/default"
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.show_volume_type, resp, body)
return rest_client.ResponseBody(resp, body)
def create_volume_type(self, **kwargs):
"""Create volume type.

View File

@ -121,6 +121,13 @@ class TestTypesClient(base.BaseServiceTest):
to_utf=bytes_body,
volume_type_id="6685584b-1eac-4da6-b5c3-555430cf68ff")
def _test_show_default_volume_type(self, bytes_body=False):
self.check_service_client_function(
self.client.show_default_volume_type,
'tempest.lib.common.rest_client.RestClient.get',
self.FAKE_DEFAULT_VOLUME_TYPE_INFO,
to_utf=bytes_body)
def _test_create_volume_type(self, bytes_body=False):
self.check_service_client_function(
self.client.create_volume_type,
@ -224,6 +231,12 @@ class TestTypesClient(base.BaseServiceTest):
def test_show_volume_type_with_bytes_body(self):
self._test_show_volume_type(bytes_body=True)
def test_show_default_volume_type_with_str_body(self):
self._test_show_default_volume_type()
def test_show_default_volume_type_with_bytes_body(self):
self._test_show_default_volume_type(bytes_body=True)
def test_create_volume_type_str_body(self):
self._test_create_volume_type()