brellium-api-client 0.2.0__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 (89) hide show
  1. brellium_api_client/__init__.py +98 -0
  2. brellium_api_client/_base_client.py +2904 -0
  3. brellium_api_client/_client.py +721 -0
  4. brellium_api_client/_compat.py +195 -0
  5. brellium_api_client/_constants.py +14 -0
  6. brellium_api_client/_decoding.py +187 -0
  7. brellium_api_client/_event_handler.py +85 -0
  8. brellium_api_client/_exceptions.py +126 -0
  9. brellium_api_client/_files.py +173 -0
  10. brellium_api_client/_models.py +965 -0
  11. brellium_api_client/_qs.py +147 -0
  12. brellium_api_client/_resource.py +43 -0
  13. brellium_api_client/_response.py +842 -0
  14. brellium_api_client/_send_queue.py +90 -0
  15. brellium_api_client/_streaming.py +412 -0
  16. brellium_api_client/_types.py +279 -0
  17. brellium_api_client/_utils/__init__.py +64 -0
  18. brellium_api_client/_utils/_compat.py +45 -0
  19. brellium_api_client/_utils/_datetime_parse.py +156 -0
  20. brellium_api_client/_utils/_json.py +35 -0
  21. brellium_api_client/_utils/_logs.py +356 -0
  22. brellium_api_client/_utils/_path.py +127 -0
  23. brellium_api_client/_utils/_proxy.py +65 -0
  24. brellium_api_client/_utils/_reflection.py +42 -0
  25. brellium_api_client/_utils/_resources_proxy.py +24 -0
  26. brellium_api_client/_utils/_streams.py +12 -0
  27. brellium_api_client/_utils/_sync.py +58 -0
  28. brellium_api_client/_utils/_transform.py +472 -0
  29. brellium_api_client/_utils/_typing.py +156 -0
  30. brellium_api_client/_utils/_utils.py +428 -0
  31. brellium_api_client/_version.py +4 -0
  32. brellium_api_client/py.typed +0 -0
  33. brellium_api_client/resources/__init__.py +89 -0
  34. brellium_api_client/resources/audits.py +597 -0
  35. brellium_api_client/resources/coding_evaluations.py +354 -0
  36. brellium_api_client/resources/documents.py +654 -0
  37. brellium_api_client/resources/email_recipients.py +718 -0
  38. brellium_api_client/resources/question_sets.py +313 -0
  39. brellium_api_client/resources/users.py +852 -0
  40. brellium_api_client/types/__init__.py +49 -0
  41. brellium_api_client/types/audit.py +56 -0
  42. brellium_api_client/types/audit_batch_result.py +59 -0
  43. brellium_api_client/types/audit_batch_update_flags_params.py +22 -0
  44. brellium_api_client/types/audit_display_info_item.py +21 -0
  45. brellium_api_client/types/audit_list.py +26 -0
  46. brellium_api_client/types/audit_list_params.py +56 -0
  47. brellium_api_client/types/audit_person.py +23 -0
  48. brellium_api_client/types/audit_response.py +32 -0
  49. brellium_api_client/types/audit_update_params.py +13 -0
  50. brellium_api_client/types/coding_evaluation.py +54 -0
  51. brellium_api_client/types/coding_evaluation_list.py +26 -0
  52. brellium_api_client/types/coding_evaluation_list_params.py +50 -0
  53. brellium_api_client/types/created_user.py +13 -0
  54. brellium_api_client/types/document.py +64 -0
  55. brellium_api_client/types/document_create_params.py +32 -0
  56. brellium_api_client/types/document_list.py +26 -0
  57. brellium_api_client/types/document_list_params.py +50 -0
  58. brellium_api_client/types/document_update_params.py +16 -0
  59. brellium_api_client/types/document_upload_list.py +26 -0
  60. brellium_api_client/types/document_with_upload.py +15 -0
  61. brellium_api_client/types/em_evaluation.py +85 -0
  62. brellium_api_client/types/email_recipient.py +37 -0
  63. brellium_api_client/types/email_recipient_create_params.py +22 -0
  64. brellium_api_client/types/email_recipient_list.py +26 -0
  65. brellium_api_client/types/email_recipient_list_params.py +38 -0
  66. brellium_api_client/types/email_recipient_update_params.py +22 -0
  67. brellium_api_client/types/icd_code_finding.py +22 -0
  68. brellium_api_client/types/icd_criterion.py +21 -0
  69. brellium_api_client/types/icd_evaluation.py +32 -0
  70. brellium_api_client/types/mdm_data.py +18 -0
  71. brellium_api_client/types/mdm_problem.py +18 -0
  72. brellium_api_client/types/mdm_risk.py +18 -0
  73. brellium_api_client/types/presigned_upload.py +25 -0
  74. brellium_api_client/types/question.py +33 -0
  75. brellium_api_client/types/question_set.py +42 -0
  76. brellium_api_client/types/question_set_list.py +26 -0
  77. brellium_api_client/types/question_set_list_params.py +29 -0
  78. brellium_api_client/types/user.py +37 -0
  79. brellium_api_client/types/user_batch_result.py +59 -0
  80. brellium_api_client/types/user_batch_update_params.py +27 -0
  81. brellium_api_client/types/user_create_params.py +19 -0
  82. brellium_api_client/types/user_invitation.py +17 -0
  83. brellium_api_client/types/user_list.py +26 -0
  84. brellium_api_client/types/user_list_params.py +38 -0
  85. brellium_api_client/types/user_update_params.py +19 -0
  86. brellium_api_client-0.2.0.dist-info/METADATA +183 -0
  87. brellium_api_client-0.2.0.dist-info/RECORD +89 -0
  88. brellium_api_client-0.2.0.dist-info/WHEEL +4 -0
  89. brellium_api_client-0.2.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,721 @@
1
+ # File generated from our OpenAPI spec by Scalar. See README.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import threading
7
+ from typing import TYPE_CHECKING, Any, Mapping
8
+ from typing_extensions import Self, override
9
+
10
+ import httpx
11
+
12
+ from . import _exceptions
13
+ from ._qs import Querystring
14
+ from ._types import (
15
+ Omit,
16
+ Headers,
17
+ Timeout,
18
+ NotGiven,
19
+ Transport,
20
+ ProxiesTypes,
21
+ RequestOptions,
22
+ not_given,
23
+ )
24
+ from ._utils import is_given, is_mapping_t, get_async_library
25
+ from ._compat import cached_property
26
+ from ._exceptions import APIStatusError, BrelliumClientError
27
+ from ._models import SecurityOptions
28
+ from ._base_client import (
29
+ DEFAULT_MAX_RETRIES,
30
+ AuthLocations,
31
+ SchemeCredentials,
32
+ SyncAPIClient,
33
+ AsyncAPIClient,
34
+ )
35
+ from ._streaming import Stream as Stream, AsyncStream as AsyncStream
36
+ from ._version import __version__
37
+
38
+ if TYPE_CHECKING:
39
+ from .resources import documents, audits, coding_evaluations, users, question_sets, email_recipients
40
+ from .resources.documents import DocumentsResource, AsyncDocumentsResource
41
+ from .resources.audits import AuditsResource, AsyncAuditsResource
42
+ from .resources.coding_evaluations import CodingEvaluationsResource, AsyncCodingEvaluationsResource
43
+ from .resources.users import UsersResource, AsyncUsersResource
44
+ from .resources.question_sets import QuestionSetsResource, AsyncQuestionSetsResource
45
+ from .resources.email_recipients import EmailRecipientsResource, AsyncEmailRecipientsResource
46
+
47
+ # Serializes lazy resource imports so concurrent cold access from multiple
48
+ # threads cannot deadlock on CPython import locks (see CPython 3.14).
49
+ _RESOURCE_IMPORT_LOCK = threading.RLock()
50
+
51
+ __all__ = [
52
+ "BrelliumClient",
53
+ "AsyncBrelliumClient",
54
+ "Client",
55
+ "AsyncClient",
56
+ "Timeout",
57
+ "Transport",
58
+ "ProxiesTypes",
59
+ "RequestOptions",
60
+ ]
61
+
62
+
63
+ class BrelliumClient(SyncAPIClient):
64
+ # client options
65
+ o_auth2: str
66
+
67
+ def __init__(
68
+ self,
69
+ *,
70
+ o_auth2: str | None = None,
71
+ base_url: str | httpx.URL | None = None,
72
+ timeout: float | Timeout | None | NotGiven = not_given,
73
+ max_retries: int = DEFAULT_MAX_RETRIES,
74
+ default_headers: Mapping[str, str] | None = None,
75
+ default_query: Mapping[str, object] | None = None,
76
+ # Configure a custom httpx client.
77
+ # We provide a `DefaultHttpxClient` class that you can pass to retain the default values we use for `limits` & `timeout`.
78
+ # The SDK follows redirects itself, whatever the client's `follow_redirects` says.
79
+ # See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
80
+ http_client: httpx.Client | None = None,
81
+ # Enable or disable schema validation for data returned by the API.
82
+ # When enabled an error APIResponseValidationError is raised
83
+ # if the API responds with invalid data for the expected schema.
84
+ #
85
+ # This parameter may be removed or changed in the future.
86
+ # If you rely on this feature, please open a GitHub issue
87
+ # outlining your use-case to help us decide if it should be
88
+ # part of our public interface in the future.
89
+ _strict_response_validation: bool = False,
90
+ ) -> None:
91
+ """Construct a new synchronous BrelliumClient client instance.
92
+
93
+ This automatically infers the following arguments from their corresponding environment variables if they are not provided:
94
+ - `o_auth2` from `BRELLIUM_ACCESS_TOKEN`
95
+ """
96
+ if o_auth2 is None:
97
+ o_auth2 = os.environ.get("BRELLIUM_ACCESS_TOKEN")
98
+ if o_auth2 is None:
99
+ raise BrelliumClientError(
100
+ "The o_auth2 client option must be set either by passing o_auth2 to the client or by setting the BRELLIUM_ACCESS_TOKEN environment variable"
101
+ )
102
+ self.o_auth2 = o_auth2
103
+ if base_url is None:
104
+ base_url = os.environ.get("BRELLIUM_BASE_URL")
105
+ if base_url is None:
106
+ base_url = "https://api.brellium.dev"
107
+ custom_headers_env = os.environ.get("BRELLIUM_CUSTOM_HEADERS")
108
+ if custom_headers_env is not None:
109
+ parsed: dict[str, str] = {}
110
+ for line in custom_headers_env.split("\n"):
111
+ colon = line.find(":")
112
+ if colon >= 0:
113
+ parsed[line[:colon].strip()] = line[colon + 1 :].strip()
114
+ default_headers = {**parsed, **(default_headers if is_mapping_t(default_headers) else {})}
115
+ super().__init__(
116
+ version=__version__,
117
+ base_url=base_url,
118
+ max_retries=max_retries,
119
+ timeout=timeout,
120
+ http_client=http_client,
121
+ custom_headers=default_headers,
122
+ custom_query=default_query,
123
+ _strict_response_validation=_strict_response_validation,
124
+ )
125
+ self._idempotency_header = None
126
+ self._default_stream_cls = Stream
127
+
128
+ @cached_property
129
+ def documents(self) -> "DocumentsResource":
130
+ with _RESOURCE_IMPORT_LOCK:
131
+ from .resources.documents import DocumentsResource
132
+ return DocumentsResource(self)
133
+
134
+ @cached_property
135
+ def audits(self) -> "AuditsResource":
136
+ with _RESOURCE_IMPORT_LOCK:
137
+ from .resources.audits import AuditsResource
138
+ return AuditsResource(self)
139
+
140
+ @cached_property
141
+ def coding_evaluations(self) -> "CodingEvaluationsResource":
142
+ with _RESOURCE_IMPORT_LOCK:
143
+ from .resources.coding_evaluations import CodingEvaluationsResource
144
+ return CodingEvaluationsResource(self)
145
+
146
+ @cached_property
147
+ def users(self) -> "UsersResource":
148
+ with _RESOURCE_IMPORT_LOCK:
149
+ from .resources.users import UsersResource
150
+ return UsersResource(self)
151
+
152
+ @cached_property
153
+ def question_sets(self) -> "QuestionSetsResource":
154
+ with _RESOURCE_IMPORT_LOCK:
155
+ from .resources.question_sets import QuestionSetsResource
156
+ return QuestionSetsResource(self)
157
+
158
+ @cached_property
159
+ def email_recipients(self) -> "EmailRecipientsResource":
160
+ with _RESOURCE_IMPORT_LOCK:
161
+ from .resources.email_recipients import EmailRecipientsResource
162
+ return EmailRecipientsResource(self)
163
+
164
+ @cached_property
165
+ def with_raw_response(self) -> BrelliumClientWithRawResponse:
166
+ return BrelliumClientWithRawResponse(self)
167
+
168
+ @cached_property
169
+ def with_streaming_response(self) -> BrelliumClientWithStreamedResponse:
170
+ return BrelliumClientWithStreamedResponse(self)
171
+
172
+ @property
173
+ @override
174
+ def qs(self) -> Querystring:
175
+ return Querystring(array_format="comma")
176
+
177
+ @property
178
+ @override
179
+ def auth_headers(self) -> dict[str, str]:
180
+ return {
181
+ **self._o_auth2_header_auth,
182
+ }
183
+
184
+ @override
185
+ def _auth_query(self, security: SecurityOptions | None) -> dict[str, str]:
186
+ if security is not None:
187
+ return self._select_auth(security).query
188
+ return {}
189
+
190
+ @override
191
+ def _auth_cookies(self, security: SecurityOptions | None) -> dict[str, str]:
192
+ if security is not None:
193
+ return self._select_auth(security).cookies
194
+ return {}
195
+
196
+ @property
197
+ @override
198
+ def _auth_by_scheme(self) -> dict[str, SchemeCredentials]:
199
+ return {
200
+ "OAuth2": SchemeCredentials(headers=self._o_auth2_header_auth),
201
+ }
202
+
203
+ @property
204
+ @override
205
+ def _auth_locations(self) -> AuthLocations:
206
+ return AuthLocations(headers=frozenset({"authorization"}))
207
+
208
+ @property
209
+ def _o_auth2_header_auth(self) -> dict[str, str]:
210
+ value = self.o_auth2
211
+ if value is None:
212
+ return {}
213
+ return {"Authorization": f"Bearer {value}"}
214
+
215
+ @property
216
+ @override
217
+ def default_headers(self) -> dict[str, str | Omit]:
218
+ return {
219
+ **super().default_headers,
220
+ "X-Scalar-Async": "false",
221
+ **self._custom_headers,
222
+ }
223
+
224
+ @override
225
+ def _validate_headers(
226
+ self,
227
+ headers: Headers,
228
+ custom_headers: Headers,
229
+ params: Mapping[str, object],
230
+ cookies: Mapping[str, str],
231
+ ) -> None:
232
+ if headers.get("Authorization"):
233
+ return
234
+ if isinstance(custom_headers.get("Authorization"), Omit):
235
+ return
236
+ raise TypeError(
237
+ '"Could not resolve authentication method. Expected the o_auth2 to be set. Or for the `Authorization` headers to be explicitly omitted"'
238
+ )
239
+
240
+ def copy(
241
+ self,
242
+ *,
243
+ o_auth2: str | None = None,
244
+ base_url: str | httpx.URL | None = None,
245
+ timeout: float | Timeout | None | NotGiven = not_given,
246
+ http_client: httpx.Client | None = None,
247
+ max_retries: int | NotGiven = not_given,
248
+ default_headers: Mapping[str, str] | None = None,
249
+ set_default_headers: Mapping[str, str] | None = None,
250
+ default_query: Mapping[str, object] | None = None,
251
+ set_default_query: Mapping[str, object] | None = None,
252
+ _extra_kwargs: Mapping[str, Any] = {},
253
+ ) -> Self:
254
+ """Create a new client reusing this client's options with optional overrides."""
255
+ if default_headers is not None and set_default_headers is not None:
256
+ raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
257
+ if default_query is not None and set_default_query is not None:
258
+ raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
259
+ headers = self._custom_headers
260
+ if default_headers is not None:
261
+ headers = {**headers, **default_headers}
262
+ elif set_default_headers is not None:
263
+ headers = set_default_headers
264
+ params = self._custom_query
265
+ if default_query is not None:
266
+ params = {**params, **default_query}
267
+ elif set_default_query is not None:
268
+ params = set_default_query
269
+ http_client = http_client or self._client
270
+ return self.__class__(
271
+ o_auth2=o_auth2 or self.o_auth2,
272
+ base_url=base_url or self.base_url,
273
+ timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
274
+ http_client=http_client,
275
+ max_retries=max_retries if is_given(max_retries) else self.max_retries,
276
+ default_headers=headers,
277
+ default_query=params,
278
+ _strict_response_validation=self._strict_response_validation,
279
+ **_extra_kwargs,
280
+ )
281
+
282
+ with_options = copy
283
+
284
+ @override
285
+ def _make_status_error(self, err_msg: str, *, body: object, response: httpx.Response) -> APIStatusError:
286
+ if response.status_code == 400:
287
+ return _exceptions.BadRequestError(err_msg, response=response, body=body)
288
+ if response.status_code == 401:
289
+ return _exceptions.AuthenticationError(err_msg, response=response, body=body)
290
+ if response.status_code == 403:
291
+ return _exceptions.PermissionDeniedError(err_msg, response=response, body=body)
292
+ if response.status_code == 404:
293
+ return _exceptions.NotFoundError(err_msg, response=response, body=body)
294
+ if response.status_code == 409:
295
+ return _exceptions.ConflictError(err_msg, response=response, body=body)
296
+ if response.status_code == 422:
297
+ return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)
298
+ if response.status_code == 429:
299
+ return _exceptions.RateLimitError(err_msg, response=response, body=body)
300
+ if response.status_code >= 500:
301
+ return _exceptions.InternalServerError(err_msg, response=response, body=body)
302
+ return APIStatusError(err_msg, response=response, body=body)
303
+
304
+
305
+ class AsyncBrelliumClient(AsyncAPIClient):
306
+ # client options
307
+ o_auth2: str
308
+
309
+ def __init__(
310
+ self,
311
+ *,
312
+ o_auth2: str | None = None,
313
+ base_url: str | httpx.URL | None = None,
314
+ timeout: float | Timeout | None | NotGiven = not_given,
315
+ max_retries: int = DEFAULT_MAX_RETRIES,
316
+ default_headers: Mapping[str, str] | None = None,
317
+ default_query: Mapping[str, object] | None = None,
318
+ # Configure a custom httpx client.
319
+ # We provide a `DefaultAsyncHttpxClient` class that you can pass to retain the default values we use for `limits` & `timeout`.
320
+ # The SDK follows redirects itself, whatever the client's `follow_redirects` says.
321
+ # See the [httpx documentation](https://www.python-httpx.org/api/#asyncclient) for more details.
322
+ http_client: httpx.AsyncClient | None = None,
323
+ # Enable or disable schema validation for data returned by the API.
324
+ # When enabled an error APIResponseValidationError is raised
325
+ # if the API responds with invalid data for the expected schema.
326
+ #
327
+ # This parameter may be removed or changed in the future.
328
+ # If you rely on this feature, please open a GitHub issue
329
+ # outlining your use-case to help us decide if it should be
330
+ # part of our public interface in the future.
331
+ _strict_response_validation: bool = False,
332
+ ) -> None:
333
+ """Construct a new async AsyncBrelliumClient client instance.
334
+
335
+ This automatically infers the following arguments from their corresponding environment variables if they are not provided:
336
+ - `o_auth2` from `BRELLIUM_ACCESS_TOKEN`
337
+ """
338
+ if o_auth2 is None:
339
+ o_auth2 = os.environ.get("BRELLIUM_ACCESS_TOKEN")
340
+ if o_auth2 is None:
341
+ raise BrelliumClientError(
342
+ "The o_auth2 client option must be set either by passing o_auth2 to the client or by setting the BRELLIUM_ACCESS_TOKEN environment variable"
343
+ )
344
+ self.o_auth2 = o_auth2
345
+ if base_url is None:
346
+ base_url = os.environ.get("BRELLIUM_BASE_URL")
347
+ if base_url is None:
348
+ base_url = "https://api.brellium.dev"
349
+ custom_headers_env = os.environ.get("BRELLIUM_CUSTOM_HEADERS")
350
+ if custom_headers_env is not None:
351
+ parsed: dict[str, str] = {}
352
+ for line in custom_headers_env.split("\n"):
353
+ colon = line.find(":")
354
+ if colon >= 0:
355
+ parsed[line[:colon].strip()] = line[colon + 1 :].strip()
356
+ default_headers = {**parsed, **(default_headers if is_mapping_t(default_headers) else {})}
357
+ super().__init__(
358
+ version=__version__,
359
+ base_url=base_url,
360
+ max_retries=max_retries,
361
+ timeout=timeout,
362
+ http_client=http_client,
363
+ custom_headers=default_headers,
364
+ custom_query=default_query,
365
+ _strict_response_validation=_strict_response_validation,
366
+ )
367
+ self._idempotency_header = None
368
+ self._default_stream_cls = AsyncStream
369
+
370
+ @cached_property
371
+ def documents(self) -> "AsyncDocumentsResource":
372
+ with _RESOURCE_IMPORT_LOCK:
373
+ from .resources.documents import AsyncDocumentsResource
374
+ return AsyncDocumentsResource(self)
375
+
376
+ @cached_property
377
+ def audits(self) -> "AsyncAuditsResource":
378
+ with _RESOURCE_IMPORT_LOCK:
379
+ from .resources.audits import AsyncAuditsResource
380
+ return AsyncAuditsResource(self)
381
+
382
+ @cached_property
383
+ def coding_evaluations(self) -> "AsyncCodingEvaluationsResource":
384
+ with _RESOURCE_IMPORT_LOCK:
385
+ from .resources.coding_evaluations import AsyncCodingEvaluationsResource
386
+ return AsyncCodingEvaluationsResource(self)
387
+
388
+ @cached_property
389
+ def users(self) -> "AsyncUsersResource":
390
+ with _RESOURCE_IMPORT_LOCK:
391
+ from .resources.users import AsyncUsersResource
392
+ return AsyncUsersResource(self)
393
+
394
+ @cached_property
395
+ def question_sets(self) -> "AsyncQuestionSetsResource":
396
+ with _RESOURCE_IMPORT_LOCK:
397
+ from .resources.question_sets import AsyncQuestionSetsResource
398
+ return AsyncQuestionSetsResource(self)
399
+
400
+ @cached_property
401
+ def email_recipients(self) -> "AsyncEmailRecipientsResource":
402
+ with _RESOURCE_IMPORT_LOCK:
403
+ from .resources.email_recipients import AsyncEmailRecipientsResource
404
+ return AsyncEmailRecipientsResource(self)
405
+
406
+ @cached_property
407
+ def with_raw_response(self) -> AsyncBrelliumClientWithRawResponse:
408
+ return AsyncBrelliumClientWithRawResponse(self)
409
+
410
+ @cached_property
411
+ def with_streaming_response(self) -> AsyncBrelliumClientWithStreamedResponse:
412
+ return AsyncBrelliumClientWithStreamedResponse(self)
413
+
414
+ @property
415
+ @override
416
+ def qs(self) -> Querystring:
417
+ return Querystring(array_format="comma")
418
+
419
+ @property
420
+ @override
421
+ def auth_headers(self) -> dict[str, str]:
422
+ return {
423
+ **self._o_auth2_header_auth,
424
+ }
425
+
426
+ @override
427
+ def _auth_query(self, security: SecurityOptions | None) -> dict[str, str]:
428
+ if security is not None:
429
+ return self._select_auth(security).query
430
+ return {}
431
+
432
+ @override
433
+ def _auth_cookies(self, security: SecurityOptions | None) -> dict[str, str]:
434
+ if security is not None:
435
+ return self._select_auth(security).cookies
436
+ return {}
437
+
438
+ @property
439
+ @override
440
+ def _auth_by_scheme(self) -> dict[str, SchemeCredentials]:
441
+ return {
442
+ "OAuth2": SchemeCredentials(headers=self._o_auth2_header_auth),
443
+ }
444
+
445
+ @property
446
+ @override
447
+ def _auth_locations(self) -> AuthLocations:
448
+ return AuthLocations(headers=frozenset({"authorization"}))
449
+
450
+ @property
451
+ def _o_auth2_header_auth(self) -> dict[str, str]:
452
+ value = self.o_auth2
453
+ if value is None:
454
+ return {}
455
+ return {"Authorization": f"Bearer {value}"}
456
+
457
+ @property
458
+ @override
459
+ def default_headers(self) -> dict[str, str | Omit]:
460
+ return {
461
+ **super().default_headers,
462
+ "X-Scalar-Async": f"async:{get_async_library()}",
463
+ **self._custom_headers,
464
+ }
465
+
466
+ @override
467
+ def _validate_headers(
468
+ self,
469
+ headers: Headers,
470
+ custom_headers: Headers,
471
+ params: Mapping[str, object],
472
+ cookies: Mapping[str, str],
473
+ ) -> None:
474
+ if headers.get("Authorization"):
475
+ return
476
+ if isinstance(custom_headers.get("Authorization"), Omit):
477
+ return
478
+ raise TypeError(
479
+ '"Could not resolve authentication method. Expected the o_auth2 to be set. Or for the `Authorization` headers to be explicitly omitted"'
480
+ )
481
+
482
+ def copy(
483
+ self,
484
+ *,
485
+ o_auth2: str | None = None,
486
+ base_url: str | httpx.URL | None = None,
487
+ timeout: float | Timeout | None | NotGiven = not_given,
488
+ http_client: httpx.AsyncClient | None = None,
489
+ max_retries: int | NotGiven = not_given,
490
+ default_headers: Mapping[str, str] | None = None,
491
+ set_default_headers: Mapping[str, str] | None = None,
492
+ default_query: Mapping[str, object] | None = None,
493
+ set_default_query: Mapping[str, object] | None = None,
494
+ _extra_kwargs: Mapping[str, Any] = {},
495
+ ) -> Self:
496
+ """Create a new client reusing this client's options with optional overrides."""
497
+ if default_headers is not None and set_default_headers is not None:
498
+ raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
499
+ if default_query is not None and set_default_query is not None:
500
+ raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
501
+ headers = self._custom_headers
502
+ if default_headers is not None:
503
+ headers = {**headers, **default_headers}
504
+ elif set_default_headers is not None:
505
+ headers = set_default_headers
506
+ params = self._custom_query
507
+ if default_query is not None:
508
+ params = {**params, **default_query}
509
+ elif set_default_query is not None:
510
+ params = set_default_query
511
+ http_client = http_client or self._client
512
+ return self.__class__(
513
+ o_auth2=o_auth2 or self.o_auth2,
514
+ base_url=base_url or self.base_url,
515
+ timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
516
+ http_client=http_client,
517
+ max_retries=max_retries if is_given(max_retries) else self.max_retries,
518
+ default_headers=headers,
519
+ default_query=params,
520
+ _strict_response_validation=self._strict_response_validation,
521
+ **_extra_kwargs,
522
+ )
523
+
524
+ with_options = copy
525
+
526
+ @override
527
+ def _make_status_error(self, err_msg: str, *, body: object, response: httpx.Response) -> APIStatusError:
528
+ if response.status_code == 400:
529
+ return _exceptions.BadRequestError(err_msg, response=response, body=body)
530
+ if response.status_code == 401:
531
+ return _exceptions.AuthenticationError(err_msg, response=response, body=body)
532
+ if response.status_code == 403:
533
+ return _exceptions.PermissionDeniedError(err_msg, response=response, body=body)
534
+ if response.status_code == 404:
535
+ return _exceptions.NotFoundError(err_msg, response=response, body=body)
536
+ if response.status_code == 409:
537
+ return _exceptions.ConflictError(err_msg, response=response, body=body)
538
+ if response.status_code == 422:
539
+ return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)
540
+ if response.status_code == 429:
541
+ return _exceptions.RateLimitError(err_msg, response=response, body=body)
542
+ if response.status_code >= 500:
543
+ return _exceptions.InternalServerError(err_msg, response=response, body=body)
544
+ return APIStatusError(err_msg, response=response, body=body)
545
+
546
+
547
+ class BrelliumClientWithRawResponse:
548
+ _client: BrelliumClient
549
+
550
+ def __init__(self, client: BrelliumClient) -> None:
551
+ self._client = client
552
+
553
+ @cached_property
554
+ def documents(self) -> documents.DocumentsResourceWithRawResponse:
555
+ with _RESOURCE_IMPORT_LOCK:
556
+ from .resources.documents import DocumentsResourceWithRawResponse
557
+ return DocumentsResourceWithRawResponse(self._client.documents)
558
+
559
+ @cached_property
560
+ def audits(self) -> audits.AuditsResourceWithRawResponse:
561
+ with _RESOURCE_IMPORT_LOCK:
562
+ from .resources.audits import AuditsResourceWithRawResponse
563
+ return AuditsResourceWithRawResponse(self._client.audits)
564
+
565
+ @cached_property
566
+ def coding_evaluations(self) -> coding_evaluations.CodingEvaluationsResourceWithRawResponse:
567
+ with _RESOURCE_IMPORT_LOCK:
568
+ from .resources.coding_evaluations import CodingEvaluationsResourceWithRawResponse
569
+ return CodingEvaluationsResourceWithRawResponse(self._client.coding_evaluations)
570
+
571
+ @cached_property
572
+ def users(self) -> users.UsersResourceWithRawResponse:
573
+ with _RESOURCE_IMPORT_LOCK:
574
+ from .resources.users import UsersResourceWithRawResponse
575
+ return UsersResourceWithRawResponse(self._client.users)
576
+
577
+ @cached_property
578
+ def question_sets(self) -> question_sets.QuestionSetsResourceWithRawResponse:
579
+ with _RESOURCE_IMPORT_LOCK:
580
+ from .resources.question_sets import QuestionSetsResourceWithRawResponse
581
+ return QuestionSetsResourceWithRawResponse(self._client.question_sets)
582
+
583
+ @cached_property
584
+ def email_recipients(self) -> email_recipients.EmailRecipientsResourceWithRawResponse:
585
+ with _RESOURCE_IMPORT_LOCK:
586
+ from .resources.email_recipients import EmailRecipientsResourceWithRawResponse
587
+ return EmailRecipientsResourceWithRawResponse(self._client.email_recipients)
588
+
589
+
590
+ class AsyncBrelliumClientWithRawResponse:
591
+ _client: AsyncBrelliumClient
592
+
593
+ def __init__(self, client: AsyncBrelliumClient) -> None:
594
+ self._client = client
595
+
596
+ @cached_property
597
+ def documents(self) -> documents.AsyncDocumentsResourceWithRawResponse:
598
+ with _RESOURCE_IMPORT_LOCK:
599
+ from .resources.documents import AsyncDocumentsResourceWithRawResponse
600
+ return AsyncDocumentsResourceWithRawResponse(self._client.documents)
601
+
602
+ @cached_property
603
+ def audits(self) -> audits.AsyncAuditsResourceWithRawResponse:
604
+ with _RESOURCE_IMPORT_LOCK:
605
+ from .resources.audits import AsyncAuditsResourceWithRawResponse
606
+ return AsyncAuditsResourceWithRawResponse(self._client.audits)
607
+
608
+ @cached_property
609
+ def coding_evaluations(self) -> coding_evaluations.AsyncCodingEvaluationsResourceWithRawResponse:
610
+ with _RESOURCE_IMPORT_LOCK:
611
+ from .resources.coding_evaluations import AsyncCodingEvaluationsResourceWithRawResponse
612
+ return AsyncCodingEvaluationsResourceWithRawResponse(self._client.coding_evaluations)
613
+
614
+ @cached_property
615
+ def users(self) -> users.AsyncUsersResourceWithRawResponse:
616
+ with _RESOURCE_IMPORT_LOCK:
617
+ from .resources.users import AsyncUsersResourceWithRawResponse
618
+ return AsyncUsersResourceWithRawResponse(self._client.users)
619
+
620
+ @cached_property
621
+ def question_sets(self) -> question_sets.AsyncQuestionSetsResourceWithRawResponse:
622
+ with _RESOURCE_IMPORT_LOCK:
623
+ from .resources.question_sets import AsyncQuestionSetsResourceWithRawResponse
624
+ return AsyncQuestionSetsResourceWithRawResponse(self._client.question_sets)
625
+
626
+ @cached_property
627
+ def email_recipients(self) -> email_recipients.AsyncEmailRecipientsResourceWithRawResponse:
628
+ with _RESOURCE_IMPORT_LOCK:
629
+ from .resources.email_recipients import AsyncEmailRecipientsResourceWithRawResponse
630
+ return AsyncEmailRecipientsResourceWithRawResponse(self._client.email_recipients)
631
+
632
+
633
+ class BrelliumClientWithStreamedResponse:
634
+ _client: BrelliumClient
635
+
636
+ def __init__(self, client: BrelliumClient) -> None:
637
+ self._client = client
638
+
639
+ @cached_property
640
+ def documents(self) -> documents.DocumentsResourceWithStreamingResponse:
641
+ with _RESOURCE_IMPORT_LOCK:
642
+ from .resources.documents import DocumentsResourceWithStreamingResponse
643
+ return DocumentsResourceWithStreamingResponse(self._client.documents)
644
+
645
+ @cached_property
646
+ def audits(self) -> audits.AuditsResourceWithStreamingResponse:
647
+ with _RESOURCE_IMPORT_LOCK:
648
+ from .resources.audits import AuditsResourceWithStreamingResponse
649
+ return AuditsResourceWithStreamingResponse(self._client.audits)
650
+
651
+ @cached_property
652
+ def coding_evaluations(self) -> coding_evaluations.CodingEvaluationsResourceWithStreamingResponse:
653
+ with _RESOURCE_IMPORT_LOCK:
654
+ from .resources.coding_evaluations import CodingEvaluationsResourceWithStreamingResponse
655
+ return CodingEvaluationsResourceWithStreamingResponse(self._client.coding_evaluations)
656
+
657
+ @cached_property
658
+ def users(self) -> users.UsersResourceWithStreamingResponse:
659
+ with _RESOURCE_IMPORT_LOCK:
660
+ from .resources.users import UsersResourceWithStreamingResponse
661
+ return UsersResourceWithStreamingResponse(self._client.users)
662
+
663
+ @cached_property
664
+ def question_sets(self) -> question_sets.QuestionSetsResourceWithStreamingResponse:
665
+ with _RESOURCE_IMPORT_LOCK:
666
+ from .resources.question_sets import QuestionSetsResourceWithStreamingResponse
667
+ return QuestionSetsResourceWithStreamingResponse(self._client.question_sets)
668
+
669
+ @cached_property
670
+ def email_recipients(self) -> email_recipients.EmailRecipientsResourceWithStreamingResponse:
671
+ with _RESOURCE_IMPORT_LOCK:
672
+ from .resources.email_recipients import EmailRecipientsResourceWithStreamingResponse
673
+ return EmailRecipientsResourceWithStreamingResponse(self._client.email_recipients)
674
+
675
+
676
+ class AsyncBrelliumClientWithStreamedResponse:
677
+ _client: AsyncBrelliumClient
678
+
679
+ def __init__(self, client: AsyncBrelliumClient) -> None:
680
+ self._client = client
681
+
682
+ @cached_property
683
+ def documents(self) -> documents.AsyncDocumentsResourceWithStreamingResponse:
684
+ with _RESOURCE_IMPORT_LOCK:
685
+ from .resources.documents import AsyncDocumentsResourceWithStreamingResponse
686
+ return AsyncDocumentsResourceWithStreamingResponse(self._client.documents)
687
+
688
+ @cached_property
689
+ def audits(self) -> audits.AsyncAuditsResourceWithStreamingResponse:
690
+ with _RESOURCE_IMPORT_LOCK:
691
+ from .resources.audits import AsyncAuditsResourceWithStreamingResponse
692
+ return AsyncAuditsResourceWithStreamingResponse(self._client.audits)
693
+
694
+ @cached_property
695
+ def coding_evaluations(self) -> coding_evaluations.AsyncCodingEvaluationsResourceWithStreamingResponse:
696
+ with _RESOURCE_IMPORT_LOCK:
697
+ from .resources.coding_evaluations import AsyncCodingEvaluationsResourceWithStreamingResponse
698
+ return AsyncCodingEvaluationsResourceWithStreamingResponse(self._client.coding_evaluations)
699
+
700
+ @cached_property
701
+ def users(self) -> users.AsyncUsersResourceWithStreamingResponse:
702
+ with _RESOURCE_IMPORT_LOCK:
703
+ from .resources.users import AsyncUsersResourceWithStreamingResponse
704
+ return AsyncUsersResourceWithStreamingResponse(self._client.users)
705
+
706
+ @cached_property
707
+ def question_sets(self) -> question_sets.AsyncQuestionSetsResourceWithStreamingResponse:
708
+ with _RESOURCE_IMPORT_LOCK:
709
+ from .resources.question_sets import AsyncQuestionSetsResourceWithStreamingResponse
710
+ return AsyncQuestionSetsResourceWithStreamingResponse(self._client.question_sets)
711
+
712
+ @cached_property
713
+ def email_recipients(self) -> email_recipients.AsyncEmailRecipientsResourceWithStreamingResponse:
714
+ with _RESOURCE_IMPORT_LOCK:
715
+ from .resources.email_recipients import AsyncEmailRecipientsResourceWithStreamingResponse
716
+ return AsyncEmailRecipientsResourceWithStreamingResponse(self._client.email_recipients)
717
+
718
+
719
+ # Alias names for the documented `Client` / `AsyncClient` symbols.
720
+ Client = BrelliumClient
721
+ AsyncClient = AsyncBrelliumClient