Merge "Support query user message by timestamp"
This commit is contained in:
commit
1e3f4002e4
@ -27,7 +27,7 @@ from manilaclient import utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
MAX_VERSION = '2.51'
|
||||
MAX_VERSION = '2.52'
|
||||
MIN_VERSION = '2.0'
|
||||
DEPRECATED_VERSION = '1.0'
|
||||
_VERSIONED_METHOD_MAP = {}
|
||||
|
@ -3354,6 +3354,22 @@ class ShellTest(test_utils.TestCase):
|
||||
'Action ID', 'User Message', 'Detail ID',
|
||||
'Created At'], sortby_index=None)
|
||||
|
||||
@mock.patch.object(cliutils, 'print_list', mock.Mock())
|
||||
def test_share_message_list_created_before_aliases(self):
|
||||
self.run_command('message-list --before 2001-01-01')
|
||||
self.assert_called(
|
||||
'GET',
|
||||
'/messages?created_before=2001-01-01',
|
||||
)
|
||||
|
||||
@mock.patch.object(cliutils, 'print_list', mock.Mock())
|
||||
def test_share_message_list_created_since_aliases(self):
|
||||
self.run_command('message-list --since 2001-01-01')
|
||||
self.assert_called(
|
||||
'GET',
|
||||
'/messages?created_since=2001-01-01',
|
||||
)
|
||||
|
||||
@mock.patch.object(cliutils, 'print_list', mock.Mock())
|
||||
def test_message_list_select_column(self):
|
||||
self.run_command('message-list --columns id,resource_type')
|
||||
|
@ -5602,6 +5602,20 @@ def do_share_replica_resync(cs, args):
|
||||
default=None,
|
||||
help='Comma separated list of columns to be displayed '
|
||||
'example --columns "resource_id,user_message".')
|
||||
@cliutils.arg(
|
||||
'--since',
|
||||
metavar='<since>',
|
||||
default=None,
|
||||
help='Return only user messages created since given date. '
|
||||
'The date format must be conforming to ISO8601. '
|
||||
'Available only for microversion >= 2.52.')
|
||||
@cliutils.arg(
|
||||
'--before',
|
||||
metavar='<before>',
|
||||
default=None,
|
||||
help='Return only user messages created before given date. '
|
||||
'The date format must be conforming to ISO8601. '
|
||||
'Available only for microversion >= 2.52.')
|
||||
def do_message_list(cs, args):
|
||||
"""Lists all messages."""
|
||||
if args.columns is not None:
|
||||
@ -5620,6 +5634,15 @@ def do_message_list(cs, args):
|
||||
'detail_id': args.detail_id,
|
||||
'message_level': args.level
|
||||
}
|
||||
if cs.api_version < api_versions.APIVersion("2.52"):
|
||||
msg = ("Filtering messages by 'since' and 'before' is possible only "
|
||||
"with Manila API version >=2.52")
|
||||
if getattr(args, 'since') or getattr(args, 'before'):
|
||||
raise exceptions.CommandError(msg)
|
||||
else:
|
||||
search_opts['created_since'] = args.since
|
||||
search_opts['created_before'] = args.before
|
||||
|
||||
messages = cs.messages.list(
|
||||
search_opts=search_opts, sort_key=args.sort_key,
|
||||
sort_dir=args.sort_dir)
|
||||
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- Added ``since`` and ``before`` to messages list API. User messages can be
|
||||
queried by stimestamp with API version ``2.52`` and beyond.
|
Loading…
Reference in New Issue
Block a user