From 964c61ffb47cb2cc3dfba61511ac4aecd02d9e98 Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Mon, 4 Dec 2023 16:08:51 +0000 Subject: [PATCH] Adding Tag decorator --- brewtils/decorators.py | 4 ++++ brewtils/models.py | 2 ++ brewtils/schemas.py | 1 + brewtils/test/fixtures.py | 1 + 4 files changed, 8 insertions(+) diff --git a/brewtils/decorators.py b/brewtils/decorators.py index 69e282c1..9438bc73 100644 --- a/brewtils/decorators.py +++ b/brewtils/decorators.py @@ -90,6 +90,7 @@ def command( icon_name=None, # type: Optional[str] hidden=False, # type: Optional[bool] metadata=None, # type: Optional[Dict] + tags=None, # type: Optional[List[str]] allow_any_kwargs=None, # type: Optional[bool] ): """Decorator for specifying Command details @@ -119,6 +120,7 @@ def echo_json(self, message): icon_name: The icon name. Should be either a FontAwesome or a Glyphicon name. hidden: Flag controlling whether the command is visible on the user interface. metadata: Free-form dictionary + tags: A list of tags that can be used to filter commands allow_any_kwargs: Flag controlling whether passed kwargs will be restricted to the Command parameters defined. @@ -156,6 +158,7 @@ def echo_json(self, message): icon_name=icon_name, hidden=hidden, metadata=metadata, + tags=tags, allow_any_kwargs=allow_any_kwargs, ) @@ -178,6 +181,7 @@ def echo_json(self, message): icon_name=icon_name, hidden=hidden, metadata=metadata, + tags=tags, allow_any_kwargs=allow_any_kwargs, ) diff --git a/brewtils/models.py b/brewtils/models.py index 7bb9af05..d71f5968 100644 --- a/brewtils/models.py +++ b/brewtils/models.py @@ -119,6 +119,7 @@ def __init__( icon_name=None, hidden=False, metadata=None, + tags=None, topics=None, allow_any_kwargs=None, ): @@ -133,6 +134,7 @@ def __init__( self.icon_name = icon_name self.hidden = hidden self.metadata = metadata or {} + self.tags = tags or [] self.topics = topics or [] self.allow_any_kwargs = allow_any_kwargs diff --git a/brewtils/schemas.py b/brewtils/schemas.py index d5d0501f..9e6a2b23 100644 --- a/brewtils/schemas.py +++ b/brewtils/schemas.py @@ -221,6 +221,7 @@ class CommandSchema(BaseSchema): icon_name = fields.Str(allow_none=True) hidden = fields.Boolean(allow_none=True) metadata = fields.Dict(allow_none=True) + tags = fields.List(fields.Str(), allow_none=True) topics = fields.List(fields.Str(), allow_none=True) allow_any_kwargs = fields.Boolean(allow_none=True) diff --git a/brewtils/test/fixtures.py b/brewtils/test/fixtures.py index 43e1be42..05cac166 100644 --- a/brewtils/test/fixtures.py +++ b/brewtils/test/fixtures.py @@ -170,6 +170,7 @@ def command_dict(parameter_dict, system_id): "template": "", "icon_name": "icon!", "metadata": {"meta": "data"}, + "tags": [], "topics": [], "allow_any_kwargs": False, }