1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
================
Summary endpoint
================
Get a rating summary
====================
Get a rating summary for one or several tenants.
.. rest_method:: GET /v2/summary
.. rest_parameters:: summary/summary_parameters.yml
- limit: limit
- offset: offset
- begin: begin
- end: end
- groupby: groupby
- filters: filters
- custom_fields: custom_fields
- response_format: response_format
Status codes
------------
.. rest_status_code:: success http_status.yml
- 200
.. rest_status_code:: error http_status.yml
- 400
- 403
- 405
Response
--------
The response has the following default format (response_format='table'):
.. code-block:: javascript
{
"columns": [
"begin",
"end",
"qty",
"rate",
"group1",
"group2",
],
"results": [
[
"2019-06-01T00:00:00Z",
"2019-07-01T00:00:00Z",
2590.421676635742,
1295.210838317871,
"group1",
"group2",
]
],
"total": 4
}
``total`` is the total amount of found elements. ``columns`` contains the name of
the columns for each element of ``results``. The columns are the four mandatory ones
(``begin``, ``end``, ``qty``, ``rate``) along with each attribute the result is
grouped by.
``format`` is the response format. It can be "table" or "object". The default
response structure is "table", which is presented above. The object structure
uses the following pattern.
.. code-block:: javascript
{
"results": [
{"begin": "2019-06-01T00:00:00Z",
"end": "2019-07-01T00:00:00Z",
"qty": 2590.421676635742,
"rate": 1295.210838317871,
"group1": "group1",
"group2": "group2",
},
],
"total": 4
}
.. note:: It is also possible to group data by time, in order to obtain timeseries.
In order to do this, group by ``time``. No extra column will be added,
but you'll get one entry per collect period in the queried timeframe.
See examples below.
.. rest_parameters:: summary/summary_parameters.yml
- begin: begin_resp
- end: end_resp
- qty: qty_resp
- rate: rate_resp
Response Example
----------------
Grouping by time and project_id:
.. code-block:: shell
curl "http://cloudkitty-api:8889/v2/summary?groupby=time&groupby=project_id&limit=3"
.. literalinclude:: ./api_samples/summary/summary_get_groupby_time.json
:language: javascript
.. code-block:: shell
curl "http://cloudkitty-api:8889/v2/summary?filters=project_id%3Afe9c35372db6420089883805b37a34af&groupby=type&groupby=project_id"
.. literalinclude:: ./api_samples/summary/summary_get.json
:language: javascript
|