blob: ade60e5415fe6bb02bccb8034875330e632b6ba8 [file] [log] [blame]
Matthew Treinish9e26ca82016-02-23 11:43:20 -05001# Copyright 2013 NEC Corporation
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
17from six.moves.urllib import parse as urllib
18
19from tempest.lib.api_schema.response.compute.v2_1 import tenant_usages
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 TenantUsagesClient(base_compute_client.BaseComputeClient):
Matthew Treinish9e26ca82016-02-23 11:43:20 -050025
26 def list_tenant_usages(self, **params):
zhufl29ea88b2016-11-16 14:01:05 +080027 """List Tenant Usage For All Tenants.
28
29 For a full list of available parameters, please refer to the official
30 API reference:
zhufl6ea5f8b2017-04-05 17:34:08 +080031 https://developer.openstack.org/api-ref/compute/#list-tenant-usage-statistics-for-all-tenants
zhufl29ea88b2016-11-16 14:01:05 +080032 """
Matthew Treinish9e26ca82016-02-23 11:43:20 -050033 url = 'os-simple-tenant-usage'
34 if params:
35 url += '?%s' % urllib.urlencode(params)
36
37 resp, body = self.get(url)
38 body = json.loads(body)
39 self.validate_response(tenant_usages.list_tenant_usage, resp, body)
40 return rest_client.ResponseBody(resp, body)
41
42 def show_tenant_usage(self, tenant_id, **params):
zhufl29ea88b2016-11-16 14:01:05 +080043 """Show Usage Details For Tenant.
44
45 For a full list of available parameters, please refer to the official
46 API reference:
zhufl6ea5f8b2017-04-05 17:34:08 +080047 https://developer.openstack.org/api-ref/compute/#show-usage-statistics-for-tenant
zhufl29ea88b2016-11-16 14:01:05 +080048 """
Matthew Treinish9e26ca82016-02-23 11:43:20 -050049 url = 'os-simple-tenant-usage/%s' % tenant_id
50 if params:
51 url += '?%s' % urllib.urlencode(params)
52
53 resp, body = self.get(url)
54 body = json.loads(body)
55 self.validate_response(tenant_usages.get_tenant_usage, resp, body)
56 return rest_client.ResponseBody(resp, body)