api-ref: Example verification for os-simple-tenant-usage.inc

Change-Id: I575412d578d670bdc598c687256a33f0b579a99e
Implements: blueprint api-ref-in-rst
This commit is contained in:
Takashi NATSUME 2016-07-08 11:01:26 +09:00
parent 0da6c64611
commit 51073b3132
4 changed files with 77 additions and 1 deletions

View File

@ -1,5 +1,4 @@
.. -*- rst -*-
.. needs:example_verification
.. needs:body_verification
========================================
@ -57,9 +56,19 @@ Response
**Example List Tenant Usage For All Tenants: JSON response**
If the ``detailed`` query parameter is not specified or
is set to other than 1 (e.g. ``detailed=0``), the response is as follows:
.. literalinclude:: ../../doc/api_samples/os-simple-tenant-usage/simple-tenant-usage-get.json
:language: javascript
If the ``detailed`` query parameter is set to one (``detailed=1``),
the response includes ``server_usages`` information for each tenant.
The response is as follows:
.. literalinclude:: ../../doc/api_samples/os-simple-tenant-usage/simple-tenant-usage-get-detail.json
:language: javascript
Show Usage Details For Tenant
=============================

View File

@ -0,0 +1,29 @@
{
"tenant_usages": [
{
"start": "2012-10-08T20:10:44.587336",
"stop": "2012-10-08T21:10:44.587336",
"tenant_id": "6f70656e737461636b20342065766572",
"total_hours": 1.0,
"total_local_gb_usage": 1.0,
"total_memory_mb_usage": 512.0,
"total_vcpus_usage": 1.0,
"server_usages": [
{
"ended_at": null,
"flavor": "m1.tiny",
"hours": 1.0,
"instance_id": "1f1deceb-17b5-4c04-84c7-e0d4499c8fe0",
"local_gb": 1,
"memory_mb": 512,
"name": "new-server-test",
"started_at": "2012-10-08T20:10:44.541277",
"state": "active",
"tenant_id": "6f70656e737461636b20342065766572",
"uptime": 3600,
"vcpus": 1
}
]
}
]
}

View File

@ -0,0 +1,29 @@
{
"tenant_usages": [
{
"start": "%(strtime)s",
"stop": "%(strtime)s",
"tenant_id": "6f70656e737461636b20342065766572",
"total_hours": 1.0,
"total_local_gb_usage": 1.0,
"total_memory_mb_usage": 512.0,
"total_vcpus_usage": 1.0,
"server_usages": [
{
"ended_at": null,
"flavor": "m1.tiny",
"hours": 1.0,
"instance_id": "%(uuid)s",
"local_gb": 1,
"memory_mb": 512,
"name": "new-server-test",
"started_at": "%(strtime)s",
"state": "active",
"tenant_id": "6f70656e737461636b20342065766572",
"uptime": 3600,
"vcpus": 1
}
]
}
]
}

View File

@ -51,6 +51,15 @@ class SimpleTenantUsageSampleJsonTest(test_servers.ServersSampleBase):
urllib.urlencode(self.query)))
self._verify_response('simple-tenant-usage-get', {}, response, 200)
def test_get_tenants_usage_with_detail(self):
# Get all tenants usage information with detail.
query = self.query.copy()
query.update({'detailed': 1})
response = self._do_get('os-simple-tenant-usage?%s' % (
urllib.urlencode(query)))
self._verify_response('simple-tenant-usage-get-detail', {},
response, 200)
def test_get_tenant_usage_details(self):
# Get api sample to get specific tenant usage request.
tenant_id = astb.PROJECT_ID