motor-python-sdk 0.0.2__py3-none-any.whl

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 (60) hide show
  1. motor_python_sdk-0.0.2.dist-info/METADATA +230 -0
  2. motor_python_sdk-0.0.2.dist-info/RECORD +60 -0
  3. motor_python_sdk-0.0.2.dist-info/WHEEL +4 -0
  4. yasminaai/__init__.py +113 -0
  5. yasminaai/_default_clients.py +32 -0
  6. yasminaai/client.py +255 -0
  7. yasminaai/core/__init__.py +127 -0
  8. yasminaai/core/api_error.py +23 -0
  9. yasminaai/core/client_wrapper.py +119 -0
  10. yasminaai/core/datetime_utils.py +70 -0
  11. yasminaai/core/file.py +67 -0
  12. yasminaai/core/force_multipart.py +18 -0
  13. yasminaai/core/http_client.py +839 -0
  14. yasminaai/core/http_response.py +59 -0
  15. yasminaai/core/http_sse/__init__.py +42 -0
  16. yasminaai/core/http_sse/_api.py +170 -0
  17. yasminaai/core/http_sse/_decoders.py +61 -0
  18. yasminaai/core/http_sse/_exceptions.py +7 -0
  19. yasminaai/core/http_sse/_models.py +17 -0
  20. yasminaai/core/jsonable_encoder.py +120 -0
  21. yasminaai/core/logging.py +107 -0
  22. yasminaai/core/parse_error.py +36 -0
  23. yasminaai/core/pydantic_utilities.py +508 -0
  24. yasminaai/core/query_encoder.py +58 -0
  25. yasminaai/core/remove_none_from_dict.py +11 -0
  26. yasminaai/core/request_options.py +35 -0
  27. yasminaai/core/serialization.py +347 -0
  28. yasminaai/environment.py +7 -0
  29. yasminaai/errors/__init__.py +42 -0
  30. yasminaai/errors/bad_request_error.py +10 -0
  31. yasminaai/errors/not_found_error.py +10 -0
  32. yasminaai/errors/unauthorized_error.py +10 -0
  33. yasminaai/errors/unprocessable_entity_error.py +10 -0
  34. yasminaai/ot_ps/__init__.py +4 -0
  35. yasminaai/ot_ps/client.py +278 -0
  36. yasminaai/ot_ps/raw_client.py +355 -0
  37. yasminaai/policies/__init__.py +4 -0
  38. yasminaai/policies/client.py +393 -0
  39. yasminaai/policies/raw_client.py +493 -0
  40. yasminaai/py.typed +0 -0
  41. yasminaai/quotes/__init__.py +49 -0
  42. yasminaai/quotes/client.py +438 -0
  43. yasminaai/quotes/raw_client.py +548 -0
  44. yasminaai/quotes/types/__init__.py +47 -0
  45. yasminaai/quotes/types/delete_quote_requests_id_response.py +19 -0
  46. yasminaai/quotes/types/get_quote_requests_response.py +37 -0
  47. yasminaai/quotes/types/get_quote_requests_response_links_item.py +21 -0
  48. yasminaai/quotes/types/post_quote_requests_request_drivers_item.py +33 -0
  49. yasminaai/types/__init__.py +65 -0
  50. yasminaai/types/bad_request_error_body.py +20 -0
  51. yasminaai/types/benefit.py +24 -0
  52. yasminaai/types/company_quote.py +23 -0
  53. yasminaai/types/error.py +20 -0
  54. yasminaai/types/policy.py +33 -0
  55. yasminaai/types/quote_price.py +24 -0
  56. yasminaai/types/quote_response.py +90 -0
  57. yasminaai/types/quote_response_drivers_item.py +33 -0
  58. yasminaai/types/quote_response_quotes_item.py +30 -0
  59. yasminaai/types/unauthorized_error_body.py +20 -0
  60. yasminaai/version.py +3 -0
@@ -0,0 +1,59 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from typing import Dict, Generic, TypeVar
4
+
5
+ import httpx
6
+
7
+ # Generic to represent the underlying type of the data wrapped by the HTTP response.
8
+ T = TypeVar("T")
9
+
10
+
11
+ class BaseHttpResponse:
12
+ """Minimalist HTTP response wrapper that exposes response headers and status code."""
13
+
14
+ _response: httpx.Response
15
+
16
+ def __init__(self, response: httpx.Response):
17
+ self._response = response
18
+
19
+ @property
20
+ def headers(self) -> Dict[str, str]:
21
+ return dict(self._response.headers)
22
+
23
+ @property
24
+ def status_code(self) -> int:
25
+ return self._response.status_code
26
+
27
+
28
+ class HttpResponse(Generic[T], BaseHttpResponse):
29
+ """HTTP response wrapper that exposes response headers and data."""
30
+
31
+ _data: T
32
+
33
+ def __init__(self, response: httpx.Response, data: T):
34
+ super().__init__(response)
35
+ self._data = data
36
+
37
+ @property
38
+ def data(self) -> T:
39
+ return self._data
40
+
41
+ def close(self) -> None:
42
+ self._response.close()
43
+
44
+
45
+ class AsyncHttpResponse(Generic[T], BaseHttpResponse):
46
+ """HTTP response wrapper that exposes response headers and data."""
47
+
48
+ _data: T
49
+
50
+ def __init__(self, response: httpx.Response, data: T):
51
+ super().__init__(response)
52
+ self._data = data
53
+
54
+ @property
55
+ def data(self) -> T:
56
+ return self._data
57
+
58
+ async def close(self) -> None:
59
+ await self._response.aclose()
@@ -0,0 +1,42 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ import typing
6
+ from importlib import import_module
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from ._api import EventSource, aconnect_sse, connect_sse
10
+ from ._exceptions import SSEError
11
+ from ._models import ServerSentEvent
12
+ _dynamic_imports: typing.Dict[str, str] = {
13
+ "EventSource": "._api",
14
+ "SSEError": "._exceptions",
15
+ "ServerSentEvent": "._models",
16
+ "aconnect_sse": "._api",
17
+ "connect_sse": "._api",
18
+ }
19
+
20
+
21
+ def __getattr__(attr_name: str) -> typing.Any:
22
+ module_name = _dynamic_imports.get(attr_name)
23
+ if module_name is None:
24
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
25
+ try:
26
+ module = import_module(module_name, __package__)
27
+ if module_name == f".{attr_name}":
28
+ return module
29
+ else:
30
+ return getattr(module, attr_name)
31
+ except ImportError as e:
32
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
33
+ except AttributeError as e:
34
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
35
+
36
+
37
+ def __dir__():
38
+ lazy_attrs = list(_dynamic_imports.keys())
39
+ return sorted(lazy_attrs)
40
+
41
+
42
+ __all__ = ["EventSource", "SSEError", "ServerSentEvent", "aconnect_sse", "connect_sse"]
@@ -0,0 +1,170 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import codecs
4
+ import re
5
+ from contextlib import asynccontextmanager, contextmanager
6
+ from typing import Any, AsyncGenerator, AsyncIterator, Iterator
7
+
8
+ import httpx
9
+ from ._decoders import SSEDecoder
10
+ from ._exceptions import SSEError
11
+ from ._models import ServerSentEvent
12
+
13
+ MAX_LINE_SIZE: int = 1_048_576 # 1 MiB
14
+
15
+
16
+ class EventSource:
17
+ def __init__(self, response: httpx.Response) -> None:
18
+ self._response = response
19
+
20
+ def _check_content_type(self) -> None:
21
+ content_type = self._response.headers.get("content-type", "").partition(";")[0]
22
+ if "text/event-stream" not in content_type:
23
+ raise SSEError(
24
+ f"Expected response header Content-Type to contain 'text/event-stream', got {content_type!r}"
25
+ )
26
+
27
+ def _get_charset(self) -> str:
28
+ """Extract charset from Content-Type header, fallback to UTF-8."""
29
+ content_type = self._response.headers.get("content-type", "")
30
+
31
+ # Parse charset parameter using regex
32
+ charset_match = re.search(r"charset=([^;\s]+)", content_type, re.IGNORECASE)
33
+ if charset_match:
34
+ charset = charset_match.group(1).strip("\"'")
35
+ # Validate that it's a known encoding
36
+ try:
37
+ # Test if the charset is valid by trying to encode/decode
38
+ "test".encode(charset).decode(charset)
39
+ return charset
40
+ except (LookupError, UnicodeError):
41
+ # If charset is invalid, fall back to UTF-8
42
+ pass
43
+
44
+ # Default to UTF-8 if no charset specified or invalid charset
45
+ return "utf-8"
46
+
47
+ @property
48
+ def response(self) -> httpx.Response:
49
+ return self._response
50
+
51
+ @staticmethod
52
+ def _normalize_sse_line_endings(buf: str) -> str:
53
+ """Normalize line endings per the SSE spec (\\r\\n → \\n, bare \\r → \\n).
54
+
55
+ A trailing \\r is preserved because it may pair with a leading \\n in
56
+ the next chunk to form a single \\r\\n terminator.
57
+ """
58
+ buf = buf.replace("\r\n", "\n")
59
+ if buf.endswith("\r"):
60
+ return buf[:-1].replace("\r", "\n") + "\r"
61
+ return buf.replace("\r", "\n")
62
+
63
+ def iter_sse(self) -> Iterator[ServerSentEvent]:
64
+ self._check_content_type()
65
+ decoder = SSEDecoder()
66
+ charset = self._get_charset()
67
+ text_decoder = codecs.getincrementaldecoder(charset)(errors="replace")
68
+
69
+ buf = ""
70
+ for chunk in self._response.iter_bytes():
71
+ buf += text_decoder.decode(chunk)
72
+ buf = self._normalize_sse_line_endings(buf)
73
+
74
+ while "\n" in buf:
75
+ line, buf = buf.split("\n", 1)
76
+ sse = decoder.decode(line)
77
+ if sse is not None:
78
+ yield sse
79
+
80
+ if len(buf) > MAX_LINE_SIZE:
81
+ raise SSEError(
82
+ f"SSE line exceeded maximum size of {MAX_LINE_SIZE} characters without encountering a newline"
83
+ )
84
+
85
+ # Flush any remaining bytes from the incremental decoder
86
+ buf += text_decoder.decode(b"", final=True)
87
+ buf = buf.replace("\r\n", "\n").replace("\r", "\n")
88
+
89
+ if len(buf) > MAX_LINE_SIZE:
90
+ raise SSEError(
91
+ f"SSE line exceeded maximum size of {MAX_LINE_SIZE} characters without encountering a newline"
92
+ )
93
+
94
+ while "\n" in buf:
95
+ line, buf = buf.split("\n", 1)
96
+ sse = decoder.decode(line)
97
+ if sse is not None:
98
+ yield sse
99
+
100
+ if buf.strip():
101
+ sse = decoder.decode(buf)
102
+ if sse is not None:
103
+ yield sse
104
+
105
+ async def aiter_sse(self) -> AsyncGenerator[ServerSentEvent, None]:
106
+ self._check_content_type()
107
+ decoder = SSEDecoder()
108
+ charset = self._get_charset()
109
+ text_decoder = codecs.getincrementaldecoder(charset)(errors="replace")
110
+
111
+ buf = ""
112
+ async for chunk in self._response.aiter_bytes():
113
+ buf += text_decoder.decode(chunk)
114
+ buf = self._normalize_sse_line_endings(buf)
115
+
116
+ while "\n" in buf:
117
+ line, buf = buf.split("\n", 1)
118
+ sse = decoder.decode(line)
119
+ if sse is not None:
120
+ yield sse
121
+
122
+ if len(buf) > MAX_LINE_SIZE:
123
+ raise SSEError(
124
+ f"SSE line exceeded maximum size of {MAX_LINE_SIZE} characters without encountering a newline"
125
+ )
126
+
127
+ # Flush any remaining bytes from the incremental decoder
128
+ buf += text_decoder.decode(b"", final=True)
129
+ buf = buf.replace("\r\n", "\n").replace("\r", "\n")
130
+
131
+ if len(buf) > MAX_LINE_SIZE:
132
+ raise SSEError(
133
+ f"SSE line exceeded maximum size of {MAX_LINE_SIZE} characters without encountering a newline"
134
+ )
135
+
136
+ while "\n" in buf:
137
+ line, buf = buf.split("\n", 1)
138
+ sse = decoder.decode(line)
139
+ if sse is not None:
140
+ yield sse
141
+
142
+ if buf.strip():
143
+ sse = decoder.decode(buf)
144
+ if sse is not None:
145
+ yield sse
146
+
147
+
148
+ @contextmanager
149
+ def connect_sse(client: httpx.Client, method: str, url: str, **kwargs: Any) -> Iterator[EventSource]:
150
+ headers = kwargs.pop("headers", {})
151
+ headers["Accept"] = "text/event-stream"
152
+ headers["Cache-Control"] = "no-store"
153
+
154
+ with client.stream(method, url, headers=headers, **kwargs) as response:
155
+ yield EventSource(response)
156
+
157
+
158
+ @asynccontextmanager
159
+ async def aconnect_sse(
160
+ client: httpx.AsyncClient,
161
+ method: str,
162
+ url: str,
163
+ **kwargs: Any,
164
+ ) -> AsyncIterator[EventSource]:
165
+ headers = kwargs.pop("headers", {})
166
+ headers["Accept"] = "text/event-stream"
167
+ headers["Cache-Control"] = "no-store"
168
+
169
+ async with client.stream(method, url, headers=headers, **kwargs) as response:
170
+ yield EventSource(response)
@@ -0,0 +1,61 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from typing import List, Optional
4
+
5
+ from ._models import ServerSentEvent
6
+
7
+
8
+ class SSEDecoder:
9
+ def __init__(self) -> None:
10
+ self._event = ""
11
+ self._data: List[str] = []
12
+ self._last_event_id = ""
13
+ self._retry: Optional[int] = None
14
+
15
+ def decode(self, line: str) -> Optional[ServerSentEvent]:
16
+ # See: https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation # noqa: E501
17
+
18
+ if not line:
19
+ if not self._event and not self._data and not self._last_event_id and self._retry is None:
20
+ return None
21
+
22
+ sse = ServerSentEvent(
23
+ event=self._event,
24
+ data="\n".join(self._data),
25
+ id=self._last_event_id,
26
+ retry=self._retry,
27
+ )
28
+
29
+ # NOTE: as per the SSE spec, do not reset last_event_id.
30
+ self._event = ""
31
+ self._data = []
32
+ self._retry = None
33
+
34
+ return sse
35
+
36
+ if line.startswith(":"):
37
+ return None
38
+
39
+ fieldname, _, value = line.partition(":")
40
+
41
+ if value.startswith(" "):
42
+ value = value[1:]
43
+
44
+ if fieldname == "event":
45
+ self._event = value
46
+ elif fieldname == "data":
47
+ self._data.append(value)
48
+ elif fieldname == "id":
49
+ if "\0" in value:
50
+ pass
51
+ else:
52
+ self._last_event_id = value
53
+ elif fieldname == "retry":
54
+ try:
55
+ self._retry = int(value)
56
+ except (TypeError, ValueError):
57
+ pass
58
+ else:
59
+ pass # Field is ignored.
60
+
61
+ return None
@@ -0,0 +1,7 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import httpx
4
+
5
+
6
+ class SSEError(httpx.TransportError):
7
+ pass
@@ -0,0 +1,17 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import json
4
+ from dataclasses import dataclass
5
+ from typing import Any, Optional
6
+
7
+
8
+ @dataclass(frozen=True)
9
+ class ServerSentEvent:
10
+ event: str = "message"
11
+ data: str = ""
12
+ id: str = ""
13
+ retry: Optional[int] = None
14
+
15
+ def json(self) -> Any:
16
+ """Parse the data field as JSON."""
17
+ return json.loads(self.data)
@@ -0,0 +1,120 @@
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 base64
12
+ import dataclasses
13
+ import datetime as dt
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, Union
18
+
19
+ import pydantic
20
+ from .datetime_utils import serialize_datetime
21
+ from .pydantic_utilities import (
22
+ IS_PYDANTIC_V2,
23
+ encode_by_type,
24
+ to_jsonable_with_fallback,
25
+ )
26
+
27
+ SetIntStr = Set[Union[int, str]]
28
+ DictIntStrAny = Dict[Union[int, str], Any]
29
+
30
+
31
+ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any], Any]]] = None) -> Any:
32
+ custom_encoder = custom_encoder or {}
33
+ # Generated SDKs use Ellipsis (`...`) as the sentinel value for "OMIT".
34
+ # OMIT values should be excluded from serialized payloads.
35
+ if obj is Ellipsis:
36
+ return None
37
+ if custom_encoder:
38
+ if type(obj) in custom_encoder:
39
+ return custom_encoder[type(obj)](obj)
40
+ else:
41
+ for encoder_type, encoder_instance in custom_encoder.items():
42
+ if isinstance(obj, encoder_type):
43
+ return encoder_instance(obj)
44
+ if isinstance(obj, pydantic.BaseModel):
45
+ if IS_PYDANTIC_V2:
46
+ encoder = getattr(obj.model_config, "json_encoders", {}) # type: ignore # Pydantic v2
47
+ else:
48
+ encoder = getattr(obj.__config__, "json_encoders", {}) # type: ignore # Pydantic v1
49
+ if custom_encoder:
50
+ encoder.update(custom_encoder)
51
+ obj_dict = obj.dict(by_alias=True)
52
+ if "__root__" in obj_dict:
53
+ obj_dict = obj_dict["__root__"]
54
+ if "root" in obj_dict:
55
+ obj_dict = obj_dict["root"]
56
+ return jsonable_encoder(obj_dict, custom_encoder=encoder)
57
+ if dataclasses.is_dataclass(obj):
58
+ obj_dict = dataclasses.asdict(obj) # type: ignore
59
+ return jsonable_encoder(obj_dict, custom_encoder=custom_encoder)
60
+ if isinstance(obj, bytes):
61
+ return base64.b64encode(obj).decode("utf-8")
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.datetime):
69
+ return serialize_datetime(obj)
70
+ if isinstance(obj, dt.date):
71
+ return str(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
+ if value is Ellipsis:
78
+ continue
79
+ encoded_key = jsonable_encoder(key, custom_encoder=custom_encoder)
80
+ encoded_value = jsonable_encoder(value, custom_encoder=custom_encoder)
81
+ encoded_dict[encoded_key] = encoded_value
82
+ return encoded_dict
83
+ if isinstance(obj, (list, set, frozenset, GeneratorType, tuple)):
84
+ encoded_list = []
85
+ for item in obj:
86
+ if item is Ellipsis:
87
+ continue
88
+ encoded_list.append(jsonable_encoder(item, custom_encoder=custom_encoder))
89
+ return encoded_list
90
+
91
+ def fallback_serializer(o: Any) -> Any:
92
+ attempt_encode = encode_by_type(o)
93
+ if attempt_encode is not None:
94
+ return attempt_encode
95
+
96
+ try:
97
+ data = dict(o)
98
+ except Exception as e:
99
+ errors: List[Exception] = []
100
+ errors.append(e)
101
+ try:
102
+ data = vars(o)
103
+ except Exception as e:
104
+ errors.append(e)
105
+ raise ValueError(errors) from e
106
+ return jsonable_encoder(data, custom_encoder=custom_encoder)
107
+
108
+ return to_jsonable_with_fallback(obj, fallback_serializer)
109
+
110
+
111
+ def encode_path_param(obj: Any) -> str:
112
+ """Encode a value for use in a URL path segment.
113
+
114
+ Ensures proper string conversion for all types, including
115
+ booleans which need lowercase 'true'/'false' rather than
116
+ Python's 'True'/'False'.
117
+ """
118
+ if isinstance(obj, bool):
119
+ return "true" if obj else "false"
120
+ return str(jsonable_encoder(obj))
@@ -0,0 +1,107 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import logging
4
+ import typing
5
+
6
+ LogLevel = typing.Literal["debug", "info", "warn", "error"]
7
+
8
+ _LOG_LEVEL_MAP: typing.Dict[LogLevel, int] = {
9
+ "debug": 1,
10
+ "info": 2,
11
+ "warn": 3,
12
+ "error": 4,
13
+ }
14
+
15
+
16
+ class ILogger(typing.Protocol):
17
+ def debug(self, message: str, **kwargs: typing.Any) -> None: ...
18
+ def info(self, message: str, **kwargs: typing.Any) -> None: ...
19
+ def warn(self, message: str, **kwargs: typing.Any) -> None: ...
20
+ def error(self, message: str, **kwargs: typing.Any) -> None: ...
21
+
22
+
23
+ class ConsoleLogger:
24
+ _logger: logging.Logger
25
+
26
+ def __init__(self) -> None:
27
+ self._logger = logging.getLogger("fern")
28
+ if not self._logger.handlers:
29
+ handler = logging.StreamHandler()
30
+ handler.setFormatter(logging.Formatter("%(levelname)s - %(message)s"))
31
+ self._logger.addHandler(handler)
32
+ self._logger.setLevel(logging.DEBUG)
33
+
34
+ def debug(self, message: str, **kwargs: typing.Any) -> None:
35
+ self._logger.debug(message, extra=kwargs)
36
+
37
+ def info(self, message: str, **kwargs: typing.Any) -> None:
38
+ self._logger.info(message, extra=kwargs)
39
+
40
+ def warn(self, message: str, **kwargs: typing.Any) -> None:
41
+ self._logger.warning(message, extra=kwargs)
42
+
43
+ def error(self, message: str, **kwargs: typing.Any) -> None:
44
+ self._logger.error(message, extra=kwargs)
45
+
46
+
47
+ class LogConfig(typing.TypedDict, total=False):
48
+ level: LogLevel
49
+ logger: ILogger
50
+ silent: bool
51
+
52
+
53
+ class Logger:
54
+ _level: int
55
+ _logger: ILogger
56
+ _silent: bool
57
+
58
+ def __init__(self, *, level: LogLevel, logger: ILogger, silent: bool) -> None:
59
+ self._level = _LOG_LEVEL_MAP[level]
60
+ self._logger = logger
61
+ self._silent = silent
62
+
63
+ def _should_log(self, level: LogLevel) -> bool:
64
+ return not self._silent and self._level <= _LOG_LEVEL_MAP[level]
65
+
66
+ def is_debug(self) -> bool:
67
+ return self._should_log("debug")
68
+
69
+ def is_info(self) -> bool:
70
+ return self._should_log("info")
71
+
72
+ def is_warn(self) -> bool:
73
+ return self._should_log("warn")
74
+
75
+ def is_error(self) -> bool:
76
+ return self._should_log("error")
77
+
78
+ def debug(self, message: str, **kwargs: typing.Any) -> None:
79
+ if self.is_debug():
80
+ self._logger.debug(message, **kwargs)
81
+
82
+ def info(self, message: str, **kwargs: typing.Any) -> None:
83
+ if self.is_info():
84
+ self._logger.info(message, **kwargs)
85
+
86
+ def warn(self, message: str, **kwargs: typing.Any) -> None:
87
+ if self.is_warn():
88
+ self._logger.warn(message, **kwargs)
89
+
90
+ def error(self, message: str, **kwargs: typing.Any) -> None:
91
+ if self.is_error():
92
+ self._logger.error(message, **kwargs)
93
+
94
+
95
+ _default_logger: Logger = Logger(level="info", logger=ConsoleLogger(), silent=True)
96
+
97
+
98
+ def create_logger(config: typing.Optional[typing.Union[LogConfig, Logger]] = None) -> Logger:
99
+ if config is None:
100
+ return _default_logger
101
+ if isinstance(config, Logger):
102
+ return config
103
+ return Logger(
104
+ level=config.get("level", "info"),
105
+ logger=config.get("logger", ConsoleLogger()),
106
+ silent=config.get("silent", True),
107
+ )
@@ -0,0 +1,36 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from typing import Any, Dict, Optional
4
+
5
+
6
+ class ParsingError(Exception):
7
+ """
8
+ Raised when the SDK fails to parse/validate a response from the server.
9
+ This typically indicates that the server returned a response whose shape
10
+ does not match the expected schema.
11
+ """
12
+
13
+ headers: Optional[Dict[str, str]]
14
+ status_code: Optional[int]
15
+ body: Any
16
+ cause: Optional[Exception]
17
+
18
+ def __init__(
19
+ self,
20
+ *,
21
+ headers: Optional[Dict[str, str]] = None,
22
+ status_code: Optional[int] = None,
23
+ body: Any = None,
24
+ cause: Optional[Exception] = None,
25
+ ) -> None:
26
+ self.headers = headers
27
+ self.status_code = status_code
28
+ self.body = body
29
+ self.cause = cause
30
+ super().__init__()
31
+ if cause is not None:
32
+ self.__cause__ = cause
33
+
34
+ def __str__(self) -> str:
35
+ cause_str = f", cause: {self.cause}" if self.cause is not None else ""
36
+ return f"headers: {self.headers}, status_code: {self.status_code}, body: {self.body}{cause_str}"