Change meter_id to meter_name in generated docs

All operations on API level use meter name.
GET or POST /v2/meters/name_of_meter.
In docs we have meter_id, it is confusing, because meter_id is
syntetic UUID that is not used in DB ops.

The change should be done in v2.py because docs are generated
automatically and it's content is based on variables names from
the code.

Change-Id: I29abbefdaaa039f790f78fac102ede933d61d911
This commit is contained in:
Nadya Privalova 2014-01-24 16:50:38 +04:00
parent a00917a935
commit 737cd748a6
2 changed files with 12 additions and 12 deletions

View File

@ -710,9 +710,9 @@ class MeterController(rest.RestController):
'statistics': ['GET'], 'statistics': ['GET'],
} }
def __init__(self, meter_id): def __init__(self, meter_name):
pecan.request.context['meter_id'] = meter_id pecan.request.context['meter_name'] = meter_name
self._id = meter_id self.meter_name = meter_name
@wsme_pecan.wsexpose([OldSample], [Query], int) @wsme_pecan.wsexpose([OldSample], [Query], int)
def get_all(self, q=[], limit=None): def get_all(self, q=[], limit=None):
@ -724,7 +724,7 @@ class MeterController(rest.RestController):
if limit and limit < 0: if limit and limit < 0:
raise ClientSideError(_("Limit must be positive")) raise ClientSideError(_("Limit must be positive"))
kwargs = _query_to_kwargs(q, storage.SampleFilter.__init__) kwargs = _query_to_kwargs(q, storage.SampleFilter.__init__)
kwargs['meter'] = self._id kwargs['meter'] = self.meter_name
f = storage.SampleFilter(**kwargs) f = storage.SampleFilter(**kwargs)
return [OldSample.from_db_model(e) return [OldSample.from_db_model(e)
for e in pecan.request.storage_conn.get_samples(f, limit=limit) for e in pecan.request.storage_conn.get_samples(f, limit=limit)
@ -744,9 +744,9 @@ class MeterController(rest.RestController):
published_samples = [] published_samples = []
for s in samples: for s in samples:
if self._id != s.counter_name: if self.meter_name != s.counter_name:
raise wsme.exc.InvalidInput('counter_name', s.counter_name, raise wsme.exc.InvalidInput('counter_name', s.counter_name,
'should be %s' % self._id) 'should be %s' % self.meter_name)
if s.message_id: if s.message_id:
raise wsme.exc.InvalidInput('message_id', s.message_id, raise wsme.exc.InvalidInput('message_id', s.message_id,
@ -802,7 +802,7 @@ class MeterController(rest.RestController):
raise ClientSideError(_("Period must be positive.")) raise ClientSideError(_("Period must be positive."))
kwargs = _query_to_kwargs(q, storage.SampleFilter.__init__) kwargs = _query_to_kwargs(q, storage.SampleFilter.__init__)
kwargs['meter'] = self._id kwargs['meter'] = self.meter_name
f = storage.SampleFilter(**kwargs) f = storage.SampleFilter(**kwargs)
g = _validate_groupby_fields(groupby) g = _validate_groupby_fields(groupby)
computed = pecan.request.storage_conn.get_meter_statistics(f, computed = pecan.request.storage_conn.get_meter_statistics(f,
@ -875,11 +875,11 @@ class MetersController(rest.RestController):
"""Works on meters.""" """Works on meters."""
@pecan.expose() @pecan.expose()
def _lookup(self, meter_id, *remainder): def _lookup(self, meter_name, *remainder):
# NOTE(gordc): drop last path if empty (Bug #1202739) # NOTE(gordc): drop last path if empty (Bug #1202739)
if remainder and not remainder[-1]: if remainder and not remainder[-1]:
remainder = remainder[:-1] remainder = remainder[:-1]
return MeterController(meter_id), remainder return MeterController(meter_name), remainder
@wsme_pecan.wsexpose([Meter], [Query]) @wsme_pecan.wsexpose([Meter], [Query])
def get_all(self, q=[]): def get_all(self, q=[]):

View File

@ -22,12 +22,12 @@ Meters
.. rest-controller:: ceilometer.api.controllers.v2:MeterController .. rest-controller:: ceilometer.api.controllers.v2:MeterController
:webprefix: /v2/meters :webprefix: /v2/meters
Samples and Statistics
======================
.. autotype:: ceilometer.api.controllers.v2.Meter .. autotype:: ceilometer.api.controllers.v2.Meter
:members: :members:
Samples and Statistics
======================
.. autotype:: ceilometer.api.controllers.v2.Sample .. autotype:: ceilometer.api.controllers.v2.Sample
:members: :members: