newscatcher-catchall-sdk 0.0.0.dev0__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 (195) hide show
  1. newscatcher_catchall/__init__.py +496 -0
  2. newscatcher_catchall/_default_clients.py +32 -0
  3. newscatcher_catchall/client.py +326 -0
  4. newscatcher_catchall/core/__init__.py +127 -0
  5. newscatcher_catchall/core/api_error.py +23 -0
  6. newscatcher_catchall/core/client_wrapper.py +123 -0
  7. newscatcher_catchall/core/datetime_utils.py +70 -0
  8. newscatcher_catchall/core/file.py +67 -0
  9. newscatcher_catchall/core/force_multipart.py +18 -0
  10. newscatcher_catchall/core/http_client.py +839 -0
  11. newscatcher_catchall/core/http_response.py +59 -0
  12. newscatcher_catchall/core/http_sse/__init__.py +42 -0
  13. newscatcher_catchall/core/http_sse/_api.py +170 -0
  14. newscatcher_catchall/core/http_sse/_decoders.py +61 -0
  15. newscatcher_catchall/core/http_sse/_exceptions.py +7 -0
  16. newscatcher_catchall/core/http_sse/_models.py +17 -0
  17. newscatcher_catchall/core/jsonable_encoder.py +120 -0
  18. newscatcher_catchall/core/logging.py +107 -0
  19. newscatcher_catchall/core/parse_error.py +36 -0
  20. newscatcher_catchall/core/pydantic_utilities.py +508 -0
  21. newscatcher_catchall/core/query_encoder.py +58 -0
  22. newscatcher_catchall/core/remove_none_from_dict.py +11 -0
  23. newscatcher_catchall/core/request_options.py +35 -0
  24. newscatcher_catchall/core/serialization.py +347 -0
  25. newscatcher_catchall/datasets/__init__.py +4 -0
  26. newscatcher_catchall/datasets/client.py +1213 -0
  27. newscatcher_catchall/datasets/raw_client.py +1963 -0
  28. newscatcher_catchall/entities/__init__.py +4 -0
  29. newscatcher_catchall/entities/client.py +772 -0
  30. newscatcher_catchall/entities/raw_client.py +1019 -0
  31. newscatcher_catchall/environment.py +7 -0
  32. newscatcher_catchall/errors/__init__.py +44 -0
  33. newscatcher_catchall/errors/bad_request_error.py +10 -0
  34. newscatcher_catchall/errors/forbidden_error.py +11 -0
  35. newscatcher_catchall/errors/not_found_error.py +11 -0
  36. newscatcher_catchall/errors/unauthorized_error.py +11 -0
  37. newscatcher_catchall/errors/unprocessable_entity_error.py +11 -0
  38. newscatcher_catchall/jobs/__init__.py +34 -0
  39. newscatcher_catchall/jobs/client.py +1053 -0
  40. newscatcher_catchall/jobs/raw_client.py +1592 -0
  41. newscatcher_catchall/jobs/types/__init__.py +34 -0
  42. newscatcher_catchall/jobs/types/submit_request_dto_mode.py +5 -0
  43. newscatcher_catchall/meta/__init__.py +34 -0
  44. newscatcher_catchall/meta/client.py +224 -0
  45. newscatcher_catchall/meta/raw_client.py +289 -0
  46. newscatcher_catchall/meta/types/__init__.py +38 -0
  47. newscatcher_catchall/meta/types/get_version_response.py +19 -0
  48. newscatcher_catchall/meta/types/health_check_response.py +19 -0
  49. newscatcher_catchall/monitors/__init__.py +52 -0
  50. newscatcher_catchall/monitors/client.py +1025 -0
  51. newscatcher_catchall/monitors/raw_client.py +1629 -0
  52. newscatcher_catchall/monitors/types/__init__.py +50 -0
  53. newscatcher_catchall/monitors/types/disable_monitor_response.py +32 -0
  54. newscatcher_catchall/monitors/types/enable_monitor_response.py +32 -0
  55. newscatcher_catchall/monitors/types/list_monitor_jobs_request_sort.py +5 -0
  56. newscatcher_catchall/monitors/types/list_monitor_jobs_response.py +39 -0
  57. newscatcher_catchall/monitors/types/list_monitor_jobs_response_sort_order.py +5 -0
  58. newscatcher_catchall/projects/__init__.py +4 -0
  59. newscatcher_catchall/projects/client.py +909 -0
  60. newscatcher_catchall/projects/raw_client.py +1488 -0
  61. newscatcher_catchall/py.typed +0 -0
  62. newscatcher_catchall/types/__init__.py +403 -0
  63. newscatcher_catchall/types/add_resource_response_dto.py +33 -0
  64. newscatcher_catchall/types/additional_attributes.py +24 -0
  65. newscatcher_catchall/types/api_key_auth_dto.py +27 -0
  66. newscatcher_catchall/types/assign_webhook_resource_response_dto.py +38 -0
  67. newscatcher_catchall/types/base_record.py +37 -0
  68. newscatcher_catchall/types/base_record_enrichment.py +31 -0
  69. newscatcher_catchall/types/base_record_enrichment_enrichment_confidence.py +5 -0
  70. newscatcher_catchall/types/basic_auth_dto.py +27 -0
  71. newscatcher_catchall/types/bearer_auth_dto.py +22 -0
  72. newscatcher_catchall/types/citation.py +33 -0
  73. newscatcher_catchall/types/company_attributes.py +43 -0
  74. newscatcher_catchall/types/company_enrichment_output.py +34 -0
  75. newscatcher_catchall/types/company_enrichment_output_metadata.py +35 -0
  76. newscatcher_catchall/types/company_enrichment_output_metadata_domain_url_confidence.py +5 -0
  77. newscatcher_catchall/types/connected_dataset.py +36 -0
  78. newscatcher_catchall/types/connected_entity.py +73 -0
  79. newscatcher_catchall/types/context.py +6 -0
  80. newscatcher_catchall/types/continue_response_dto.py +37 -0
  81. newscatcher_catchall/types/create_dataset_csv_response.py +35 -0
  82. newscatcher_catchall/types/create_entities_batch_response.py +28 -0
  83. newscatcher_catchall/types/create_entity_request.py +42 -0
  84. newscatcher_catchall/types/create_entity_response.py +27 -0
  85. newscatcher_catchall/types/create_monitor_response_dto.py +27 -0
  86. newscatcher_catchall/types/create_project_response_dto.py +37 -0
  87. newscatcher_catchall/types/create_webhook_response_dto.py +33 -0
  88. newscatcher_catchall/types/dataset_entity_ids_request.py +22 -0
  89. newscatcher_catchall/types/dataset_entity_list_response.py +38 -0
  90. newscatcher_catchall/types/dataset_list_response.py +38 -0
  91. newscatcher_catchall/types/dataset_response.py +60 -0
  92. newscatcher_catchall/types/dataset_sort_by.py +5 -0
  93. newscatcher_catchall/types/dataset_status.py +5 -0
  94. newscatcher_catchall/types/dataset_status_entry.py +34 -0
  95. newscatcher_catchall/types/dataset_status_history_response.py +28 -0
  96. newscatcher_catchall/types/delete_job_response_dto.py +32 -0
  97. newscatcher_catchall/types/delete_monitor_response_dto.py +32 -0
  98. newscatcher_catchall/types/delivery_history_item_dto.py +75 -0
  99. newscatcher_catchall/types/delivery_history_response_dto.py +54 -0
  100. newscatcher_catchall/types/delivery_mode.py +5 -0
  101. newscatcher_catchall/types/delivery_status.py +5 -0
  102. newscatcher_catchall/types/end_date.py +12 -0
  103. newscatcher_catchall/types/enrichment_schema.py +36 -0
  104. newscatcher_catchall/types/enrichment_type.py +5 -0
  105. newscatcher_catchall/types/entity_association_type.py +5 -0
  106. newscatcher_catchall/types/entity_list_response.py +38 -0
  107. newscatcher_catchall/types/entity_response.py +64 -0
  108. newscatcher_catchall/types/entity_sort_by.py +5 -0
  109. newscatcher_catchall/types/entity_status.py +5 -0
  110. newscatcher_catchall/types/entity_summary.py +51 -0
  111. newscatcher_catchall/types/entity_type.py +5 -0
  112. newscatcher_catchall/types/entity_validation_error_body.py +39 -0
  113. newscatcher_catchall/types/error.py +22 -0
  114. newscatcher_catchall/types/get_plan_limits_response_dto.py +23 -0
  115. newscatcher_catchall/types/get_webhook_response_dto.py +33 -0
  116. newscatcher_catchall/types/http_method.py +5 -0
  117. newscatcher_catchall/types/initialize_response_dto.py +50 -0
  118. newscatcher_catchall/types/issue_type.py +18 -0
  119. newscatcher_catchall/types/job_step.py +29 -0
  120. newscatcher_catchall/types/limit.py +8 -0
  121. newscatcher_catchall/types/list_monitors_response_dto.py +43 -0
  122. newscatcher_catchall/types/list_user_jobs_response_dto.py +43 -0
  123. newscatcher_catchall/types/list_webhook_resources_response_dto.py +43 -0
  124. newscatcher_catchall/types/list_webhooks_response_dto.py +43 -0
  125. newscatcher_catchall/types/manage_entities_response.py +27 -0
  126. newscatcher_catchall/types/mappable_resource_type.py +5 -0
  127. newscatcher_catchall/types/monitor_citation.py +39 -0
  128. newscatcher_catchall/types/monitor_job_item.py +33 -0
  129. newscatcher_catchall/types/monitor_list_item_dto.py +75 -0
  130. newscatcher_catchall/types/monitor_record.py +41 -0
  131. newscatcher_catchall/types/monitor_status_entry.py +67 -0
  132. newscatcher_catchall/types/monitor_status_entry_status.py +5 -0
  133. newscatcher_catchall/types/monitor_status_history_response_dto.py +43 -0
  134. newscatcher_catchall/types/ownership_filter.py +5 -0
  135. newscatcher_catchall/types/plan_feature.py +42 -0
  136. newscatcher_catchall/types/project_list_response_dto.py +43 -0
  137. newscatcher_catchall/types/project_overview_counts_dto.py +8 -0
  138. newscatcher_catchall/types/project_overview_response_dto.py +28 -0
  139. newscatcher_catchall/types/project_overview_response_dto_overview.py +27 -0
  140. newscatcher_catchall/types/project_resource_dto.py +45 -0
  141. newscatcher_catchall/types/project_resource_list_response_dto.py +43 -0
  142. newscatcher_catchall/types/project_resource_type.py +5 -0
  143. newscatcher_catchall/types/project_response_dto.py +58 -0
  144. newscatcher_catchall/types/project_summary_dto.py +52 -0
  145. newscatcher_catchall/types/public_job_status.py +7 -0
  146. newscatcher_catchall/types/pull_job_response_dto.py +125 -0
  147. newscatcher_catchall/types/pull_job_response_dto_date_range.py +21 -0
  148. newscatcher_catchall/types/pull_job_response_dto_mode.py +5 -0
  149. newscatcher_catchall/types/pull_monitor_response_dto.py +74 -0
  150. newscatcher_catchall/types/pull_monitor_response_dto_run_info.py +32 -0
  151. newscatcher_catchall/types/query.py +8 -0
  152. newscatcher_catchall/types/query_status.py +5 -0
  153. newscatcher_catchall/types/record.py +31 -0
  154. newscatcher_catchall/types/reference_job.py +27 -0
  155. newscatcher_catchall/types/remove_resource_response_dto.py +27 -0
  156. newscatcher_catchall/types/resource_item_dto.py +24 -0
  157. newscatcher_catchall/types/resource_result_dto.py +42 -0
  158. newscatcher_catchall/types/sharing_info.py +40 -0
  159. newscatcher_catchall/types/sharing_info_permission.py +5 -0
  160. newscatcher_catchall/types/skipped_row.py +33 -0
  161. newscatcher_catchall/types/sort_order.py +5 -0
  162. newscatcher_catchall/types/start_date.py +12 -0
  163. newscatcher_catchall/types/status_response_dto.py +34 -0
  164. newscatcher_catchall/types/submit_response_dto.py +22 -0
  165. newscatcher_catchall/types/suggestion.py +37 -0
  166. newscatcher_catchall/types/test_webhook_response_dto.py +37 -0
  167. newscatcher_catchall/types/update_monitor_response_dto.py +27 -0
  168. newscatcher_catchall/types/update_project_response_dto.py +32 -0
  169. newscatcher_catchall/types/update_webhook_response_dto.py +33 -0
  170. newscatcher_catchall/types/upload_csv_to_dataset_response.py +30 -0
  171. newscatcher_catchall/types/user_job.py +55 -0
  172. newscatcher_catchall/types/user_job_mode.py +5 -0
  173. newscatcher_catchall/types/validate_query_response_dto.py +54 -0
  174. newscatcher_catchall/types/validation_error_detail.py +33 -0
  175. newscatcher_catchall/types/validation_error_detail_loc_item.py +5 -0
  176. newscatcher_catchall/types/validation_error_response.py +20 -0
  177. newscatcher_catchall/types/validation_report.py +43 -0
  178. newscatcher_catchall/types/validator_schema.py +38 -0
  179. newscatcher_catchall/types/webhook_dto.py +43 -0
  180. newscatcher_catchall/types/webhook_dto_method.py +5 -0
  181. newscatcher_catchall/types/webhook_payload.py +70 -0
  182. newscatcher_catchall/types/webhook_resource_mapping_response_dto.py +43 -0
  183. newscatcher_catchall/types/webhook_response_dto.py +79 -0
  184. newscatcher_catchall/types/webhook_type.py +5 -0
  185. newscatcher_catchall/version.py +3 -0
  186. newscatcher_catchall/webhooks/__init__.py +61 -0
  187. newscatcher_catchall/webhooks/client.py +1336 -0
  188. newscatcher_catchall/webhooks/raw_client.py +2127 -0
  189. newscatcher_catchall/webhooks/types/__init__.py +63 -0
  190. newscatcher_catchall/webhooks/types/create_webhook_request_dto_auth.py +82 -0
  191. newscatcher_catchall/webhooks/types/update_webhook_request_dto_auth.py +73 -0
  192. newscatcher_catchall_sdk-0.0.0.dev0.dist-info/LICENSE +21 -0
  193. newscatcher_catchall_sdk-0.0.0.dev0.dist-info/METADATA +255 -0
  194. newscatcher_catchall_sdk-0.0.0.dev0.dist-info/RECORD +195 -0
  195. newscatcher_catchall_sdk-0.0.0.dev0.dist-info/WHEEL +4 -0
@@ -0,0 +1,326 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from __future__ import annotations
4
+
5
+ import typing
6
+
7
+ import httpx
8
+ from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+ from .core.logging import LogConfig, Logger
10
+ from .environment import CatchAllApiEnvironment
11
+
12
+ if typing.TYPE_CHECKING:
13
+ from .datasets.client import AsyncDatasetsClient, DatasetsClient
14
+ from .entities.client import AsyncEntitiesClient, EntitiesClient
15
+ from .jobs.client import AsyncJobsClient, JobsClient
16
+ from .meta.client import AsyncMetaClient, MetaClient
17
+ from .monitors.client import AsyncMonitorsClient, MonitorsClient
18
+ from .projects.client import AsyncProjectsClient, ProjectsClient
19
+ from .webhooks.client import AsyncWebhooksClient, WebhooksClient
20
+
21
+
22
+ class CatchAllApi:
23
+ """
24
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
25
+
26
+ Parameters
27
+ ----------
28
+ base_url : typing.Optional[str]
29
+ The base url to use for requests from the client.
30
+
31
+ environment : CatchAllApiEnvironment
32
+ The environment to use for requests from the client. from .environment import CatchAllApiEnvironment
33
+
34
+
35
+
36
+ Defaults to CatchAllApiEnvironment.DEFAULT
37
+
38
+
39
+
40
+ api_key : str
41
+ headers : typing.Optional[typing.Dict[str, str]]
42
+ Additional headers to send with every request.
43
+
44
+ timeout : typing.Optional[float]
45
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
46
+
47
+ max_retries : typing.Optional[int]
48
+ The default maximum number of retries for failed requests. Defaults to 2. Per-request `max_retries` in `request_options` takes precedence over this value.
49
+
50
+ follow_redirects : typing.Optional[bool]
51
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
52
+
53
+ httpx_client : typing.Optional[httpx.Client]
54
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
55
+
56
+ logging : typing.Optional[typing.Union[LogConfig, Logger]]
57
+ Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.
58
+
59
+ Examples
60
+ --------
61
+ from newscatcher_catchall import CatchAllApi
62
+
63
+ client = CatchAllApi(
64
+ api_key="YOUR_API_KEY",
65
+ )
66
+ """
67
+
68
+ def __init__(
69
+ self,
70
+ *,
71
+ base_url: typing.Optional[str] = None,
72
+ environment: CatchAllApiEnvironment = CatchAllApiEnvironment.DEFAULT,
73
+ api_key: str,
74
+ headers: typing.Optional[typing.Dict[str, str]] = None,
75
+ timeout: typing.Optional[float] = None,
76
+ max_retries: typing.Optional[int] = None,
77
+ follow_redirects: typing.Optional[bool] = True,
78
+ httpx_client: typing.Optional[httpx.Client] = None,
79
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
80
+ ):
81
+ _defaulted_timeout = (
82
+ timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
83
+ )
84
+ _defaulted_max_retries = max_retries if max_retries is not None else 2
85
+ self._client_wrapper = SyncClientWrapper(
86
+ base_url=_get_base_url(base_url=base_url, environment=environment),
87
+ api_key=api_key,
88
+ headers=headers,
89
+ httpx_client=httpx_client
90
+ if httpx_client is not None
91
+ else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
92
+ if follow_redirects is not None
93
+ else httpx.Client(timeout=_defaulted_timeout),
94
+ timeout=_defaulted_timeout,
95
+ max_retries=_defaulted_max_retries,
96
+ logging=logging,
97
+ )
98
+ self._jobs: typing.Optional[JobsClient] = None
99
+ self._monitors: typing.Optional[MonitorsClient] = None
100
+ self._webhooks: typing.Optional[WebhooksClient] = None
101
+ self._entities: typing.Optional[EntitiesClient] = None
102
+ self._datasets: typing.Optional[DatasetsClient] = None
103
+ self._projects: typing.Optional[ProjectsClient] = None
104
+ self._meta: typing.Optional[MetaClient] = None
105
+
106
+ @property
107
+ def jobs(self):
108
+ if self._jobs is None:
109
+ from .jobs.client import JobsClient # noqa: E402
110
+
111
+ self._jobs = JobsClient(client_wrapper=self._client_wrapper)
112
+ return self._jobs
113
+
114
+ @property
115
+ def monitors(self):
116
+ if self._monitors is None:
117
+ from .monitors.client import MonitorsClient # noqa: E402
118
+
119
+ self._monitors = MonitorsClient(client_wrapper=self._client_wrapper)
120
+ return self._monitors
121
+
122
+ @property
123
+ def webhooks(self):
124
+ if self._webhooks is None:
125
+ from .webhooks.client import WebhooksClient # noqa: E402
126
+
127
+ self._webhooks = WebhooksClient(client_wrapper=self._client_wrapper)
128
+ return self._webhooks
129
+
130
+ @property
131
+ def entities(self):
132
+ if self._entities is None:
133
+ from .entities.client import EntitiesClient # noqa: E402
134
+
135
+ self._entities = EntitiesClient(client_wrapper=self._client_wrapper)
136
+ return self._entities
137
+
138
+ @property
139
+ def datasets(self):
140
+ if self._datasets is None:
141
+ from .datasets.client import DatasetsClient # noqa: E402
142
+
143
+ self._datasets = DatasetsClient(client_wrapper=self._client_wrapper)
144
+ return self._datasets
145
+
146
+ @property
147
+ def projects(self):
148
+ if self._projects is None:
149
+ from .projects.client import ProjectsClient # noqa: E402
150
+
151
+ self._projects = ProjectsClient(client_wrapper=self._client_wrapper)
152
+ return self._projects
153
+
154
+ @property
155
+ def meta(self):
156
+ if self._meta is None:
157
+ from .meta.client import MetaClient # noqa: E402
158
+
159
+ self._meta = MetaClient(client_wrapper=self._client_wrapper)
160
+ return self._meta
161
+
162
+
163
+ def _make_default_async_client(
164
+ timeout: typing.Optional[float],
165
+ follow_redirects: typing.Optional[bool],
166
+ ) -> httpx.AsyncClient:
167
+ try:
168
+ import httpx_aiohttp # type: ignore[import-not-found]
169
+ except ImportError:
170
+ pass
171
+ else:
172
+ if follow_redirects is not None:
173
+ return httpx_aiohttp.HttpxAiohttpClient(timeout=timeout, follow_redirects=follow_redirects)
174
+ return httpx_aiohttp.HttpxAiohttpClient(timeout=timeout)
175
+
176
+ if follow_redirects is not None:
177
+ return httpx.AsyncClient(timeout=timeout, follow_redirects=follow_redirects)
178
+ return httpx.AsyncClient(timeout=timeout)
179
+
180
+
181
+ class AsyncCatchAllApi:
182
+ """
183
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
184
+
185
+ Parameters
186
+ ----------
187
+ base_url : typing.Optional[str]
188
+ The base url to use for requests from the client.
189
+
190
+ environment : CatchAllApiEnvironment
191
+ The environment to use for requests from the client. from .environment import CatchAllApiEnvironment
192
+
193
+
194
+
195
+ Defaults to CatchAllApiEnvironment.DEFAULT
196
+
197
+
198
+
199
+ api_key : str
200
+ headers : typing.Optional[typing.Dict[str, str]]
201
+ Additional headers to send with every request.
202
+
203
+ timeout : typing.Optional[float]
204
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
205
+
206
+ max_retries : typing.Optional[int]
207
+ The default maximum number of retries for failed requests. Defaults to 2. Per-request `max_retries` in `request_options` takes precedence over this value.
208
+
209
+ follow_redirects : typing.Optional[bool]
210
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
211
+
212
+ httpx_client : typing.Optional[httpx.AsyncClient]
213
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
214
+
215
+ logging : typing.Optional[typing.Union[LogConfig, Logger]]
216
+ Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.
217
+
218
+ Examples
219
+ --------
220
+ from newscatcher_catchall import AsyncCatchAllApi
221
+
222
+ client = AsyncCatchAllApi(
223
+ api_key="YOUR_API_KEY",
224
+ )
225
+ """
226
+
227
+ def __init__(
228
+ self,
229
+ *,
230
+ base_url: typing.Optional[str] = None,
231
+ environment: CatchAllApiEnvironment = CatchAllApiEnvironment.DEFAULT,
232
+ api_key: str,
233
+ headers: typing.Optional[typing.Dict[str, str]] = None,
234
+ timeout: typing.Optional[float] = None,
235
+ max_retries: typing.Optional[int] = None,
236
+ follow_redirects: typing.Optional[bool] = True,
237
+ httpx_client: typing.Optional[httpx.AsyncClient] = None,
238
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
239
+ ):
240
+ _defaulted_timeout = (
241
+ timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
242
+ )
243
+ _defaulted_max_retries = max_retries if max_retries is not None else 2
244
+ self._client_wrapper = AsyncClientWrapper(
245
+ base_url=_get_base_url(base_url=base_url, environment=environment),
246
+ api_key=api_key,
247
+ headers=headers,
248
+ httpx_client=httpx_client
249
+ if httpx_client is not None
250
+ else _make_default_async_client(timeout=_defaulted_timeout, follow_redirects=follow_redirects),
251
+ timeout=_defaulted_timeout,
252
+ max_retries=_defaulted_max_retries,
253
+ logging=logging,
254
+ )
255
+ self._jobs: typing.Optional[AsyncJobsClient] = None
256
+ self._monitors: typing.Optional[AsyncMonitorsClient] = None
257
+ self._webhooks: typing.Optional[AsyncWebhooksClient] = None
258
+ self._entities: typing.Optional[AsyncEntitiesClient] = None
259
+ self._datasets: typing.Optional[AsyncDatasetsClient] = None
260
+ self._projects: typing.Optional[AsyncProjectsClient] = None
261
+ self._meta: typing.Optional[AsyncMetaClient] = None
262
+
263
+ @property
264
+ def jobs(self):
265
+ if self._jobs is None:
266
+ from .jobs.client import AsyncJobsClient # noqa: E402
267
+
268
+ self._jobs = AsyncJobsClient(client_wrapper=self._client_wrapper)
269
+ return self._jobs
270
+
271
+ @property
272
+ def monitors(self):
273
+ if self._monitors is None:
274
+ from .monitors.client import AsyncMonitorsClient # noqa: E402
275
+
276
+ self._monitors = AsyncMonitorsClient(client_wrapper=self._client_wrapper)
277
+ return self._monitors
278
+
279
+ @property
280
+ def webhooks(self):
281
+ if self._webhooks is None:
282
+ from .webhooks.client import AsyncWebhooksClient # noqa: E402
283
+
284
+ self._webhooks = AsyncWebhooksClient(client_wrapper=self._client_wrapper)
285
+ return self._webhooks
286
+
287
+ @property
288
+ def entities(self):
289
+ if self._entities is None:
290
+ from .entities.client import AsyncEntitiesClient # noqa: E402
291
+
292
+ self._entities = AsyncEntitiesClient(client_wrapper=self._client_wrapper)
293
+ return self._entities
294
+
295
+ @property
296
+ def datasets(self):
297
+ if self._datasets is None:
298
+ from .datasets.client import AsyncDatasetsClient # noqa: E402
299
+
300
+ self._datasets = AsyncDatasetsClient(client_wrapper=self._client_wrapper)
301
+ return self._datasets
302
+
303
+ @property
304
+ def projects(self):
305
+ if self._projects is None:
306
+ from .projects.client import AsyncProjectsClient # noqa: E402
307
+
308
+ self._projects = AsyncProjectsClient(client_wrapper=self._client_wrapper)
309
+ return self._projects
310
+
311
+ @property
312
+ def meta(self):
313
+ if self._meta is None:
314
+ from .meta.client import AsyncMetaClient # noqa: E402
315
+
316
+ self._meta = AsyncMetaClient(client_wrapper=self._client_wrapper)
317
+ return self._meta
318
+
319
+
320
+ def _get_base_url(*, base_url: typing.Optional[str] = None, environment: CatchAllApiEnvironment) -> str:
321
+ if base_url is not None:
322
+ return base_url
323
+ elif environment is not None:
324
+ return environment.value
325
+ else:
326
+ raise Exception("Please pass in either base_url or environment to construct the client")
@@ -0,0 +1,127 @@
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_error import ApiError
10
+ from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
11
+ from .datetime_utils import Rfc2822DateTime, parse_rfc2822_datetime, serialize_datetime
12
+ from .file import File, convert_file_dict_to_httpx_tuples, with_content_type
13
+ from .http_client import AsyncHttpClient, HttpClient
14
+ from .http_response import AsyncHttpResponse, HttpResponse
15
+ from .jsonable_encoder import encode_path_param, jsonable_encoder
16
+ from .logging import ConsoleLogger, ILogger, LogConfig, LogLevel, Logger, create_logger
17
+ from .parse_error import ParsingError
18
+ from .pydantic_utilities import (
19
+ IS_PYDANTIC_V2,
20
+ UniversalBaseModel,
21
+ UniversalRootModel,
22
+ parse_obj_as,
23
+ universal_field_validator,
24
+ universal_root_validator,
25
+ update_forward_refs,
26
+ )
27
+ from .query_encoder import encode_query
28
+ from .remove_none_from_dict import remove_none_from_dict
29
+ from .request_options import RequestOptions
30
+ from .serialization import FieldMetadata, convert_and_respect_annotation_metadata
31
+ _dynamic_imports: typing.Dict[str, str] = {
32
+ "ApiError": ".api_error",
33
+ "AsyncClientWrapper": ".client_wrapper",
34
+ "AsyncHttpClient": ".http_client",
35
+ "AsyncHttpResponse": ".http_response",
36
+ "BaseClientWrapper": ".client_wrapper",
37
+ "ConsoleLogger": ".logging",
38
+ "FieldMetadata": ".serialization",
39
+ "File": ".file",
40
+ "HttpClient": ".http_client",
41
+ "HttpResponse": ".http_response",
42
+ "ILogger": ".logging",
43
+ "IS_PYDANTIC_V2": ".pydantic_utilities",
44
+ "LogConfig": ".logging",
45
+ "LogLevel": ".logging",
46
+ "Logger": ".logging",
47
+ "ParsingError": ".parse_error",
48
+ "RequestOptions": ".request_options",
49
+ "Rfc2822DateTime": ".datetime_utils",
50
+ "SyncClientWrapper": ".client_wrapper",
51
+ "UniversalBaseModel": ".pydantic_utilities",
52
+ "UniversalRootModel": ".pydantic_utilities",
53
+ "convert_and_respect_annotation_metadata": ".serialization",
54
+ "convert_file_dict_to_httpx_tuples": ".file",
55
+ "create_logger": ".logging",
56
+ "encode_path_param": ".jsonable_encoder",
57
+ "encode_query": ".query_encoder",
58
+ "jsonable_encoder": ".jsonable_encoder",
59
+ "parse_obj_as": ".pydantic_utilities",
60
+ "parse_rfc2822_datetime": ".datetime_utils",
61
+ "remove_none_from_dict": ".remove_none_from_dict",
62
+ "serialize_datetime": ".datetime_utils",
63
+ "universal_field_validator": ".pydantic_utilities",
64
+ "universal_root_validator": ".pydantic_utilities",
65
+ "update_forward_refs": ".pydantic_utilities",
66
+ "with_content_type": ".file",
67
+ }
68
+
69
+
70
+ def __getattr__(attr_name: str) -> typing.Any:
71
+ module_name = _dynamic_imports.get(attr_name)
72
+ if module_name is None:
73
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
74
+ try:
75
+ module = import_module(module_name, __package__)
76
+ if module_name == f".{attr_name}":
77
+ return module
78
+ else:
79
+ return getattr(module, attr_name)
80
+ except ImportError as e:
81
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
82
+ except AttributeError as e:
83
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
84
+
85
+
86
+ def __dir__():
87
+ lazy_attrs = list(_dynamic_imports.keys())
88
+ return sorted(lazy_attrs)
89
+
90
+
91
+ __all__ = [
92
+ "ApiError",
93
+ "AsyncClientWrapper",
94
+ "AsyncHttpClient",
95
+ "AsyncHttpResponse",
96
+ "BaseClientWrapper",
97
+ "ConsoleLogger",
98
+ "FieldMetadata",
99
+ "File",
100
+ "HttpClient",
101
+ "HttpResponse",
102
+ "ILogger",
103
+ "IS_PYDANTIC_V2",
104
+ "LogConfig",
105
+ "LogLevel",
106
+ "Logger",
107
+ "ParsingError",
108
+ "RequestOptions",
109
+ "Rfc2822DateTime",
110
+ "SyncClientWrapper",
111
+ "UniversalBaseModel",
112
+ "UniversalRootModel",
113
+ "convert_and_respect_annotation_metadata",
114
+ "convert_file_dict_to_httpx_tuples",
115
+ "create_logger",
116
+ "encode_path_param",
117
+ "encode_query",
118
+ "jsonable_encoder",
119
+ "parse_obj_as",
120
+ "parse_rfc2822_datetime",
121
+ "remove_none_from_dict",
122
+ "serialize_datetime",
123
+ "universal_field_validator",
124
+ "universal_root_validator",
125
+ "update_forward_refs",
126
+ "with_content_type",
127
+ ]
@@ -0,0 +1,23 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from typing import Any, Dict, Optional
4
+
5
+
6
+ class ApiError(Exception):
7
+ headers: Optional[Dict[str, str]]
8
+ status_code: Optional[int]
9
+ body: Any
10
+
11
+ def __init__(
12
+ self,
13
+ *,
14
+ headers: Optional[Dict[str, str]] = None,
15
+ status_code: Optional[int] = None,
16
+ body: Any = None,
17
+ ) -> None:
18
+ self.headers = headers
19
+ self.status_code = status_code
20
+ self.body = body
21
+
22
+ def __str__(self) -> str:
23
+ return f"headers: {self.headers}, status_code: {self.status_code}, body: {self.body}"
@@ -0,0 +1,123 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import httpx
6
+ from .http_client import AsyncHttpClient, HttpClient
7
+ from .logging import LogConfig, Logger
8
+
9
+
10
+ class BaseClientWrapper:
11
+ def __init__(
12
+ self,
13
+ *,
14
+ api_key: str,
15
+ headers: typing.Optional[typing.Dict[str, str]] = None,
16
+ base_url: str,
17
+ timeout: typing.Optional[float] = None,
18
+ max_retries: int = 2,
19
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
20
+ ):
21
+ self.api_key = api_key
22
+ self._headers = headers
23
+ self._base_url = base_url
24
+ self._timeout = timeout
25
+ self._max_retries = max_retries
26
+ self._logging = logging
27
+
28
+ def get_headers(self) -> typing.Dict[str, str]:
29
+ import platform
30
+
31
+ headers: typing.Dict[str, str] = {
32
+ "User-Agent": "newscatcher-catchall-sdk/0.0.0.dev0",
33
+ "X-Fern-Language": "Python",
34
+ "X-Fern-Runtime": f"python/{platform.python_version()}",
35
+ "X-Fern-Platform": f"{platform.system().lower()}/{platform.release()}",
36
+ "X-Fern-SDK-Name": "newscatcher-catchall-sdk",
37
+ "X-Fern-SDK-Version": "0.0.0.dev0",
38
+ **(self.get_custom_headers() or {}),
39
+ }
40
+ headers["x-api-key"] = self.api_key
41
+ return headers
42
+
43
+ def get_custom_headers(self) -> typing.Optional[typing.Dict[str, str]]:
44
+ return self._headers
45
+
46
+ def get_base_url(self) -> str:
47
+ return self._base_url
48
+
49
+ def get_timeout(self) -> typing.Optional[float]:
50
+ return self._timeout
51
+
52
+ def get_max_retries(self) -> int:
53
+ return self._max_retries
54
+
55
+
56
+ class SyncClientWrapper(BaseClientWrapper):
57
+ def __init__(
58
+ self,
59
+ *,
60
+ api_key: str,
61
+ headers: typing.Optional[typing.Dict[str, str]] = None,
62
+ base_url: str,
63
+ timeout: typing.Optional[float] = None,
64
+ max_retries: int = 2,
65
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
66
+ httpx_client: httpx.Client,
67
+ ):
68
+ super().__init__(
69
+ api_key=api_key,
70
+ headers=headers,
71
+ base_url=base_url,
72
+ timeout=timeout,
73
+ max_retries=max_retries,
74
+ logging=logging,
75
+ )
76
+ self.httpx_client = HttpClient(
77
+ httpx_client=httpx_client,
78
+ base_headers=self.get_headers,
79
+ base_timeout=self.get_timeout,
80
+ base_url=self.get_base_url,
81
+ base_max_retries=self.get_max_retries(),
82
+ logging_config=self._logging,
83
+ )
84
+
85
+
86
+ class AsyncClientWrapper(BaseClientWrapper):
87
+ def __init__(
88
+ self,
89
+ *,
90
+ api_key: str,
91
+ headers: typing.Optional[typing.Dict[str, str]] = None,
92
+ base_url: str,
93
+ timeout: typing.Optional[float] = None,
94
+ max_retries: int = 2,
95
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
96
+ async_token: typing.Optional[typing.Callable[[], typing.Awaitable[str]]] = None,
97
+ httpx_client: httpx.AsyncClient,
98
+ ):
99
+ super().__init__(
100
+ api_key=api_key,
101
+ headers=headers,
102
+ base_url=base_url,
103
+ timeout=timeout,
104
+ max_retries=max_retries,
105
+ logging=logging,
106
+ )
107
+ self._async_token = async_token
108
+ self.httpx_client = AsyncHttpClient(
109
+ httpx_client=httpx_client,
110
+ base_headers=self.get_headers,
111
+ base_timeout=self.get_timeout,
112
+ base_url=self.get_base_url,
113
+ base_max_retries=self.get_max_retries(),
114
+ async_base_headers=self.async_get_headers,
115
+ logging_config=self._logging,
116
+ )
117
+
118
+ async def async_get_headers(self) -> typing.Dict[str, str]:
119
+ headers = self.get_headers()
120
+ if self._async_token is not None:
121
+ token = await self._async_token()
122
+ headers["Authorization"] = f"Bearer {token}"
123
+ return headers
@@ -0,0 +1,70 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ from email.utils import parsedate_to_datetime
5
+ from typing import Any
6
+
7
+ import pydantic
8
+
9
+ IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.")
10
+
11
+
12
+ def parse_rfc2822_datetime(v: Any) -> dt.datetime:
13
+ """
14
+ Parse an RFC 2822 datetime string (e.g., "Wed, 02 Oct 2002 13:00:00 GMT")
15
+ into a datetime object. If the value is already a datetime, return it as-is.
16
+ Falls back to ISO 8601 parsing if RFC 2822 parsing fails.
17
+ """
18
+ if isinstance(v, dt.datetime):
19
+ return v
20
+ if isinstance(v, str):
21
+ try:
22
+ return parsedate_to_datetime(v)
23
+ except Exception:
24
+ pass
25
+ # Fallback to ISO 8601 parsing
26
+ return dt.datetime.fromisoformat(v.replace("Z", "+00:00"))
27
+ raise ValueError(f"Expected str or datetime, got {type(v)}")
28
+
29
+
30
+ class Rfc2822DateTime(dt.datetime):
31
+ """A datetime subclass that parses RFC 2822 date strings.
32
+
33
+ On Pydantic V1, uses __get_validators__ for pre-validation.
34
+ On Pydantic V2, uses __get_pydantic_core_schema__ for BeforeValidator-style parsing.
35
+ """
36
+
37
+ @classmethod
38
+ def __get_validators__(cls): # type: ignore[no-untyped-def]
39
+ yield parse_rfc2822_datetime
40
+
41
+ @classmethod
42
+ def __get_pydantic_core_schema__(cls, _source_type: Any, _handler: Any) -> Any: # type: ignore[override]
43
+ from pydantic_core import core_schema
44
+
45
+ return core_schema.no_info_before_validator_function(parse_rfc2822_datetime, core_schema.datetime_schema())
46
+
47
+
48
+ def serialize_datetime(v: dt.datetime) -> str:
49
+ """
50
+ Serialize a datetime including timezone info.
51
+
52
+ Uses the timezone info provided if present, otherwise uses the current runtime's timezone info.
53
+
54
+ UTC datetimes end in "Z" while all other timezones are represented as offset from UTC, e.g. +05:00.
55
+ """
56
+
57
+ def _serialize_zoned_datetime(v: dt.datetime) -> str:
58
+ if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname(None):
59
+ # UTC is a special case where we use "Z" at the end instead of "+00:00"
60
+ return v.isoformat().replace("+00:00", "Z")
61
+ else:
62
+ # Delegate to the typical +/- offset format
63
+ return v.isoformat()
64
+
65
+ if v.tzinfo is not None:
66
+ return _serialize_zoned_datetime(v)
67
+ else:
68
+ local_tz = dt.datetime.now().astimezone().tzinfo
69
+ localized_dt = v.replace(tzinfo=local_tz)
70
+ return _serialize_zoned_datetime(localized_dt)