BasisTheoryClient 0.0.1__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.
- basis_theory/__init__.py +350 -0
- basis_theory/account_updater/__init__.py +7 -0
- basis_theory/account_updater/client.py +44 -0
- basis_theory/account_updater/jobs/__init__.py +4 -0
- basis_theory/account_updater/jobs/client.py +259 -0
- basis_theory/account_updater/jobs/raw_client.py +450 -0
- basis_theory/account_updater/raw_client.py +13 -0
- basis_theory/account_updater/real_time/__init__.py +4 -0
- basis_theory/account_updater/real_time/client.py +161 -0
- basis_theory/account_updater/real_time/raw_client.py +246 -0
- basis_theory/apple_pay/__init__.py +7 -0
- basis_theory/apple_pay/client.py +267 -0
- basis_theory/apple_pay/domain/__init__.py +4 -0
- basis_theory/apple_pay/domain/client.py +309 -0
- basis_theory/apple_pay/domain/raw_client.py +631 -0
- basis_theory/apple_pay/raw_client.py +499 -0
- basis_theory/apple_pay/session/__init__.py +4 -0
- basis_theory/apple_pay/session/client.py +130 -0
- basis_theory/apple_pay/session/raw_client.py +225 -0
- basis_theory/application_keys/__init__.py +4 -0
- basis_theory/application_keys/client.py +354 -0
- basis_theory/application_keys/raw_client.py +615 -0
- basis_theory/application_templates/__init__.py +4 -0
- basis_theory/application_templates/client.py +166 -0
- basis_theory/application_templates/raw_client.py +253 -0
- basis_theory/applications/__init__.py +4 -0
- basis_theory/applications/client.py +582 -0
- basis_theory/applications/raw_client.py +1030 -0
- basis_theory/client.py +230 -0
- basis_theory/connection/__init__.py +7 -0
- basis_theory/connection/apple_pay/__init__.py +7 -0
- basis_theory/connection/apple_pay/client.py +128 -0
- basis_theory/connection/apple_pay/domain/__init__.py +4 -0
- basis_theory/connection/apple_pay/domain/client.py +309 -0
- basis_theory/connection/apple_pay/domain/raw_client.py +631 -0
- basis_theory/connection/apple_pay/raw_client.py +216 -0
- basis_theory/connection/apple_pay/session/__init__.py +4 -0
- basis_theory/connection/apple_pay/session/client.py +130 -0
- basis_theory/connection/apple_pay/session/raw_client.py +225 -0
- basis_theory/connection/client.py +39 -0
- basis_theory/connection/raw_client.py +13 -0
- basis_theory/core/__init__.py +55 -0
- basis_theory/core/api_error.py +23 -0
- basis_theory/core/client_wrapper.py +89 -0
- basis_theory/core/datetime_utils.py +28 -0
- basis_theory/core/file.py +67 -0
- basis_theory/core/force_multipart.py +16 -0
- basis_theory/core/http_client.py +543 -0
- basis_theory/core/http_response.py +55 -0
- basis_theory/core/jsonable_encoder.py +100 -0
- basis_theory/core/pagination.py +82 -0
- basis_theory/core/pydantic_utilities.py +255 -0
- basis_theory/core/query_encoder.py +58 -0
- basis_theory/core/remove_none_from_dict.py +11 -0
- basis_theory/core/request_options.py +35 -0
- basis_theory/core/serialization.py +276 -0
- basis_theory/documents/__init__.py +7 -0
- basis_theory/documents/client.py +258 -0
- basis_theory/documents/data/__init__.py +4 -0
- basis_theory/documents/data/client.py +78 -0
- basis_theory/documents/data/raw_client.py +173 -0
- basis_theory/documents/raw_client.py +442 -0
- basis_theory/enrichments/__init__.py +4 -0
- basis_theory/enrichments/client.py +135 -0
- basis_theory/enrichments/raw_client.py +203 -0
- basis_theory/environment.py +7 -0
- basis_theory/errors/__init__.py +23 -0
- basis_theory/errors/bad_request_error.py +11 -0
- basis_theory/errors/conflict_error.py +11 -0
- basis_theory/errors/forbidden_error.py +11 -0
- basis_theory/errors/internal_server_error.py +11 -0
- basis_theory/errors/not_found_error.py +10 -0
- basis_theory/errors/service_unavailable_error.py +11 -0
- basis_theory/errors/unauthorized_error.py +11 -0
- basis_theory/errors/unprocessable_entity_error.py +11 -0
- basis_theory/googlepay/__init__.py +4 -0
- basis_theory/googlepay/client.py +120 -0
- basis_theory/googlepay/raw_client.py +239 -0
- basis_theory/keys/__init__.py +4 -0
- basis_theory/keys/client.py +313 -0
- basis_theory/keys/raw_client.py +673 -0
- basis_theory/logs/__init__.py +4 -0
- basis_theory/logs/client.py +240 -0
- basis_theory/logs/raw_client.py +376 -0
- basis_theory/network_tokens/__init__.py +4 -0
- basis_theory/network_tokens/client.py +478 -0
- basis_theory/network_tokens/raw_client.py +1113 -0
- basis_theory/permissions/__init__.py +4 -0
- basis_theory/permissions/client.py +106 -0
- basis_theory/permissions/raw_client.py +170 -0
- basis_theory/proxies/__init__.py +4 -0
- basis_theory/proxies/client.py +751 -0
- basis_theory/proxies/raw_client.py +1255 -0
- basis_theory/py.typed +0 -0
- basis_theory/reactors/__init__.py +7 -0
- basis_theory/reactors/client.py +823 -0
- basis_theory/reactors/raw_client.py +1553 -0
- basis_theory/reactors/results/__init__.py +4 -0
- basis_theory/reactors/results/client.py +115 -0
- basis_theory/reactors/results/raw_client.py +194 -0
- basis_theory/roles/__init__.py +4 -0
- basis_theory/roles/client.py +98 -0
- basis_theory/roles/raw_client.py +134 -0
- basis_theory/sessions/__init__.py +4 -0
- basis_theory/sessions/client.py +222 -0
- basis_theory/sessions/raw_client.py +399 -0
- basis_theory/tenants/__init__.py +7 -0
- basis_theory/tenants/client.py +59 -0
- basis_theory/tenants/connections/__init__.py +4 -0
- basis_theory/tenants/connections/client.py +198 -0
- basis_theory/tenants/connections/raw_client.py +344 -0
- basis_theory/tenants/invitations/__init__.py +4 -0
- basis_theory/tenants/invitations/client.py +458 -0
- basis_theory/tenants/invitations/raw_client.py +805 -0
- basis_theory/tenants/members/__init__.py +4 -0
- basis_theory/tenants/members/client.py +296 -0
- basis_theory/tenants/members/raw_client.py +497 -0
- basis_theory/tenants/owner/__init__.py +4 -0
- basis_theory/tenants/owner/client.py +98 -0
- basis_theory/tenants/owner/raw_client.py +157 -0
- basis_theory/tenants/raw_client.py +13 -0
- basis_theory/tenants/self_/__init__.py +4 -0
- basis_theory/tenants/self_/client.py +308 -0
- basis_theory/tenants/self_/raw_client.py +605 -0
- basis_theory/threeds/__init__.py +7 -0
- basis_theory/threeds/client.py +39 -0
- basis_theory/threeds/raw_client.py +13 -0
- basis_theory/threeds/sessions/__init__.py +4 -0
- basis_theory/threeds/sessions/client.py +521 -0
- basis_theory/threeds/sessions/raw_client.py +808 -0
- basis_theory/token_intents/__init__.py +4 -0
- basis_theory/token_intents/client.py +258 -0
- basis_theory/token_intents/raw_client.py +454 -0
- basis_theory/tokens/__init__.py +4 -0
- basis_theory/tokens/client.py +1015 -0
- basis_theory/tokens/raw_client.py +1861 -0
- basis_theory/types/__init__.py +277 -0
- basis_theory/types/access_rule.py +25 -0
- basis_theory/types/account_updater_job.py +55 -0
- basis_theory/types/account_updater_job_list.py +22 -0
- basis_theory/types/account_updater_job_list_pagination.py +20 -0
- basis_theory/types/account_updater_job_status.py +5 -0
- basis_theory/types/account_updater_real_time_response.py +24 -0
- basis_theory/types/additional_card_details.py +23 -0
- basis_theory/types/address.py +25 -0
- basis_theory/types/apple_pay_create_response.py +20 -0
- basis_theory/types/apple_pay_create_token_response.py +28 -0
- basis_theory/types/apple_pay_domain_deregistration_request.py +19 -0
- basis_theory/types/apple_pay_domain_registration_list_request.py +19 -0
- basis_theory/types/apple_pay_domain_registration_request.py +19 -0
- basis_theory/types/apple_pay_domain_registration_response.py +20 -0
- basis_theory/types/apple_pay_method_token.py +25 -0
- basis_theory/types/apple_pay_session_request.py +21 -0
- basis_theory/types/apple_pay_token.py +33 -0
- basis_theory/types/apple_pay_tokenize_response.py +20 -0
- basis_theory/types/application.py +33 -0
- basis_theory/types/application_key.py +24 -0
- basis_theory/types/application_paginated_list.py +22 -0
- basis_theory/types/application_template.py +27 -0
- basis_theory/types/assurance_details.py +20 -0
- basis_theory/types/async_react_response.py +23 -0
- basis_theory/types/authenticate_three_ds_session_request.py +35 -0
- basis_theory/types/authentication.py +22 -0
- basis_theory/types/authentication_response.py +21 -0
- basis_theory/types/bank_details.py +20 -0
- basis_theory/types/bank_verification_response.py +19 -0
- basis_theory/types/bin_details.py +41 -0
- basis_theory/types/bin_details_bank.py +22 -0
- basis_theory/types/bin_details_country.py +21 -0
- basis_theory/types/bin_details_product.py +20 -0
- basis_theory/types/card.py +22 -0
- basis_theory/types/card_details.py +32 -0
- basis_theory/types/card_issuer.py +20 -0
- basis_theory/types/card_issuer_country.py +21 -0
- basis_theory/types/cardholder_info.py +21 -0
- basis_theory/types/client_encryption_key_metadata_response.py +23 -0
- basis_theory/types/client_encryption_key_response.py +24 -0
- basis_theory/types/condition.py +21 -0
- basis_theory/types/create_account_updater_job_request.py +22 -0
- basis_theory/types/create_document_request.py +19 -0
- basis_theory/types/create_reactor_formula_request.py +28 -0
- basis_theory/types/create_session_response.py +22 -0
- basis_theory/types/create_tenant_connection_response.py +19 -0
- basis_theory/types/create_three_ds_session_response.py +29 -0
- basis_theory/types/create_token_intent_response.py +36 -0
- basis_theory/types/cursor_pagination.py +20 -0
- basis_theory/types/document.py +25 -0
- basis_theory/types/domain_registration_response.py +20 -0
- basis_theory/types/event_types.py +5 -0
- basis_theory/types/get_applications.py +23 -0
- basis_theory/types/get_logs.py +26 -0
- basis_theory/types/get_permissions.py +19 -0
- basis_theory/types/get_proxies.py +23 -0
- basis_theory/types/get_reactor_formulas.py +22 -0
- basis_theory/types/get_reactors.py +23 -0
- basis_theory/types/get_tenant_invitations.py +23 -0
- basis_theory/types/get_tenant_members.py +22 -0
- basis_theory/types/get_tokens.py +23 -0
- basis_theory/types/get_tokens_v2.py +24 -0
- basis_theory/types/google_pay_tokenize_response.py +20 -0
- basis_theory/types/google_payment_method_token.py +27 -0
- basis_theory/types/header.py +26 -0
- basis_theory/types/intermediate_signing_key.py +22 -0
- basis_theory/types/log.py +28 -0
- basis_theory/types/log_entity_type.py +20 -0
- basis_theory/types/log_paginated_list.py +22 -0
- basis_theory/types/network_token.py +38 -0
- basis_theory/types/network_token_cryptogram.py +20 -0
- basis_theory/types/network_token_extras.py +19 -0
- basis_theory/types/pagination.py +24 -0
- basis_theory/types/payment_data.py +23 -0
- basis_theory/types/permission.py +21 -0
- basis_theory/types/privacy.py +21 -0
- basis_theory/types/problem_details.py +23 -0
- basis_theory/types/proxy.py +39 -0
- basis_theory/types/proxy_paginated_list.py +22 -0
- basis_theory/types/proxy_transform.py +23 -0
- basis_theory/types/public_key.py +3 -0
- basis_theory/types/react_response.py +22 -0
- basis_theory/types/reactor.py +32 -0
- basis_theory/types/reactor_formula.py +34 -0
- basis_theory/types/reactor_formula_configuration.py +21 -0
- basis_theory/types/reactor_formula_paginated_list.py +22 -0
- basis_theory/types/reactor_formula_request_parameter.py +22 -0
- basis_theory/types/reactor_paginated_list.py +22 -0
- basis_theory/types/role.py +19 -0
- basis_theory/types/string_string_key_value_pair.py +20 -0
- basis_theory/types/submerchant_authentication_response.py +21 -0
- basis_theory/types/tenant.py +28 -0
- basis_theory/types/tenant_connection_options.py +19 -0
- basis_theory/types/tenant_invitation_response.py +30 -0
- basis_theory/types/tenant_invitation_response_paginated_list.py +22 -0
- basis_theory/types/tenant_invitation_status.py +5 -0
- basis_theory/types/tenant_member_response.py +28 -0
- basis_theory/types/tenant_member_response_paginated_list.py +22 -0
- basis_theory/types/tenant_usage_report.py +19 -0
- basis_theory/types/three_ds_acs_rendering_type.py +22 -0
- basis_theory/types/three_ds_address.py +25 -0
- basis_theory/types/three_ds_authentication.py +53 -0
- basis_theory/types/three_ds_callback_urls.py +20 -0
- basis_theory/types/three_ds_cardholder_account_info.py +33 -0
- basis_theory/types/three_ds_cardholder_authentication_info.py +21 -0
- basis_theory/types/three_ds_cardholder_info.py +36 -0
- basis_theory/types/three_ds_cardholder_phone_number.py +20 -0
- basis_theory/types/three_ds_device_info.py +36 -0
- basis_theory/types/three_ds_merchant_info.py +26 -0
- basis_theory/types/three_ds_merchant_risk_info.py +27 -0
- basis_theory/types/three_ds_message_extension.py +22 -0
- basis_theory/types/three_ds_method.py +20 -0
- basis_theory/types/three_ds_mobile_sdk_render_options.py +20 -0
- basis_theory/types/three_ds_prior_authentication_info.py +22 -0
- basis_theory/types/three_ds_purchase_info.py +26 -0
- basis_theory/types/three_ds_requestor_info.py +25 -0
- basis_theory/types/three_ds_session.py +42 -0
- basis_theory/types/three_ds_version.py +25 -0
- basis_theory/types/token.py +49 -0
- basis_theory/types/token_cursor_paginated_list.py +22 -0
- basis_theory/types/token_enrichments.py +22 -0
- basis_theory/types/token_enrichments_card_details.py +20 -0
- basis_theory/types/token_extras.py +24 -0
- basis_theory/types/token_intent.py +36 -0
- basis_theory/types/token_intent_extras.py +21 -0
- basis_theory/types/token_paginated_list.py +22 -0
- basis_theory/types/token_service_provider_details.py +34 -0
- basis_theory/types/update_privacy.py +20 -0
- basis_theory/types/update_reactor_formula_request.py +27 -0
- basis_theory/types/user.py +25 -0
- basis_theory/types/validation_problem_details.py +24 -0
- basis_theory/types/webhook.py +35 -0
- basis_theory/types/webhook_list.py +22 -0
- basis_theory/types/webhook_list_pagination.py +20 -0
- basis_theory/types/webhook_status.py +5 -0
- basis_theory/version.py +3 -0
- basis_theory/webhooks/__init__.py +7 -0
- basis_theory/webhooks/client.py +543 -0
- basis_theory/webhooks/events/__init__.py +4 -0
- basis_theory/webhooks/events/client.py +102 -0
- basis_theory/webhooks/events/raw_client.py +136 -0
- basis_theory/webhooks/raw_client.py +943 -0
- basistheoryclient-0.0.1.dist-info/LICENSE +201 -0
- basistheoryclient-0.0.1.dist-info/METADATA +213 -0
- basistheoryclient-0.0.1.dist-info/RECORD +283 -0
- basistheoryclient-0.0.1.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import contextlib
|
|
4
|
+
import typing
|
|
5
|
+
from json.decoder import JSONDecodeError
|
|
6
|
+
|
|
7
|
+
from ...core.api_error import ApiError
|
|
8
|
+
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
9
|
+
from ...core.http_response import AsyncHttpResponse, HttpResponse
|
|
10
|
+
from ...core.jsonable_encoder import jsonable_encoder
|
|
11
|
+
from ...core.pydantic_utilities import parse_obj_as
|
|
12
|
+
from ...core.request_options import RequestOptions
|
|
13
|
+
from ...errors.forbidden_error import ForbiddenError
|
|
14
|
+
from ...errors.not_found_error import NotFoundError
|
|
15
|
+
from ...errors.unauthorized_error import UnauthorizedError
|
|
16
|
+
from ...types.problem_details import ProblemDetails
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class RawDataClient:
|
|
20
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
21
|
+
self._client_wrapper = client_wrapper
|
|
22
|
+
|
|
23
|
+
@contextlib.contextmanager
|
|
24
|
+
def get(
|
|
25
|
+
self, document_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
26
|
+
) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]:
|
|
27
|
+
"""
|
|
28
|
+
Parameters
|
|
29
|
+
----------
|
|
30
|
+
document_id : str
|
|
31
|
+
|
|
32
|
+
request_options : typing.Optional[RequestOptions]
|
|
33
|
+
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
|
|
34
|
+
|
|
35
|
+
Returns
|
|
36
|
+
-------
|
|
37
|
+
typing.Iterator[HttpResponse[typing.Iterator[bytes]]]
|
|
38
|
+
Success
|
|
39
|
+
"""
|
|
40
|
+
with self._client_wrapper.httpx_client.stream(
|
|
41
|
+
f"documents/{jsonable_encoder(document_id)}/data",
|
|
42
|
+
method="GET",
|
|
43
|
+
request_options=request_options,
|
|
44
|
+
) as _response:
|
|
45
|
+
|
|
46
|
+
def _stream() -> HttpResponse[typing.Iterator[bytes]]:
|
|
47
|
+
try:
|
|
48
|
+
if 200 <= _response.status_code < 300:
|
|
49
|
+
_chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
|
|
50
|
+
return HttpResponse(
|
|
51
|
+
response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size))
|
|
52
|
+
)
|
|
53
|
+
_response.read()
|
|
54
|
+
if _response.status_code == 401:
|
|
55
|
+
raise UnauthorizedError(
|
|
56
|
+
headers=dict(_response.headers),
|
|
57
|
+
body=typing.cast(
|
|
58
|
+
ProblemDetails,
|
|
59
|
+
parse_obj_as(
|
|
60
|
+
type_=ProblemDetails, # type: ignore
|
|
61
|
+
object_=_response.json(),
|
|
62
|
+
),
|
|
63
|
+
),
|
|
64
|
+
)
|
|
65
|
+
if _response.status_code == 403:
|
|
66
|
+
raise ForbiddenError(
|
|
67
|
+
headers=dict(_response.headers),
|
|
68
|
+
body=typing.cast(
|
|
69
|
+
ProblemDetails,
|
|
70
|
+
parse_obj_as(
|
|
71
|
+
type_=ProblemDetails, # type: ignore
|
|
72
|
+
object_=_response.json(),
|
|
73
|
+
),
|
|
74
|
+
),
|
|
75
|
+
)
|
|
76
|
+
if _response.status_code == 404:
|
|
77
|
+
raise NotFoundError(
|
|
78
|
+
headers=dict(_response.headers),
|
|
79
|
+
body=typing.cast(
|
|
80
|
+
typing.Optional[typing.Any],
|
|
81
|
+
parse_obj_as(
|
|
82
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
83
|
+
object_=_response.json(),
|
|
84
|
+
),
|
|
85
|
+
),
|
|
86
|
+
)
|
|
87
|
+
_response_json = _response.json()
|
|
88
|
+
except JSONDecodeError:
|
|
89
|
+
raise ApiError(
|
|
90
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.text
|
|
91
|
+
)
|
|
92
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
93
|
+
|
|
94
|
+
yield _stream()
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class AsyncRawDataClient:
|
|
98
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
99
|
+
self._client_wrapper = client_wrapper
|
|
100
|
+
|
|
101
|
+
@contextlib.asynccontextmanager
|
|
102
|
+
async def get(
|
|
103
|
+
self, document_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
104
|
+
) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]:
|
|
105
|
+
"""
|
|
106
|
+
Parameters
|
|
107
|
+
----------
|
|
108
|
+
document_id : str
|
|
109
|
+
|
|
110
|
+
request_options : typing.Optional[RequestOptions]
|
|
111
|
+
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
|
|
112
|
+
|
|
113
|
+
Returns
|
|
114
|
+
-------
|
|
115
|
+
typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]
|
|
116
|
+
Success
|
|
117
|
+
"""
|
|
118
|
+
async with self._client_wrapper.httpx_client.stream(
|
|
119
|
+
f"documents/{jsonable_encoder(document_id)}/data",
|
|
120
|
+
method="GET",
|
|
121
|
+
request_options=request_options,
|
|
122
|
+
) as _response:
|
|
123
|
+
|
|
124
|
+
async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]:
|
|
125
|
+
try:
|
|
126
|
+
if 200 <= _response.status_code < 300:
|
|
127
|
+
_chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
|
|
128
|
+
return AsyncHttpResponse(
|
|
129
|
+
response=_response,
|
|
130
|
+
data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)),
|
|
131
|
+
)
|
|
132
|
+
await _response.aread()
|
|
133
|
+
if _response.status_code == 401:
|
|
134
|
+
raise UnauthorizedError(
|
|
135
|
+
headers=dict(_response.headers),
|
|
136
|
+
body=typing.cast(
|
|
137
|
+
ProblemDetails,
|
|
138
|
+
parse_obj_as(
|
|
139
|
+
type_=ProblemDetails, # type: ignore
|
|
140
|
+
object_=_response.json(),
|
|
141
|
+
),
|
|
142
|
+
),
|
|
143
|
+
)
|
|
144
|
+
if _response.status_code == 403:
|
|
145
|
+
raise ForbiddenError(
|
|
146
|
+
headers=dict(_response.headers),
|
|
147
|
+
body=typing.cast(
|
|
148
|
+
ProblemDetails,
|
|
149
|
+
parse_obj_as(
|
|
150
|
+
type_=ProblemDetails, # type: ignore
|
|
151
|
+
object_=_response.json(),
|
|
152
|
+
),
|
|
153
|
+
),
|
|
154
|
+
)
|
|
155
|
+
if _response.status_code == 404:
|
|
156
|
+
raise NotFoundError(
|
|
157
|
+
headers=dict(_response.headers),
|
|
158
|
+
body=typing.cast(
|
|
159
|
+
typing.Optional[typing.Any],
|
|
160
|
+
parse_obj_as(
|
|
161
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
162
|
+
object_=_response.json(),
|
|
163
|
+
),
|
|
164
|
+
),
|
|
165
|
+
)
|
|
166
|
+
_response_json = _response.json()
|
|
167
|
+
except JSONDecodeError:
|
|
168
|
+
raise ApiError(
|
|
169
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.text
|
|
170
|
+
)
|
|
171
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
172
|
+
|
|
173
|
+
yield await _stream()
|
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import typing
|
|
5
|
+
from json.decoder import JSONDecodeError
|
|
6
|
+
|
|
7
|
+
from .. import core
|
|
8
|
+
from ..core.api_error import ApiError
|
|
9
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
10
|
+
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
11
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
|
12
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
13
|
+
from ..core.request_options import RequestOptions
|
|
14
|
+
from ..errors.bad_request_error import BadRequestError
|
|
15
|
+
from ..errors.forbidden_error import ForbiddenError
|
|
16
|
+
from ..errors.not_found_error import NotFoundError
|
|
17
|
+
from ..errors.unauthorized_error import UnauthorizedError
|
|
18
|
+
from ..types.create_document_request import CreateDocumentRequest
|
|
19
|
+
from ..types.document import Document
|
|
20
|
+
from ..types.problem_details import ProblemDetails
|
|
21
|
+
from ..types.validation_problem_details import ValidationProblemDetails
|
|
22
|
+
|
|
23
|
+
# this is used as the default value for optional parameters
|
|
24
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class RawDocumentsClient:
|
|
28
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
29
|
+
self._client_wrapper = client_wrapper
|
|
30
|
+
|
|
31
|
+
def upload(
|
|
32
|
+
self,
|
|
33
|
+
*,
|
|
34
|
+
document: typing.Optional[core.File] = OMIT,
|
|
35
|
+
request: typing.Optional[CreateDocumentRequest] = OMIT,
|
|
36
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
37
|
+
) -> HttpResponse[Document]:
|
|
38
|
+
"""
|
|
39
|
+
Parameters
|
|
40
|
+
----------
|
|
41
|
+
document : typing.Optional[core.File]
|
|
42
|
+
See core.File for more documentation
|
|
43
|
+
|
|
44
|
+
request : typing.Optional[CreateDocumentRequest]
|
|
45
|
+
|
|
46
|
+
request_options : typing.Optional[RequestOptions]
|
|
47
|
+
Request-specific configuration.
|
|
48
|
+
|
|
49
|
+
Returns
|
|
50
|
+
-------
|
|
51
|
+
HttpResponse[Document]
|
|
52
|
+
Accepted
|
|
53
|
+
"""
|
|
54
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
55
|
+
"documents",
|
|
56
|
+
method="POST",
|
|
57
|
+
data={},
|
|
58
|
+
files={
|
|
59
|
+
**({"document": document} if document is not None else {}),
|
|
60
|
+
**(
|
|
61
|
+
{"request": (None, json.dumps(jsonable_encoder(request)), "application/json")}
|
|
62
|
+
if request is not OMIT
|
|
63
|
+
else {}
|
|
64
|
+
),
|
|
65
|
+
},
|
|
66
|
+
request_options=request_options,
|
|
67
|
+
omit=OMIT,
|
|
68
|
+
force_multipart=True,
|
|
69
|
+
)
|
|
70
|
+
try:
|
|
71
|
+
if 200 <= _response.status_code < 300:
|
|
72
|
+
_data = typing.cast(
|
|
73
|
+
Document,
|
|
74
|
+
parse_obj_as(
|
|
75
|
+
type_=Document, # type: ignore
|
|
76
|
+
object_=_response.json(),
|
|
77
|
+
),
|
|
78
|
+
)
|
|
79
|
+
return HttpResponse(response=_response, data=_data)
|
|
80
|
+
if _response.status_code == 400:
|
|
81
|
+
raise BadRequestError(
|
|
82
|
+
headers=dict(_response.headers),
|
|
83
|
+
body=typing.cast(
|
|
84
|
+
ValidationProblemDetails,
|
|
85
|
+
parse_obj_as(
|
|
86
|
+
type_=ValidationProblemDetails, # type: ignore
|
|
87
|
+
object_=_response.json(),
|
|
88
|
+
),
|
|
89
|
+
),
|
|
90
|
+
)
|
|
91
|
+
if _response.status_code == 401:
|
|
92
|
+
raise UnauthorizedError(
|
|
93
|
+
headers=dict(_response.headers),
|
|
94
|
+
body=typing.cast(
|
|
95
|
+
ProblemDetails,
|
|
96
|
+
parse_obj_as(
|
|
97
|
+
type_=ProblemDetails, # type: ignore
|
|
98
|
+
object_=_response.json(),
|
|
99
|
+
),
|
|
100
|
+
),
|
|
101
|
+
)
|
|
102
|
+
if _response.status_code == 403:
|
|
103
|
+
raise ForbiddenError(
|
|
104
|
+
headers=dict(_response.headers),
|
|
105
|
+
body=typing.cast(
|
|
106
|
+
ProblemDetails,
|
|
107
|
+
parse_obj_as(
|
|
108
|
+
type_=ProblemDetails, # type: ignore
|
|
109
|
+
object_=_response.json(),
|
|
110
|
+
),
|
|
111
|
+
),
|
|
112
|
+
)
|
|
113
|
+
_response_json = _response.json()
|
|
114
|
+
except JSONDecodeError:
|
|
115
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
116
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
117
|
+
|
|
118
|
+
def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[Document]:
|
|
119
|
+
"""
|
|
120
|
+
Parameters
|
|
121
|
+
----------
|
|
122
|
+
id : str
|
|
123
|
+
|
|
124
|
+
request_options : typing.Optional[RequestOptions]
|
|
125
|
+
Request-specific configuration.
|
|
126
|
+
|
|
127
|
+
Returns
|
|
128
|
+
-------
|
|
129
|
+
HttpResponse[Document]
|
|
130
|
+
Success
|
|
131
|
+
"""
|
|
132
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
133
|
+
f"documents/{jsonable_encoder(id)}",
|
|
134
|
+
method="GET",
|
|
135
|
+
request_options=request_options,
|
|
136
|
+
)
|
|
137
|
+
try:
|
|
138
|
+
if 200 <= _response.status_code < 300:
|
|
139
|
+
_data = typing.cast(
|
|
140
|
+
Document,
|
|
141
|
+
parse_obj_as(
|
|
142
|
+
type_=Document, # type: ignore
|
|
143
|
+
object_=_response.json(),
|
|
144
|
+
),
|
|
145
|
+
)
|
|
146
|
+
return HttpResponse(response=_response, data=_data)
|
|
147
|
+
if _response.status_code == 401:
|
|
148
|
+
raise UnauthorizedError(
|
|
149
|
+
headers=dict(_response.headers),
|
|
150
|
+
body=typing.cast(
|
|
151
|
+
ProblemDetails,
|
|
152
|
+
parse_obj_as(
|
|
153
|
+
type_=ProblemDetails, # type: ignore
|
|
154
|
+
object_=_response.json(),
|
|
155
|
+
),
|
|
156
|
+
),
|
|
157
|
+
)
|
|
158
|
+
if _response.status_code == 403:
|
|
159
|
+
raise ForbiddenError(
|
|
160
|
+
headers=dict(_response.headers),
|
|
161
|
+
body=typing.cast(
|
|
162
|
+
ProblemDetails,
|
|
163
|
+
parse_obj_as(
|
|
164
|
+
type_=ProblemDetails, # type: ignore
|
|
165
|
+
object_=_response.json(),
|
|
166
|
+
),
|
|
167
|
+
),
|
|
168
|
+
)
|
|
169
|
+
if _response.status_code == 404:
|
|
170
|
+
raise NotFoundError(
|
|
171
|
+
headers=dict(_response.headers),
|
|
172
|
+
body=typing.cast(
|
|
173
|
+
typing.Optional[typing.Any],
|
|
174
|
+
parse_obj_as(
|
|
175
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
176
|
+
object_=_response.json(),
|
|
177
|
+
),
|
|
178
|
+
),
|
|
179
|
+
)
|
|
180
|
+
_response_json = _response.json()
|
|
181
|
+
except JSONDecodeError:
|
|
182
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
183
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
184
|
+
|
|
185
|
+
def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]:
|
|
186
|
+
"""
|
|
187
|
+
Parameters
|
|
188
|
+
----------
|
|
189
|
+
id : str
|
|
190
|
+
|
|
191
|
+
request_options : typing.Optional[RequestOptions]
|
|
192
|
+
Request-specific configuration.
|
|
193
|
+
|
|
194
|
+
Returns
|
|
195
|
+
-------
|
|
196
|
+
HttpResponse[None]
|
|
197
|
+
"""
|
|
198
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
199
|
+
f"documents/{jsonable_encoder(id)}",
|
|
200
|
+
method="DELETE",
|
|
201
|
+
request_options=request_options,
|
|
202
|
+
)
|
|
203
|
+
try:
|
|
204
|
+
if 200 <= _response.status_code < 300:
|
|
205
|
+
return HttpResponse(response=_response, data=None)
|
|
206
|
+
if _response.status_code == 401:
|
|
207
|
+
raise UnauthorizedError(
|
|
208
|
+
headers=dict(_response.headers),
|
|
209
|
+
body=typing.cast(
|
|
210
|
+
ProblemDetails,
|
|
211
|
+
parse_obj_as(
|
|
212
|
+
type_=ProblemDetails, # type: ignore
|
|
213
|
+
object_=_response.json(),
|
|
214
|
+
),
|
|
215
|
+
),
|
|
216
|
+
)
|
|
217
|
+
if _response.status_code == 403:
|
|
218
|
+
raise ForbiddenError(
|
|
219
|
+
headers=dict(_response.headers),
|
|
220
|
+
body=typing.cast(
|
|
221
|
+
ProblemDetails,
|
|
222
|
+
parse_obj_as(
|
|
223
|
+
type_=ProblemDetails, # type: ignore
|
|
224
|
+
object_=_response.json(),
|
|
225
|
+
),
|
|
226
|
+
),
|
|
227
|
+
)
|
|
228
|
+
_response_json = _response.json()
|
|
229
|
+
except JSONDecodeError:
|
|
230
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
231
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
class AsyncRawDocumentsClient:
|
|
235
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
236
|
+
self._client_wrapper = client_wrapper
|
|
237
|
+
|
|
238
|
+
async def upload(
|
|
239
|
+
self,
|
|
240
|
+
*,
|
|
241
|
+
document: typing.Optional[core.File] = OMIT,
|
|
242
|
+
request: typing.Optional[CreateDocumentRequest] = OMIT,
|
|
243
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
244
|
+
) -> AsyncHttpResponse[Document]:
|
|
245
|
+
"""
|
|
246
|
+
Parameters
|
|
247
|
+
----------
|
|
248
|
+
document : typing.Optional[core.File]
|
|
249
|
+
See core.File for more documentation
|
|
250
|
+
|
|
251
|
+
request : typing.Optional[CreateDocumentRequest]
|
|
252
|
+
|
|
253
|
+
request_options : typing.Optional[RequestOptions]
|
|
254
|
+
Request-specific configuration.
|
|
255
|
+
|
|
256
|
+
Returns
|
|
257
|
+
-------
|
|
258
|
+
AsyncHttpResponse[Document]
|
|
259
|
+
Accepted
|
|
260
|
+
"""
|
|
261
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
262
|
+
"documents",
|
|
263
|
+
method="POST",
|
|
264
|
+
data={},
|
|
265
|
+
files={
|
|
266
|
+
**({"document": document} if document is not None else {}),
|
|
267
|
+
**(
|
|
268
|
+
{"request": (None, json.dumps(jsonable_encoder(request)), "application/json")}
|
|
269
|
+
if request is not OMIT
|
|
270
|
+
else {}
|
|
271
|
+
),
|
|
272
|
+
},
|
|
273
|
+
request_options=request_options,
|
|
274
|
+
omit=OMIT,
|
|
275
|
+
force_multipart=True,
|
|
276
|
+
)
|
|
277
|
+
try:
|
|
278
|
+
if 200 <= _response.status_code < 300:
|
|
279
|
+
_data = typing.cast(
|
|
280
|
+
Document,
|
|
281
|
+
parse_obj_as(
|
|
282
|
+
type_=Document, # type: ignore
|
|
283
|
+
object_=_response.json(),
|
|
284
|
+
),
|
|
285
|
+
)
|
|
286
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
287
|
+
if _response.status_code == 400:
|
|
288
|
+
raise BadRequestError(
|
|
289
|
+
headers=dict(_response.headers),
|
|
290
|
+
body=typing.cast(
|
|
291
|
+
ValidationProblemDetails,
|
|
292
|
+
parse_obj_as(
|
|
293
|
+
type_=ValidationProblemDetails, # type: ignore
|
|
294
|
+
object_=_response.json(),
|
|
295
|
+
),
|
|
296
|
+
),
|
|
297
|
+
)
|
|
298
|
+
if _response.status_code == 401:
|
|
299
|
+
raise UnauthorizedError(
|
|
300
|
+
headers=dict(_response.headers),
|
|
301
|
+
body=typing.cast(
|
|
302
|
+
ProblemDetails,
|
|
303
|
+
parse_obj_as(
|
|
304
|
+
type_=ProblemDetails, # type: ignore
|
|
305
|
+
object_=_response.json(),
|
|
306
|
+
),
|
|
307
|
+
),
|
|
308
|
+
)
|
|
309
|
+
if _response.status_code == 403:
|
|
310
|
+
raise ForbiddenError(
|
|
311
|
+
headers=dict(_response.headers),
|
|
312
|
+
body=typing.cast(
|
|
313
|
+
ProblemDetails,
|
|
314
|
+
parse_obj_as(
|
|
315
|
+
type_=ProblemDetails, # type: ignore
|
|
316
|
+
object_=_response.json(),
|
|
317
|
+
),
|
|
318
|
+
),
|
|
319
|
+
)
|
|
320
|
+
_response_json = _response.json()
|
|
321
|
+
except JSONDecodeError:
|
|
322
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
323
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
324
|
+
|
|
325
|
+
async def get(
|
|
326
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
327
|
+
) -> AsyncHttpResponse[Document]:
|
|
328
|
+
"""
|
|
329
|
+
Parameters
|
|
330
|
+
----------
|
|
331
|
+
id : str
|
|
332
|
+
|
|
333
|
+
request_options : typing.Optional[RequestOptions]
|
|
334
|
+
Request-specific configuration.
|
|
335
|
+
|
|
336
|
+
Returns
|
|
337
|
+
-------
|
|
338
|
+
AsyncHttpResponse[Document]
|
|
339
|
+
Success
|
|
340
|
+
"""
|
|
341
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
342
|
+
f"documents/{jsonable_encoder(id)}",
|
|
343
|
+
method="GET",
|
|
344
|
+
request_options=request_options,
|
|
345
|
+
)
|
|
346
|
+
try:
|
|
347
|
+
if 200 <= _response.status_code < 300:
|
|
348
|
+
_data = typing.cast(
|
|
349
|
+
Document,
|
|
350
|
+
parse_obj_as(
|
|
351
|
+
type_=Document, # type: ignore
|
|
352
|
+
object_=_response.json(),
|
|
353
|
+
),
|
|
354
|
+
)
|
|
355
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
356
|
+
if _response.status_code == 401:
|
|
357
|
+
raise UnauthorizedError(
|
|
358
|
+
headers=dict(_response.headers),
|
|
359
|
+
body=typing.cast(
|
|
360
|
+
ProblemDetails,
|
|
361
|
+
parse_obj_as(
|
|
362
|
+
type_=ProblemDetails, # type: ignore
|
|
363
|
+
object_=_response.json(),
|
|
364
|
+
),
|
|
365
|
+
),
|
|
366
|
+
)
|
|
367
|
+
if _response.status_code == 403:
|
|
368
|
+
raise ForbiddenError(
|
|
369
|
+
headers=dict(_response.headers),
|
|
370
|
+
body=typing.cast(
|
|
371
|
+
ProblemDetails,
|
|
372
|
+
parse_obj_as(
|
|
373
|
+
type_=ProblemDetails, # type: ignore
|
|
374
|
+
object_=_response.json(),
|
|
375
|
+
),
|
|
376
|
+
),
|
|
377
|
+
)
|
|
378
|
+
if _response.status_code == 404:
|
|
379
|
+
raise NotFoundError(
|
|
380
|
+
headers=dict(_response.headers),
|
|
381
|
+
body=typing.cast(
|
|
382
|
+
typing.Optional[typing.Any],
|
|
383
|
+
parse_obj_as(
|
|
384
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
385
|
+
object_=_response.json(),
|
|
386
|
+
),
|
|
387
|
+
),
|
|
388
|
+
)
|
|
389
|
+
_response_json = _response.json()
|
|
390
|
+
except JSONDecodeError:
|
|
391
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
392
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
393
|
+
|
|
394
|
+
async def delete(
|
|
395
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
396
|
+
) -> AsyncHttpResponse[None]:
|
|
397
|
+
"""
|
|
398
|
+
Parameters
|
|
399
|
+
----------
|
|
400
|
+
id : str
|
|
401
|
+
|
|
402
|
+
request_options : typing.Optional[RequestOptions]
|
|
403
|
+
Request-specific configuration.
|
|
404
|
+
|
|
405
|
+
Returns
|
|
406
|
+
-------
|
|
407
|
+
AsyncHttpResponse[None]
|
|
408
|
+
"""
|
|
409
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
410
|
+
f"documents/{jsonable_encoder(id)}",
|
|
411
|
+
method="DELETE",
|
|
412
|
+
request_options=request_options,
|
|
413
|
+
)
|
|
414
|
+
try:
|
|
415
|
+
if 200 <= _response.status_code < 300:
|
|
416
|
+
return AsyncHttpResponse(response=_response, data=None)
|
|
417
|
+
if _response.status_code == 401:
|
|
418
|
+
raise UnauthorizedError(
|
|
419
|
+
headers=dict(_response.headers),
|
|
420
|
+
body=typing.cast(
|
|
421
|
+
ProblemDetails,
|
|
422
|
+
parse_obj_as(
|
|
423
|
+
type_=ProblemDetails, # type: ignore
|
|
424
|
+
object_=_response.json(),
|
|
425
|
+
),
|
|
426
|
+
),
|
|
427
|
+
)
|
|
428
|
+
if _response.status_code == 403:
|
|
429
|
+
raise ForbiddenError(
|
|
430
|
+
headers=dict(_response.headers),
|
|
431
|
+
body=typing.cast(
|
|
432
|
+
ProblemDetails,
|
|
433
|
+
parse_obj_as(
|
|
434
|
+
type_=ProblemDetails, # type: ignore
|
|
435
|
+
object_=_response.json(),
|
|
436
|
+
),
|
|
437
|
+
),
|
|
438
|
+
)
|
|
439
|
+
_response_json = _response.json()
|
|
440
|
+
except JSONDecodeError:
|
|
441
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
442
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|