blob: a741be47496723814fa38d2cb46fe65a8922abfe [file] [log] [blame]
Ken'ichi Ohmichia89dd6b2015-06-15 05:25:14 +00001# 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
16import json
17
18from tempest.api_schema.response.compute.v2_1\
19 import quota_classes as classes_schema
20from tempest.common import service_client
21
22
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000023class QuotaClassesClient(service_client.ServiceClient):
Ken'ichi Ohmichia89dd6b2015-06-15 05:25:14 +000024
Ken'ichi Ohmichif9868fc2015-06-17 02:36:06 +000025 def show_quota_class_set(self, quota_class_id):
Ken'ichi Ohmichia89dd6b2015-06-15 05:25:14 +000026 """List the quota class set for a quota class."""
27
Ken'ichi Ohmichif9868fc2015-06-17 02:36:06 +000028 url = 'os-quota-class-sets/%s' % quota_class_id
Ken'ichi Ohmichia89dd6b2015-06-15 05:25:14 +000029 resp, body = self.get(url)
30 body = json.loads(body)
31 self.validate_response(classes_schema.get_quota_class_set, resp, body)
32 return service_client.ResponseBody(resp, body['quota_class_set'])
33
34 def update_quota_class_set(self, quota_class_id, **kwargs):
35 """
36 Updates the quota class's limits for one or more resources.
37 """
38 post_body = json.dumps({'quota_class_set': kwargs})
39
Ken'ichi Ohmichif9868fc2015-06-17 02:36:06 +000040 resp, body = self.put('os-quota-class-sets/%s' % quota_class_id,
Ken'ichi Ohmichia89dd6b2015-06-15 05:25:14 +000041 post_body)
42
43 body = json.loads(body)
44 self.validate_response(classes_schema.update_quota_class_set,
45 resp, body)
46 return service_client.ResponseBody(resp, body['quota_class_set'])