autoassembler 0.3.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.
- autoassembler/.fernignore +7 -0
- autoassembler/__init__.py +537 -0
- autoassembler/_custom/__init__.py +56 -0
- autoassembler/_custom/assemblies.py +226 -0
- autoassembler/_custom/assemblies_api.py +188 -0
- autoassembler/_custom/credentials.py +248 -0
- autoassembler/_custom/http.py +42 -0
- autoassembler/_custom/operations.py +258 -0
- autoassembler/_custom/planning.py +598 -0
- autoassembler/_custom/planning_api.py +225 -0
- autoassembler/_default_clients.py +32 -0
- autoassembler/_version.py +8 -0
- autoassembler/alpha/__init__.py +63 -0
- autoassembler/alpha/client.py +82 -0
- autoassembler/alpha/jobs/__init__.py +39 -0
- autoassembler/alpha/jobs/client.py +338 -0
- autoassembler/alpha/jobs/raw_client.py +641 -0
- autoassembler/alpha/jobs/types/__init__.py +42 -0
- autoassembler/alpha/jobs/types/cancel_job_jobs_response.py +12 -0
- autoassembler/alpha/jobs/types/list_jobs_jobs_response.py +30 -0
- autoassembler/alpha/jobs/types/list_jobs_jobs_response_pagination.py +22 -0
- autoassembler/alpha/jobs/types/retry_job_jobs_response.py +16 -0
- autoassembler/alpha/planning/__init__.py +49 -0
- autoassembler/alpha/planning/client.py +201 -0
- autoassembler/alpha/planning/raw_client.py +268 -0
- autoassembler/alpha/planning/types/__init__.py +47 -0
- autoassembler/alpha/planning/types/apply_ops_planning_request_namespace.py +5 -0
- autoassembler/alpha/planning/types/apply_ops_planning_request_ops_item.py +13 -0
- autoassembler/alpha/planning/types/apply_ops_planning_request_ops_item_op.py +58 -0
- autoassembler/alpha/planning/types/apply_ops_planning_response.py +13 -0
- autoassembler/alpha/raw_client.py +13 -0
- autoassembler/assemblies/__init__.py +73 -0
- autoassembler/assemblies/client.py +1177 -0
- autoassembler/assemblies/raw_client.py +1557 -0
- autoassembler/assemblies/types/__init__.py +71 -0
- autoassembler/assemblies/types/delete_assembly_response.py +12 -0
- autoassembler/assemblies/types/download_assembly_cad_request_namespace.py +5 -0
- autoassembler/assemblies/types/get_assembly_info_request_namespace.py +5 -0
- autoassembler/assemblies/types/get_status_request_namespace.py +5 -0
- autoassembler/assemblies/types/get_status_response.py +16 -0
- autoassembler/assemblies/types/get_status_response_progress.py +13 -0
- autoassembler/assemblies/types/get_status_response_status.py +7 -0
- autoassembler/assemblies/types/get_structure_request_namespace.py +5 -0
- autoassembler/assemblies/types/list_assembly_versions_request_namespace.py +5 -0
- autoassembler/assemblies/types/list_connections_request_namespace.py +5 -0
- autoassembler/assemblies/types/process_request_namespace.py +5 -0
- autoassembler/assemblies/types/update_assembly_info_request_namespace.py +5 -0
- autoassembler/auth/__init__.py +34 -0
- autoassembler/auth/client.py +282 -0
- autoassembler/auth/raw_client.py +413 -0
- autoassembler/auth/types/__init__.py +36 -0
- autoassembler/auth/types/create_access_token_request_grant_type.py +7 -0
- autoassembler/base_client.py +328 -0
- autoassembler/client.py +262 -0
- autoassembler/core/__init__.py +127 -0
- autoassembler/core/api_error.py +23 -0
- autoassembler/core/client_wrapper.py +147 -0
- autoassembler/core/datetime_utils.py +70 -0
- autoassembler/core/file.py +67 -0
- autoassembler/core/force_multipart.py +18 -0
- autoassembler/core/http_client.py +965 -0
- autoassembler/core/http_response.py +63 -0
- autoassembler/core/http_sse/__init__.py +42 -0
- autoassembler/core/http_sse/_api.py +455 -0
- autoassembler/core/http_sse/_decoders.py +74 -0
- autoassembler/core/http_sse/_exceptions.py +7 -0
- autoassembler/core/http_sse/_models.py +17 -0
- autoassembler/core/jsonable_encoder.py +133 -0
- autoassembler/core/logging.py +107 -0
- autoassembler/core/parse_error.py +36 -0
- autoassembler/core/pydantic_utilities.py +486 -0
- autoassembler/core/query_encoder.py +58 -0
- autoassembler/core/remove_none_from_dict.py +11 -0
- autoassembler/core/request_options.py +40 -0
- autoassembler/core/serialization.py +347 -0
- autoassembler/environment.py +7 -0
- autoassembler/errors/__init__.py +56 -0
- autoassembler/errors/bad_request_error.py +10 -0
- autoassembler/errors/conflict_error.py +10 -0
- autoassembler/errors/forbidden_error.py +11 -0
- autoassembler/errors/internal_server_error.py +11 -0
- autoassembler/errors/not_found_error.py +11 -0
- autoassembler/errors/unauthorized_error.py +10 -0
- autoassembler/errors/unprocessable_entity_error.py +11 -0
- autoassembler/operation.py +196 -0
- autoassembler/operations/__init__.py +4 -0
- autoassembler/operations/client.py +209 -0
- autoassembler/operations/raw_client.py +343 -0
- autoassembler/planning/__init__.py +70 -0
- autoassembler/planning/client.py +1174 -0
- autoassembler/planning/raw_client.py +1349 -0
- autoassembler/planning/types/__init__.py +68 -0
- autoassembler/planning/types/adapt_request_namespace.py +5 -0
- autoassembler/planning/types/create_mpp_request_body.py +8 -0
- autoassembler/planning/types/create_mpp_request_namespace.py +5 -0
- autoassembler/planning/types/delete_mpp_request_namespace.py +5 -0
- autoassembler/planning/types/delete_mpp_response.py +12 -0
- autoassembler/planning/types/evaluate_dfa_request_namespace.py +5 -0
- autoassembler/planning/types/get_mpp_request_namespace.py +5 -0
- autoassembler/planning/types/get_mpp_response.py +27 -0
- autoassembler/planning/types/list_mpps_request_namespace.py +5 -0
- autoassembler/planning/types/plan_request_namespace.py +5 -0
- autoassembler/planning/types/validate_request_namespace.py +5 -0
- autoassembler/py.typed +0 -0
- autoassembler/sessions/__init__.py +4 -0
- autoassembler/sessions/client.py +102 -0
- autoassembler/sessions/raw_client.py +126 -0
- autoassembler/types/__init__.py +344 -0
- autoassembler/types/access_token_response.py +14 -0
- autoassembler/types/active_session.py +25 -0
- autoassembler/types/active_session_namespace.py +5 -0
- autoassembler/types/adapt_mpp_accepted.py +26 -0
- autoassembler/types/assembly.py +30 -0
- autoassembler/types/assembly_connection.py +21 -0
- autoassembler/types/assembly_connection_relationship.py +5 -0
- autoassembler/types/assembly_connections_response.py +13 -0
- autoassembler/types/assembly_diff_metadata.py +35 -0
- autoassembler/types/assembly_diff_response.py +34 -0
- autoassembler/types/assembly_info.py +36 -0
- autoassembler/types/assembly_json_response.py +15 -0
- autoassembler/types/assembly_process_metadata.py +32 -0
- autoassembler/types/assembly_process_response.py +18 -0
- autoassembler/types/assembly_search_hit.py +31 -0
- autoassembler/types/assembly_version_summary.py +27 -0
- autoassembler/types/conflict_error_body.py +19 -0
- autoassembler/types/conflict_error_body_error.py +5 -0
- autoassembler/types/create_mpp_request.py +13 -0
- autoassembler/types/device_authorization_response.py +17 -0
- autoassembler/types/diff_accepted.py +42 -0
- autoassembler/types/diff_context_node.py +20 -0
- autoassembler/types/diff_details.py +73 -0
- autoassembler/types/diff_error_response.py +38 -0
- autoassembler/types/diff_flags.py +74 -0
- autoassembler/types/diff_ml_semantics.py +55 -0
- autoassembler/types/diff_node.py +26 -0
- autoassembler/types/diff_node_pair_with_parts.py +90 -0
- autoassembler/types/diff_node_with_parent.py +15 -0
- autoassembler/types/diff_reference_target_nodes.py +25 -0
- autoassembler/types/diff_report.py +24 -0
- autoassembler/types/diff_rigid_alignment.py +30 -0
- autoassembler/types/diff_summary.py +121 -0
- autoassembler/types/diff_summary_assembly_labels.py +44 -0
- autoassembler/types/diff_summary_geometric_diffs.py +24 -0
- autoassembler/types/diff_summary_persistent_edges_congruence.py +24 -0
- autoassembler/types/diff_summary_persistent_edges_congruence_pose.py +24 -0
- autoassembler/types/diff_summary_persistent_nodes_congruence.py +24 -0
- autoassembler/types/diff_summary_persistent_nodes_congruence_pose.py +24 -0
- autoassembler/types/diff_summary_total_parts.py +24 -0
- autoassembler/types/diff_swap.py +65 -0
- autoassembler/types/diff_swap_confidence.py +5 -0
- autoassembler/types/diff_swap_group.py +92 -0
- autoassembler/types/diff_validation_issue.py +38 -0
- autoassembler/types/diff_validation_issue_severity.py +5 -0
- autoassembler/types/diff_validation_result.py +35 -0
- autoassembler/types/diff_warning.py +79 -0
- autoassembler/types/diff_warning_reason.py +18 -0
- autoassembler/types/diff_warning_severity.py +5 -0
- autoassembler/types/error_response.py +30 -0
- autoassembler/types/filter.py +19 -0
- autoassembler/types/filter_field.py +7 -0
- autoassembler/types/filter_operator.py +5 -0
- autoassembler/types/job.py +123 -0
- autoassembler/types/job_progress.py +24 -0
- autoassembler/types/job_status.py +5 -0
- autoassembler/types/list_operations_response.py +25 -0
- autoassembler/types/manufacturing_process_plan.py +57 -0
- autoassembler/types/mpp_adapt_metadata.py +48 -0
- autoassembler/types/mpp_adapt_response.py +22 -0
- autoassembler/types/mpp_evaluate_dfa_metadata.py +47 -0
- autoassembler/types/mpp_evaluate_dfa_response.py +22 -0
- autoassembler/types/mpp_plan_metadata.py +47 -0
- autoassembler/types/mpp_plan_response.py +22 -0
- autoassembler/types/mpp_summary.py +20 -0
- autoassembler/types/mpp_validate_metadata.py +47 -0
- autoassembler/types/mpp_validate_response.py +22 -0
- autoassembler/types/o_auth_error_response.py +14 -0
- autoassembler/types/o_auth_error_response_error.py +18 -0
- autoassembler/types/operation.py +27 -0
- autoassembler/types/operation_error.py +21 -0
- autoassembler/types/operation_metadata.py +148 -0
- autoassembler/types/operation_response.py +94 -0
- autoassembler/types/process_assembly_accepted.py +14 -0
- autoassembler/types/process_assembly_response.py +55 -0
- autoassembler/types/process_assembly_skipped.py +14 -0
- autoassembler/types/search_assemblies_response.py +14 -0
- autoassembler/types/seq_plan_accepted.py +24 -0
- autoassembler/types/sever.py +33 -0
- autoassembler/types/sever_kind.py +5 -0
- autoassembler/types/sever_source.py +5 -0
- autoassembler/types/sort.py +8 -0
- autoassembler/types/upload_response.py +19 -0
- autoassembler/types/user_info.py +19 -0
- autoassembler/types/user_info_response.py +23 -0
- autoassembler/types/user_info_response_providers.py +14 -0
- autoassembler-0.3.1.dist-info/METADATA +209 -0
- autoassembler-0.3.1.dist-info/RECORD +198 -0
- autoassembler-0.3.1.dist-info/WHEEL +4 -0
- autoassembler-0.3.1.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import typing
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
9
|
+
from .core.logging import LogConfig, Logger
|
|
10
|
+
from .environment import AutoAssemblerEnvironment
|
|
11
|
+
|
|
12
|
+
if typing.TYPE_CHECKING:
|
|
13
|
+
from .alpha.client import AlphaClient, AsyncAlphaClient
|
|
14
|
+
from .assemblies.client import AssembliesClient, AsyncAssembliesClient
|
|
15
|
+
from .auth.client import AsyncAuthClient, AuthClient
|
|
16
|
+
from .operations.client import AsyncOperationsClient, OperationsClient
|
|
17
|
+
from .planning.client import AsyncPlanningClient, PlanningClient
|
|
18
|
+
from .sessions.client import AsyncSessionsClient, SessionsClient
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class BaseAutoAssembler:
|
|
22
|
+
"""
|
|
23
|
+
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
|
24
|
+
|
|
25
|
+
Parameters
|
|
26
|
+
----------
|
|
27
|
+
base_url : typing.Optional[str]
|
|
28
|
+
The base url to use for requests from the client.
|
|
29
|
+
|
|
30
|
+
environment : AutoAssemblerEnvironment
|
|
31
|
+
The environment to use for requests from the client. from .environment import AutoAssemblerEnvironment
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
Defaults to AutoAssemblerEnvironment.PRODUCTION
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
token : typing.Optional[typing.Union[str, typing.Callable[[], str]]]
|
|
40
|
+
headers : typing.Optional[typing.Dict[str, str]]
|
|
41
|
+
Additional headers to send with every request.
|
|
42
|
+
|
|
43
|
+
timeout : typing.Optional[float]
|
|
44
|
+
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
|
45
|
+
|
|
46
|
+
max_retries : typing.Optional[int]
|
|
47
|
+
The default maximum number of retries for failed requests. Defaults to 2. Per-request `max_retries` in `request_options` takes precedence over this value.
|
|
48
|
+
|
|
49
|
+
stream_reconnection_enabled : typing.Optional[bool]
|
|
50
|
+
Whether to automatically reconnect on stream disconnection for resumable streaming endpoints. Defaults to True. Per-request `stream_reconnection_enabled` in `request_options` takes precedence over this value.
|
|
51
|
+
|
|
52
|
+
max_stream_reconnection_attempts : typing.Optional[int]
|
|
53
|
+
The maximum number of reconnection attempts for resumable streaming endpoints. Defaults to no limit. Per-request `max_stream_reconnection_attempts` in `request_options` takes precedence over this value.
|
|
54
|
+
|
|
55
|
+
follow_redirects : typing.Optional[bool]
|
|
56
|
+
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
|
57
|
+
|
|
58
|
+
httpx_client : typing.Optional[httpx.Client]
|
|
59
|
+
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
|
|
60
|
+
|
|
61
|
+
logging : typing.Optional[typing.Union[LogConfig, Logger]]
|
|
62
|
+
Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.
|
|
63
|
+
|
|
64
|
+
Examples
|
|
65
|
+
--------
|
|
66
|
+
from autoassembler import AutoAssembler
|
|
67
|
+
|
|
68
|
+
client = AutoAssembler(
|
|
69
|
+
token="YOUR_TOKEN",
|
|
70
|
+
)
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
def __init__(
|
|
74
|
+
self,
|
|
75
|
+
*,
|
|
76
|
+
base_url: typing.Optional[str] = None,
|
|
77
|
+
environment: AutoAssemblerEnvironment = AutoAssemblerEnvironment.PRODUCTION,
|
|
78
|
+
token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
|
|
79
|
+
headers: typing.Optional[typing.Dict[str, str]] = None,
|
|
80
|
+
timeout: typing.Optional[float] = None,
|
|
81
|
+
max_retries: typing.Optional[int] = None,
|
|
82
|
+
stream_reconnection_enabled: typing.Optional[bool] = None,
|
|
83
|
+
max_stream_reconnection_attempts: typing.Optional[int] = None,
|
|
84
|
+
follow_redirects: typing.Optional[bool] = True,
|
|
85
|
+
httpx_client: typing.Optional[httpx.Client] = None,
|
|
86
|
+
logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
|
|
87
|
+
):
|
|
88
|
+
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
|
|
89
|
+
_defaulted_max_retries = max_retries if max_retries is not None else 2
|
|
90
|
+
self._client_wrapper = SyncClientWrapper(
|
|
91
|
+
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
92
|
+
token=token,
|
|
93
|
+
headers=headers,
|
|
94
|
+
httpx_client=httpx_client
|
|
95
|
+
if httpx_client is not None
|
|
96
|
+
else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
|
|
97
|
+
if follow_redirects is not None
|
|
98
|
+
else httpx.Client(timeout=_defaulted_timeout),
|
|
99
|
+
timeout=_defaulted_timeout,
|
|
100
|
+
max_retries=_defaulted_max_retries,
|
|
101
|
+
stream_reconnection_enabled=stream_reconnection_enabled,
|
|
102
|
+
max_stream_reconnection_attempts=max_stream_reconnection_attempts,
|
|
103
|
+
logging=logging,
|
|
104
|
+
)
|
|
105
|
+
self._auth: typing.Optional[AuthClient] = None
|
|
106
|
+
self._sessions: typing.Optional[SessionsClient] = None
|
|
107
|
+
self._assemblies: typing.Optional[AssembliesClient] = None
|
|
108
|
+
self._operations: typing.Optional[OperationsClient] = None
|
|
109
|
+
self._planning: typing.Optional[PlanningClient] = None
|
|
110
|
+
self._alpha: typing.Optional[AlphaClient] = None
|
|
111
|
+
|
|
112
|
+
@property
|
|
113
|
+
def auth(self):
|
|
114
|
+
if self._auth is None:
|
|
115
|
+
from .auth.client import AuthClient # noqa: E402
|
|
116
|
+
|
|
117
|
+
self._auth = AuthClient(client_wrapper=self._client_wrapper)
|
|
118
|
+
return self._auth
|
|
119
|
+
|
|
120
|
+
@property
|
|
121
|
+
def sessions(self):
|
|
122
|
+
if self._sessions is None:
|
|
123
|
+
from .sessions.client import SessionsClient # noqa: E402
|
|
124
|
+
|
|
125
|
+
self._sessions = SessionsClient(client_wrapper=self._client_wrapper)
|
|
126
|
+
return self._sessions
|
|
127
|
+
|
|
128
|
+
@property
|
|
129
|
+
def assemblies(self):
|
|
130
|
+
if self._assemblies is None:
|
|
131
|
+
from .assemblies.client import AssembliesClient # noqa: E402
|
|
132
|
+
|
|
133
|
+
self._assemblies = AssembliesClient(client_wrapper=self._client_wrapper)
|
|
134
|
+
return self._assemblies
|
|
135
|
+
|
|
136
|
+
@property
|
|
137
|
+
def operations(self):
|
|
138
|
+
if self._operations is None:
|
|
139
|
+
from .operations.client import OperationsClient # noqa: E402
|
|
140
|
+
|
|
141
|
+
self._operations = OperationsClient(client_wrapper=self._client_wrapper)
|
|
142
|
+
return self._operations
|
|
143
|
+
|
|
144
|
+
@property
|
|
145
|
+
def planning(self):
|
|
146
|
+
if self._planning is None:
|
|
147
|
+
from .planning.client import PlanningClient # noqa: E402
|
|
148
|
+
|
|
149
|
+
self._planning = PlanningClient(client_wrapper=self._client_wrapper)
|
|
150
|
+
return self._planning
|
|
151
|
+
|
|
152
|
+
@property
|
|
153
|
+
def alpha(self):
|
|
154
|
+
if self._alpha is None:
|
|
155
|
+
from .alpha.client import AlphaClient # noqa: E402
|
|
156
|
+
|
|
157
|
+
self._alpha = AlphaClient(client_wrapper=self._client_wrapper)
|
|
158
|
+
return self._alpha
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def _make_default_async_client(
|
|
162
|
+
timeout: typing.Optional[float],
|
|
163
|
+
follow_redirects: typing.Optional[bool],
|
|
164
|
+
) -> httpx.AsyncClient:
|
|
165
|
+
try:
|
|
166
|
+
import httpx_aiohttp # type: ignore[import-not-found]
|
|
167
|
+
except ImportError:
|
|
168
|
+
pass
|
|
169
|
+
else:
|
|
170
|
+
if follow_redirects is not None:
|
|
171
|
+
return httpx_aiohttp.HttpxAiohttpClient(timeout=timeout, follow_redirects=follow_redirects)
|
|
172
|
+
return httpx_aiohttp.HttpxAiohttpClient(timeout=timeout)
|
|
173
|
+
|
|
174
|
+
if follow_redirects is not None:
|
|
175
|
+
return httpx.AsyncClient(timeout=timeout, follow_redirects=follow_redirects)
|
|
176
|
+
return httpx.AsyncClient(timeout=timeout)
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class AsyncBaseAutoAssembler:
|
|
180
|
+
"""
|
|
181
|
+
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
|
182
|
+
|
|
183
|
+
Parameters
|
|
184
|
+
----------
|
|
185
|
+
base_url : typing.Optional[str]
|
|
186
|
+
The base url to use for requests from the client.
|
|
187
|
+
|
|
188
|
+
environment : AutoAssemblerEnvironment
|
|
189
|
+
The environment to use for requests from the client. from .environment import AutoAssemblerEnvironment
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
Defaults to AutoAssemblerEnvironment.PRODUCTION
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
token : typing.Optional[typing.Union[str, typing.Callable[[], str]]]
|
|
198
|
+
headers : typing.Optional[typing.Dict[str, str]]
|
|
199
|
+
Additional headers to send with every request.
|
|
200
|
+
|
|
201
|
+
async_token : typing.Optional[typing.Callable[[], typing.Awaitable[str]]]
|
|
202
|
+
An async callable that returns a bearer token. Use this when token acquisition involves async I/O (e.g., refreshing tokens via an async HTTP client). When provided, this is used instead of the synchronous token for async requests.
|
|
203
|
+
|
|
204
|
+
timeout : typing.Optional[float]
|
|
205
|
+
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
|
206
|
+
|
|
207
|
+
max_retries : typing.Optional[int]
|
|
208
|
+
The default maximum number of retries for failed requests. Defaults to 2. Per-request `max_retries` in `request_options` takes precedence over this value.
|
|
209
|
+
|
|
210
|
+
stream_reconnection_enabled : typing.Optional[bool]
|
|
211
|
+
Whether to automatically reconnect on stream disconnection for resumable streaming endpoints. Defaults to True. Per-request `stream_reconnection_enabled` in `request_options` takes precedence over this value.
|
|
212
|
+
|
|
213
|
+
max_stream_reconnection_attempts : typing.Optional[int]
|
|
214
|
+
The maximum number of reconnection attempts for resumable streaming endpoints. Defaults to no limit. Per-request `max_stream_reconnection_attempts` in `request_options` takes precedence over this value.
|
|
215
|
+
|
|
216
|
+
follow_redirects : typing.Optional[bool]
|
|
217
|
+
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
|
218
|
+
|
|
219
|
+
httpx_client : typing.Optional[httpx.AsyncClient]
|
|
220
|
+
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
|
|
221
|
+
|
|
222
|
+
logging : typing.Optional[typing.Union[LogConfig, Logger]]
|
|
223
|
+
Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.
|
|
224
|
+
|
|
225
|
+
Examples
|
|
226
|
+
--------
|
|
227
|
+
from autoassembler import AsyncAutoAssembler
|
|
228
|
+
|
|
229
|
+
client = AsyncAutoAssembler(
|
|
230
|
+
token="YOUR_TOKEN",
|
|
231
|
+
)
|
|
232
|
+
"""
|
|
233
|
+
|
|
234
|
+
def __init__(
|
|
235
|
+
self,
|
|
236
|
+
*,
|
|
237
|
+
base_url: typing.Optional[str] = None,
|
|
238
|
+
environment: AutoAssemblerEnvironment = AutoAssemblerEnvironment.PRODUCTION,
|
|
239
|
+
token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
|
|
240
|
+
headers: typing.Optional[typing.Dict[str, str]] = None,
|
|
241
|
+
async_token: typing.Optional[typing.Callable[[], typing.Awaitable[str]]] = None,
|
|
242
|
+
timeout: typing.Optional[float] = None,
|
|
243
|
+
max_retries: typing.Optional[int] = None,
|
|
244
|
+
stream_reconnection_enabled: typing.Optional[bool] = None,
|
|
245
|
+
max_stream_reconnection_attempts: typing.Optional[int] = None,
|
|
246
|
+
follow_redirects: typing.Optional[bool] = True,
|
|
247
|
+
httpx_client: typing.Optional[httpx.AsyncClient] = None,
|
|
248
|
+
logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
|
|
249
|
+
):
|
|
250
|
+
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
|
|
251
|
+
_defaulted_max_retries = max_retries if max_retries is not None else 2
|
|
252
|
+
self._client_wrapper = AsyncClientWrapper(
|
|
253
|
+
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
254
|
+
token=token,
|
|
255
|
+
headers=headers,
|
|
256
|
+
async_token=async_token,
|
|
257
|
+
httpx_client=httpx_client
|
|
258
|
+
if httpx_client is not None
|
|
259
|
+
else _make_default_async_client(timeout=_defaulted_timeout, follow_redirects=follow_redirects),
|
|
260
|
+
timeout=_defaulted_timeout,
|
|
261
|
+
max_retries=_defaulted_max_retries,
|
|
262
|
+
stream_reconnection_enabled=stream_reconnection_enabled,
|
|
263
|
+
max_stream_reconnection_attempts=max_stream_reconnection_attempts,
|
|
264
|
+
logging=logging,
|
|
265
|
+
)
|
|
266
|
+
self._auth: typing.Optional[AsyncAuthClient] = None
|
|
267
|
+
self._sessions: typing.Optional[AsyncSessionsClient] = None
|
|
268
|
+
self._assemblies: typing.Optional[AsyncAssembliesClient] = None
|
|
269
|
+
self._operations: typing.Optional[AsyncOperationsClient] = None
|
|
270
|
+
self._planning: typing.Optional[AsyncPlanningClient] = None
|
|
271
|
+
self._alpha: typing.Optional[AsyncAlphaClient] = None
|
|
272
|
+
|
|
273
|
+
@property
|
|
274
|
+
def auth(self):
|
|
275
|
+
if self._auth is None:
|
|
276
|
+
from .auth.client import AsyncAuthClient # noqa: E402
|
|
277
|
+
|
|
278
|
+
self._auth = AsyncAuthClient(client_wrapper=self._client_wrapper)
|
|
279
|
+
return self._auth
|
|
280
|
+
|
|
281
|
+
@property
|
|
282
|
+
def sessions(self):
|
|
283
|
+
if self._sessions is None:
|
|
284
|
+
from .sessions.client import AsyncSessionsClient # noqa: E402
|
|
285
|
+
|
|
286
|
+
self._sessions = AsyncSessionsClient(client_wrapper=self._client_wrapper)
|
|
287
|
+
return self._sessions
|
|
288
|
+
|
|
289
|
+
@property
|
|
290
|
+
def assemblies(self):
|
|
291
|
+
if self._assemblies is None:
|
|
292
|
+
from .assemblies.client import AsyncAssembliesClient # noqa: E402
|
|
293
|
+
|
|
294
|
+
self._assemblies = AsyncAssembliesClient(client_wrapper=self._client_wrapper)
|
|
295
|
+
return self._assemblies
|
|
296
|
+
|
|
297
|
+
@property
|
|
298
|
+
def operations(self):
|
|
299
|
+
if self._operations is None:
|
|
300
|
+
from .operations.client import AsyncOperationsClient # noqa: E402
|
|
301
|
+
|
|
302
|
+
self._operations = AsyncOperationsClient(client_wrapper=self._client_wrapper)
|
|
303
|
+
return self._operations
|
|
304
|
+
|
|
305
|
+
@property
|
|
306
|
+
def planning(self):
|
|
307
|
+
if self._planning is None:
|
|
308
|
+
from .planning.client import AsyncPlanningClient # noqa: E402
|
|
309
|
+
|
|
310
|
+
self._planning = AsyncPlanningClient(client_wrapper=self._client_wrapper)
|
|
311
|
+
return self._planning
|
|
312
|
+
|
|
313
|
+
@property
|
|
314
|
+
def alpha(self):
|
|
315
|
+
if self._alpha is None:
|
|
316
|
+
from .alpha.client import AsyncAlphaClient # noqa: E402
|
|
317
|
+
|
|
318
|
+
self._alpha = AsyncAlphaClient(client_wrapper=self._client_wrapper)
|
|
319
|
+
return self._alpha
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
def _get_base_url(*, base_url: typing.Optional[str] = None, environment: AutoAssemblerEnvironment) -> str:
|
|
323
|
+
if base_url is not None:
|
|
324
|
+
return base_url
|
|
325
|
+
elif environment is not None:
|
|
326
|
+
return environment.value
|
|
327
|
+
else:
|
|
328
|
+
raise Exception("Please pass in either base_url or environment to construct the client")
|
autoassembler/client.py
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"""Public client — hand-written, protected via `.fernignore`.
|
|
2
|
+
|
|
3
|
+
Two layers, one attribute apart:
|
|
4
|
+
|
|
5
|
+
* **The curated surface.** ``client.assemblies`` and ``client.planning`` are
|
|
6
|
+
hand-written namespaces that speak the domain's vocabulary (`Assembly`,
|
|
7
|
+
`ProcessPlan`, `Station`; ``upload``, ``diff``, ``plan``, ``validate``,
|
|
8
|
+
``evaluate_dfa``) and return `Operation` handles for anything long-running.
|
|
9
|
+
``client.operations`` wraps any operation, or the name of one, in an `Operation`.
|
|
10
|
+
* **The generated client**, every namespace and every operation of the API as Fern
|
|
11
|
+
generated it, at ``client.api`` (``client.api.assemblies.get_status(...)``,
|
|
12
|
+
``client.api.alpha.planning.apply_ops(...)``). The curated layer is built on it, and it
|
|
13
|
+
is the escape hatch when the vocabulary above does not cover what you need. Its
|
|
14
|
+
``planning.plan`` / ``validate`` / ``evaluate_dfa`` / ``adapt`` and
|
|
15
|
+
``assemblies.diff(async_=True)`` return an `Operation` too.
|
|
16
|
+
|
|
17
|
+
Namespaces the curated layer has nothing to add to yet (``auth``, ``sessions``) are the
|
|
18
|
+
generated ones, inherited from `BaseAutoAssembler`. So is ``alpha``: the operations the API
|
|
19
|
+
offers before they are stable (``client.alpha.jobs``, ``client.alpha.planning.apply_ops``),
|
|
20
|
+
which may change or go away in any release.
|
|
21
|
+
|
|
22
|
+
`AsyncAutoAssembler` ships **sync-first**: it offers ``api`` and ``operations``; the
|
|
23
|
+
curated ``assemblies`` / ``planning`` arrive in a later release with the same names,
|
|
24
|
+
so code written against ``client.api`` keeps working.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
import typing
|
|
28
|
+
from functools import cached_property
|
|
29
|
+
|
|
30
|
+
from ._custom.assemblies import Assemblies
|
|
31
|
+
from ._custom.assemblies_api import AssembliesApi, AsyncAssembliesApi
|
|
32
|
+
from ._custom.credentials import resolve_token
|
|
33
|
+
from ._custom.operations import AsyncOperations, Operations
|
|
34
|
+
from ._custom.planning import Planning
|
|
35
|
+
from ._custom.planning_api import AsyncPlanningApi, PlanningApi
|
|
36
|
+
from ._version import __version__
|
|
37
|
+
from .base_client import AsyncBaseAutoAssembler, BaseAutoAssembler, _get_base_url
|
|
38
|
+
from .environment import AutoAssemblerEnvironment
|
|
39
|
+
|
|
40
|
+
if typing.TYPE_CHECKING:
|
|
41
|
+
from .alpha.client import AlphaClient, AsyncAlphaClient
|
|
42
|
+
from .auth.client import AsyncAuthClient, AuthClient
|
|
43
|
+
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
44
|
+
from .sessions.client import AsyncSessionsClient, SessionsClient
|
|
45
|
+
|
|
46
|
+
USER_AGENT = f"autoassembler-python/{__version__}"
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _with_user_agent(headers: dict[str, str] | None) -> dict[str, str]:
|
|
50
|
+
# A caller-supplied User-Agent wins.
|
|
51
|
+
return {"User-Agent": USER_AGENT, **(headers or {})}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class Api:
|
|
55
|
+
"""The generated client: every namespace, every operation, exactly as the spec says.
|
|
56
|
+
|
|
57
|
+
Reached as ``client.api``. Each namespace is the Fern-generated sub-client
|
|
58
|
+
(``reference.md`` documents them all).
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
def __init__(self, client_wrapper: "SyncClientWrapper"):
|
|
62
|
+
self._client_wrapper = client_wrapper
|
|
63
|
+
|
|
64
|
+
@cached_property
|
|
65
|
+
def alpha(self) -> "AlphaClient":
|
|
66
|
+
from .alpha.client import AlphaClient
|
|
67
|
+
|
|
68
|
+
return AlphaClient(client_wrapper=self._client_wrapper)
|
|
69
|
+
|
|
70
|
+
@cached_property
|
|
71
|
+
def assemblies(self) -> AssembliesApi:
|
|
72
|
+
return AssembliesApi(client_wrapper=self._client_wrapper, operations=self.operations)
|
|
73
|
+
|
|
74
|
+
@cached_property
|
|
75
|
+
def auth(self) -> "AuthClient":
|
|
76
|
+
from .auth.client import AuthClient
|
|
77
|
+
|
|
78
|
+
return AuthClient(client_wrapper=self._client_wrapper)
|
|
79
|
+
|
|
80
|
+
@cached_property
|
|
81
|
+
def operations(self) -> Operations:
|
|
82
|
+
return Operations(client_wrapper=self._client_wrapper)
|
|
83
|
+
|
|
84
|
+
@cached_property
|
|
85
|
+
def planning(self) -> PlanningApi:
|
|
86
|
+
return PlanningApi(client_wrapper=self._client_wrapper, operations=self.operations)
|
|
87
|
+
|
|
88
|
+
@cached_property
|
|
89
|
+
def sessions(self) -> "SessionsClient":
|
|
90
|
+
from .sessions.client import SessionsClient
|
|
91
|
+
|
|
92
|
+
return SessionsClient(client_wrapper=self._client_wrapper)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class AsyncApi:
|
|
96
|
+
"""The generated async client, reached as ``client.api`` on `AsyncAutoAssembler`."""
|
|
97
|
+
|
|
98
|
+
def __init__(self, client_wrapper: "AsyncClientWrapper"):
|
|
99
|
+
self._client_wrapper = client_wrapper
|
|
100
|
+
|
|
101
|
+
@cached_property
|
|
102
|
+
def alpha(self) -> "AsyncAlphaClient":
|
|
103
|
+
from .alpha.client import AsyncAlphaClient
|
|
104
|
+
|
|
105
|
+
return AsyncAlphaClient(client_wrapper=self._client_wrapper)
|
|
106
|
+
|
|
107
|
+
@cached_property
|
|
108
|
+
def assemblies(self) -> AsyncAssembliesApi:
|
|
109
|
+
return AsyncAssembliesApi(client_wrapper=self._client_wrapper, operations=self.operations)
|
|
110
|
+
|
|
111
|
+
@cached_property
|
|
112
|
+
def auth(self) -> "AsyncAuthClient":
|
|
113
|
+
from .auth.client import AsyncAuthClient
|
|
114
|
+
|
|
115
|
+
return AsyncAuthClient(client_wrapper=self._client_wrapper)
|
|
116
|
+
|
|
117
|
+
@cached_property
|
|
118
|
+
def operations(self) -> AsyncOperations:
|
|
119
|
+
return AsyncOperations(client_wrapper=self._client_wrapper)
|
|
120
|
+
|
|
121
|
+
@cached_property
|
|
122
|
+
def planning(self) -> AsyncPlanningApi:
|
|
123
|
+
return AsyncPlanningApi(client_wrapper=self._client_wrapper, operations=self.operations)
|
|
124
|
+
|
|
125
|
+
@cached_property
|
|
126
|
+
def sessions(self) -> "AsyncSessionsClient":
|
|
127
|
+
from .sessions.client import AsyncSessionsClient
|
|
128
|
+
|
|
129
|
+
return AsyncSessionsClient(client_wrapper=self._client_wrapper)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class AutoAssembler(BaseAutoAssembler):
|
|
133
|
+
"""AutoAssembler API client: the curated surface, with the generated client at ``.api``."""
|
|
134
|
+
|
|
135
|
+
# Runtime-only, so type checkers and IDEs keep the generated constructor's signature.
|
|
136
|
+
# With no `token`, one is resolved: AA_TOKEN, then the store `autoassembler.login()` writes.
|
|
137
|
+
if not typing.TYPE_CHECKING:
|
|
138
|
+
|
|
139
|
+
def __init__(
|
|
140
|
+
self,
|
|
141
|
+
*args,
|
|
142
|
+
token=None,
|
|
143
|
+
base_url=None,
|
|
144
|
+
environment=AutoAssemblerEnvironment.PRODUCTION,
|
|
145
|
+
headers=None,
|
|
146
|
+
**kwargs,
|
|
147
|
+
):
|
|
148
|
+
if token is None:
|
|
149
|
+
token = resolve_token(_get_base_url(base_url=base_url, environment=environment))
|
|
150
|
+
super().__init__(
|
|
151
|
+
*args,
|
|
152
|
+
token=token,
|
|
153
|
+
base_url=base_url,
|
|
154
|
+
environment=environment,
|
|
155
|
+
headers=_with_user_agent(headers),
|
|
156
|
+
**kwargs,
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
@property
|
|
160
|
+
def base_url(self) -> str:
|
|
161
|
+
"""The API origin requests go to (no trailing slash)."""
|
|
162
|
+
return self._client_wrapper.get_base_url().rstrip("/")
|
|
163
|
+
|
|
164
|
+
@cached_property
|
|
165
|
+
def api(self) -> Api:
|
|
166
|
+
"""The generated client: every operation of the API, one attribute away."""
|
|
167
|
+
return Api(self._client_wrapper)
|
|
168
|
+
|
|
169
|
+
@cached_property
|
|
170
|
+
def assemblies(self) -> Assemblies: # pyright: ignore[reportIncompatibleMethodOverride]
|
|
171
|
+
"""CAD files in, `Assembly` handles and diff reports out."""
|
|
172
|
+
return Assemblies(self)
|
|
173
|
+
|
|
174
|
+
@cached_property
|
|
175
|
+
def planning(self) -> Planning: # pyright: ignore[reportIncompatibleMethodOverride]
|
|
176
|
+
"""Process plans: create, author a station, plan, validate, score."""
|
|
177
|
+
return Planning(self)
|
|
178
|
+
|
|
179
|
+
@property
|
|
180
|
+
def operations(self) -> Operations: # pyright: ignore[reportIncompatibleMethodOverride]
|
|
181
|
+
"""Long-running operations: ``handle(operation_or_name)`` to wait on one."""
|
|
182
|
+
return self.api.operations
|
|
183
|
+
|
|
184
|
+
# Plain construction works and is what the examples use; `with` additionally closes
|
|
185
|
+
# the underlying connection pool when the block ends (as httpx's own clients do).
|
|
186
|
+
def close(self) -> None:
|
|
187
|
+
"""Close the underlying HTTP connection pool."""
|
|
188
|
+
self._client_wrapper.httpx_client.httpx_client.close()
|
|
189
|
+
|
|
190
|
+
def __enter__(self) -> "AutoAssembler":
|
|
191
|
+
return self
|
|
192
|
+
|
|
193
|
+
def __exit__(self, *exc_info: object) -> None:
|
|
194
|
+
self.close()
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
class AsyncAutoAssembler(AsyncBaseAutoAssembler):
|
|
198
|
+
"""Async client: ``api`` and ``operations`` today; the curated namespaces come next."""
|
|
199
|
+
|
|
200
|
+
# Runtime-only, so type checkers and IDEs keep the generated constructor's signature.
|
|
201
|
+
# With no `token`, one is resolved: AA_TOKEN, then the store `autoassembler.login()` writes.
|
|
202
|
+
if not typing.TYPE_CHECKING:
|
|
203
|
+
|
|
204
|
+
def __init__(
|
|
205
|
+
self,
|
|
206
|
+
*args,
|
|
207
|
+
token=None,
|
|
208
|
+
base_url=None,
|
|
209
|
+
environment=AutoAssemblerEnvironment.PRODUCTION,
|
|
210
|
+
headers=None,
|
|
211
|
+
**kwargs,
|
|
212
|
+
):
|
|
213
|
+
if token is None:
|
|
214
|
+
token = resolve_token(_get_base_url(base_url=base_url, environment=environment))
|
|
215
|
+
super().__init__(
|
|
216
|
+
*args,
|
|
217
|
+
token=token,
|
|
218
|
+
base_url=base_url,
|
|
219
|
+
environment=environment,
|
|
220
|
+
headers=_with_user_agent(headers),
|
|
221
|
+
**kwargs,
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
@property
|
|
225
|
+
def base_url(self) -> str:
|
|
226
|
+
"""The API origin requests go to (no trailing slash)."""
|
|
227
|
+
return self._client_wrapper.get_base_url().rstrip("/")
|
|
228
|
+
|
|
229
|
+
@cached_property
|
|
230
|
+
def api(self) -> AsyncApi:
|
|
231
|
+
"""The generated async client: every operation of the API, one attribute away."""
|
|
232
|
+
return AsyncApi(self._client_wrapper)
|
|
233
|
+
|
|
234
|
+
@property
|
|
235
|
+
def operations(self) -> AsyncOperations: # pyright: ignore[reportIncompatibleMethodOverride]
|
|
236
|
+
"""Long-running operations: ``await handle(operation_or_name)`` to wait on one."""
|
|
237
|
+
return self.api.operations
|
|
238
|
+
|
|
239
|
+
async def aclose(self) -> None:
|
|
240
|
+
"""Close the underlying HTTP connection pool."""
|
|
241
|
+
await self._client_wrapper.httpx_client.httpx_client.aclose()
|
|
242
|
+
|
|
243
|
+
async def __aenter__(self) -> "AsyncAutoAssembler":
|
|
244
|
+
return self
|
|
245
|
+
|
|
246
|
+
async def __aexit__(self, *exc_info: object) -> None:
|
|
247
|
+
await self.aclose()
|
|
248
|
+
|
|
249
|
+
@property
|
|
250
|
+
def assemblies(self) -> typing.NoReturn: # pyright: ignore[reportIncompatibleMethodOverride]
|
|
251
|
+
raise NotImplementedError(_NOT_YET.format(name="assemblies"))
|
|
252
|
+
|
|
253
|
+
@property
|
|
254
|
+
def planning(self) -> typing.NoReturn: # pyright: ignore[reportIncompatibleMethodOverride]
|
|
255
|
+
raise NotImplementedError(_NOT_YET.format(name="planning"))
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
_NOT_YET = (
|
|
259
|
+
"AsyncAutoAssembler.{name} is not available yet: the curated namespaces ship sync-first and "
|
|
260
|
+
"arrive on the async client in a later release with the same names. Until then use the "
|
|
261
|
+
"generated client, client.api.{name}."
|
|
262
|
+
)
|