Schemas¶
azuma.schemas.Rule
¶
Bases: YamlBaseModel
match(event)
¶
Check whether an event is matched with the rule or not
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
dict[Any, Any]
|
Event |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
Returns True if an event is matched with the rule. False if not |
Source code in azuma/schemas/rule.py
94 95 96 97 98 99 100 101 102 103 104 105 106 | |
azuma.schemas.RuleSet
¶
Bases: RootModel
from_dir(dir, *, pattern='*.{yml,yaml}')
classmethod
¶
Load rules from a directory
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir
|
str | Path
|
Directory |
required |
pattern
|
str
|
YAML file pattern. Defaults to "*.{yml,yaml}". |
'*.{yml,yaml}'
|
Returns:
| Name | Type | Description |
|---|---|---|
RuleSet |
RuleSet
|
Rule set |
Source code in azuma/schemas/rule_set.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
match_all(event)
¶
Check whether an event is matched with the rules
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
dict[Any, Any]
|
Event |
required |
Returns:
| Type | Description |
|---|---|
list[Rule]
|
list[Rule]: A list of matched rules |
Source code in azuma/schemas/rule_set.py
19 20 21 22 23 24 25 26 27 28 | |
unique()
¶
Returns unique rule set.
Returns:
| Name | Type | Description |
|---|---|---|
RuleSet |
RuleSet
|
Rule set |
Source code in azuma/schemas/rule_set.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
azuma.schemas.yaml_model.YamlBaseModel
¶
Bases: BaseModel
BaseModel with YAML support
model_validate_file(path, *, encoding='utf8', strict=None, context=None)
classmethod
¶
Parse a YAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to a file. |
required |
encoding
|
str
|
Encoding. Defaults to "utf8". |
'utf8'
|
strict
|
bool | None
|
Strict or not. Defaults to None. |
None
|
context
|
dict[str, Any] | None
|
Context. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
YamlBaseModel |
Parsed instance. |
Source code in azuma/schemas/yaml_model.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
model_validate_yaml(b, *, strict=None, context=None)
classmethod
¶
Parse a YAML text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
b
|
str | bytes
|
String or bytes. |
required |
strict
|
bool | None
|
Strict or not. Defaults to None. |
None
|
context
|
dict[str, Any] | None
|
Context. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
YamlBaseModel |
Parsed instance. |
Source code in azuma/schemas/yaml_model.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |