Debian Codegraph @

src/auth0/management/self_service_profiles/sso_ticket/raw_client.py

raw symbols SCIP
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.jsonable_encoder import encode_path_param
10 from ...core.parse_error import ParsingError
11 from ...core.pydantic_utilities import parse_obj_as
12 from ...core.request_options import RequestOptions
13 from ...core.serialization import convert_and_respect_annotation_metadata
14 from ...errors.bad_request_error import BadRequestError
15 from ...errors.conflict_error import ConflictError
16 from ...errors.forbidden_error import ForbiddenError
17 from ...errors.too_many_requests_error import TooManyRequestsError
18 from ...errors.unauthorized_error import UnauthorizedError
19 from ...types.create_self_service_profile_sso_ticket_response_content import (
20 CreateSelfServiceProfileSsoTicketResponseContent,
21 )
22 from ...types.self_service_profile_sso_ticket_connection_config import SelfServiceProfileSsoTicketConnectionConfig
23 from ...types.self_service_profile_sso_ticket_domain_aliases_config import (
24 SelfServiceProfileSsoTicketDomainAliasesConfig,
25 )
26 from ...types.self_service_profile_sso_ticket_enabled_features import SelfServiceProfileSsoTicketEnabledFeatures
27 from ...types.self_service_profile_sso_ticket_enabled_organization import SelfServiceProfileSsoTicketEnabledOrganization
28 from ...types.self_service_profile_sso_ticket_provisioning_config import SelfServiceProfileSsoTicketProvisioningConfig
29 from ...types.third_party_client_access_config import ThirdPartyClientAccessConfig
30 from pydantic import ValidationError
31
32 # this is used as the default value for optional parameters
33 OMIT = typing.cast(typing.Any, ...)
34
35
36 class RawSsoTicketClient:
37 def __init__(self, *, client_wrapper: SyncClientWrapper):
38 self._client_wrapper = client_wrapper
39
40 def create(
41 self,
42 id: str,
43 *,
44 connection_id: typing.Optional[str] = OMIT,
45 connection_config: typing.Optional[SelfServiceProfileSsoTicketConnectionConfig] = OMIT,
46 enabled_clients: typing.Optional[typing.Sequence[str]] = OMIT,
47 enabled_organizations: typing.Optional[typing.Sequence[SelfServiceProfileSsoTicketEnabledOrganization]] = OMIT,
48 ttl_sec: typing.Optional[int] = OMIT,
49 domain_aliases_config: typing.Optional[SelfServiceProfileSsoTicketDomainAliasesConfig] = OMIT,
50 provisioning_config: typing.Optional[SelfServiceProfileSsoTicketProvisioningConfig] = OMIT,
51 use_for_organization_discovery: typing.Optional[bool] = OMIT,
52 third_party_client_access_config: typing.Optional[ThirdPartyClientAccessConfig] = OMIT,
53 enabled_features: typing.Optional[SelfServiceProfileSsoTicketEnabledFeatures] = OMIT,
54 request_options: typing.Optional[RequestOptions] = None,
55 ) -> HttpResponse[CreateSelfServiceProfileSsoTicketResponseContent]:
56 """
57 Creates an access ticket to initiate the Self-Service Enterprise Configuration flow using a self-service profile.
58
59 Parameters
60 ----------
61 id : str
62 The id of the self-service profile to retrieve
63
64 connection_id : typing.Optional[str]
65 If provided, this will allow editing of the provided connection during the Self-Service Enterprise Configuration flow
66
67 connection_config : typing.Optional[SelfServiceProfileSsoTicketConnectionConfig]
68
69 enabled_clients : typing.Optional[typing.Sequence[str]]
70 List of client_ids that the connection will be enabled for.
71
72 enabled_organizations : typing.Optional[typing.Sequence[SelfServiceProfileSsoTicketEnabledOrganization]]
73 List of organizations that the connection will be enabled for.
74
75 ttl_sec : typing.Optional[int]
76 Number of seconds for which the ticket is valid before expiration. If unspecified or set to 0, this value defaults to 432000 seconds (5 days).
77
78 domain_aliases_config : typing.Optional[SelfServiceProfileSsoTicketDomainAliasesConfig]
79
80 provisioning_config : typing.Optional[SelfServiceProfileSsoTicketProvisioningConfig]
81
82 use_for_organization_discovery : typing.Optional[bool]
83 Indicates whether a verified domain should be used for organization discovery during authentication.
84
85 third_party_client_access_config : typing.Optional[ThirdPartyClientAccessConfig]
86
87 enabled_features : typing.Optional[SelfServiceProfileSsoTicketEnabledFeatures]
88
89 request_options : typing.Optional[RequestOptions]
90 Request-specific configuration.
91
92 Returns
93 -------
94 HttpResponse[CreateSelfServiceProfileSsoTicketResponseContent]
95 Self-Service Enterprise Configuration Access Ticket successfully created.
96 """
97 _response = self._client_wrapper.httpx_client.request(
98 f"self-service-profiles/{encode_path_param(id)}/sso-ticket",
99 method="POST",
100 json={
101 "connection_id": connection_id,
102 "connection_config": convert_and_respect_annotation_metadata(
103 object_=connection_config, annotation=SelfServiceProfileSsoTicketConnectionConfig, direction="write"
104 ),
105 "enabled_clients": enabled_clients,
106 "enabled_organizations": convert_and_respect_annotation_metadata(
107 object_=enabled_organizations,
108 annotation=typing.Sequence[SelfServiceProfileSsoTicketEnabledOrganization],
109 direction="write",
110 ),
111 "ttl_sec": ttl_sec,
112 "domain_aliases_config": convert_and_respect_annotation_metadata(
113 object_=domain_aliases_config,
114 annotation=SelfServiceProfileSsoTicketDomainAliasesConfig,
115 direction="write",
116 ),
117 "provisioning_config": convert_and_respect_annotation_metadata(
118 object_=provisioning_config,
119 annotation=SelfServiceProfileSsoTicketProvisioningConfig,
120 direction="write",
121 ),
122 "use_for_organization_discovery": use_for_organization_discovery,
123 "third_party_client_access_config": convert_and_respect_annotation_metadata(
124 object_=third_party_client_access_config, annotation=ThirdPartyClientAccessConfig, direction="write"
125 ),
126 "enabled_features": convert_and_respect_annotation_metadata(
127 object_=enabled_features, annotation=SelfServiceProfileSsoTicketEnabledFeatures, direction="write"
128 ),
129 },
130 headers={
131 "content-type": "application/json",
132 },
133 request_options=request_options,
134 omit=OMIT,
135 )
136 try:
137 if 200 <= _response.status_code < 300:
138 _data = typing.cast(
139 CreateSelfServiceProfileSsoTicketResponseContent,
140 parse_obj_as(
141 type_=CreateSelfServiceProfileSsoTicketResponseContent, # type: ignore
142 object_=_response.json(),
143 ),
144 )
145 return HttpResponse(response=_response, data=_data)
146 if _response.status_code == 400:
147 raise BadRequestError(
148 headers=dict(_response.headers),
149 body=typing.cast(
150 typing.Any,
151 parse_obj_as(
152 type_=typing.Any, # type: ignore
153 object_=_response.json(),
154 ),
155 ),
156 )
157 if _response.status_code == 401:
158 raise UnauthorizedError(
159 headers=dict(_response.headers),
160 body=typing.cast(
161 typing.Any,
162 parse_obj_as(
163 type_=typing.Any, # type: ignore
164 object_=_response.json(),
165 ),
166 ),
167 )
168 if _response.status_code == 403:
169 raise ForbiddenError(
170 headers=dict(_response.headers),
171 body=typing.cast(
172 typing.Any,
173 parse_obj_as(
174 type_=typing.Any, # type: ignore
175 object_=_response.json(),
176 ),
177 ),
178 )
179 if _response.status_code == 409:
180 raise ConflictError(
181 headers=dict(_response.headers),
182 body=typing.cast(
183 typing.Any,
184 parse_obj_as(
185 type_=typing.Any, # type: ignore
186 object_=_response.json(),
187 ),
188 ),
189 )
190 if _response.status_code == 429:
191 raise TooManyRequestsError(
192 headers=dict(_response.headers),
193 body=typing.cast(
194 typing.Any,
195 parse_obj_as(
196 type_=typing.Any, # type: ignore
197 object_=_response.json(),
198 ),
199 ),
200 )
201 _response_json = _response.json()
202 except JSONDecodeError:
203 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
204 except ValidationError as e:
205 raise ParsingError(
206 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
207 )
208 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
209
210 def revoke(
211 self, profile_id: str, id: str, *, request_options: typing.Optional[RequestOptions] = None
212 ) -> HttpResponse[None]:
213 """
214 Revokes a Self-Service Enterprise Configuration access ticket and invalidates associated sessions. The ticket will no longer be accepted to initiate a Self-Service Enterprise Configuration session. If any users have already started a session through this ticket, their session will be terminated. Clients should expect a `202 Accepted` response upon successful processing, indicating that the request has been acknowledged and that the revocation is underway but may not be fully completed at the time of response. If the specified ticket does not exist, a `202 Accepted` response is also returned, signaling that no further action is required.
215 Clients should treat these `202` responses as an acknowledgment that the request has been accepted and is in progress, even if the ticket was not found.
216
217 Parameters
218 ----------
219 profile_id : str
220 The id of the self-service profile
221
222 id : str
223 The id of the ticket to revoke
224
225 request_options : typing.Optional[RequestOptions]
226 Request-specific configuration.
227
228 Returns
229 -------
230 HttpResponse[None]
231 """
232 _response = self._client_wrapper.httpx_client.request(
233 f"self-service-profiles/{encode_path_param(profile_id)}/sso-ticket/{encode_path_param(id)}/revoke",
234 method="POST",
235 request_options=request_options,
236 )
237 try:
238 if 200 <= _response.status_code < 300:
239 return HttpResponse(response=_response, data=None)
240 if _response.status_code == 401:
241 raise UnauthorizedError(
242 headers=dict(_response.headers),
243 body=typing.cast(
244 typing.Any,
245 parse_obj_as(
246 type_=typing.Any, # type: ignore
247 object_=_response.json(),
248 ),
249 ),
250 )
251 if _response.status_code == 403:
252 raise ForbiddenError(
253 headers=dict(_response.headers),
254 body=typing.cast(
255 typing.Any,
256 parse_obj_as(
257 type_=typing.Any, # type: ignore
258 object_=_response.json(),
259 ),
260 ),
261 )
262 if _response.status_code == 429:
263 raise TooManyRequestsError(
264 headers=dict(_response.headers),
265 body=typing.cast(
266 typing.Any,
267 parse_obj_as(
268 type_=typing.Any, # type: ignore
269 object_=_response.json(),
270 ),
271 ),
272 )
273 _response_json = _response.json()
274 except JSONDecodeError:
275 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
276 except ValidationError as e:
277 raise ParsingError(
278 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
279 )
280 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
281
282
283 class AsyncRawSsoTicketClient:
284 def __init__(self, *, client_wrapper: AsyncClientWrapper):
285 self._client_wrapper = client_wrapper
286
287 async def create(
288 self,
289 id: str,
290 *,
291 connection_id: typing.Optional[str] = OMIT,
292 connection_config: typing.Optional[SelfServiceProfileSsoTicketConnectionConfig] = OMIT,
293 enabled_clients: typing.Optional[typing.Sequence[str]] = OMIT,
294 enabled_organizations: typing.Optional[typing.Sequence[SelfServiceProfileSsoTicketEnabledOrganization]] = OMIT,
295 ttl_sec: typing.Optional[int] = OMIT,
296 domain_aliases_config: typing.Optional[SelfServiceProfileSsoTicketDomainAliasesConfig] = OMIT,
297 provisioning_config: typing.Optional[SelfServiceProfileSsoTicketProvisioningConfig] = OMIT,
298 use_for_organization_discovery: typing.Optional[bool] = OMIT,
299 third_party_client_access_config: typing.Optional[ThirdPartyClientAccessConfig] = OMIT,
300 enabled_features: typing.Optional[SelfServiceProfileSsoTicketEnabledFeatures] = OMIT,
301 request_options: typing.Optional[RequestOptions] = None,
302 ) -> AsyncHttpResponse[CreateSelfServiceProfileSsoTicketResponseContent]:
303 """
304 Creates an access ticket to initiate the Self-Service Enterprise Configuration flow using a self-service profile.
305
306 Parameters
307 ----------
308 id : str
309 The id of the self-service profile to retrieve
310
311 connection_id : typing.Optional[str]
312 If provided, this will allow editing of the provided connection during the Self-Service Enterprise Configuration flow
313
314 connection_config : typing.Optional[SelfServiceProfileSsoTicketConnectionConfig]
315
316 enabled_clients : typing.Optional[typing.Sequence[str]]
317 List of client_ids that the connection will be enabled for.
318
319 enabled_organizations : typing.Optional[typing.Sequence[SelfServiceProfileSsoTicketEnabledOrganization]]
320 List of organizations that the connection will be enabled for.
321
322 ttl_sec : typing.Optional[int]
323 Number of seconds for which the ticket is valid before expiration. If unspecified or set to 0, this value defaults to 432000 seconds (5 days).
324
325 domain_aliases_config : typing.Optional[SelfServiceProfileSsoTicketDomainAliasesConfig]
326
327 provisioning_config : typing.Optional[SelfServiceProfileSsoTicketProvisioningConfig]
328
329 use_for_organization_discovery : typing.Optional[bool]
330 Indicates whether a verified domain should be used for organization discovery during authentication.
331
332 third_party_client_access_config : typing.Optional[ThirdPartyClientAccessConfig]
333
334 enabled_features : typing.Optional[SelfServiceProfileSsoTicketEnabledFeatures]
335
336 request_options : typing.Optional[RequestOptions]
337 Request-specific configuration.
338
339 Returns
340 -------
341 AsyncHttpResponse[CreateSelfServiceProfileSsoTicketResponseContent]
342 Self-Service Enterprise Configuration Access Ticket successfully created.
343 """
344 _response = await self._client_wrapper.httpx_client.request(
345 f"self-service-profiles/{encode_path_param(id)}/sso-ticket",
346 method="POST",
347 json={
348 "connection_id": connection_id,
349 "connection_config": convert_and_respect_annotation_metadata(
350 object_=connection_config, annotation=SelfServiceProfileSsoTicketConnectionConfig, direction="write"
351 ),
352 "enabled_clients": enabled_clients,
353 "enabled_organizations": convert_and_respect_annotation_metadata(
354 object_=enabled_organizations,
355 annotation=typing.Sequence[SelfServiceProfileSsoTicketEnabledOrganization],
356 direction="write",
357 ),
358 "ttl_sec": ttl_sec,
359 "domain_aliases_config": convert_and_respect_annotation_metadata(
360 object_=domain_aliases_config,
361 annotation=SelfServiceProfileSsoTicketDomainAliasesConfig,
362 direction="write",
363 ),
364 "provisioning_config": convert_and_respect_annotation_metadata(
365 object_=provisioning_config,
366 annotation=SelfServiceProfileSsoTicketProvisioningConfig,
367 direction="write",
368 ),
369 "use_for_organization_discovery": use_for_organization_discovery,
370 "third_party_client_access_config": convert_and_respect_annotation_metadata(
371 object_=third_party_client_access_config, annotation=ThirdPartyClientAccessConfig, direction="write"
372 ),
373 "enabled_features": convert_and_respect_annotation_metadata(
374 object_=enabled_features, annotation=SelfServiceProfileSsoTicketEnabledFeatures, direction="write"
375 ),
376 },
377 headers={
378 "content-type": "application/json",
379 },
380 request_options=request_options,
381 omit=OMIT,
382 )
383 try:
384 if 200 <= _response.status_code < 300:
385 _data = typing.cast(
386 CreateSelfServiceProfileSsoTicketResponseContent,
387 parse_obj_as(
388 type_=CreateSelfServiceProfileSsoTicketResponseContent, # type: ignore
389 object_=_response.json(),
390 ),
391 )
392 return AsyncHttpResponse(response=_response, data=_data)
393 if _response.status_code == 400:
394 raise BadRequestError(
395 headers=dict(_response.headers),
396 body=typing.cast(
397 typing.Any,
398 parse_obj_as(
399 type_=typing.Any, # type: ignore
400 object_=_response.json(),
401 ),
402 ),
403 )
404 if _response.status_code == 401:
405 raise UnauthorizedError(
406 headers=dict(_response.headers),
407 body=typing.cast(
408 typing.Any,
409 parse_obj_as(
410 type_=typing.Any, # type: ignore
411 object_=_response.json(),
412 ),
413 ),
414 )
415 if _response.status_code == 403:
416 raise ForbiddenError(
417 headers=dict(_response.headers),
418 body=typing.cast(
419 typing.Any,
420 parse_obj_as(
421 type_=typing.Any, # type: ignore
422 object_=_response.json(),
423 ),
424 ),
425 )
426 if _response.status_code == 409:
427 raise ConflictError(
428 headers=dict(_response.headers),
429 body=typing.cast(
430 typing.Any,
431 parse_obj_as(
432 type_=typing.Any, # type: ignore
433 object_=_response.json(),
434 ),
435 ),
436 )
437 if _response.status_code == 429:
438 raise TooManyRequestsError(
439 headers=dict(_response.headers),
440 body=typing.cast(
441 typing.Any,
442 parse_obj_as(
443 type_=typing.Any, # type: ignore
444 object_=_response.json(),
445 ),
446 ),
447 )
448 _response_json = _response.json()
449 except JSONDecodeError:
450 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
451 except ValidationError as e:
452 raise ParsingError(
453 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
454 )
455 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
456
457 async def revoke(
458 self, profile_id: str, id: str, *, request_options: typing.Optional[RequestOptions] = None
459 ) -> AsyncHttpResponse[None]:
460 """
461 Revokes a Self-Service Enterprise Configuration access ticket and invalidates associated sessions. The ticket will no longer be accepted to initiate a Self-Service Enterprise Configuration session. If any users have already started a session through this ticket, their session will be terminated. Clients should expect a `202 Accepted` response upon successful processing, indicating that the request has been acknowledged and that the revocation is underway but may not be fully completed at the time of response. If the specified ticket does not exist, a `202 Accepted` response is also returned, signaling that no further action is required.
462 Clients should treat these `202` responses as an acknowledgment that the request has been accepted and is in progress, even if the ticket was not found.
463
464 Parameters
465 ----------
466 profile_id : str
467 The id of the self-service profile
468
469 id : str
470 The id of the ticket to revoke
471
472 request_options : typing.Optional[RequestOptions]
473 Request-specific configuration.
474
475 Returns
476 -------
477 AsyncHttpResponse[None]
478 """
479 _response = await self._client_wrapper.httpx_client.request(
480 f"self-service-profiles/{encode_path_param(profile_id)}/sso-ticket/{encode_path_param(id)}/revoke",
481 method="POST",
482 request_options=request_options,
483 )
484 try:
485 if 200 <= _response.status_code < 300:
486 return AsyncHttpResponse(response=_response, data=None)
487 if _response.status_code == 401:
488 raise UnauthorizedError(
489 headers=dict(_response.headers),
490 body=typing.cast(
491 typing.Any,
492 parse_obj_as(
493 type_=typing.Any, # type: ignore
494 object_=_response.json(),
495 ),
496 ),
497 )
498 if _response.status_code == 403:
499 raise ForbiddenError(
500 headers=dict(_response.headers),
501 body=typing.cast(
502 typing.Any,
503 parse_obj_as(
504 type_=typing.Any, # type: ignore
505 object_=_response.json(),
506 ),
507 ),
508 )
509 if _response.status_code == 429:
510 raise TooManyRequestsError(
511 headers=dict(_response.headers),
512 body=typing.cast(
513 typing.Any,
514 parse_obj_as(
515 type_=typing.Any, # type: ignore
516 object_=_response.json(),
517 ),
518 ),
519 )
520 _response_json = _response.json()
521 except JSONDecodeError:
522 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
523 except ValidationError as e:
524 raise ParsingError(
525 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
526 )
527 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)