rulebricks 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. rulebricks-0.0.1/PKG-INFO +60 -0
  2. rulebricks-0.0.1/README.md +44 -0
  3. rulebricks-0.0.1/pyproject.toml +23 -0
  4. rulebricks-0.0.1/src/rulebricks/__init__.py +22 -0
  5. rulebricks-0.0.1/src/rulebricks/client.py +45 -0
  6. rulebricks-0.0.1/src/rulebricks/core/__init__.py +17 -0
  7. rulebricks-0.0.1/src/rulebricks/core/api_error.py +15 -0
  8. rulebricks-0.0.1/src/rulebricks/core/client_wrapper.py +31 -0
  9. rulebricks-0.0.1/src/rulebricks/core/datetime_utils.py +28 -0
  10. rulebricks-0.0.1/src/rulebricks/core/jsonable_encoder.py +103 -0
  11. rulebricks-0.0.1/src/rulebricks/core/remove_none_from_dict.py +11 -0
  12. rulebricks-0.0.1/src/rulebricks/errors/__init__.py +6 -0
  13. rulebricks-0.0.1/src/rulebricks/errors/bad_request_error.py +10 -0
  14. rulebricks-0.0.1/src/rulebricks/errors/internal_server_error.py +10 -0
  15. rulebricks-0.0.1/src/rulebricks/resources/__init__.py +18 -0
  16. rulebricks-0.0.1/src/rulebricks/resources/flows/__init__.py +2 -0
  17. rulebricks-0.0.1/src/rulebricks/resources/flows/client.py +107 -0
  18. rulebricks-0.0.1/src/rulebricks/resources/rules/__init__.py +15 -0
  19. rulebricks-0.0.1/src/rulebricks/resources/rules/client.py +403 -0
  20. rulebricks-0.0.1/src/rulebricks/resources/rules/types/__init__.py +13 -0
  21. rulebricks-0.0.1/src/rulebricks/resources/rules/types/list_response_item.py +36 -0
  22. rulebricks-0.0.1/src/rulebricks/resources/rules/types/list_response_item_request_schema_item.py +40 -0
  23. rulebricks-0.0.1/src/rulebricks/resources/rules/types/list_response_item_response_schema_item.py +40 -0
  24. rulebricks-0.0.1/src/rulebricks/resources/rules/types/usage_response.py +41 -0
@@ -0,0 +1,60 @@
1
+ Metadata-Version: 2.1
2
+ Name: rulebricks
3
+ Version: 0.0.1
4
+ Summary:
5
+ Requires-Python: >=3.8,<4.0
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Programming Language :: Python :: 3.8
8
+ Classifier: Programming Language :: Python :: 3.9
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Requires-Dist: httpx (>=0.21.2)
12
+ Requires-Dist: pydantic (>=1.9.2)
13
+ Requires-Dist: typing_extensions (>=4.0.0)
14
+ Description-Content-Type: text/markdown
15
+
16
+ # Rulebricks Python Library
17
+
18
+ ## Documentation
19
+
20
+ API reference documentation is available [here](https://rulebricks.com/docs).
21
+
22
+ ## Installation
23
+
24
+ Add this dependency to your project's build file:
25
+
26
+ ```bash
27
+ pip install rulebricks
28
+ # or
29
+ poetry add rulebricks
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ ```python
35
+ from rulebricks.client import Rulebricks
36
+
37
+ rulebricks_client = Rulebricks(
38
+ api_key="YOUR_API_KEY",
39
+ base_url="https://yourhost.com/path/to/api",
40
+ )
41
+ ```
42
+
43
+ ## Async Client
44
+
45
+ ```python
46
+ from rulebricks.client import AsyncFlatFile
47
+ import flatfile
48
+
49
+ import asyncio
50
+
51
+ rulebricks_client = AsyncRulebricks(
52
+ api_key="YOUR_API_KEY",
53
+ base_url="https://yourhost.com/path/to/api",
54
+ )
55
+ ```
56
+
57
+ ## Beta status
58
+
59
+ This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning the package version to a specific version in your pyproject.toml file. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
60
+
@@ -0,0 +1,44 @@
1
+ # Rulebricks Python Library
2
+
3
+ ## Documentation
4
+
5
+ API reference documentation is available [here](https://rulebricks.com/docs).
6
+
7
+ ## Installation
8
+
9
+ Add this dependency to your project's build file:
10
+
11
+ ```bash
12
+ pip install rulebricks
13
+ # or
14
+ poetry add rulebricks
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```python
20
+ from rulebricks.client import Rulebricks
21
+
22
+ rulebricks_client = Rulebricks(
23
+ api_key="YOUR_API_KEY",
24
+ base_url="https://yourhost.com/path/to/api",
25
+ )
26
+ ```
27
+
28
+ ## Async Client
29
+
30
+ ```python
31
+ from rulebricks.client import AsyncFlatFile
32
+ import flatfile
33
+
34
+ import asyncio
35
+
36
+ rulebricks_client = AsyncRulebricks(
37
+ api_key="YOUR_API_KEY",
38
+ base_url="https://yourhost.com/path/to/api",
39
+ )
40
+ ```
41
+
42
+ ## Beta status
43
+
44
+ This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning the package version to a specific version in your pyproject.toml file. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
@@ -0,0 +1,23 @@
1
+ [tool.poetry]
2
+ name = "rulebricks"
3
+ version = "0.0.1"
4
+ description = ""
5
+ readme = "README.md"
6
+ authors = []
7
+ packages = [
8
+ { include = "rulebricks", from = "src"}
9
+ ]
10
+
11
+ [tool.poetry.dependencies]
12
+ python = "^3.8"
13
+ httpx = ">=0.21.2"
14
+ pydantic = ">= 1.9.2"
15
+ typing_extensions = ">= 4.0.0"
16
+
17
+ [tool.poetry.dev-dependencies]
18
+ mypy = "^1.8.0"
19
+ pytest = "^7.4.0"
20
+
21
+ [build-system]
22
+ requires = ["poetry-core"]
23
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,22 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from .errors import BadRequestError, InternalServerError
4
+ from .resources import (
5
+ ListResponseItem,
6
+ ListResponseItemRequestSchemaItem,
7
+ ListResponseItemResponseSchemaItem,
8
+ UsageResponse,
9
+ flows,
10
+ rules,
11
+ )
12
+
13
+ __all__ = [
14
+ "BadRequestError",
15
+ "InternalServerError",
16
+ "ListResponseItem",
17
+ "ListResponseItemRequestSchemaItem",
18
+ "ListResponseItemResponseSchemaItem",
19
+ "UsageResponse",
20
+ "flows",
21
+ "rules",
22
+ ]
@@ -0,0 +1,45 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import httpx
6
+
7
+ from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8
+ from .resources.flows.client import AsyncFlowsClient, FlowsClient
9
+ from .resources.rules.client import AsyncRulesClient, RulesClient
10
+
11
+
12
+ class RulebricksApi:
13
+ def __init__(
14
+ self,
15
+ *,
16
+ base_url: str,
17
+ api_key: str,
18
+ timeout: typing.Optional[float] = 60,
19
+ httpx_client: typing.Optional[httpx.Client] = None
20
+ ):
21
+ self._client_wrapper = SyncClientWrapper(
22
+ base_url=base_url,
23
+ api_key=api_key,
24
+ httpx_client=httpx.Client(timeout=timeout) if httpx_client is None else httpx_client,
25
+ )
26
+ self.rules = RulesClient(client_wrapper=self._client_wrapper)
27
+ self.flows = FlowsClient(client_wrapper=self._client_wrapper)
28
+
29
+
30
+ class AsyncRulebricksApi:
31
+ def __init__(
32
+ self,
33
+ *,
34
+ base_url: str,
35
+ api_key: str,
36
+ timeout: typing.Optional[float] = 60,
37
+ httpx_client: typing.Optional[httpx.AsyncClient] = None
38
+ ):
39
+ self._client_wrapper = AsyncClientWrapper(
40
+ base_url=base_url,
41
+ api_key=api_key,
42
+ httpx_client=httpx.AsyncClient(timeout=timeout) if httpx_client is None else httpx_client,
43
+ )
44
+ self.rules = AsyncRulesClient(client_wrapper=self._client_wrapper)
45
+ self.flows = AsyncFlowsClient(client_wrapper=self._client_wrapper)
@@ -0,0 +1,17 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from .api_error import ApiError
4
+ from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
5
+ from .datetime_utils import serialize_datetime
6
+ from .jsonable_encoder import jsonable_encoder
7
+ from .remove_none_from_dict import remove_none_from_dict
8
+
9
+ __all__ = [
10
+ "ApiError",
11
+ "AsyncClientWrapper",
12
+ "BaseClientWrapper",
13
+ "SyncClientWrapper",
14
+ "jsonable_encoder",
15
+ "remove_none_from_dict",
16
+ "serialize_datetime",
17
+ ]
@@ -0,0 +1,15 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+
6
+ class ApiError(Exception):
7
+ status_code: typing.Optional[int]
8
+ body: typing.Any
9
+
10
+ def __init__(self, *, status_code: typing.Optional[int] = None, body: typing.Any = None):
11
+ self.status_code = status_code
12
+ self.body = body
13
+
14
+ def __str__(self) -> str:
15
+ return f"status_code: {self.status_code}, body: {self.body}"
@@ -0,0 +1,31 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import httpx
6
+
7
+
8
+ class BaseClientWrapper:
9
+ def __init__(self, *, api_key: str, base_url: str):
10
+ self.api_key = api_key
11
+ self._base_url = base_url
12
+
13
+ def get_headers(self) -> typing.Dict[str, str]:
14
+ headers: typing.Dict[str, str] = {"X-Fern-Language": "Python"}
15
+ headers["x-api-key"] = self.api_key
16
+ return headers
17
+
18
+ def get_base_url(self) -> str:
19
+ return self._base_url
20
+
21
+
22
+ class SyncClientWrapper(BaseClientWrapper):
23
+ def __init__(self, *, api_key: str, base_url: str, httpx_client: httpx.Client):
24
+ super().__init__(api_key=api_key, base_url=base_url)
25
+ self.httpx_client = httpx_client
26
+
27
+
28
+ class AsyncClientWrapper(BaseClientWrapper):
29
+ def __init__(self, *, api_key: str, base_url: str, httpx_client: httpx.AsyncClient):
30
+ super().__init__(api_key=api_key, base_url=base_url)
31
+ self.httpx_client = httpx_client
@@ -0,0 +1,28 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+
5
+
6
+ def serialize_datetime(v: dt.datetime) -> str:
7
+ """
8
+ Serialize a datetime including timezone info.
9
+
10
+ Uses the timezone info provided if present, otherwise uses the current runtime's timezone info.
11
+
12
+ UTC datetimes end in "Z" while all other timezones are represented as offset from UTC, e.g. +05:00.
13
+ """
14
+
15
+ def _serialize_zoned_datetime(v: dt.datetime) -> str:
16
+ if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname(None):
17
+ # UTC is a special case where we use "Z" at the end instead of "+00:00"
18
+ return v.isoformat().replace("+00:00", "Z")
19
+ else:
20
+ # Delegate to the typical +/- offset format
21
+ return v.isoformat()
22
+
23
+ if v.tzinfo is not None:
24
+ return _serialize_zoned_datetime(v)
25
+ else:
26
+ local_tz = dt.datetime.now().astimezone().tzinfo
27
+ localized_dt = v.replace(tzinfo=local_tz)
28
+ return _serialize_zoned_datetime(localized_dt)
@@ -0,0 +1,103 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ """
4
+ jsonable_encoder converts a Python object to a JSON-friendly dict
5
+ (e.g. datetimes to strings, Pydantic models to dicts).
6
+
7
+ Taken from FastAPI, and made a bit simpler
8
+ https://github.com/tiangolo/fastapi/blob/master/fastapi/encoders.py
9
+ """
10
+
11
+ import dataclasses
12
+ import datetime as dt
13
+ from collections import defaultdict
14
+ from enum import Enum
15
+ from pathlib import PurePath
16
+ from types import GeneratorType
17
+ from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union
18
+
19
+ try:
20
+ import pydantic.v1 as pydantic # type: ignore
21
+ except ImportError:
22
+ import pydantic # type: ignore
23
+
24
+ from .datetime_utils import serialize_datetime
25
+
26
+ SetIntStr = Set[Union[int, str]]
27
+ DictIntStrAny = Dict[Union[int, str], Any]
28
+
29
+
30
+ def generate_encoders_by_class_tuples(
31
+ type_encoder_map: Dict[Any, Callable[[Any], Any]]
32
+ ) -> Dict[Callable[[Any], Any], Tuple[Any, ...]]:
33
+ encoders_by_class_tuples: Dict[Callable[[Any], Any], Tuple[Any, ...]] = defaultdict(tuple)
34
+ for type_, encoder in type_encoder_map.items():
35
+ encoders_by_class_tuples[encoder] += (type_,)
36
+ return encoders_by_class_tuples
37
+
38
+
39
+ encoders_by_class_tuples = generate_encoders_by_class_tuples(pydantic.json.ENCODERS_BY_TYPE)
40
+
41
+
42
+ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any], Any]]] = None) -> Any:
43
+ custom_encoder = custom_encoder or {}
44
+ if custom_encoder:
45
+ if type(obj) in custom_encoder:
46
+ return custom_encoder[type(obj)](obj)
47
+ else:
48
+ for encoder_type, encoder_instance in custom_encoder.items():
49
+ if isinstance(obj, encoder_type):
50
+ return encoder_instance(obj)
51
+ if isinstance(obj, pydantic.BaseModel):
52
+ encoder = getattr(obj.__config__, "json_encoders", {})
53
+ if custom_encoder:
54
+ encoder.update(custom_encoder)
55
+ obj_dict = obj.dict(by_alias=True)
56
+ if "__root__" in obj_dict:
57
+ obj_dict = obj_dict["__root__"]
58
+ return jsonable_encoder(obj_dict, custom_encoder=encoder)
59
+ if dataclasses.is_dataclass(obj):
60
+ obj_dict = dataclasses.asdict(obj)
61
+ return jsonable_encoder(obj_dict, custom_encoder=custom_encoder)
62
+ if isinstance(obj, Enum):
63
+ return obj.value
64
+ if isinstance(obj, PurePath):
65
+ return str(obj)
66
+ if isinstance(obj, (str, int, float, type(None))):
67
+ return obj
68
+ if isinstance(obj, dt.date):
69
+ return str(obj)
70
+ if isinstance(obj, dt.datetime):
71
+ return serialize_datetime(obj)
72
+ if isinstance(obj, dict):
73
+ encoded_dict = {}
74
+ allowed_keys = set(obj.keys())
75
+ for key, value in obj.items():
76
+ if key in allowed_keys:
77
+ encoded_key = jsonable_encoder(key, custom_encoder=custom_encoder)
78
+ encoded_value = jsonable_encoder(value, custom_encoder=custom_encoder)
79
+ encoded_dict[encoded_key] = encoded_value
80
+ return encoded_dict
81
+ if isinstance(obj, (list, set, frozenset, GeneratorType, tuple)):
82
+ encoded_list = []
83
+ for item in obj:
84
+ encoded_list.append(jsonable_encoder(item, custom_encoder=custom_encoder))
85
+ return encoded_list
86
+
87
+ if type(obj) in pydantic.json.ENCODERS_BY_TYPE:
88
+ return pydantic.json.ENCODERS_BY_TYPE[type(obj)](obj)
89
+ for encoder, classes_tuple in encoders_by_class_tuples.items():
90
+ if isinstance(obj, classes_tuple):
91
+ return encoder(obj)
92
+
93
+ try:
94
+ data = dict(obj)
95
+ except Exception as e:
96
+ errors: List[Exception] = []
97
+ errors.append(e)
98
+ try:
99
+ data = vars(obj)
100
+ except Exception as e:
101
+ errors.append(e)
102
+ raise ValueError(errors) from e
103
+ return jsonable_encoder(data, custom_encoder=custom_encoder)
@@ -0,0 +1,11 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from typing import Any, Dict, Optional
4
+
5
+
6
+ def remove_none_from_dict(original: Dict[str, Optional[Any]]) -> Dict[str, Any]:
7
+ new: Dict[str, Any] = {}
8
+ for key, value in original.items():
9
+ if value is not None:
10
+ new[key] = value
11
+ return new
@@ -0,0 +1,6 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from .bad_request_error import BadRequestError
4
+ from .internal_server_error import InternalServerError
5
+
6
+ __all__ = ["BadRequestError", "InternalServerError"]
@@ -0,0 +1,10 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from ..core.api_error import ApiError
6
+
7
+
8
+ class BadRequestError(ApiError):
9
+ def __init__(self, body: typing.Any):
10
+ super().__init__(status_code=400, body=body)
@@ -0,0 +1,10 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from ..core.api_error import ApiError
6
+
7
+
8
+ class InternalServerError(ApiError):
9
+ def __init__(self, body: typing.Any):
10
+ super().__init__(status_code=500, body=body)
@@ -0,0 +1,18 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from . import flows, rules
4
+ from .rules import (
5
+ ListResponseItem,
6
+ ListResponseItemRequestSchemaItem,
7
+ ListResponseItemResponseSchemaItem,
8
+ UsageResponse,
9
+ )
10
+
11
+ __all__ = [
12
+ "ListResponseItem",
13
+ "ListResponseItemRequestSchemaItem",
14
+ "ListResponseItemResponseSchemaItem",
15
+ "UsageResponse",
16
+ "flows",
17
+ "rules",
18
+ ]
@@ -0,0 +1,2 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
@@ -0,0 +1,107 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ import urllib.parse
5
+ from json.decoder import JSONDecodeError
6
+
7
+ from ...core.api_error import ApiError
8
+ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+ from ...core.jsonable_encoder import jsonable_encoder
10
+ from ...errors.bad_request_error import BadRequestError
11
+ from ...errors.internal_server_error import InternalServerError
12
+
13
+ try:
14
+ import pydantic.v1 as pydantic # type: ignore
15
+ except ImportError:
16
+ import pydantic # type: ignore
17
+
18
+ # this is used as the default value for optional parameters
19
+ OMIT = typing.cast(typing.Any, ...)
20
+
21
+
22
+ class FlowsClient:
23
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
24
+ self._client_wrapper = client_wrapper
25
+
26
+ def execute(self, slug: str, *, request: typing.Dict[str, typing.Any]) -> typing.Dict[str, typing.Any]:
27
+ """
28
+ Execute a flow by its slug.
29
+
30
+ Parameters:
31
+ - slug: str. The unique identifier for the flow.
32
+
33
+ - request: typing.Dict[str, typing.Any].
34
+ ---
35
+ from rulebricks.client import RulebricksApi
36
+
37
+ client = RulebricksApi(
38
+ api_key="YOUR_API_KEY",
39
+ base_url="https://yourhost.com/path/to/api",
40
+ )
41
+ client.flows.execute(
42
+ slug="slug",
43
+ request={"name": "John Doe", "age": 30, "email": "jdoe@acme.co"},
44
+ )
45
+ """
46
+ _response = self._client_wrapper.httpx_client.request(
47
+ "POST",
48
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/flow/{slug}"),
49
+ json=jsonable_encoder(request),
50
+ headers=self._client_wrapper.get_headers(),
51
+ timeout=60,
52
+ )
53
+ if 200 <= _response.status_code < 300:
54
+ return pydantic.parse_obj_as(typing.Dict[str, typing.Any], _response.json()) # type: ignore
55
+ if _response.status_code == 400:
56
+ raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
57
+ if _response.status_code == 500:
58
+ raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
59
+ try:
60
+ _response_json = _response.json()
61
+ except JSONDecodeError:
62
+ raise ApiError(status_code=_response.status_code, body=_response.text)
63
+ raise ApiError(status_code=_response.status_code, body=_response_json)
64
+
65
+
66
+ class AsyncFlowsClient:
67
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
68
+ self._client_wrapper = client_wrapper
69
+
70
+ async def execute(self, slug: str, *, request: typing.Dict[str, typing.Any]) -> typing.Dict[str, typing.Any]:
71
+ """
72
+ Execute a flow by its slug.
73
+
74
+ Parameters:
75
+ - slug: str. The unique identifier for the flow.
76
+
77
+ - request: typing.Dict[str, typing.Any].
78
+ ---
79
+ from rulebricks.client import AsyncRulebricksApi
80
+
81
+ client = AsyncRulebricksApi(
82
+ api_key="YOUR_API_KEY",
83
+ base_url="https://yourhost.com/path/to/api",
84
+ )
85
+ await client.flows.execute(
86
+ slug="slug",
87
+ request={"name": "John Doe", "age": 30, "email": "jdoe@acme.co"},
88
+ )
89
+ """
90
+ _response = await self._client_wrapper.httpx_client.request(
91
+ "POST",
92
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/flow/{slug}"),
93
+ json=jsonable_encoder(request),
94
+ headers=self._client_wrapper.get_headers(),
95
+ timeout=60,
96
+ )
97
+ if 200 <= _response.status_code < 300:
98
+ return pydantic.parse_obj_as(typing.Dict[str, typing.Any], _response.json()) # type: ignore
99
+ if _response.status_code == 400:
100
+ raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
101
+ if _response.status_code == 500:
102
+ raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
103
+ try:
104
+ _response_json = _response.json()
105
+ except JSONDecodeError:
106
+ raise ApiError(status_code=_response.status_code, body=_response.text)
107
+ raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -0,0 +1,15 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from .types import (
4
+ ListResponseItem,
5
+ ListResponseItemRequestSchemaItem,
6
+ ListResponseItemResponseSchemaItem,
7
+ UsageResponse,
8
+ )
9
+
10
+ __all__ = [
11
+ "ListResponseItem",
12
+ "ListResponseItemRequestSchemaItem",
13
+ "ListResponseItemResponseSchemaItem",
14
+ "UsageResponse",
15
+ ]
@@ -0,0 +1,403 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ import urllib.parse
5
+ from json.decoder import JSONDecodeError
6
+
7
+ from ...core.api_error import ApiError
8
+ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+ from ...core.jsonable_encoder import jsonable_encoder
10
+ from ...errors.bad_request_error import BadRequestError
11
+ from ...errors.internal_server_error import InternalServerError
12
+ from .types.list_response_item import ListResponseItem
13
+ from .types.usage_response import UsageResponse
14
+
15
+ try:
16
+ import pydantic.v1 as pydantic # type: ignore
17
+ except ImportError:
18
+ import pydantic # type: ignore
19
+
20
+ # this is used as the default value for optional parameters
21
+ OMIT = typing.cast(typing.Any, ...)
22
+
23
+
24
+ class RulesClient:
25
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
26
+ self._client_wrapper = client_wrapper
27
+
28
+ def solve(self, slug: str, *, request: typing.Dict[str, typing.Any]) -> typing.Dict[str, typing.Any]:
29
+ """
30
+ Executes a single rule identified by a unique slug. The request and response formats are dynamic, dependent on the rule configuration.
31
+
32
+ Parameters:
33
+ - slug: str. The unique identifier for the rule.
34
+
35
+ - request: typing.Dict[str, typing.Any].
36
+ ---
37
+ from rulebricks.client import RulebricksApi
38
+
39
+ client = RulebricksApi(
40
+ api_key="YOUR_API_KEY",
41
+ base_url="https://yourhost.com/path/to/api",
42
+ )
43
+ client.rules.solve(
44
+ slug="slug",
45
+ request={"name": "John Doe", "age": 30, "email": "jdoe@acme.co"},
46
+ )
47
+ """
48
+ _response = self._client_wrapper.httpx_client.request(
49
+ "POST",
50
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/solve/{slug}"),
51
+ json=jsonable_encoder(request),
52
+ headers=self._client_wrapper.get_headers(),
53
+ timeout=60,
54
+ )
55
+ if 200 <= _response.status_code < 300:
56
+ return pydantic.parse_obj_as(typing.Dict[str, typing.Any], _response.json()) # type: ignore
57
+ if _response.status_code == 400:
58
+ raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
59
+ if _response.status_code == 500:
60
+ raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
61
+ try:
62
+ _response_json = _response.json()
63
+ except JSONDecodeError:
64
+ raise ApiError(status_code=_response.status_code, body=_response.text)
65
+ raise ApiError(status_code=_response.status_code, body=_response_json)
66
+
67
+ def bulk_solve(
68
+ self, slug: str, *, request: typing.List[typing.Dict[str, typing.Any]]
69
+ ) -> typing.List[typing.Dict[str, typing.Any]]:
70
+ """
71
+ Executes a particular rule against multiple request data payloads provided in a list.
72
+
73
+ Parameters:
74
+ - slug: str. The unique identifier of the rule to execute against all payloads.
75
+
76
+ - request: typing.List[typing.Dict[str, typing.Any]].
77
+ ---
78
+ from rulebricks.client import RulebricksApi
79
+
80
+ client = RulebricksApi(
81
+ api_key="YOUR_API_KEY",
82
+ base_url="https://yourhost.com/path/to/api",
83
+ )
84
+ client.rules.bulk_solve(
85
+ slug="slug",
86
+ request=[
87
+ {"name": "John Doe", "age": 30, "email": "jdoe@acme.co"},
88
+ {"name": "Jane Doe", "age": 28, "email": "jane@example.com"},
89
+ ],
90
+ )
91
+ """
92
+ _response = self._client_wrapper.httpx_client.request(
93
+ "POST",
94
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/bulk-solve/{slug}"),
95
+ json=jsonable_encoder(request),
96
+ headers=self._client_wrapper.get_headers(),
97
+ timeout=60,
98
+ )
99
+ if 200 <= _response.status_code < 300:
100
+ return pydantic.parse_obj_as(typing.List[typing.Dict[str, typing.Any]], _response.json()) # type: ignore
101
+ if _response.status_code == 400:
102
+ raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
103
+ if _response.status_code == 500:
104
+ raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
105
+ try:
106
+ _response_json = _response.json()
107
+ except JSONDecodeError:
108
+ raise ApiError(status_code=_response.status_code, body=_response.text)
109
+ raise ApiError(status_code=_response.status_code, body=_response_json)
110
+
111
+ def parallel_solve(self, *, request: typing.Dict[str, typing.Any]) -> typing.Dict[str, typing.Any]:
112
+ """
113
+ Executes multiple rules in parallel based on a provided mapping of rule slugs to payloads.
114
+
115
+ Parameters:
116
+ - request: typing.Dict[str, typing.Any].
117
+ ---
118
+ from rulebricks.client import RulebricksApi
119
+
120
+ client = RulebricksApi(
121
+ api_key="YOUR_API_KEY",
122
+ base_url="https://yourhost.com/path/to/api",
123
+ )
124
+ client.rules.parallel_solve(
125
+ request={
126
+ "eligibility": {
127
+ "rule": "1ef03ms",
128
+ "name": "John Doe",
129
+ "age": 30,
130
+ "email": "jdoe@acme.co",
131
+ },
132
+ "offers": {
133
+ "rule": "OvmsYwn",
134
+ "customer_id": "12345",
135
+ "last_purchase_days_ago": 30,
136
+ "selected_plan": "premium",
137
+ },
138
+ },
139
+ )
140
+ """
141
+ _response = self._client_wrapper.httpx_client.request(
142
+ "POST",
143
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/parallel-solve"),
144
+ json=jsonable_encoder(request),
145
+ headers=self._client_wrapper.get_headers(),
146
+ timeout=60,
147
+ )
148
+ if 200 <= _response.status_code < 300:
149
+ return pydantic.parse_obj_as(typing.Dict[str, typing.Any], _response.json()) # type: ignore
150
+ if _response.status_code == 400:
151
+ raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
152
+ if _response.status_code == 500:
153
+ raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
154
+ try:
155
+ _response_json = _response.json()
156
+ except JSONDecodeError:
157
+ raise ApiError(status_code=_response.status_code, body=_response.text)
158
+ raise ApiError(status_code=_response.status_code, body=_response_json)
159
+
160
+ def list(self) -> typing.List[ListResponseItem]:
161
+ """
162
+ List all rules in the organization.
163
+
164
+ ---
165
+ from rulebricks.client import RulebricksApi
166
+
167
+ client = RulebricksApi(
168
+ api_key="YOUR_API_KEY",
169
+ base_url="https://yourhost.com/path/to/api",
170
+ )
171
+ client.rules.list()
172
+ """
173
+ _response = self._client_wrapper.httpx_client.request(
174
+ "GET",
175
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/list"),
176
+ headers=self._client_wrapper.get_headers(),
177
+ timeout=60,
178
+ )
179
+ if 200 <= _response.status_code < 300:
180
+ return pydantic.parse_obj_as(typing.List[ListResponseItem], _response.json()) # type: ignore
181
+ try:
182
+ _response_json = _response.json()
183
+ except JSONDecodeError:
184
+ raise ApiError(status_code=_response.status_code, body=_response.text)
185
+ raise ApiError(status_code=_response.status_code, body=_response_json)
186
+
187
+ def usage(self) -> UsageResponse:
188
+ """
189
+ Get the rule execution usage of your organization.
190
+
191
+ ---
192
+ from rulebricks.client import RulebricksApi
193
+
194
+ client = RulebricksApi(
195
+ api_key="YOUR_API_KEY",
196
+ base_url="https://yourhost.com/path/to/api",
197
+ )
198
+ client.rules.usage()
199
+ """
200
+ _response = self._client_wrapper.httpx_client.request(
201
+ "GET",
202
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/usage"),
203
+ headers=self._client_wrapper.get_headers(),
204
+ timeout=60,
205
+ )
206
+ if 200 <= _response.status_code < 300:
207
+ return pydantic.parse_obj_as(UsageResponse, _response.json()) # type: ignore
208
+ try:
209
+ _response_json = _response.json()
210
+ except JSONDecodeError:
211
+ raise ApiError(status_code=_response.status_code, body=_response.text)
212
+ raise ApiError(status_code=_response.status_code, body=_response_json)
213
+
214
+
215
+ class AsyncRulesClient:
216
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
217
+ self._client_wrapper = client_wrapper
218
+
219
+ async def solve(self, slug: str, *, request: typing.Dict[str, typing.Any]) -> typing.Dict[str, typing.Any]:
220
+ """
221
+ Executes a single rule identified by a unique slug. The request and response formats are dynamic, dependent on the rule configuration.
222
+
223
+ Parameters:
224
+ - slug: str. The unique identifier for the rule.
225
+
226
+ - request: typing.Dict[str, typing.Any].
227
+ ---
228
+ from rulebricks.client import AsyncRulebricksApi
229
+
230
+ client = AsyncRulebricksApi(
231
+ api_key="YOUR_API_KEY",
232
+ base_url="https://yourhost.com/path/to/api",
233
+ )
234
+ await client.rules.solve(
235
+ slug="slug",
236
+ request={"name": "John Doe", "age": 30, "email": "jdoe@acme.co"},
237
+ )
238
+ """
239
+ _response = await self._client_wrapper.httpx_client.request(
240
+ "POST",
241
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/solve/{slug}"),
242
+ json=jsonable_encoder(request),
243
+ headers=self._client_wrapper.get_headers(),
244
+ timeout=60,
245
+ )
246
+ if 200 <= _response.status_code < 300:
247
+ return pydantic.parse_obj_as(typing.Dict[str, typing.Any], _response.json()) # type: ignore
248
+ if _response.status_code == 400:
249
+ raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
250
+ if _response.status_code == 500:
251
+ raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
252
+ try:
253
+ _response_json = _response.json()
254
+ except JSONDecodeError:
255
+ raise ApiError(status_code=_response.status_code, body=_response.text)
256
+ raise ApiError(status_code=_response.status_code, body=_response_json)
257
+
258
+ async def bulk_solve(
259
+ self, slug: str, *, request: typing.List[typing.Dict[str, typing.Any]]
260
+ ) -> typing.List[typing.Dict[str, typing.Any]]:
261
+ """
262
+ Executes a particular rule against multiple request data payloads provided in a list.
263
+
264
+ Parameters:
265
+ - slug: str. The unique identifier of the rule to execute against all payloads.
266
+
267
+ - request: typing.List[typing.Dict[str, typing.Any]].
268
+ ---
269
+ from rulebricks.client import AsyncRulebricksApi
270
+
271
+ client = AsyncRulebricksApi(
272
+ api_key="YOUR_API_KEY",
273
+ base_url="https://yourhost.com/path/to/api",
274
+ )
275
+ await client.rules.bulk_solve(
276
+ slug="slug",
277
+ request=[
278
+ {"name": "John Doe", "age": 30, "email": "jdoe@acme.co"},
279
+ {"name": "Jane Doe", "age": 28, "email": "jane@example.com"},
280
+ ],
281
+ )
282
+ """
283
+ _response = await self._client_wrapper.httpx_client.request(
284
+ "POST",
285
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/bulk-solve/{slug}"),
286
+ json=jsonable_encoder(request),
287
+ headers=self._client_wrapper.get_headers(),
288
+ timeout=60,
289
+ )
290
+ if 200 <= _response.status_code < 300:
291
+ return pydantic.parse_obj_as(typing.List[typing.Dict[str, typing.Any]], _response.json()) # type: ignore
292
+ if _response.status_code == 400:
293
+ raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
294
+ if _response.status_code == 500:
295
+ raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
296
+ try:
297
+ _response_json = _response.json()
298
+ except JSONDecodeError:
299
+ raise ApiError(status_code=_response.status_code, body=_response.text)
300
+ raise ApiError(status_code=_response.status_code, body=_response_json)
301
+
302
+ async def parallel_solve(self, *, request: typing.Dict[str, typing.Any]) -> typing.Dict[str, typing.Any]:
303
+ """
304
+ Executes multiple rules in parallel based on a provided mapping of rule slugs to payloads.
305
+
306
+ Parameters:
307
+ - request: typing.Dict[str, typing.Any].
308
+ ---
309
+ from rulebricks.client import AsyncRulebricksApi
310
+
311
+ client = AsyncRulebricksApi(
312
+ api_key="YOUR_API_KEY",
313
+ base_url="https://yourhost.com/path/to/api",
314
+ )
315
+ await client.rules.parallel_solve(
316
+ request={
317
+ "eligibility": {
318
+ "rule": "1ef03ms",
319
+ "name": "John Doe",
320
+ "age": 30,
321
+ "email": "jdoe@acme.co",
322
+ },
323
+ "offers": {
324
+ "rule": "OvmsYwn",
325
+ "customer_id": "12345",
326
+ "last_purchase_days_ago": 30,
327
+ "selected_plan": "premium",
328
+ },
329
+ },
330
+ )
331
+ """
332
+ _response = await self._client_wrapper.httpx_client.request(
333
+ "POST",
334
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/parallel-solve"),
335
+ json=jsonable_encoder(request),
336
+ headers=self._client_wrapper.get_headers(),
337
+ timeout=60,
338
+ )
339
+ if 200 <= _response.status_code < 300:
340
+ return pydantic.parse_obj_as(typing.Dict[str, typing.Any], _response.json()) # type: ignore
341
+ if _response.status_code == 400:
342
+ raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
343
+ if _response.status_code == 500:
344
+ raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
345
+ try:
346
+ _response_json = _response.json()
347
+ except JSONDecodeError:
348
+ raise ApiError(status_code=_response.status_code, body=_response.text)
349
+ raise ApiError(status_code=_response.status_code, body=_response_json)
350
+
351
+ async def list(self) -> typing.List[ListResponseItem]:
352
+ """
353
+ List all rules in the organization.
354
+
355
+ ---
356
+ from rulebricks.client import AsyncRulebricksApi
357
+
358
+ client = AsyncRulebricksApi(
359
+ api_key="YOUR_API_KEY",
360
+ base_url="https://yourhost.com/path/to/api",
361
+ )
362
+ await client.rules.list()
363
+ """
364
+ _response = await self._client_wrapper.httpx_client.request(
365
+ "GET",
366
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/list"),
367
+ headers=self._client_wrapper.get_headers(),
368
+ timeout=60,
369
+ )
370
+ if 200 <= _response.status_code < 300:
371
+ return pydantic.parse_obj_as(typing.List[ListResponseItem], _response.json()) # type: ignore
372
+ try:
373
+ _response_json = _response.json()
374
+ except JSONDecodeError:
375
+ raise ApiError(status_code=_response.status_code, body=_response.text)
376
+ raise ApiError(status_code=_response.status_code, body=_response_json)
377
+
378
+ async def usage(self) -> UsageResponse:
379
+ """
380
+ Get the rule execution usage of your organization.
381
+
382
+ ---
383
+ from rulebricks.client import AsyncRulebricksApi
384
+
385
+ client = AsyncRulebricksApi(
386
+ api_key="YOUR_API_KEY",
387
+ base_url="https://yourhost.com/path/to/api",
388
+ )
389
+ await client.rules.usage()
390
+ """
391
+ _response = await self._client_wrapper.httpx_client.request(
392
+ "GET",
393
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/usage"),
394
+ headers=self._client_wrapper.get_headers(),
395
+ timeout=60,
396
+ )
397
+ if 200 <= _response.status_code < 300:
398
+ return pydantic.parse_obj_as(UsageResponse, _response.json()) # type: ignore
399
+ try:
400
+ _response_json = _response.json()
401
+ except JSONDecodeError:
402
+ raise ApiError(status_code=_response.status_code, body=_response.text)
403
+ raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -0,0 +1,13 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from .list_response_item import ListResponseItem
4
+ from .list_response_item_request_schema_item import ListResponseItemRequestSchemaItem
5
+ from .list_response_item_response_schema_item import ListResponseItemResponseSchemaItem
6
+ from .usage_response import UsageResponse
7
+
8
+ __all__ = [
9
+ "ListResponseItem",
10
+ "ListResponseItemRequestSchemaItem",
11
+ "ListResponseItemResponseSchemaItem",
12
+ "UsageResponse",
13
+ ]
@@ -0,0 +1,36 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+
6
+ from ....core.datetime_utils import serialize_datetime
7
+ from .list_response_item_request_schema_item import ListResponseItemRequestSchemaItem
8
+ from .list_response_item_response_schema_item import ListResponseItemResponseSchemaItem
9
+
10
+ try:
11
+ import pydantic.v1 as pydantic # type: ignore
12
+ except ImportError:
13
+ import pydantic # type: ignore
14
+
15
+
16
+ class ListResponseItem(pydantic.BaseModel):
17
+ id: typing.Optional[str] = pydantic.Field(description="The unique identifier for the rule.")
18
+ name: typing.Optional[str] = pydantic.Field(description="The name of the rule.")
19
+ description: typing.Optional[str] = pydantic.Field(description="The description of the rule.")
20
+ created_at: typing.Optional[str] = pydantic.Field(description="The creation date of the rule.")
21
+ slug: typing.Optional[str] = pydantic.Field(description="The unique slug for the rule used in API requests.")
22
+ request_schema: typing.Optional[typing.List[ListResponseItemRequestSchemaItem]]
23
+ response_schema: typing.Optional[typing.List[ListResponseItemResponseSchemaItem]]
24
+
25
+ def json(self, **kwargs: typing.Any) -> str:
26
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
27
+ return super().json(**kwargs_with_defaults)
28
+
29
+ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
30
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
31
+ return super().dict(**kwargs_with_defaults)
32
+
33
+ class Config:
34
+ frozen = True
35
+ smart_union = True
36
+ json_encoders = {dt.datetime: serialize_datetime}
@@ -0,0 +1,40 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+
6
+ from ....core.datetime_utils import serialize_datetime
7
+
8
+ try:
9
+ import pydantic.v1 as pydantic # type: ignore
10
+ except ImportError:
11
+ import pydantic # type: ignore
12
+
13
+
14
+ class ListResponseItemRequestSchemaItem(pydantic.BaseModel):
15
+ key: typing.Optional[str] = pydantic.Field(description="The key for the request field.")
16
+ show: typing.Optional[bool] = pydantic.Field(description="Whether the field is visible in the rule editor.")
17
+ name: typing.Optional[str] = pydantic.Field(description="The name of the request field.")
18
+ description: typing.Optional[str] = pydantic.Field(description="The description of the request field.")
19
+ type: typing.Optional[str] = pydantic.Field(description="The data type of the request field.")
20
+ default_value: typing.Optional[str] = pydantic.Field(
21
+ alias="defaultValue", description="The default value of the request field."
22
+ )
23
+ default_computed_value: typing.Optional[str] = pydantic.Field(
24
+ alias="defaultComputedValue", description="The computed default value of the request field."
25
+ )
26
+ transform: typing.Optional[str] = pydantic.Field(description="The transformation applied to the request field.")
27
+
28
+ def json(self, **kwargs: typing.Any) -> str:
29
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
30
+ return super().json(**kwargs_with_defaults)
31
+
32
+ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
33
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
34
+ return super().dict(**kwargs_with_defaults)
35
+
36
+ class Config:
37
+ frozen = True
38
+ smart_union = True
39
+ allow_population_by_field_name = True
40
+ json_encoders = {dt.datetime: serialize_datetime}
@@ -0,0 +1,40 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+
6
+ from ....core.datetime_utils import serialize_datetime
7
+
8
+ try:
9
+ import pydantic.v1 as pydantic # type: ignore
10
+ except ImportError:
11
+ import pydantic # type: ignore
12
+
13
+
14
+ class ListResponseItemResponseSchemaItem(pydantic.BaseModel):
15
+ key: typing.Optional[str] = pydantic.Field(description="The key for the response field.")
16
+ show: typing.Optional[bool] = pydantic.Field(description="Whether the field is visible in the rule editor.")
17
+ name: typing.Optional[str] = pydantic.Field(description="The name of the response field.")
18
+ description: typing.Optional[str] = pydantic.Field(description="The description of the response field.")
19
+ type: typing.Optional[str] = pydantic.Field(description="The data type of the response field.")
20
+ default_value: typing.Optional[str] = pydantic.Field(
21
+ alias="defaultValue", description="The default value of the response field."
22
+ )
23
+ default_computed_value: typing.Optional[str] = pydantic.Field(
24
+ alias="defaultComputedValue", description="The computed default value of the response field."
25
+ )
26
+ transform: typing.Optional[str] = pydantic.Field(description="The transformation applied to the response field.")
27
+
28
+ def json(self, **kwargs: typing.Any) -> str:
29
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
30
+ return super().json(**kwargs_with_defaults)
31
+
32
+ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
33
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
34
+ return super().dict(**kwargs_with_defaults)
35
+
36
+ class Config:
37
+ frozen = True
38
+ smart_union = True
39
+ allow_population_by_field_name = True
40
+ json_encoders = {dt.datetime: serialize_datetime}
@@ -0,0 +1,41 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+
6
+ from ....core.datetime_utils import serialize_datetime
7
+
8
+ try:
9
+ import pydantic.v1 as pydantic # type: ignore
10
+ except ImportError:
11
+ import pydantic # type: ignore
12
+
13
+
14
+ class UsageResponse(pydantic.BaseModel):
15
+ plan: typing.Optional[str] = pydantic.Field(description="The current plan of the organization.")
16
+ monthly_period_start: typing.Optional[str] = pydantic.Field(
17
+ description="The start date of the current monthly period."
18
+ )
19
+ monthly_period_end: typing.Optional[str] = pydantic.Field(description="The end date of the current monthly period.")
20
+ monthly_executions_usage: typing.Optional[float] = pydantic.Field(
21
+ description="The number of rule executions used this month."
22
+ )
23
+ monthly_executions_limit: typing.Optional[float] = pydantic.Field(
24
+ description="The total number of rule executions allowed this month."
25
+ )
26
+ monthly_executions_remaining: typing.Optional[float] = pydantic.Field(
27
+ description="The number of rule executions remaining this month."
28
+ )
29
+
30
+ def json(self, **kwargs: typing.Any) -> str:
31
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
32
+ return super().json(**kwargs_with_defaults)
33
+
34
+ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
35
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
36
+ return super().dict(**kwargs_with_defaults)
37
+
38
+ class Config:
39
+ frozen = True
40
+ smart_union = True
41
+ json_encoders = {dt.datetime: serialize_datetime}