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,413 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from json.decoder import JSONDecodeError
|
|
5
|
+
|
|
6
|
+
from ..core.api_error import ApiError
|
|
7
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
|
+
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
9
|
+
from ..core.parse_error import ParsingError
|
|
10
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
11
|
+
from ..core.request_options import RequestOptions
|
|
12
|
+
from ..errors.bad_request_error import BadRequestError
|
|
13
|
+
from ..errors.internal_server_error import InternalServerError
|
|
14
|
+
from ..errors.unauthorized_error import UnauthorizedError
|
|
15
|
+
from ..types.access_token_response import AccessTokenResponse
|
|
16
|
+
from ..types.device_authorization_response import DeviceAuthorizationResponse
|
|
17
|
+
from ..types.o_auth_error_response import OAuthErrorResponse
|
|
18
|
+
from ..types.user_info_response import UserInfoResponse
|
|
19
|
+
from .types.create_access_token_request_grant_type import CreateAccessTokenRequestGrantType
|
|
20
|
+
from pydantic import ValidationError
|
|
21
|
+
|
|
22
|
+
# this is used as the default value for optional parameters
|
|
23
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class RawAuthClient:
|
|
27
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
28
|
+
self._client_wrapper = client_wrapper
|
|
29
|
+
|
|
30
|
+
def create_device_authorization(
|
|
31
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
32
|
+
) -> HttpResponse[DeviceAuthorizationResponse]:
|
|
33
|
+
"""
|
|
34
|
+
Starts the OAuth 2.0 device authorization grant (RFC 8628). Show the user `verification_uri_complete`, then poll `POST /oauth/token` with `device_code` every `interval` seconds until it returns a token or a terminal error.
|
|
35
|
+
|
|
36
|
+
Parameters
|
|
37
|
+
----------
|
|
38
|
+
request_options : typing.Optional[RequestOptions]
|
|
39
|
+
Request-specific configuration.
|
|
40
|
+
|
|
41
|
+
Returns
|
|
42
|
+
-------
|
|
43
|
+
HttpResponse[DeviceAuthorizationResponse]
|
|
44
|
+
Successful initiation of device authorization
|
|
45
|
+
"""
|
|
46
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
47
|
+
"oauth/device/code",
|
|
48
|
+
method="POST",
|
|
49
|
+
request_options=request_options,
|
|
50
|
+
)
|
|
51
|
+
try:
|
|
52
|
+
if 200 <= _response.status_code < 300:
|
|
53
|
+
_data = typing.cast(
|
|
54
|
+
DeviceAuthorizationResponse,
|
|
55
|
+
parse_obj_as(
|
|
56
|
+
type_=DeviceAuthorizationResponse, # type: ignore
|
|
57
|
+
object_=_response.json(),
|
|
58
|
+
),
|
|
59
|
+
)
|
|
60
|
+
return HttpResponse(response=_response, data=_data)
|
|
61
|
+
_response_json = _response.json()
|
|
62
|
+
except JSONDecodeError:
|
|
63
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
64
|
+
except ValidationError as e:
|
|
65
|
+
raise ParsingError(
|
|
66
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
67
|
+
)
|
|
68
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
69
|
+
|
|
70
|
+
def create_access_token(
|
|
71
|
+
self,
|
|
72
|
+
*,
|
|
73
|
+
grant_type: CreateAccessTokenRequestGrantType,
|
|
74
|
+
device_code: typing.Optional[str] = OMIT,
|
|
75
|
+
client_id: typing.Optional[str] = OMIT,
|
|
76
|
+
client_secret: typing.Optional[str] = OMIT,
|
|
77
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
78
|
+
) -> HttpResponse[AccessTokenResponse]:
|
|
79
|
+
"""
|
|
80
|
+
Follows OAuth 2.0 token endpoint (RFC 6749 §5). Device flow §4.3.3; client_credentials grant §4.4. Send the resulting token as `Authorization: Bearer <token>`.
|
|
81
|
+
|
|
82
|
+
Parameters
|
|
83
|
+
----------
|
|
84
|
+
grant_type : CreateAccessTokenRequestGrantType
|
|
85
|
+
`client_credentials` uses an API key for machine-to-machine access. `urn:ietf:params:oauth:grant-type:device_code` completes the device authorization flow.
|
|
86
|
+
|
|
87
|
+
device_code : typing.Optional[str]
|
|
88
|
+
Code returned by `POST /oauth/device/code`. Required for the device authorization flow.
|
|
89
|
+
|
|
90
|
+
client_id : typing.Optional[str]
|
|
91
|
+
API key ID. Required for machine-to-machine access.
|
|
92
|
+
|
|
93
|
+
client_secret : typing.Optional[str]
|
|
94
|
+
API key secret shown once when the key was created. Required for machine-to-machine access.
|
|
95
|
+
|
|
96
|
+
request_options : typing.Optional[RequestOptions]
|
|
97
|
+
Request-specific configuration.
|
|
98
|
+
|
|
99
|
+
Returns
|
|
100
|
+
-------
|
|
101
|
+
HttpResponse[AccessTokenResponse]
|
|
102
|
+
Access token granted. Send it as `Authorization: Bearer <token>`.
|
|
103
|
+
"""
|
|
104
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
105
|
+
"oauth/token",
|
|
106
|
+
method="POST",
|
|
107
|
+
data={
|
|
108
|
+
"grant_type": grant_type,
|
|
109
|
+
"device_code": device_code,
|
|
110
|
+
"client_id": client_id,
|
|
111
|
+
"client_secret": client_secret,
|
|
112
|
+
},
|
|
113
|
+
headers={
|
|
114
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
115
|
+
},
|
|
116
|
+
request_options=request_options,
|
|
117
|
+
omit=OMIT,
|
|
118
|
+
)
|
|
119
|
+
try:
|
|
120
|
+
if 200 <= _response.status_code < 300:
|
|
121
|
+
_data = typing.cast(
|
|
122
|
+
AccessTokenResponse,
|
|
123
|
+
parse_obj_as(
|
|
124
|
+
type_=AccessTokenResponse, # type: ignore
|
|
125
|
+
object_=_response.json(),
|
|
126
|
+
),
|
|
127
|
+
)
|
|
128
|
+
return HttpResponse(response=_response, data=_data)
|
|
129
|
+
if _response.status_code == 400:
|
|
130
|
+
raise BadRequestError(
|
|
131
|
+
headers=dict(_response.headers),
|
|
132
|
+
body=typing.cast(
|
|
133
|
+
typing.Any,
|
|
134
|
+
parse_obj_as(
|
|
135
|
+
type_=typing.Any, # type: ignore
|
|
136
|
+
object_=_response.json(),
|
|
137
|
+
),
|
|
138
|
+
),
|
|
139
|
+
)
|
|
140
|
+
if _response.status_code == 401:
|
|
141
|
+
raise UnauthorizedError(
|
|
142
|
+
headers=dict(_response.headers),
|
|
143
|
+
body=typing.cast(
|
|
144
|
+
typing.Any,
|
|
145
|
+
parse_obj_as(
|
|
146
|
+
type_=typing.Any, # type: ignore
|
|
147
|
+
object_=_response.json(),
|
|
148
|
+
),
|
|
149
|
+
),
|
|
150
|
+
)
|
|
151
|
+
if _response.status_code == 500:
|
|
152
|
+
raise InternalServerError(
|
|
153
|
+
headers=dict(_response.headers),
|
|
154
|
+
body=typing.cast(
|
|
155
|
+
OAuthErrorResponse,
|
|
156
|
+
parse_obj_as(
|
|
157
|
+
type_=OAuthErrorResponse, # type: ignore
|
|
158
|
+
object_=_response.json(),
|
|
159
|
+
),
|
|
160
|
+
),
|
|
161
|
+
)
|
|
162
|
+
_response_json = _response.json()
|
|
163
|
+
except JSONDecodeError:
|
|
164
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
165
|
+
except ValidationError as e:
|
|
166
|
+
raise ParsingError(
|
|
167
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
168
|
+
)
|
|
169
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
170
|
+
|
|
171
|
+
def get_current_user(
|
|
172
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
173
|
+
) -> HttpResponse[UserInfoResponse]:
|
|
174
|
+
"""
|
|
175
|
+
Parameters
|
|
176
|
+
----------
|
|
177
|
+
request_options : typing.Optional[RequestOptions]
|
|
178
|
+
Request-specific configuration.
|
|
179
|
+
|
|
180
|
+
Returns
|
|
181
|
+
-------
|
|
182
|
+
HttpResponse[UserInfoResponse]
|
|
183
|
+
Successful retrieval of user info
|
|
184
|
+
"""
|
|
185
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
186
|
+
"api/v4/user",
|
|
187
|
+
method="GET",
|
|
188
|
+
request_options=request_options,
|
|
189
|
+
)
|
|
190
|
+
try:
|
|
191
|
+
if 200 <= _response.status_code < 300:
|
|
192
|
+
_data = typing.cast(
|
|
193
|
+
UserInfoResponse,
|
|
194
|
+
parse_obj_as(
|
|
195
|
+
type_=UserInfoResponse, # type: ignore
|
|
196
|
+
object_=_response.json(),
|
|
197
|
+
),
|
|
198
|
+
)
|
|
199
|
+
return HttpResponse(response=_response, data=_data)
|
|
200
|
+
if _response.status_code == 401:
|
|
201
|
+
raise UnauthorizedError(
|
|
202
|
+
headers=dict(_response.headers),
|
|
203
|
+
body=typing.cast(
|
|
204
|
+
typing.Any,
|
|
205
|
+
parse_obj_as(
|
|
206
|
+
type_=typing.Any, # type: ignore
|
|
207
|
+
object_=_response.json(),
|
|
208
|
+
),
|
|
209
|
+
),
|
|
210
|
+
)
|
|
211
|
+
_response_json = _response.json()
|
|
212
|
+
except JSONDecodeError:
|
|
213
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
214
|
+
except ValidationError as e:
|
|
215
|
+
raise ParsingError(
|
|
216
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
217
|
+
)
|
|
218
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
class AsyncRawAuthClient:
|
|
222
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
223
|
+
self._client_wrapper = client_wrapper
|
|
224
|
+
|
|
225
|
+
async def create_device_authorization(
|
|
226
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
227
|
+
) -> AsyncHttpResponse[DeviceAuthorizationResponse]:
|
|
228
|
+
"""
|
|
229
|
+
Starts the OAuth 2.0 device authorization grant (RFC 8628). Show the user `verification_uri_complete`, then poll `POST /oauth/token` with `device_code` every `interval` seconds until it returns a token or a terminal error.
|
|
230
|
+
|
|
231
|
+
Parameters
|
|
232
|
+
----------
|
|
233
|
+
request_options : typing.Optional[RequestOptions]
|
|
234
|
+
Request-specific configuration.
|
|
235
|
+
|
|
236
|
+
Returns
|
|
237
|
+
-------
|
|
238
|
+
AsyncHttpResponse[DeviceAuthorizationResponse]
|
|
239
|
+
Successful initiation of device authorization
|
|
240
|
+
"""
|
|
241
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
242
|
+
"oauth/device/code",
|
|
243
|
+
method="POST",
|
|
244
|
+
request_options=request_options,
|
|
245
|
+
)
|
|
246
|
+
try:
|
|
247
|
+
if 200 <= _response.status_code < 300:
|
|
248
|
+
_data = typing.cast(
|
|
249
|
+
DeviceAuthorizationResponse,
|
|
250
|
+
parse_obj_as(
|
|
251
|
+
type_=DeviceAuthorizationResponse, # type: ignore
|
|
252
|
+
object_=_response.json(),
|
|
253
|
+
),
|
|
254
|
+
)
|
|
255
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
256
|
+
_response_json = _response.json()
|
|
257
|
+
except JSONDecodeError:
|
|
258
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
259
|
+
except ValidationError as e:
|
|
260
|
+
raise ParsingError(
|
|
261
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
262
|
+
)
|
|
263
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
264
|
+
|
|
265
|
+
async def create_access_token(
|
|
266
|
+
self,
|
|
267
|
+
*,
|
|
268
|
+
grant_type: CreateAccessTokenRequestGrantType,
|
|
269
|
+
device_code: typing.Optional[str] = OMIT,
|
|
270
|
+
client_id: typing.Optional[str] = OMIT,
|
|
271
|
+
client_secret: typing.Optional[str] = OMIT,
|
|
272
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
273
|
+
) -> AsyncHttpResponse[AccessTokenResponse]:
|
|
274
|
+
"""
|
|
275
|
+
Follows OAuth 2.0 token endpoint (RFC 6749 §5). Device flow §4.3.3; client_credentials grant §4.4. Send the resulting token as `Authorization: Bearer <token>`.
|
|
276
|
+
|
|
277
|
+
Parameters
|
|
278
|
+
----------
|
|
279
|
+
grant_type : CreateAccessTokenRequestGrantType
|
|
280
|
+
`client_credentials` uses an API key for machine-to-machine access. `urn:ietf:params:oauth:grant-type:device_code` completes the device authorization flow.
|
|
281
|
+
|
|
282
|
+
device_code : typing.Optional[str]
|
|
283
|
+
Code returned by `POST /oauth/device/code`. Required for the device authorization flow.
|
|
284
|
+
|
|
285
|
+
client_id : typing.Optional[str]
|
|
286
|
+
API key ID. Required for machine-to-machine access.
|
|
287
|
+
|
|
288
|
+
client_secret : typing.Optional[str]
|
|
289
|
+
API key secret shown once when the key was created. Required for machine-to-machine access.
|
|
290
|
+
|
|
291
|
+
request_options : typing.Optional[RequestOptions]
|
|
292
|
+
Request-specific configuration.
|
|
293
|
+
|
|
294
|
+
Returns
|
|
295
|
+
-------
|
|
296
|
+
AsyncHttpResponse[AccessTokenResponse]
|
|
297
|
+
Access token granted. Send it as `Authorization: Bearer <token>`.
|
|
298
|
+
"""
|
|
299
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
300
|
+
"oauth/token",
|
|
301
|
+
method="POST",
|
|
302
|
+
data={
|
|
303
|
+
"grant_type": grant_type,
|
|
304
|
+
"device_code": device_code,
|
|
305
|
+
"client_id": client_id,
|
|
306
|
+
"client_secret": client_secret,
|
|
307
|
+
},
|
|
308
|
+
headers={
|
|
309
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
310
|
+
},
|
|
311
|
+
request_options=request_options,
|
|
312
|
+
omit=OMIT,
|
|
313
|
+
)
|
|
314
|
+
try:
|
|
315
|
+
if 200 <= _response.status_code < 300:
|
|
316
|
+
_data = typing.cast(
|
|
317
|
+
AccessTokenResponse,
|
|
318
|
+
parse_obj_as(
|
|
319
|
+
type_=AccessTokenResponse, # type: ignore
|
|
320
|
+
object_=_response.json(),
|
|
321
|
+
),
|
|
322
|
+
)
|
|
323
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
324
|
+
if _response.status_code == 400:
|
|
325
|
+
raise BadRequestError(
|
|
326
|
+
headers=dict(_response.headers),
|
|
327
|
+
body=typing.cast(
|
|
328
|
+
typing.Any,
|
|
329
|
+
parse_obj_as(
|
|
330
|
+
type_=typing.Any, # type: ignore
|
|
331
|
+
object_=_response.json(),
|
|
332
|
+
),
|
|
333
|
+
),
|
|
334
|
+
)
|
|
335
|
+
if _response.status_code == 401:
|
|
336
|
+
raise UnauthorizedError(
|
|
337
|
+
headers=dict(_response.headers),
|
|
338
|
+
body=typing.cast(
|
|
339
|
+
typing.Any,
|
|
340
|
+
parse_obj_as(
|
|
341
|
+
type_=typing.Any, # type: ignore
|
|
342
|
+
object_=_response.json(),
|
|
343
|
+
),
|
|
344
|
+
),
|
|
345
|
+
)
|
|
346
|
+
if _response.status_code == 500:
|
|
347
|
+
raise InternalServerError(
|
|
348
|
+
headers=dict(_response.headers),
|
|
349
|
+
body=typing.cast(
|
|
350
|
+
OAuthErrorResponse,
|
|
351
|
+
parse_obj_as(
|
|
352
|
+
type_=OAuthErrorResponse, # type: ignore
|
|
353
|
+
object_=_response.json(),
|
|
354
|
+
),
|
|
355
|
+
),
|
|
356
|
+
)
|
|
357
|
+
_response_json = _response.json()
|
|
358
|
+
except JSONDecodeError:
|
|
359
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
360
|
+
except ValidationError as e:
|
|
361
|
+
raise ParsingError(
|
|
362
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
363
|
+
)
|
|
364
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
365
|
+
|
|
366
|
+
async def get_current_user(
|
|
367
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
368
|
+
) -> AsyncHttpResponse[UserInfoResponse]:
|
|
369
|
+
"""
|
|
370
|
+
Parameters
|
|
371
|
+
----------
|
|
372
|
+
request_options : typing.Optional[RequestOptions]
|
|
373
|
+
Request-specific configuration.
|
|
374
|
+
|
|
375
|
+
Returns
|
|
376
|
+
-------
|
|
377
|
+
AsyncHttpResponse[UserInfoResponse]
|
|
378
|
+
Successful retrieval of user info
|
|
379
|
+
"""
|
|
380
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
381
|
+
"api/v4/user",
|
|
382
|
+
method="GET",
|
|
383
|
+
request_options=request_options,
|
|
384
|
+
)
|
|
385
|
+
try:
|
|
386
|
+
if 200 <= _response.status_code < 300:
|
|
387
|
+
_data = typing.cast(
|
|
388
|
+
UserInfoResponse,
|
|
389
|
+
parse_obj_as(
|
|
390
|
+
type_=UserInfoResponse, # type: ignore
|
|
391
|
+
object_=_response.json(),
|
|
392
|
+
),
|
|
393
|
+
)
|
|
394
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
395
|
+
if _response.status_code == 401:
|
|
396
|
+
raise UnauthorizedError(
|
|
397
|
+
headers=dict(_response.headers),
|
|
398
|
+
body=typing.cast(
|
|
399
|
+
typing.Any,
|
|
400
|
+
parse_obj_as(
|
|
401
|
+
type_=typing.Any, # type: ignore
|
|
402
|
+
object_=_response.json(),
|
|
403
|
+
),
|
|
404
|
+
),
|
|
405
|
+
)
|
|
406
|
+
_response_json = _response.json()
|
|
407
|
+
except JSONDecodeError:
|
|
408
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
409
|
+
except ValidationError as e:
|
|
410
|
+
raise ParsingError(
|
|
411
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
412
|
+
)
|
|
413
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
# isort: skip_file
|
|
4
|
+
|
|
5
|
+
import typing
|
|
6
|
+
from importlib import import_module
|
|
7
|
+
|
|
8
|
+
if typing.TYPE_CHECKING:
|
|
9
|
+
from .create_access_token_request_grant_type import CreateAccessTokenRequestGrantType
|
|
10
|
+
_dynamic_imports: typing.Dict[str, str] = {
|
|
11
|
+
"CreateAccessTokenRequestGrantType": ".create_access_token_request_grant_type"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def __getattr__(attr_name: str) -> typing.Any:
|
|
16
|
+
module_name = _dynamic_imports.get(attr_name)
|
|
17
|
+
if module_name is None:
|
|
18
|
+
raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
|
|
19
|
+
try:
|
|
20
|
+
module = import_module(module_name, __package__)
|
|
21
|
+
if module_name == f".{attr_name}":
|
|
22
|
+
return module
|
|
23
|
+
else:
|
|
24
|
+
return getattr(module, attr_name)
|
|
25
|
+
except ImportError as e:
|
|
26
|
+
raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
|
|
27
|
+
except AttributeError as e:
|
|
28
|
+
raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def __dir__():
|
|
32
|
+
lazy_attrs = list(_dynamic_imports.keys())
|
|
33
|
+
return sorted(lazy_attrs)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
__all__ = ["CreateAccessTokenRequestGrantType"]
|