blob: 9b6409911bdf6a60684d9fedfc8bebba44ecd6dd [file] [log] [blame]
Matthew Treinish9e26ca82016-02-23 11:43:20 -05001# Copyright 2012 NTT Data
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from oslo_serialization import jsonutils as json
17
18from tempest.lib.api_schema.response.compute.v2_1\
19 import quota_classes as classes_schema
20from tempest.lib.common import rest_client
Ghanshyamee9af302016-02-25 06:12:43 +090021from tempest.lib.services.compute import base_compute_client
Matthew Treinish9e26ca82016-02-23 11:43:20 -050022
23
Ghanshyamee9af302016-02-25 06:12:43 +090024class QuotaClassesClient(base_compute_client.BaseComputeClient):
Matthew Treinish9e26ca82016-02-23 11:43:20 -050025
26 def show_quota_class_set(self, quota_class_id):
27 """List the quota class set for a quota class."""
28
29 url = 'os-quota-class-sets/%s' % quota_class_id
30 resp, body = self.get(url)
31 body = json.loads(body)
32 self.validate_response(classes_schema.get_quota_class_set, resp, body)
33 return rest_client.ResponseBody(resp, body)
34
35 def update_quota_class_set(self, quota_class_id, **kwargs):
36 """Update the quota class's limits for one or more resources.
37
kkush09a66e62018-01-29 19:00:15 +053038 For a full list of available parameters, please refer to the official
39 API reference:
Andreas Jaegerbf30ae72019-07-22 19:22:57 +020040 https://docs.openstack.org/api-ref/compute/#create-or-update-quotas-for-quota-class
Matthew Treinish9e26ca82016-02-23 11:43:20 -050041 """
42 post_body = json.dumps({'quota_class_set': kwargs})
43
44 resp, body = self.put('os-quota-class-sets/%s' % quota_class_id,
45 post_body)
46
47 body = json.loads(body)
48 self.validate_response(classes_schema.update_quota_class_set,
49 resp, body)
50 return rest_client.ResponseBody(resp, body)