# Rules ## List rules for a detector `detectors.rules.list(strdetector_id) -> RuleListResponse` **get** `/api/detectors/{detectorId}/rules` List rules for a detector ### Parameters - `detector_id: str` ### Returns - `class RuleListResponse: …` - `errors: List[Error]` - `code: int` - `message: str` - `messages: List[Message]` - `code: int` - `message: str` - `result: Result` - `rules: List[ResultRule]` - `id: str` - `condition: Condition` - `class LeafCondition: …` - `leaf: Leaf` - `fact: str` - `op: Literal["eq", "neq", "in", 4 more]` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `"contains"` - `"matches"` - `"between"` - `value: Union[str, float, bool, 2 more]` - `str` - `float` - `bool` - `List[str]` - `List[float]` - `class RefCondition: …` - `ref: Ref` - `fact: str` - `op: Literal["eq", "neq", "in", "nin"]` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `reference: str` - `class InRelationCondition: …` - `in_relation: InRelation` - `args: List[object]` - `relation: str` - `class AllCondition: …` - `all: List[Condition]` - `class AnyCondition: …` - `any: List[Condition]` - `class NotCondition: …` - `not_: Condition` - `class OnceCondition: …` - `once: Condition` - `class HistoricallyCondition: …` - `historically: Condition` - `class SinceCondition: …` - `since: Since` - `left: Condition` - `right: Condition` - `class OnceWithinCondition: …` - `once_within: OnceWithin` - `inner: Condition` - `window_secs: float` - `class HistoricallyForCondition: …` - `historically_for: HistoricallyFor` - `inner: Condition` - `window_secs: float` - `boundary: Optional[Literal["weak", "strong"]]` - `"weak"` - `"strong"` - `class SinceWithinCondition: …` - `since_within: SinceWithin` - `left: Condition` - `right: Condition` - `window_secs: float` - `class KeyedCondition: …` - `keyed: Keyed` - `inner: Condition` - `key: str` - `detector_id: str` - `enabled: bool` - `name: str` - `notify: bool` - `priority: float` - `success: bool` ### Example ```python import os from rake import Rake client = Rake( api_key=os.environ.get("RAKE_API_KEY"), # This is the default and can be omitted ) rules = client.detectors.rules.list( "detectorId", ) print(rules.errors) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message" } ], "messages": [ { "code": 1000, "message": "message" } ], "result": { "rules": [ { "id": "id", "condition": { "leaf": { "fact": "fact", "op": "eq", "value": "string" } }, "detectorId": "detectorId", "enabled": true, "name": "name", "notify": true, "priority": 0 } ] }, "success": true } ``` ## Create a new rule `detectors.rules.create(strdetector_id, RuleCreateParams**kwargs) -> RuleCreateResponse` **post** `/api/detectors/{detectorId}/rules` Create a new rule ### Parameters - `detector_id: str` - `condition: str` - `name: str` - `notify: Optional[bool]` ### Returns - `class RuleCreateResponse: …` - `errors: List[Error]` - `code: int` - `message: str` - `messages: List[Message]` - `code: int` - `message: str` - `result: Result` - `id: str` - `success: bool` ### Example ```python import os from rake import Rake client = Rake( api_key=os.environ.get("RAKE_API_KEY"), # This is the default and can be omitted ) rule = client.detectors.rules.create( detector_id="detectorId", condition="condition", name="name", ) print(rule.errors) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message" } ], "messages": [ { "code": 1000, "message": "message" } ], "result": { "id": "id" }, "success": true } ``` ## Update a rule `detectors.rules.update(strid, RuleUpdateParams**kwargs) -> RuleUpdateResponse` **patch** `/api/detectors/{detectorId}/rules/{id}` Update a rule ### Parameters - `detector_id: str` - `id: str` - `condition: Optional[str]` - `enabled: Optional[bool]` - `name: Optional[str]` - `notify: Optional[bool]` ### Returns - `class RuleUpdateResponse: …` - `errors: List[Error]` - `code: int` - `message: str` - `messages: List[Message]` - `code: int` - `message: str` - `result: Result` - `id: str` - `condition: Condition` - `class LeafCondition: …` - `leaf: Leaf` - `fact: str` - `op: Literal["eq", "neq", "in", 4 more]` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `"contains"` - `"matches"` - `"between"` - `value: Union[str, float, bool, 2 more]` - `str` - `float` - `bool` - `List[str]` - `List[float]` - `class RefCondition: …` - `ref: Ref` - `fact: str` - `op: Literal["eq", "neq", "in", "nin"]` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `reference: str` - `class InRelationCondition: …` - `in_relation: InRelation` - `args: List[object]` - `relation: str` - `class AllCondition: …` - `all: List[Condition]` - `class AnyCondition: …` - `any: List[Condition]` - `class NotCondition: …` - `not_: Condition` - `class OnceCondition: …` - `once: Condition` - `class HistoricallyCondition: …` - `historically: Condition` - `class SinceCondition: …` - `since: Since` - `left: Condition` - `right: Condition` - `class OnceWithinCondition: …` - `once_within: OnceWithin` - `inner: Condition` - `window_secs: float` - `class HistoricallyForCondition: …` - `historically_for: HistoricallyFor` - `inner: Condition` - `window_secs: float` - `boundary: Optional[Literal["weak", "strong"]]` - `"weak"` - `"strong"` - `class SinceWithinCondition: …` - `since_within: SinceWithin` - `left: Condition` - `right: Condition` - `window_secs: float` - `class KeyedCondition: …` - `keyed: Keyed` - `inner: Condition` - `key: str` - `detector_id: str` - `enabled: bool` - `name: str` - `notify: bool` - `priority: float` - `success: bool` ### Example ```python import os from rake import Rake client = Rake( api_key=os.environ.get("RAKE_API_KEY"), # This is the default and can be omitted ) rule = client.detectors.rules.update( id="id", detector_id="detectorId", ) print(rule.errors) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message" } ], "messages": [ { "code": 1000, "message": "message" } ], "result": { "id": "id", "condition": { "leaf": { "fact": "fact", "op": "eq", "value": "string" } }, "detectorId": "detectorId", "enabled": true, "name": "name", "notify": true, "priority": 0 }, "success": true } ``` ## Delete a rule `detectors.rules.delete(strid, RuleDeleteParams**kwargs) -> RuleDeleteResponse` **delete** `/api/detectors/{detectorId}/rules/{id}` Delete a rule ### Parameters - `detector_id: str` - `id: str` ### Returns - `class RuleDeleteResponse: …` - `errors: List[Error]` - `code: int` - `message: str` - `messages: List[Message]` - `code: int` - `message: str` - `result: Result` - `id: str` - `success: bool` ### Example ```python import os from rake import Rake client = Rake( api_key=os.environ.get("RAKE_API_KEY"), # This is the default and can be omitted ) rule = client.detectors.rules.delete( id="id", detector_id="detectorId", ) print(rule.errors) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message" } ], "messages": [ { "code": 1000, "message": "message" } ], "result": { "id": "id" }, "success": true } ``` ## Domain Types ### All Condition - `class AllCondition: …` - `all: List[Condition]` ### Any Condition - `class AnyCondition: …` - `any: List[Condition]` ### Condition - `Condition` - `class LeafCondition: …` - `leaf: Leaf` - `fact: str` - `op: Literal["eq", "neq", "in", 4 more]` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `"contains"` - `"matches"` - `"between"` - `value: Union[str, float, bool, 2 more]` - `str` - `float` - `bool` - `List[str]` - `List[float]` - `class RefCondition: …` - `ref: Ref` - `fact: str` - `op: Literal["eq", "neq", "in", "nin"]` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `reference: str` - `class InRelationCondition: …` - `in_relation: InRelation` - `args: List[object]` - `relation: str` - `class AllCondition: …` - `all: List[Condition]` - `class AnyCondition: …` - `any: List[Condition]` - `class NotCondition: …` - `not_: Condition` - `class OnceCondition: …` - `once: Condition` - `class HistoricallyCondition: …` - `historically: Condition` - `class SinceCondition: …` - `since: Since` - `left: Condition` - `right: Condition` - `class OnceWithinCondition: …` - `once_within: OnceWithin` - `inner: Condition` - `window_secs: float` - `class HistoricallyForCondition: …` - `historically_for: HistoricallyFor` - `inner: Condition` - `window_secs: float` - `boundary: Optional[Literal["weak", "strong"]]` - `"weak"` - `"strong"` - `class SinceWithinCondition: …` - `since_within: SinceWithin` - `left: Condition` - `right: Condition` - `window_secs: float` - `class KeyedCondition: …` - `keyed: Keyed` - `inner: Condition` - `key: str` ### Historically Condition - `class HistoricallyCondition: …` - `historically: Condition` ### Historically For Condition - `class HistoricallyForCondition: …` - `historically_for: HistoricallyFor` - `inner: Condition` - `window_secs: float` - `boundary: Optional[Literal["weak", "strong"]]` - `"weak"` - `"strong"` ### In Relation Condition - `class InRelationCondition: …` - `in_relation: InRelation` - `args: List[object]` - `relation: str` ### Keyed Condition - `class KeyedCondition: …` - `keyed: Keyed` - `inner: Condition` - `key: str` ### Leaf Condition - `class LeafCondition: …` - `leaf: Leaf` - `fact: str` - `op: Literal["eq", "neq", "in", 4 more]` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `"contains"` - `"matches"` - `"between"` - `value: Union[str, float, bool, 2 more]` - `str` - `float` - `bool` - `List[str]` - `List[float]` ### Not Condition - `class NotCondition: …` - `not_: Condition` ### Once Condition - `class OnceCondition: …` - `once: Condition` ### Once Within Condition - `class OnceWithinCondition: …` - `once_within: OnceWithin` - `inner: Condition` - `window_secs: float` ### Ref Condition - `class RefCondition: …` - `ref: Ref` - `fact: str` - `op: Literal["eq", "neq", "in", "nin"]` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `reference: str` ### Since Condition - `class SinceCondition: …` - `since: Since` - `left: Condition` - `right: Condition` ### Since Within Condition - `class SinceWithinCondition: …` - `since_within: SinceWithin` - `left: Condition` - `right: Condition` - `window_secs: float` ### Rule List Response - `class RuleListResponse: …` - `errors: List[Error]` - `code: int` - `message: str` - `messages: List[Message]` - `code: int` - `message: str` - `result: Result` - `rules: List[ResultRule]` - `id: str` - `condition: Condition` - `class LeafCondition: …` - `leaf: Leaf` - `fact: str` - `op: Literal["eq", "neq", "in", 4 more]` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `"contains"` - `"matches"` - `"between"` - `value: Union[str, float, bool, 2 more]` - `str` - `float` - `bool` - `List[str]` - `List[float]` - `class RefCondition: …` - `ref: Ref` - `fact: str` - `op: Literal["eq", "neq", "in", "nin"]` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `reference: str` - `class InRelationCondition: …` - `in_relation: InRelation` - `args: List[object]` - `relation: str` - `class AllCondition: …` - `all: List[Condition]` - `class AnyCondition: …` - `any: List[Condition]` - `class NotCondition: …` - `not_: Condition` - `class OnceCondition: …` - `once: Condition` - `class HistoricallyCondition: …` - `historically: Condition` - `class SinceCondition: …` - `since: Since` - `left: Condition` - `right: Condition` - `class OnceWithinCondition: …` - `once_within: OnceWithin` - `inner: Condition` - `window_secs: float` - `class HistoricallyForCondition: …` - `historically_for: HistoricallyFor` - `inner: Condition` - `window_secs: float` - `boundary: Optional[Literal["weak", "strong"]]` - `"weak"` - `"strong"` - `class SinceWithinCondition: …` - `since_within: SinceWithin` - `left: Condition` - `right: Condition` - `window_secs: float` - `class KeyedCondition: …` - `keyed: Keyed` - `inner: Condition` - `key: str` - `detector_id: str` - `enabled: bool` - `name: str` - `notify: bool` - `priority: float` - `success: bool` ### Rule Create Response - `class RuleCreateResponse: …` - `errors: List[Error]` - `code: int` - `message: str` - `messages: List[Message]` - `code: int` - `message: str` - `result: Result` - `id: str` - `success: bool` ### Rule Update Response - `class RuleUpdateResponse: …` - `errors: List[Error]` - `code: int` - `message: str` - `messages: List[Message]` - `code: int` - `message: str` - `result: Result` - `id: str` - `condition: Condition` - `class LeafCondition: …` - `leaf: Leaf` - `fact: str` - `op: Literal["eq", "neq", "in", 4 more]` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `"contains"` - `"matches"` - `"between"` - `value: Union[str, float, bool, 2 more]` - `str` - `float` - `bool` - `List[str]` - `List[float]` - `class RefCondition: …` - `ref: Ref` - `fact: str` - `op: Literal["eq", "neq", "in", "nin"]` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `reference: str` - `class InRelationCondition: …` - `in_relation: InRelation` - `args: List[object]` - `relation: str` - `class AllCondition: …` - `all: List[Condition]` - `class AnyCondition: …` - `any: List[Condition]` - `class NotCondition: …` - `not_: Condition` - `class OnceCondition: …` - `once: Condition` - `class HistoricallyCondition: …` - `historically: Condition` - `class SinceCondition: …` - `since: Since` - `left: Condition` - `right: Condition` - `class OnceWithinCondition: …` - `once_within: OnceWithin` - `inner: Condition` - `window_secs: float` - `class HistoricallyForCondition: …` - `historically_for: HistoricallyFor` - `inner: Condition` - `window_secs: float` - `boundary: Optional[Literal["weak", "strong"]]` - `"weak"` - `"strong"` - `class SinceWithinCondition: …` - `since_within: SinceWithin` - `left: Condition` - `right: Condition` - `window_secs: float` - `class KeyedCondition: …` - `keyed: Keyed` - `inner: Condition` - `key: str` - `detector_id: str` - `enabled: bool` - `name: str` - `notify: bool` - `priority: float` - `success: bool` ### Rule Delete Response - `class RuleDeleteResponse: …` - `errors: List[Error]` - `code: int` - `message: str` - `messages: List[Message]` - `code: int` - `message: str` - `result: Result` - `id: str` - `success: bool`