sift_py.rule.service
¶
| CLASS | DESCRIPTION |
|---|---|
RuleChannelReference |
Convenient wrapper to map rule names to relevant channel references |
RuleIdentifier |
Wrapper around RuleIdentifier for working with external rules. |
RuleService |
A service for managing rules. Allows for loading rules from YAML and creating or updating them in the Sift API. |
RuleChannelReference
dataclass
¶
Convenient wrapper to map rule names to relevant channel references when creating rules from yaml.
| ATTRIBUTE | DESCRIPTION |
|---|---|
channel_references |
|
rule_name |
TYPE:
|
RuleIdentifier
dataclass
¶
RuleService
¶
RuleService(channel: SiftChannel)
A service for managing rules. Allows for loading rules from YAML and creating or updating them in the Sift API.
| METHOD | DESCRIPTION |
|---|---|
attach_asset |
Associates a rule with an asset by name. The asset must already exist in the Sift API. |
create_external_rules |
Create external rules via RuleConfigs. The configs must have is_external set to |
create_external_rules_from_yaml |
Creates external rules from a YAML spec in the Sift API. |
create_or_update_rule |
Create or update a rule via a RuleConfig. The config must contain a rule_client_key or an exception will be raised. |
create_or_update_rules |
Create or update a list of rules via a list of RuleConfigs. |
detach_asset |
Disassociates a rule from an asset by name. The asset must already exist in the Sift API. |
get_rule |
Get a rule by rule id or client key. Returns a RuleConfig if the rule exists, otherwise None. |
load_rules_from_yaml |
Loads rules from a YAML spec, and creates or updates the rules in the Sift API. |
attach_asset
¶
attach_asset(
rule: Union[str, RuleConfig], asset_names: List[str]
) -> RuleConfig
Associates a rule with an asset by name. The asset must already exist in the Sift API. The provided rule may either be a rule client key, rule id, or a RuleConfig.
create_external_rules
¶
create_external_rules(
configs: List[RuleConfig],
) -> List[RuleIdentifier]
Create external rules via RuleConfigs. The configs must have is_external set to True or an exception will be raised. rule_client_key must be empty.
| PARAMETER | DESCRIPTION |
|---|---|
configs
|
The list of RuleConfigs to create as external rules.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
List[RuleIdentifier]
|
The list of RuleIdentifiers created. |
create_external_rules_from_yaml
¶
create_external_rules_from_yaml(
paths: List[Path],
named_expressions: Optional[Dict[str, str]] = None,
) -> List[RuleIdentifier]
Creates external rules from a YAML spec in the Sift API.
For more on rule YAML definitions, see sift_py.ingestion.config.yaml.spec.RuleYamlSpec.
| PARAMETER | DESCRIPTION |
|---|---|
paths
|
The list of YAML paths to load. |
named_expressions
|
The named expressions to substitute into the rules. |
| RETURNS | DESCRIPTION |
|---|---|
List[RuleIdentifier]
|
The loaded RuleConfigs as external rules. |
create_or_update_rule
¶
create_or_update_rule(config: RuleConfig)
Create or update a rule via a RuleConfig. The config must contain a rule_client_key or an exception will be raised.
If a rule with the given client key already exists it will be updated, otherwise it will be created.
See sift_py.rule.config.RuleConfig for more information on configuation parameters for rules.
create_or_update_rules
¶
create_or_update_rules(rule_configs: List[RuleConfig])
Create or update a list of rules via a list of RuleConfigs.
See sift_py.rule.config.RuleConfig for more information on configuation parameters for rules.
detach_asset
¶
detach_asset(
rule: Union[str, RuleConfig], asset_names: List[str]
) -> RuleConfig
Disassociates a rule from an asset by name. The asset must already exist in the Sift API. The provided rule may either be a rule client key, rule id, or a RuleConfig.
get_rule
¶
get_rule(rule: str) -> Optional[RuleConfig]
Get a rule by rule id or client key. Returns a RuleConfig if the rule exists, otherwise None.
load_rules_from_yaml
¶
load_rules_from_yaml(
paths: List[Path],
named_expressions: Optional[Dict[str, str]] = None,
) -> List[RuleConfig]
Loads rules from a YAML spec, and creates or updates the rules in the Sift API.
For more on rule YAML definitions, see sift_py.ingestion.config.yaml.spec.RuleYamlSpec.
| PARAMETER | DESCRIPTION |
|---|---|
paths
|
The list of YAML paths to load. |
named_expressions
|
The named expressions to substitute into the rules. |
| RETURNS | DESCRIPTION |
|---|---|
List[RuleConfig]
|
The loaded RuleConfigs. |