Skip to content

Commit

Permalink
Add file trigger monitor options
Browse files Browse the repository at this point in the history
  • Loading branch information
1maple1 committed Aug 1, 2024
1 parent ddea224 commit 79007a9
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
30 changes: 27 additions & 3 deletions brewtils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1406,24 +1406,44 @@ def scheduler_kwargs(self):
class FileTrigger(BaseModel):
schema = "FileTriggerSchema"

def __init__(self, pattern=None, path=None, recursive=None):
def __init__(
self,
pattern=None,
path=None,
recursive=None,
create=None,
modify=None,
move=None,
delete=None,
):
self.pattern = pattern
self.path = path
self.recursive = recursive
self.create = create
self.modify = modify
self.move = move
self.delete = delete

def __str__(self):
return repr(self)

def __repr__(self):
return "<FileTrigger: pattern=%s, path=%s, recursive=%s>" % (
return (
"<FileTrigger: pattern=%s, path=%s, recursive=%s, "
"create=%s, modify=%s, move=%s, delete=%s>"
) % (
self.pattern,
self.path,
self.recursive,
self.create,
self.modify,
self.move,
self.delete,
)

@property
def scheduler_attributes(self):
return ["pattern", "path", "recursive"]
return ["pattern", "path", "recursive", "create", "modify", "move", "delete"]

@property
def scheduler_kwargs(self):
Expand All @@ -1433,6 +1453,10 @@ def scheduler_kwargs(self):
"pattern": self.pattern,
"path": self.path,
"recursive": self.recursive,
"create": self.create,
"modify": self.modify,
"move": self.move,
"delete": self.delete,
}
)

Expand Down
4 changes: 4 additions & 0 deletions brewtils/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,10 @@ class FileTriggerSchema(BaseSchema):
pattern = fields.Str(allow_none=True)
path = fields.Str(allow_none=True)
recursive = fields.Bool(allow_none=True)
create = fields.Bool(allow_none=True)
modify = fields.Bool(allow_none=True)
move = fields.Bool(allow_none=True)
delete = fields.Bool(allow_none=True)


class ConnectionSchema(BaseSchema):
Expand Down
4 changes: 4 additions & 0 deletions brewtils/test/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,10 @@ def file_trigger_dict():
"path": "./input",
"pattern": "*",
"recursive": False,
"create": True,
"modify": False,
"move": False,
"delete": False,
}


Expand Down
14 changes: 12 additions & 2 deletions test/models_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,10 @@ def test_schedule_kwargs_default(self, bg_file_trigger):
"path": "./input",
"pattern": "*",
"recursive": False,
"create": True,
"modify": False,
"move": False,
"delete": False,
}


Expand Down Expand Up @@ -642,8 +646,14 @@ def test_scheduler_kwargs(
),
(
lazy_fixture("bg_file_trigger"),
"<FileTrigger: pattern=*, path=./input, recursive=False>",
"<FileTrigger: pattern=*, path=./input, recursive=False>",
(
"<FileTrigger: pattern=*, path=./input, recursive=False, "
"create=True, modify=False, move=False, delete=False>"
),
(
"<FileTrigger: pattern=*, path=./input, recursive=False, "
"create=True, modify=False, move=False, delete=False>"
),
),
(
lazy_fixture("bg_interval_trigger"),
Expand Down

0 comments on commit 79007a9

Please sign in to comment.