mixpeek 0.12.0__py3-none-any.whl → 0.13__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.
- mixpeek/__init__.py +5 -79
- mixpeek/_hooks/__init__.py +5 -0
- mixpeek/_hooks/registration.py +13 -0
- mixpeek/_hooks/sdkhooks.py +76 -0
- mixpeek/_hooks/types.py +94 -0
- mixpeek/_version.py +11 -3
- mixpeek/assets.py +1561 -0
- mixpeek/basesdk.py +350 -0
- mixpeek/collections.py +1029 -0
- mixpeek/featureextractors.py +205 -0
- mixpeek/features.py +1181 -0
- mixpeek/health.py +167 -0
- mixpeek/httpclient.py +84 -0
- mixpeek/ingest.py +831 -0
- mixpeek/interactions.py +221 -0
- mixpeek/models/__init__.py +751 -0
- mixpeek/models/actionusage.py +16 -0
- mixpeek/models/apierror.py +22 -0
- mixpeek/models/apikey.py +25 -0
- mixpeek/models/apikeyupdate.py +49 -0
- mixpeek/models/assetfeatures.py +55 -0
- mixpeek/models/assetresponse.py +166 -0
- mixpeek/models/assets_model_searchquery.py +21 -0
- mixpeek/models/assetupdate.py +28 -0
- mixpeek/models/availableindexesresponse.py +23 -0
- mixpeek/models/availablemodels.py +12 -0
- mixpeek/models/boolindexparams.py +18 -0
- mixpeek/models/collectionmodel.py +70 -0
- mixpeek/models/collectionresult.py +73 -0
- mixpeek/models/create_api_key_organizations_users_user_email_api_keys_postop.py +23 -0
- mixpeek/models/create_collection_collections_postop.py +62 -0
- mixpeek/models/create_interaction_features_search_interactions_postop.py +59 -0
- mixpeek/models/createcollectionrequest.py +59 -0
- mixpeek/models/createnamespacerequest.py +62 -0
- mixpeek/models/datetimeindexparams.py +18 -0
- mixpeek/models/dateusage.py +22 -0
- mixpeek/models/db_model_paginationresponse.py +59 -0
- mixpeek/models/db_model_taskresponse.py +20 -0
- mixpeek/models/delete_api_key_organizations_users_user_email_api_keys_key_name_deleteop.py +23 -0
- mixpeek/models/delete_asset_assets_asset_id_deleteop.py +57 -0
- mixpeek/models/delete_collection_collections_collection_deleteop.py +59 -0
- mixpeek/models/delete_feature_features_feature_id_deleteop.py +57 -0
- mixpeek/models/delete_interaction_features_search_interactions_interaction_id_deleteop.py +59 -0
- mixpeek/models/delete_namespace_namespaces_namespace_deleteop.py +18 -0
- mixpeek/models/delete_user_organizations_users_user_email_deleteop.py +16 -0
- mixpeek/models/denseembedding.py +16 -0
- mixpeek/models/embeddingrequest.py +59 -0
- mixpeek/models/embeddingresponse.py +64 -0
- mixpeek/models/errormessage.py +13 -0
- mixpeek/models/errorresponse.py +21 -0
- mixpeek/models/facedetectsettings.py +52 -0
- mixpeek/models/featureextractionembeddingrequest.py +54 -0
- mixpeek/models/featureresponse.py +74 -0
- mixpeek/models/features_model_paginationresponse.py +59 -0
- mixpeek/models/featureupdaterequest.py +21 -0
- mixpeek/models/filtercondition.py +74 -0
- mixpeek/models/floatindexparams.py +18 -0
- mixpeek/models/full_asset_update_assets_asset_id_putop.py +69 -0
- mixpeek/models/full_feature_update_features_feature_id_putop.py +69 -0
- mixpeek/models/geoindexparams.py +18 -0
- mixpeek/models/get_asset_assets_asset_id_getop.py +73 -0
- mixpeek/models/get_asset_with_features_assets_asset_id_features_getop.py +73 -0
- mixpeek/models/get_collection_collections_collection_getop.py +59 -0
- mixpeek/models/get_feature_features_feature_id_getop.py +70 -0
- mixpeek/models/get_interaction_features_search_interactions_interaction_id_getop.py +59 -0
- mixpeek/models/get_namespace_namespaces_namespace_getop.py +18 -0
- mixpeek/models/get_task_tasks_task_id_getop.py +57 -0
- mixpeek/models/get_user_organizations_users_user_email_getop.py +16 -0
- mixpeek/models/groupbyoptions.py +71 -0
- mixpeek/models/groupbyoptionsasset.py +71 -0
- mixpeek/models/groupedassetdata.py +18 -0
- mixpeek/models/healthcheckresponse.py +13 -0
- mixpeek/models/httpvalidationerror.py +21 -0
- mixpeek/models/imagedescribesettings.py +82 -0
- mixpeek/models/imagedetectsettings.py +53 -0
- mixpeek/models/imagereadsettings.py +71 -0
- mixpeek/models/imagesettings.py +79 -0
- mixpeek/models/ingest_image_url_ingest_images_url_postop.py +59 -0
- mixpeek/models/ingest_text_ingest_text_postop.py +59 -0
- mixpeek/models/ingest_video_url_ingest_videos_url_postop.py +59 -0
- mixpeek/models/inputtype.py +11 -0
- mixpeek/models/integerindexparams.py +24 -0
- mixpeek/models/interactionresponse.py +87 -0
- mixpeek/models/interactiontype.py +11 -0
- mixpeek/models/jsonimageoutputsettings.py +55 -0
- mixpeek/models/jsontextoutputsettings.py +55 -0
- mixpeek/models/jsonvideooutputsettings.py +55 -0
- mixpeek/models/keywordindexparams.py +21 -0
- mixpeek/models/kill_task_tasks_task_id_deleteop.py +57 -0
- mixpeek/models/list_assets_assets_postop.py +77 -0
- mixpeek/models/list_collections_collections_getop.py +65 -0
- mixpeek/models/list_features_features_postop.py +79 -0
- mixpeek/models/list_interactions_features_search_interactions_getop.py +96 -0
- mixpeek/models/listassetsrequest.py +75 -0
- mixpeek/models/listassetsresponse.py +22 -0
- mixpeek/models/listcollectionsresponse.py +22 -0
- mixpeek/models/listfeaturesrequest.py +77 -0
- mixpeek/models/listfeaturesresponse.py +22 -0
- mixpeek/models/logicaloperator_input.py +88 -0
- mixpeek/models/logicaloperator_output.py +103 -0
- mixpeek/models/logodetectsettings.py +52 -0
- mixpeek/models/modality.py +13 -0
- mixpeek/models/modeldetails.py +57 -0
- mixpeek/models/namespaceresponse.py +54 -0
- mixpeek/models/organizationmodel.py +45 -0
- mixpeek/models/partial_asset_update_assets_asset_id_patchop.py +69 -0
- mixpeek/models/payloadindexconfig.py +94 -0
- mixpeek/models/payloadindextype.py +17 -0
- mixpeek/models/payloadschematype.py +15 -0
- mixpeek/models/percolaterequest.py +57 -0
- mixpeek/models/permission.py +10 -0
- mixpeek/models/processimageurlinput.py +99 -0
- mixpeek/models/processtextinput.py +94 -0
- mixpeek/models/processvideourlinput.py +99 -0
- mixpeek/models/querysettings.py +56 -0
- mixpeek/models/rerankingoptions.py +47 -0
- mixpeek/models/search_assets_assets_search_postop.py +59 -0
- mixpeek/models/search_features_features_search_postop.py +96 -0
- mixpeek/models/search_model_searchquery_input.py +76 -0
- mixpeek/models/searchassetsrequest.py +78 -0
- mixpeek/models/searchinteraction.py +82 -0
- mixpeek/models/searchquery_output.py +79 -0
- mixpeek/models/searchrequestfeatures_input.py +151 -0
- mixpeek/models/searchrequestfeatures_output.py +151 -0
- mixpeek/models/sortoption.py +28 -0
- mixpeek/models/sparseembedding.py +21 -0
- mixpeek/models/tasks_model_taskresponse.py +24 -0
- mixpeek/models/taskstatus.py +16 -0
- mixpeek/models/textindexparams.py +31 -0
- mixpeek/models/textsettings.py +61 -0
- mixpeek/models/tokenizertype.py +11 -0
- mixpeek/models/update_api_key_organizations_users_user_email_api_keys_key_name_patchop.py +30 -0
- mixpeek/models/update_collection_collections_collection_putop.py +74 -0
- mixpeek/models/update_namespace_namespaces_namespace_putop.py +28 -0
- mixpeek/models/updateassetrequest.py +60 -0
- mixpeek/models/updatenamespacerequest.py +26 -0
- mixpeek/models/usage.py +18 -0
- mixpeek/models/usermodel_input.py +36 -0
- mixpeek/models/usermodel_output.py +36 -0
- mixpeek/models/uuidindexparams.py +21 -0
- mixpeek/models/validationerror.py +26 -0
- mixpeek/models/vectormodel.py +11 -0
- mixpeek/models/vectortype.py +9 -0
- mixpeek/models/videodescribesettings.py +82 -0
- mixpeek/models/videodetectsettings.py +53 -0
- mixpeek/models/videoreadsettings.py +71 -0
- mixpeek/models/videosettings.py +101 -0
- mixpeek/models/videotranscriptionsettings.py +69 -0
- mixpeek/namespaces.py +1143 -0
- mixpeek/organizations.py +1508 -0
- mixpeek/py.typed +1 -0
- mixpeek/sdk.py +135 -0
- mixpeek/sdkconfiguration.py +45 -0
- mixpeek/searchinteractions.py +647 -0
- mixpeek/tasks.py +387 -0
- mixpeek/types/__init__.py +19 -29
- mixpeek/types/basemodel.py +39 -0
- mixpeek/utils/__init__.py +97 -0
- mixpeek/utils/annotations.py +55 -0
- mixpeek/utils/enums.py +34 -0
- mixpeek/utils/eventstreaming.py +238 -0
- mixpeek/utils/forms.py +202 -0
- mixpeek/utils/headers.py +136 -0
- mixpeek/utils/logger.py +27 -0
- mixpeek/utils/metadata.py +118 -0
- mixpeek/utils/queryparams.py +205 -0
- mixpeek/utils/requestbodies.py +66 -0
- mixpeek/utils/retries.py +217 -0
- mixpeek/utils/security.py +174 -0
- mixpeek/utils/serializers.py +215 -0
- mixpeek/utils/url.py +155 -0
- mixpeek/utils/values.py +134 -0
- mixpeek-0.13.dist-info/METADATA +439 -0
- mixpeek-0.13.dist-info/RECORD +176 -0
- {mixpeek-0.12.0.dist-info → mixpeek-0.13.dist-info}/WHEEL +1 -1
- py.typed +1 -0
- mixpeek/_base_client.py +0 -2041
- mixpeek/_client.py +0 -444
- mixpeek/_compat.py +0 -221
- mixpeek/_constants.py +0 -14
- mixpeek/_exceptions.py +0 -108
- mixpeek/_files.py +0 -123
- mixpeek/_models.py +0 -788
- mixpeek/_qs.py +0 -150
- mixpeek/_resource.py +0 -43
- mixpeek/_response.py +0 -824
- mixpeek/_streaming.py +0 -333
- mixpeek/_types.py +0 -219
- mixpeek/_utils/__init__.py +0 -56
- mixpeek/_utils/_logs.py +0 -25
- mixpeek/_utils/_proxy.py +0 -62
- mixpeek/_utils/_reflection.py +0 -42
- mixpeek/_utils/_streams.py +0 -12
- mixpeek/_utils/_sync.py +0 -81
- mixpeek/_utils/_transform.py +0 -387
- mixpeek/_utils/_typing.py +0 -120
- mixpeek/_utils/_utils.py +0 -414
- mixpeek/lib/.keep +0 -4
- mixpeek/resources/__init__.py +0 -117
- mixpeek/resources/accounts.py +0 -271
- mixpeek/resources/assets/__init__.py +0 -33
- mixpeek/resources/assets/assets.py +0 -708
- mixpeek/resources/assets/features.py +0 -172
- mixpeek/resources/collections.py +0 -283
- mixpeek/resources/entities/__init__.py +0 -47
- mixpeek/resources/entities/entities.py +0 -134
- mixpeek/resources/entities/faces.py +0 -514
- mixpeek/resources/entities/labels.py +0 -388
- mixpeek/resources/features/__init__.py +0 -33
- mixpeek/resources/features/features.py +0 -562
- mixpeek/resources/features/search.py +0 -731
- mixpeek/resources/healthcheck.py +0 -135
- mixpeek/resources/index/__init__.py +0 -47
- mixpeek/resources/index/images.py +0 -249
- mixpeek/resources/index/index.py +0 -289
- mixpeek/resources/index/videos.py +0 -249
- mixpeek/resources/tasks.py +0 -258
- mixpeek/types/account_update_params.py +0 -28
- mixpeek/types/asset_create_params.py +0 -36
- mixpeek/types/asset_create_response.py +0 -15
- mixpeek/types/asset_response.py +0 -46
- mixpeek/types/asset_search_params.py +0 -43
- mixpeek/types/asset_search_response.py +0 -15
- mixpeek/types/asset_update_params.py +0 -25
- mixpeek/types/asset_update_response.py +0 -11
- mixpeek/types/assets/__init__.py +0 -3
- mixpeek/types/collection_list_params.py +0 -19
- mixpeek/types/collection_list_response.py +0 -14
- mixpeek/types/entities/__init__.py +0 -13
- mixpeek/types/entities/face_create_params.py +0 -21
- mixpeek/types/entities/face_list_params.py +0 -18
- mixpeek/types/entities/face_list_response.py +0 -15
- mixpeek/types/entities/face_response.py +0 -17
- mixpeek/types/entities/face_update_params.py +0 -22
- mixpeek/types/entities/label_list_params.py +0 -18
- mixpeek/types/entities/label_list_response.py +0 -30
- mixpeek/types/entities/label_response.py +0 -30
- mixpeek/types/entities/label_update_params.py +0 -21
- mixpeek/types/feature.py +0 -32
- mixpeek/types/feature_list_params.py +0 -37
- mixpeek/types/feature_list_response.py +0 -28
- mixpeek/types/feature_retrieve_params.py +0 -18
- mixpeek/types/feature_update_params.py +0 -16
- mixpeek/types/features/__init__.py +0 -8
- mixpeek/types/features/search_feedback_params.py +0 -23
- mixpeek/types/features/search_file_params.py +0 -29
- mixpeek/types/features/search_text_params.py +0 -72
- mixpeek/types/features/search_url_params.py +0 -72
- mixpeek/types/grouped_asset_data.py +0 -24
- mixpeek/types/health_check_response.py +0 -10
- mixpeek/types/index/__init__.py +0 -8
- mixpeek/types/index/image_url_params.py +0 -135
- mixpeek/types/index/image_url_response.py +0 -20
- mixpeek/types/index/video_url_params.py +0 -154
- mixpeek/types/index/video_url_response.py +0 -20
- mixpeek/types/index_text_params.py +0 -77
- mixpeek/types/index_text_response.py +0 -14
- mixpeek/types/shared/__init__.py +0 -7
- mixpeek/types/shared/filter_condition.py +0 -19
- mixpeek/types/shared/logical_operator.py +0 -12
- mixpeek/types/shared/model_pagination_response.py +0 -21
- mixpeek/types/shared/sort_option.py +0 -15
- mixpeek/types/shared/task_response.py +0 -15
- mixpeek/types/shared_params/__init__.py +0 -4
- mixpeek/types/shared_params/logical_operator.py +0 -13
- mixpeek/types/shared_params/sort_option.py +0 -15
- mixpeek/types/user.py +0 -34
- mixpeek-0.12.0.dist-info/METADATA +0 -345
- mixpeek-0.12.0.dist-info/RECORD +0 -99
- mixpeek-0.12.0.dist-info/licenses/LICENSE +0 -201
mixpeek/basesdk.py
ADDED
@@ -0,0 +1,350 @@
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
2
|
+
|
3
|
+
from .sdkconfiguration import SDKConfiguration
|
4
|
+
import httpx
|
5
|
+
from mixpeek import models, utils
|
6
|
+
from mixpeek._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext
|
7
|
+
from mixpeek.utils import RetryConfig, SerializedRequestBody, get_body_content
|
8
|
+
from typing import Callable, List, Mapping, Optional, Tuple
|
9
|
+
from urllib.parse import parse_qs, urlparse
|
10
|
+
|
11
|
+
|
12
|
+
class BaseSDK:
|
13
|
+
sdk_configuration: SDKConfiguration
|
14
|
+
|
15
|
+
def __init__(self, sdk_config: SDKConfiguration) -> None:
|
16
|
+
self.sdk_configuration = sdk_config
|
17
|
+
|
18
|
+
def get_url(self, base_url, url_variables):
|
19
|
+
sdk_url, sdk_variables = self.sdk_configuration.get_server_details()
|
20
|
+
|
21
|
+
if base_url is None:
|
22
|
+
base_url = sdk_url
|
23
|
+
|
24
|
+
if url_variables is None:
|
25
|
+
url_variables = sdk_variables
|
26
|
+
|
27
|
+
return utils.template_url(base_url, url_variables)
|
28
|
+
|
29
|
+
def build_request_async(
|
30
|
+
self,
|
31
|
+
method,
|
32
|
+
path,
|
33
|
+
base_url,
|
34
|
+
url_variables,
|
35
|
+
request,
|
36
|
+
request_body_required,
|
37
|
+
request_has_path_params,
|
38
|
+
request_has_query_params,
|
39
|
+
user_agent_header,
|
40
|
+
accept_header_value,
|
41
|
+
_globals=None,
|
42
|
+
security=None,
|
43
|
+
timeout_ms: Optional[int] = None,
|
44
|
+
get_serialized_body: Optional[
|
45
|
+
Callable[[], Optional[SerializedRequestBody]]
|
46
|
+
] = None,
|
47
|
+
url_override: Optional[str] = None,
|
48
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
49
|
+
) -> httpx.Request:
|
50
|
+
client = self.sdk_configuration.async_client
|
51
|
+
return self.build_request_with_client(
|
52
|
+
client,
|
53
|
+
method,
|
54
|
+
path,
|
55
|
+
base_url,
|
56
|
+
url_variables,
|
57
|
+
request,
|
58
|
+
request_body_required,
|
59
|
+
request_has_path_params,
|
60
|
+
request_has_query_params,
|
61
|
+
user_agent_header,
|
62
|
+
accept_header_value,
|
63
|
+
_globals,
|
64
|
+
security,
|
65
|
+
timeout_ms,
|
66
|
+
get_serialized_body,
|
67
|
+
url_override,
|
68
|
+
http_headers,
|
69
|
+
)
|
70
|
+
|
71
|
+
def build_request(
|
72
|
+
self,
|
73
|
+
method,
|
74
|
+
path,
|
75
|
+
base_url,
|
76
|
+
url_variables,
|
77
|
+
request,
|
78
|
+
request_body_required,
|
79
|
+
request_has_path_params,
|
80
|
+
request_has_query_params,
|
81
|
+
user_agent_header,
|
82
|
+
accept_header_value,
|
83
|
+
_globals=None,
|
84
|
+
security=None,
|
85
|
+
timeout_ms: Optional[int] = None,
|
86
|
+
get_serialized_body: Optional[
|
87
|
+
Callable[[], Optional[SerializedRequestBody]]
|
88
|
+
] = None,
|
89
|
+
url_override: Optional[str] = None,
|
90
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
91
|
+
) -> httpx.Request:
|
92
|
+
client = self.sdk_configuration.client
|
93
|
+
return self.build_request_with_client(
|
94
|
+
client,
|
95
|
+
method,
|
96
|
+
path,
|
97
|
+
base_url,
|
98
|
+
url_variables,
|
99
|
+
request,
|
100
|
+
request_body_required,
|
101
|
+
request_has_path_params,
|
102
|
+
request_has_query_params,
|
103
|
+
user_agent_header,
|
104
|
+
accept_header_value,
|
105
|
+
_globals,
|
106
|
+
security,
|
107
|
+
timeout_ms,
|
108
|
+
get_serialized_body,
|
109
|
+
url_override,
|
110
|
+
http_headers,
|
111
|
+
)
|
112
|
+
|
113
|
+
def build_request_with_client(
|
114
|
+
self,
|
115
|
+
client,
|
116
|
+
method,
|
117
|
+
path,
|
118
|
+
base_url,
|
119
|
+
url_variables,
|
120
|
+
request,
|
121
|
+
request_body_required,
|
122
|
+
request_has_path_params,
|
123
|
+
request_has_query_params,
|
124
|
+
user_agent_header,
|
125
|
+
accept_header_value,
|
126
|
+
_globals=None,
|
127
|
+
security=None,
|
128
|
+
timeout_ms: Optional[int] = None,
|
129
|
+
get_serialized_body: Optional[
|
130
|
+
Callable[[], Optional[SerializedRequestBody]]
|
131
|
+
] = None,
|
132
|
+
url_override: Optional[str] = None,
|
133
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
134
|
+
) -> httpx.Request:
|
135
|
+
query_params = {}
|
136
|
+
|
137
|
+
url = url_override
|
138
|
+
if url is None:
|
139
|
+
url = utils.generate_url(
|
140
|
+
self.get_url(base_url, url_variables),
|
141
|
+
path,
|
142
|
+
request if request_has_path_params else None,
|
143
|
+
_globals if request_has_path_params else None,
|
144
|
+
)
|
145
|
+
|
146
|
+
query_params = utils.get_query_params(
|
147
|
+
request if request_has_query_params else None,
|
148
|
+
_globals if request_has_query_params else None,
|
149
|
+
)
|
150
|
+
else:
|
151
|
+
# Pick up the query parameter from the override so they can be
|
152
|
+
# preserved when building the request later on (necessary as of
|
153
|
+
# httpx 0.28).
|
154
|
+
parsed_override = urlparse(str(url_override))
|
155
|
+
query_params = parse_qs(parsed_override.query, keep_blank_values=True)
|
156
|
+
|
157
|
+
headers = utils.get_headers(request, _globals)
|
158
|
+
headers["Accept"] = accept_header_value
|
159
|
+
headers[user_agent_header] = self.sdk_configuration.user_agent
|
160
|
+
|
161
|
+
if security is not None:
|
162
|
+
if callable(security):
|
163
|
+
security = security()
|
164
|
+
|
165
|
+
if security is not None:
|
166
|
+
security_headers, security_query_params = utils.get_security(security)
|
167
|
+
headers = {**headers, **security_headers}
|
168
|
+
query_params = {**query_params, **security_query_params}
|
169
|
+
|
170
|
+
serialized_request_body = SerializedRequestBody()
|
171
|
+
if get_serialized_body is not None:
|
172
|
+
rb = get_serialized_body()
|
173
|
+
if request_body_required and rb is None:
|
174
|
+
raise ValueError("request body is required")
|
175
|
+
|
176
|
+
if rb is not None:
|
177
|
+
serialized_request_body = rb
|
178
|
+
|
179
|
+
if (
|
180
|
+
serialized_request_body.media_type is not None
|
181
|
+
and serialized_request_body.media_type
|
182
|
+
not in (
|
183
|
+
"multipart/form-data",
|
184
|
+
"multipart/mixed",
|
185
|
+
)
|
186
|
+
):
|
187
|
+
headers["content-type"] = serialized_request_body.media_type
|
188
|
+
|
189
|
+
if http_headers is not None:
|
190
|
+
for header, value in http_headers.items():
|
191
|
+
headers[header] = value
|
192
|
+
|
193
|
+
timeout = timeout_ms / 1000 if timeout_ms is not None else None
|
194
|
+
|
195
|
+
return client.build_request(
|
196
|
+
method,
|
197
|
+
url,
|
198
|
+
params=query_params,
|
199
|
+
content=serialized_request_body.content,
|
200
|
+
data=serialized_request_body.data,
|
201
|
+
files=serialized_request_body.files,
|
202
|
+
headers=headers,
|
203
|
+
timeout=timeout,
|
204
|
+
)
|
205
|
+
|
206
|
+
def do_request(
|
207
|
+
self,
|
208
|
+
hook_ctx,
|
209
|
+
request,
|
210
|
+
error_status_codes,
|
211
|
+
stream=False,
|
212
|
+
retry_config: Optional[Tuple[RetryConfig, List[str]]] = None,
|
213
|
+
) -> httpx.Response:
|
214
|
+
client = self.sdk_configuration.client
|
215
|
+
logger = self.sdk_configuration.debug_logger
|
216
|
+
|
217
|
+
def do():
|
218
|
+
http_res = None
|
219
|
+
try:
|
220
|
+
req = self.sdk_configuration.get_hooks().before_request(
|
221
|
+
BeforeRequestContext(hook_ctx), request
|
222
|
+
)
|
223
|
+
logger.debug(
|
224
|
+
"Request:\nMethod: %s\nURL: %s\nHeaders: %s\nBody: %s",
|
225
|
+
req.method,
|
226
|
+
req.url,
|
227
|
+
req.headers,
|
228
|
+
get_body_content(req),
|
229
|
+
)
|
230
|
+
http_res = client.send(req, stream=stream)
|
231
|
+
except Exception as e:
|
232
|
+
_, e = self.sdk_configuration.get_hooks().after_error(
|
233
|
+
AfterErrorContext(hook_ctx), None, e
|
234
|
+
)
|
235
|
+
if e is not None:
|
236
|
+
logger.debug("Request Exception", exc_info=True)
|
237
|
+
raise e
|
238
|
+
|
239
|
+
if http_res is None:
|
240
|
+
logger.debug("Raising no response SDK error")
|
241
|
+
raise models.APIError("No response received")
|
242
|
+
|
243
|
+
logger.debug(
|
244
|
+
"Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
|
245
|
+
http_res.status_code,
|
246
|
+
http_res.url,
|
247
|
+
http_res.headers,
|
248
|
+
"<streaming response>" if stream else http_res.text,
|
249
|
+
)
|
250
|
+
|
251
|
+
if utils.match_status_codes(error_status_codes, http_res.status_code):
|
252
|
+
result, err = self.sdk_configuration.get_hooks().after_error(
|
253
|
+
AfterErrorContext(hook_ctx), http_res, None
|
254
|
+
)
|
255
|
+
if err is not None:
|
256
|
+
logger.debug("Request Exception", exc_info=True)
|
257
|
+
raise err
|
258
|
+
if result is not None:
|
259
|
+
http_res = result
|
260
|
+
else:
|
261
|
+
logger.debug("Raising unexpected SDK error")
|
262
|
+
raise models.APIError("Unexpected error occurred")
|
263
|
+
|
264
|
+
return http_res
|
265
|
+
|
266
|
+
if retry_config is not None:
|
267
|
+
http_res = utils.retry(do, utils.Retries(retry_config[0], retry_config[1]))
|
268
|
+
else:
|
269
|
+
http_res = do()
|
270
|
+
|
271
|
+
if not utils.match_status_codes(error_status_codes, http_res.status_code):
|
272
|
+
http_res = self.sdk_configuration.get_hooks().after_success(
|
273
|
+
AfterSuccessContext(hook_ctx), http_res
|
274
|
+
)
|
275
|
+
|
276
|
+
return http_res
|
277
|
+
|
278
|
+
async def do_request_async(
|
279
|
+
self,
|
280
|
+
hook_ctx,
|
281
|
+
request,
|
282
|
+
error_status_codes,
|
283
|
+
stream=False,
|
284
|
+
retry_config: Optional[Tuple[RetryConfig, List[str]]] = None,
|
285
|
+
) -> httpx.Response:
|
286
|
+
client = self.sdk_configuration.async_client
|
287
|
+
logger = self.sdk_configuration.debug_logger
|
288
|
+
|
289
|
+
async def do():
|
290
|
+
http_res = None
|
291
|
+
try:
|
292
|
+
req = self.sdk_configuration.get_hooks().before_request(
|
293
|
+
BeforeRequestContext(hook_ctx), request
|
294
|
+
)
|
295
|
+
logger.debug(
|
296
|
+
"Request:\nMethod: %s\nURL: %s\nHeaders: %s\nBody: %s",
|
297
|
+
req.method,
|
298
|
+
req.url,
|
299
|
+
req.headers,
|
300
|
+
get_body_content(req),
|
301
|
+
)
|
302
|
+
http_res = await client.send(req, stream=stream)
|
303
|
+
except Exception as e:
|
304
|
+
_, e = self.sdk_configuration.get_hooks().after_error(
|
305
|
+
AfterErrorContext(hook_ctx), None, e
|
306
|
+
)
|
307
|
+
if e is not None:
|
308
|
+
logger.debug("Request Exception", exc_info=True)
|
309
|
+
raise e
|
310
|
+
|
311
|
+
if http_res is None:
|
312
|
+
logger.debug("Raising no response SDK error")
|
313
|
+
raise models.APIError("No response received")
|
314
|
+
|
315
|
+
logger.debug(
|
316
|
+
"Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
|
317
|
+
http_res.status_code,
|
318
|
+
http_res.url,
|
319
|
+
http_res.headers,
|
320
|
+
"<streaming response>" if stream else http_res.text,
|
321
|
+
)
|
322
|
+
|
323
|
+
if utils.match_status_codes(error_status_codes, http_res.status_code):
|
324
|
+
result, err = self.sdk_configuration.get_hooks().after_error(
|
325
|
+
AfterErrorContext(hook_ctx), http_res, None
|
326
|
+
)
|
327
|
+
if err is not None:
|
328
|
+
logger.debug("Request Exception", exc_info=True)
|
329
|
+
raise err
|
330
|
+
if result is not None:
|
331
|
+
http_res = result
|
332
|
+
else:
|
333
|
+
logger.debug("Raising unexpected SDK error")
|
334
|
+
raise models.APIError("Unexpected error occurred")
|
335
|
+
|
336
|
+
return http_res
|
337
|
+
|
338
|
+
if retry_config is not None:
|
339
|
+
http_res = await utils.retry_async(
|
340
|
+
do, utils.Retries(retry_config[0], retry_config[1])
|
341
|
+
)
|
342
|
+
else:
|
343
|
+
http_res = await do()
|
344
|
+
|
345
|
+
if not utils.match_status_codes(error_status_codes, http_res.status_code):
|
346
|
+
http_res = self.sdk_configuration.get_hooks().after_success(
|
347
|
+
AfterSuccessContext(hook_ctx), http_res
|
348
|
+
)
|
349
|
+
|
350
|
+
return http_res
|