Merge pull request #4648 from ryanpetrello/format-metrics-human

cli: add special code for formatting metrics and settings with -f human

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot]
2019-09-09 18:52:29 +00:00
committed by GitHub
3 changed files with 49 additions and 7 deletions

View File

@@ -13,6 +13,13 @@ from .format import add_output_formatting_arguments
from .resource import DEPRECATED_RESOURCES_REVERSE
UNIQUENESS_RULES = {
'me': 'id, username',
'users': 'id, username',
'instances': 'id, hostname',
}
def pk_or_name(v2, model_name, value, page=None):
if isinstance(value, int):
return value
@@ -27,10 +34,8 @@ def pk_or_name(v2, model_name, value, page=None):
if model_name in DEPRECATED_RESOURCES_REVERSE:
model_name = DEPRECATED_RESOURCES_REVERSE[model_name]
if model_name == 'users':
identity = 'username'
elif model_name == 'instances':
model_name = 'hostname'
if model_name in UNIQUENESS_RULES:
identity = UNIQUENESS_RULES[model_name][-1]
if hasattr(v2, model_name):
page = getattr(v2, model_name)