forked from typesense/typesense-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalytics_rule.py
More file actions
31 lines (24 loc) · 937 Bytes
/
analytics_rule.py
File metadata and controls
31 lines (24 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""Per-rule client for Analytics rules operations."""
from typesense.api_call import ApiCall
from typesense.types.analytics import AnalyticsRuleSchema
class AnalyticsRule:
def __init__(self, api_call: ApiCall, rule_name: str) -> None:
self.api_call = api_call
self.rule_name = rule_name
@property
def _endpoint_path(self) -> str:
from typesense.analytics_rules import AnalyticsRules
return "/".join([AnalyticsRules.resource_path, self.rule_name])
def retrieve(self) -> AnalyticsRuleSchema:
response: AnalyticsRule = self.api_call.get(
self._endpoint_path,
as_json=True,
entity_type=AnalyticsRule,
)
return response
def delete(self) -> AnalyticsRuleSchema:
response: AnalyticsRule = self.api_call.delete(
self._endpoint_path,
entity_type=AnalyticsRule,
)
return response