| 1 |
|
| 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.pagination import AsyncPager, SyncPager |
| 11 |
from ..core.parse_error import ParsingError |
| 12 |
from ..core.pydantic_utilities import parse_obj_as |
| 13 |
from ..core.request_options import RequestOptions |
| 14 |
from ..core.serialization import convert_and_respect_annotation_metadata |
| 15 |
from ..errors.bad_request_error import BadRequestError |
| 16 |
from ..errors.conflict_error import ConflictError |
| 17 |
from ..errors.forbidden_error import ForbiddenError |
| 18 |
from ..errors.not_found_error import NotFoundError |
| 19 |
from ..errors.too_many_requests_error import TooManyRequestsError |
| 20 |
from ..errors.unauthorized_error import UnauthorizedError |
| 21 |
from ..types.connection_authentication_purpose import ConnectionAuthenticationPurpose |
| 22 |
from ..types.connection_connected_accounts_purpose import ConnectionConnectedAccountsPurpose |
| 23 |
from ..types.connection_for_list import ConnectionForList |
| 24 |
from ..types.connection_identity_provider_enum import ConnectionIdentityProviderEnum |
| 25 |
from ..types.connection_properties_options import ConnectionPropertiesOptions |
| 26 |
from ..types.connection_strategy_enum import ConnectionStrategyEnum |
| 27 |
from ..types.connections_metadata import ConnectionsMetadata |
| 28 |
from ..types.create_connection_response_content import CreateConnectionResponseContent |
| 29 |
from ..types.create_cross_app_access_resource_app import CreateCrossAppAccessResourceApp |
| 30 |
from ..types.cross_app_access_requesting_app import CrossAppAccessRequestingApp |
| 31 |
from ..types.get_connection_response_content import GetConnectionResponseContent |
| 32 |
from ..types.list_connections_checkpoint_paginated_response_content import ( |
| 33 |
ListConnectionsCheckpointPaginatedResponseContent, |
| 34 |
) |
| 35 |
from ..types.update_connection_options import UpdateConnectionOptions |
| 36 |
from ..types.update_connection_response_content import UpdateConnectionResponseContent |
| 37 |
from ..types.update_cross_app_access_resource_app import UpdateCrossAppAccessResourceApp |
| 38 |
from pydantic import ValidationError |
| 39 |
|
| 40 |
|
| 41 |
OMIT = typing.cast(typing.Any, ...) |
| 42 |
|
| 43 |
|
| 44 |
class RawConnectionsClient: |
| 45 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 46 |
self._client_wrapper = client_wrapper |
| 47 |
|
| 48 |
def list( |
| 49 |
self, |
| 50 |
*, |
| 51 |
from_: typing.Optional[str] = None, |
| 52 |
take: typing.Optional[int] = 50, |
| 53 |
strategy: typing.Optional[typing.Union[ConnectionStrategyEnum, typing.Sequence[ConnectionStrategyEnum]]] = None, |
| 54 |
name: typing.Optional[str] = None, |
| 55 |
fields: typing.Optional[str] = None, |
| 56 |
include_fields: typing.Optional[bool] = None, |
| 57 |
request_options: typing.Optional[RequestOptions] = None, |
| 58 |
) -> SyncPager[ConnectionForList, ListConnectionsCheckpointPaginatedResponseContent]: |
| 59 |
""" |
| 60 |
Retrieves detailed list of all [connections](https://auth0.com/docs/authenticate/identity-providers) that match the specified strategy. If no strategy is provided, all connections within your tenant are retrieved. This action can accept a list of fields to include or exclude from the resulting list of connections. |
| 61 |
|
| 62 |
This endpoint supports two types of pagination: |
| 63 |
|
| 64 |
- Offset pagination |
| 65 |
- Checkpoint pagination |
| 66 |
|
| 67 |
Checkpoint pagination must be used if you need to retrieve more than 1000 connections. |
| 68 |
|
| 69 |
**Checkpoint Pagination** |
| 70 |
|
| 71 |
To search by checkpoint, use the following parameters: |
| 72 |
|
| 73 |
- `from`: Optional id from which to start selection. |
| 74 |
- `take`: The total amount of entries to retrieve when using the from parameter. Defaults to 50. |
| 75 |
|
| 76 |
**Note**: The first time you call this endpoint using checkpoint pagination, omit the `from` parameter. If there are more results, a `next` value is included in the response. You can use this for subsequent API calls. When `next` is no longer included in the response, no pages are remaining. |
| 77 |
|
| 78 |
Parameters |
| 79 |
---------- |
| 80 |
from_ : typing.Optional[str] |
| 81 |
Optional Id from which to start selection. |
| 82 |
|
| 83 |
take : typing.Optional[int] |
| 84 |
Number of results per page. Defaults to 50. |
| 85 |
|
| 86 |
strategy : typing.Optional[typing.Union[ConnectionStrategyEnum, typing.Sequence[ConnectionStrategyEnum]]] |
| 87 |
Provide strategies to only retrieve connections with such strategies |
| 88 |
|
| 89 |
name : typing.Optional[str] |
| 90 |
Provide the name of the connection to retrieve |
| 91 |
|
| 92 |
fields : typing.Optional[str] |
| 93 |
A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve all fields |
| 94 |
|
| 95 |
include_fields : typing.Optional[bool] |
| 96 |
<code>true</code> if the fields specified are to be included in the result, <code>false</code> otherwise (defaults to <code>true</code>) |
| 97 |
|
| 98 |
request_options : typing.Optional[RequestOptions] |
| 99 |
Request-specific configuration. |
| 100 |
|
| 101 |
Returns |
| 102 |
------- |
| 103 |
SyncPager[ConnectionForList, ListConnectionsCheckpointPaginatedResponseContent] |
| 104 |
The connections were retrieved. |
| 105 |
""" |
| 106 |
_response = self._client_wrapper.httpx_client.request( |
| 107 |
"connections", |
| 108 |
method="GET", |
| 109 |
params={ |
| 110 |
"from": from_, |
| 111 |
"take": take, |
| 112 |
"strategy": strategy, |
| 113 |
"name": name, |
| 114 |
"fields": fields, |
| 115 |
"include_fields": include_fields, |
| 116 |
}, |
| 117 |
request_options=request_options, |
| 118 |
) |
| 119 |
try: |
| 120 |
if 200 <= _response.status_code < 300: |
| 121 |
_parsed_response = typing.cast( |
| 122 |
ListConnectionsCheckpointPaginatedResponseContent, |
| 123 |
parse_obj_as( |
| 124 |
type_=ListConnectionsCheckpointPaginatedResponseContent, |
| 125 |
object_=_response.json(), |
| 126 |
), |
| 127 |
) |
| 128 |
_items = _parsed_response.connections |
| 129 |
_parsed_next = _parsed_response.next |
| 130 |
_has_next = _parsed_next is not None and _parsed_next != "" |
| 131 |
_get_next = lambda: self.list( |
| 132 |
from_=_parsed_next, |
| 133 |
take=take, |
| 134 |
strategy=strategy, |
| 135 |
name=name, |
| 136 |
fields=fields, |
| 137 |
include_fields=include_fields, |
| 138 |
request_options=request_options, |
| 139 |
) |
| 140 |
return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) |
| 141 |
if _response.status_code == 400: |
| 142 |
raise BadRequestError( |
| 143 |
headers=dict(_response.headers), |
| 144 |
body=typing.cast( |
| 145 |
typing.Any, |
| 146 |
parse_obj_as( |
| 147 |
type_=typing.Any, |
| 148 |
object_=_response.json(), |
| 149 |
), |
| 150 |
), |
| 151 |
) |
| 152 |
if _response.status_code == 401: |
| 153 |
raise UnauthorizedError( |
| 154 |
headers=dict(_response.headers), |
| 155 |
body=typing.cast( |
| 156 |
typing.Any, |
| 157 |
parse_obj_as( |
| 158 |
type_=typing.Any, |
| 159 |
object_=_response.json(), |
| 160 |
), |
| 161 |
), |
| 162 |
) |
| 163 |
if _response.status_code == 403: |
| 164 |
raise ForbiddenError( |
| 165 |
headers=dict(_response.headers), |
| 166 |
body=typing.cast( |
| 167 |
typing.Any, |
| 168 |
parse_obj_as( |
| 169 |
type_=typing.Any, |
| 170 |
object_=_response.json(), |
| 171 |
), |
| 172 |
), |
| 173 |
) |
| 174 |
if _response.status_code == 429: |
| 175 |
raise TooManyRequestsError( |
| 176 |
headers=dict(_response.headers), |
| 177 |
body=typing.cast( |
| 178 |
typing.Any, |
| 179 |
parse_obj_as( |
| 180 |
type_=typing.Any, |
| 181 |
object_=_response.json(), |
| 182 |
), |
| 183 |
), |
| 184 |
) |
| 185 |
_response_json = _response.json() |
| 186 |
except JSONDecodeError: |
| 187 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 188 |
except ValidationError as e: |
| 189 |
raise ParsingError( |
| 190 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 191 |
) |
| 192 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 193 |
|
| 194 |
def create( |
| 195 |
self, |
| 196 |
*, |
| 197 |
name: str, |
| 198 |
strategy: ConnectionIdentityProviderEnum, |
| 199 |
display_name: typing.Optional[str] = OMIT, |
| 200 |
options: typing.Optional[ConnectionPropertiesOptions] = OMIT, |
| 201 |
enabled_clients: typing.Optional[typing.Sequence[str]] = OMIT, |
| 202 |
is_domain_connection: typing.Optional[bool] = OMIT, |
| 203 |
show_as_button: typing.Optional[bool] = OMIT, |
| 204 |
realms: typing.Optional[typing.Sequence[str]] = OMIT, |
| 205 |
metadata: typing.Optional[ConnectionsMetadata] = OMIT, |
| 206 |
authentication: typing.Optional[ConnectionAuthenticationPurpose] = OMIT, |
| 207 |
connected_accounts: typing.Optional[ConnectionConnectedAccountsPurpose] = OMIT, |
| 208 |
cross_app_access_requesting_app: typing.Optional[CrossAppAccessRequestingApp] = OMIT, |
| 209 |
cross_app_access_resource_app: typing.Optional[CreateCrossAppAccessResourceApp] = OMIT, |
| 210 |
request_options: typing.Optional[RequestOptions] = None, |
| 211 |
) -> HttpResponse[CreateConnectionResponseContent]: |
| 212 |
""" |
| 213 |
Creates a new connection according to the JSON object received in `body`. |
| 214 |
|
| 215 |
**Note:** If a connection with the same name was recently deleted and had a large number of associated users, the deletion may still be processing. Creating a new connection with that name before the deletion completes may fail or produce unexpected results. |
| 216 |
|
| 217 |
Parameters |
| 218 |
---------- |
| 219 |
name : str |
| 220 |
The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 |
| 221 |
|
| 222 |
strategy : ConnectionIdentityProviderEnum |
| 223 |
|
| 224 |
display_name : typing.Optional[str] |
| 225 |
Connection name used in the new universal login experience |
| 226 |
|
| 227 |
options : typing.Optional[ConnectionPropertiesOptions] |
| 228 |
|
| 229 |
enabled_clients : typing.Optional[typing.Sequence[str]] |
| 230 |
Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. |
| 231 |
|
| 232 |
is_domain_connection : typing.Optional[bool] |
| 233 |
<code>true</code> promotes to a domain-level connection so that third-party applications can use it. <code>false</code> does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to <code>false</code>.) |
| 234 |
|
| 235 |
show_as_button : typing.Optional[bool] |
| 236 |
Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. (Defaults to <code>false</code>.) |
| 237 |
|
| 238 |
realms : typing.Optional[typing.Sequence[str]] |
| 239 |
Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. |
| 240 |
|
| 241 |
metadata : typing.Optional[ConnectionsMetadata] |
| 242 |
|
| 243 |
authentication : typing.Optional[ConnectionAuthenticationPurpose] |
| 244 |
|
| 245 |
connected_accounts : typing.Optional[ConnectionConnectedAccountsPurpose] |
| 246 |
|
| 247 |
cross_app_access_requesting_app : typing.Optional[CrossAppAccessRequestingApp] |
| 248 |
|
| 249 |
cross_app_access_resource_app : typing.Optional[CreateCrossAppAccessResourceApp] |
| 250 |
|
| 251 |
request_options : typing.Optional[RequestOptions] |
| 252 |
Request-specific configuration. |
| 253 |
|
| 254 |
Returns |
| 255 |
------- |
| 256 |
HttpResponse[CreateConnectionResponseContent] |
| 257 |
The connection was created. |
| 258 |
""" |
| 259 |
_response = self._client_wrapper.httpx_client.request( |
| 260 |
"connections", |
| 261 |
method="POST", |
| 262 |
json={ |
| 263 |
"name": name, |
| 264 |
"display_name": display_name, |
| 265 |
"strategy": strategy, |
| 266 |
"options": convert_and_respect_annotation_metadata( |
| 267 |
object_=options, annotation=ConnectionPropertiesOptions, direction="write" |
| 268 |
), |
| 269 |
"enabled_clients": enabled_clients, |
| 270 |
"is_domain_connection": is_domain_connection, |
| 271 |
"show_as_button": show_as_button, |
| 272 |
"realms": realms, |
| 273 |
"metadata": metadata, |
| 274 |
"authentication": convert_and_respect_annotation_metadata( |
| 275 |
object_=authentication, annotation=ConnectionAuthenticationPurpose, direction="write" |
| 276 |
), |
| 277 |
"connected_accounts": convert_and_respect_annotation_metadata( |
| 278 |
object_=connected_accounts, annotation=ConnectionConnectedAccountsPurpose, direction="write" |
| 279 |
), |
| 280 |
"cross_app_access_requesting_app": convert_and_respect_annotation_metadata( |
| 281 |
object_=cross_app_access_requesting_app, annotation=CrossAppAccessRequestingApp, direction="write" |
| 282 |
), |
| 283 |
"cross_app_access_resource_app": convert_and_respect_annotation_metadata( |
| 284 |
object_=cross_app_access_resource_app, annotation=CreateCrossAppAccessResourceApp, direction="write" |
| 285 |
), |
| 286 |
}, |
| 287 |
headers={ |
| 288 |
"content-type": "application/json", |
| 289 |
}, |
| 290 |
request_options=request_options, |
| 291 |
omit=OMIT, |
| 292 |
) |
| 293 |
try: |
| 294 |
if 200 <= _response.status_code < 300: |
| 295 |
_data = typing.cast( |
| 296 |
CreateConnectionResponseContent, |
| 297 |
parse_obj_as( |
| 298 |
type_=CreateConnectionResponseContent, |
| 299 |
object_=_response.json(), |
| 300 |
), |
| 301 |
) |
| 302 |
return HttpResponse(response=_response, data=_data) |
| 303 |
if _response.status_code == 400: |
| 304 |
raise BadRequestError( |
| 305 |
headers=dict(_response.headers), |
| 306 |
body=typing.cast( |
| 307 |
typing.Any, |
| 308 |
parse_obj_as( |
| 309 |
type_=typing.Any, |
| 310 |
object_=_response.json(), |
| 311 |
), |
| 312 |
), |
| 313 |
) |
| 314 |
if _response.status_code == 401: |
| 315 |
raise UnauthorizedError( |
| 316 |
headers=dict(_response.headers), |
| 317 |
body=typing.cast( |
| 318 |
typing.Any, |
| 319 |
parse_obj_as( |
| 320 |
type_=typing.Any, |
| 321 |
object_=_response.json(), |
| 322 |
), |
| 323 |
), |
| 324 |
) |
| 325 |
if _response.status_code == 403: |
| 326 |
raise ForbiddenError( |
| 327 |
headers=dict(_response.headers), |
| 328 |
body=typing.cast( |
| 329 |
typing.Any, |
| 330 |
parse_obj_as( |
| 331 |
type_=typing.Any, |
| 332 |
object_=_response.json(), |
| 333 |
), |
| 334 |
), |
| 335 |
) |
| 336 |
if _response.status_code == 409: |
| 337 |
raise ConflictError( |
| 338 |
headers=dict(_response.headers), |
| 339 |
body=typing.cast( |
| 340 |
typing.Any, |
| 341 |
parse_obj_as( |
| 342 |
type_=typing.Any, |
| 343 |
object_=_response.json(), |
| 344 |
), |
| 345 |
), |
| 346 |
) |
| 347 |
if _response.status_code == 429: |
| 348 |
raise TooManyRequestsError( |
| 349 |
headers=dict(_response.headers), |
| 350 |
body=typing.cast( |
| 351 |
typing.Any, |
| 352 |
parse_obj_as( |
| 353 |
type_=typing.Any, |
| 354 |
object_=_response.json(), |
| 355 |
), |
| 356 |
), |
| 357 |
) |
| 358 |
_response_json = _response.json() |
| 359 |
except JSONDecodeError: |
| 360 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 361 |
except ValidationError as e: |
| 362 |
raise ParsingError( |
| 363 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 364 |
) |
| 365 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 366 |
|
| 367 |
def get( |
| 368 |
self, |
| 369 |
id: str, |
| 370 |
*, |
| 371 |
fields: typing.Optional[str] = None, |
| 372 |
include_fields: typing.Optional[bool] = None, |
| 373 |
request_options: typing.Optional[RequestOptions] = None, |
| 374 |
) -> HttpResponse[GetConnectionResponseContent]: |
| 375 |
""" |
| 376 |
Retrieve details for a specified [connection](https://auth0.com/docs/authenticate/identity-providers) along with options that can be used for identity provider configuration. |
| 377 |
|
| 378 |
Parameters |
| 379 |
---------- |
| 380 |
id : str |
| 381 |
The id of the connection to retrieve |
| 382 |
|
| 383 |
fields : typing.Optional[str] |
| 384 |
A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve all fields |
| 385 |
|
| 386 |
include_fields : typing.Optional[bool] |
| 387 |
<code>true</code> if the fields specified are to be included in the result, <code>false</code> otherwise (defaults to <code>true</code>) |
| 388 |
|
| 389 |
request_options : typing.Optional[RequestOptions] |
| 390 |
Request-specific configuration. |
| 391 |
|
| 392 |
Returns |
| 393 |
------- |
| 394 |
HttpResponse[GetConnectionResponseContent] |
| 395 |
The connection was retrieved. |
| 396 |
""" |
| 397 |
_response = self._client_wrapper.httpx_client.request( |
| 398 |
f"connections/{encode_path_param(id)}", |
| 399 |
method="GET", |
| 400 |
params={ |
| 401 |
"fields": fields, |
| 402 |
"include_fields": include_fields, |
| 403 |
}, |
| 404 |
request_options=request_options, |
| 405 |
) |
| 406 |
try: |
| 407 |
if 200 <= _response.status_code < 300: |
| 408 |
_data = typing.cast( |
| 409 |
GetConnectionResponseContent, |
| 410 |
parse_obj_as( |
| 411 |
type_=GetConnectionResponseContent, |
| 412 |
object_=_response.json(), |
| 413 |
), |
| 414 |
) |
| 415 |
return HttpResponse(response=_response, data=_data) |
| 416 |
if _response.status_code == 400: |
| 417 |
raise BadRequestError( |
| 418 |
headers=dict(_response.headers), |
| 419 |
body=typing.cast( |
| 420 |
typing.Any, |
| 421 |
parse_obj_as( |
| 422 |
type_=typing.Any, |
| 423 |
object_=_response.json(), |
| 424 |
), |
| 425 |
), |
| 426 |
) |
| 427 |
if _response.status_code == 401: |
| 428 |
raise UnauthorizedError( |
| 429 |
headers=dict(_response.headers), |
| 430 |
body=typing.cast( |
| 431 |
typing.Any, |
| 432 |
parse_obj_as( |
| 433 |
type_=typing.Any, |
| 434 |
object_=_response.json(), |
| 435 |
), |
| 436 |
), |
| 437 |
) |
| 438 |
if _response.status_code == 403: |
| 439 |
raise ForbiddenError( |
| 440 |
headers=dict(_response.headers), |
| 441 |
body=typing.cast( |
| 442 |
typing.Any, |
| 443 |
parse_obj_as( |
| 444 |
type_=typing.Any, |
| 445 |
object_=_response.json(), |
| 446 |
), |
| 447 |
), |
| 448 |
) |
| 449 |
if _response.status_code == 404: |
| 450 |
raise NotFoundError( |
| 451 |
headers=dict(_response.headers), |
| 452 |
body=typing.cast( |
| 453 |
typing.Any, |
| 454 |
parse_obj_as( |
| 455 |
type_=typing.Any, |
| 456 |
object_=_response.json(), |
| 457 |
), |
| 458 |
), |
| 459 |
) |
| 460 |
if _response.status_code == 429: |
| 461 |
raise TooManyRequestsError( |
| 462 |
headers=dict(_response.headers), |
| 463 |
body=typing.cast( |
| 464 |
typing.Any, |
| 465 |
parse_obj_as( |
| 466 |
type_=typing.Any, |
| 467 |
object_=_response.json(), |
| 468 |
), |
| 469 |
), |
| 470 |
) |
| 471 |
_response_json = _response.json() |
| 472 |
except JSONDecodeError: |
| 473 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 474 |
except ValidationError as e: |
| 475 |
raise ParsingError( |
| 476 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 477 |
) |
| 478 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 479 |
|
| 480 |
def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: |
| 481 |
""" |
| 482 |
Removes a specific [connection](https://auth0.com/docs/authenticate/identity-providers) from your tenant. This action cannot be undone. Once removed, users can no longer use this connection to authenticate. |
| 483 |
|
| 484 |
**Note:** If your connection has a large amount of users associated with it, please be aware that this operation can be long running after the response is returned and may impact concurrent [create connection](https://auth0.com/docs/api/management/v2/connections/post-connections) requests, if they use an identical connection name. |
| 485 |
|
| 486 |
Parameters |
| 487 |
---------- |
| 488 |
id : str |
| 489 |
The id of the connection to delete |
| 490 |
|
| 491 |
request_options : typing.Optional[RequestOptions] |
| 492 |
Request-specific configuration. |
| 493 |
|
| 494 |
Returns |
| 495 |
------- |
| 496 |
HttpResponse[None] |
| 497 |
""" |
| 498 |
_response = self._client_wrapper.httpx_client.request( |
| 499 |
f"connections/{encode_path_param(id)}", |
| 500 |
method="DELETE", |
| 501 |
request_options=request_options, |
| 502 |
) |
| 503 |
try: |
| 504 |
if 200 <= _response.status_code < 300: |
| 505 |
return HttpResponse(response=_response, data=None) |
| 506 |
if _response.status_code == 400: |
| 507 |
raise BadRequestError( |
| 508 |
headers=dict(_response.headers), |
| 509 |
body=typing.cast( |
| 510 |
typing.Any, |
| 511 |
parse_obj_as( |
| 512 |
type_=typing.Any, |
| 513 |
object_=_response.json(), |
| 514 |
), |
| 515 |
), |
| 516 |
) |
| 517 |
if _response.status_code == 401: |
| 518 |
raise UnauthorizedError( |
| 519 |
headers=dict(_response.headers), |
| 520 |
body=typing.cast( |
| 521 |
typing.Any, |
| 522 |
parse_obj_as( |
| 523 |
type_=typing.Any, |
| 524 |
object_=_response.json(), |
| 525 |
), |
| 526 |
), |
| 527 |
) |
| 528 |
if _response.status_code == 403: |
| 529 |
raise ForbiddenError( |
| 530 |
headers=dict(_response.headers), |
| 531 |
body=typing.cast( |
| 532 |
typing.Any, |
| 533 |
parse_obj_as( |
| 534 |
type_=typing.Any, |
| 535 |
object_=_response.json(), |
| 536 |
), |
| 537 |
), |
| 538 |
) |
| 539 |
if _response.status_code == 429: |
| 540 |
raise TooManyRequestsError( |
| 541 |
headers=dict(_response.headers), |
| 542 |
body=typing.cast( |
| 543 |
typing.Any, |
| 544 |
parse_obj_as( |
| 545 |
type_=typing.Any, |
| 546 |
object_=_response.json(), |
| 547 |
), |
| 548 |
), |
| 549 |
) |
| 550 |
_response_json = _response.json() |
| 551 |
except JSONDecodeError: |
| 552 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 553 |
except ValidationError as e: |
| 554 |
raise ParsingError( |
| 555 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 556 |
) |
| 557 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 558 |
|
| 559 |
def update( |
| 560 |
self, |
| 561 |
id: str, |
| 562 |
*, |
| 563 |
display_name: typing.Optional[str] = OMIT, |
| 564 |
options: typing.Optional[UpdateConnectionOptions] = OMIT, |
| 565 |
enabled_clients: typing.Optional[typing.Sequence[str]] = OMIT, |
| 566 |
is_domain_connection: typing.Optional[bool] = OMIT, |
| 567 |
show_as_button: typing.Optional[bool] = OMIT, |
| 568 |
realms: typing.Optional[typing.Sequence[str]] = OMIT, |
| 569 |
metadata: typing.Optional[ConnectionsMetadata] = OMIT, |
| 570 |
authentication: typing.Optional[ConnectionAuthenticationPurpose] = OMIT, |
| 571 |
connected_accounts: typing.Optional[ConnectionConnectedAccountsPurpose] = OMIT, |
| 572 |
cross_app_access_requesting_app: typing.Optional[CrossAppAccessRequestingApp] = OMIT, |
| 573 |
cross_app_access_resource_app: typing.Optional[UpdateCrossAppAccessResourceApp] = OMIT, |
| 574 |
request_options: typing.Optional[RequestOptions] = None, |
| 575 |
) -> HttpResponse[UpdateConnectionResponseContent]: |
| 576 |
""" |
| 577 |
Update details for a specific [connection](https://auth0.com/docs/authenticate/identity-providers), including option properties for identity provider configuration. |
| 578 |
|
| 579 |
**Note**: If you use the `options` parameter, the entire `options` object is overridden. To avoid partial data or other issues, ensure all parameters are present when using this option. |
| 580 |
|
| 581 |
Parameters |
| 582 |
---------- |
| 583 |
id : str |
| 584 |
The id of the connection to update |
| 585 |
|
| 586 |
display_name : typing.Optional[str] |
| 587 |
The connection name used in the new universal login experience. If display_name is not included in the request, the field will be overwritten with the name value. |
| 588 |
|
| 589 |
options : typing.Optional[UpdateConnectionOptions] |
| 590 |
|
| 591 |
enabled_clients : typing.Optional[typing.Sequence[str]] |
| 592 |
DEPRECATED property. Use the PATCH /v2/connections/{id}/clients endpoint to enable or disable the connection for any clients. |
| 593 |
|
| 594 |
is_domain_connection : typing.Optional[bool] |
| 595 |
<code>true</code> promotes to a domain-level connection so that third-party applications can use it. <code>false</code> does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to <code>false</code>.) |
| 596 |
|
| 597 |
show_as_button : typing.Optional[bool] |
| 598 |
Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. (Defaults to <code>false</code>.) |
| 599 |
|
| 600 |
realms : typing.Optional[typing.Sequence[str]] |
| 601 |
Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. |
| 602 |
|
| 603 |
metadata : typing.Optional[ConnectionsMetadata] |
| 604 |
|
| 605 |
authentication : typing.Optional[ConnectionAuthenticationPurpose] |
| 606 |
|
| 607 |
connected_accounts : typing.Optional[ConnectionConnectedAccountsPurpose] |
| 608 |
|
| 609 |
cross_app_access_requesting_app : typing.Optional[CrossAppAccessRequestingApp] |
| 610 |
|
| 611 |
cross_app_access_resource_app : typing.Optional[UpdateCrossAppAccessResourceApp] |
| 612 |
|
| 613 |
request_options : typing.Optional[RequestOptions] |
| 614 |
Request-specific configuration. |
| 615 |
|
| 616 |
Returns |
| 617 |
------- |
| 618 |
HttpResponse[UpdateConnectionResponseContent] |
| 619 |
The connection was updated. |
| 620 |
""" |
| 621 |
_response = self._client_wrapper.httpx_client.request( |
| 622 |
f"connections/{encode_path_param(id)}", |
| 623 |
method="PATCH", |
| 624 |
json={ |
| 625 |
"display_name": display_name, |
| 626 |
"options": convert_and_respect_annotation_metadata( |
| 627 |
object_=options, annotation=typing.Optional[UpdateConnectionOptions], direction="write" |
| 628 |
), |
| 629 |
"enabled_clients": enabled_clients, |
| 630 |
"is_domain_connection": is_domain_connection, |
| 631 |
"show_as_button": show_as_button, |
| 632 |
"realms": realms, |
| 633 |
"metadata": metadata, |
| 634 |
"authentication": convert_and_respect_annotation_metadata( |
| 635 |
object_=authentication, annotation=ConnectionAuthenticationPurpose, direction="write" |
| 636 |
), |
| 637 |
"connected_accounts": convert_and_respect_annotation_metadata( |
| 638 |
object_=connected_accounts, annotation=ConnectionConnectedAccountsPurpose, direction="write" |
| 639 |
), |
| 640 |
"cross_app_access_requesting_app": convert_and_respect_annotation_metadata( |
| 641 |
object_=cross_app_access_requesting_app, annotation=CrossAppAccessRequestingApp, direction="write" |
| 642 |
), |
| 643 |
"cross_app_access_resource_app": convert_and_respect_annotation_metadata( |
| 644 |
object_=cross_app_access_resource_app, |
| 645 |
annotation=typing.Optional[UpdateCrossAppAccessResourceApp], |
| 646 |
direction="write", |
| 647 |
), |
| 648 |
}, |
| 649 |
headers={ |
| 650 |
"content-type": "application/json", |
| 651 |
}, |
| 652 |
request_options=request_options, |
| 653 |
omit=OMIT, |
| 654 |
) |
| 655 |
try: |
| 656 |
if 200 <= _response.status_code < 300: |
| 657 |
_data = typing.cast( |
| 658 |
UpdateConnectionResponseContent, |
| 659 |
parse_obj_as( |
| 660 |
type_=UpdateConnectionResponseContent, |
| 661 |
object_=_response.json(), |
| 662 |
), |
| 663 |
) |
| 664 |
return HttpResponse(response=_response, data=_data) |
| 665 |
if _response.status_code == 400: |
| 666 |
raise BadRequestError( |
| 667 |
headers=dict(_response.headers), |
| 668 |
body=typing.cast( |
| 669 |
typing.Any, |
| 670 |
parse_obj_as( |
| 671 |
type_=typing.Any, |
| 672 |
object_=_response.json(), |
| 673 |
), |
| 674 |
), |
| 675 |
) |
| 676 |
if _response.status_code == 401: |
| 677 |
raise UnauthorizedError( |
| 678 |
headers=dict(_response.headers), |
| 679 |
body=typing.cast( |
| 680 |
typing.Any, |
| 681 |
parse_obj_as( |
| 682 |
type_=typing.Any, |
| 683 |
object_=_response.json(), |
| 684 |
), |
| 685 |
), |
| 686 |
) |
| 687 |
if _response.status_code == 403: |
| 688 |
raise ForbiddenError( |
| 689 |
headers=dict(_response.headers), |
| 690 |
body=typing.cast( |
| 691 |
typing.Any, |
| 692 |
parse_obj_as( |
| 693 |
type_=typing.Any, |
| 694 |
object_=_response.json(), |
| 695 |
), |
| 696 |
), |
| 697 |
) |
| 698 |
if _response.status_code == 404: |
| 699 |
raise NotFoundError( |
| 700 |
headers=dict(_response.headers), |
| 701 |
body=typing.cast( |
| 702 |
typing.Any, |
| 703 |
parse_obj_as( |
| 704 |
type_=typing.Any, |
| 705 |
object_=_response.json(), |
| 706 |
), |
| 707 |
), |
| 708 |
) |
| 709 |
if _response.status_code == 409: |
| 710 |
raise ConflictError( |
| 711 |
headers=dict(_response.headers), |
| 712 |
body=typing.cast( |
| 713 |
typing.Any, |
| 714 |
parse_obj_as( |
| 715 |
type_=typing.Any, |
| 716 |
object_=_response.json(), |
| 717 |
), |
| 718 |
), |
| 719 |
) |
| 720 |
if _response.status_code == 429: |
| 721 |
raise TooManyRequestsError( |
| 722 |
headers=dict(_response.headers), |
| 723 |
body=typing.cast( |
| 724 |
typing.Any, |
| 725 |
parse_obj_as( |
| 726 |
type_=typing.Any, |
| 727 |
object_=_response.json(), |
| 728 |
), |
| 729 |
), |
| 730 |
) |
| 731 |
_response_json = _response.json() |
| 732 |
except JSONDecodeError: |
| 733 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 734 |
except ValidationError as e: |
| 735 |
raise ParsingError( |
| 736 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 737 |
) |
| 738 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 739 |
|
| 740 |
def check_status(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: |
| 741 |
""" |
| 742 |
Retrieves the status of an ad/ldap connection referenced by its `ID`. `200 OK` http status code response is returned when the connection is online, otherwise a `404` status code is returned along with an error message |
| 743 |
|
| 744 |
Parameters |
| 745 |
---------- |
| 746 |
id : str |
| 747 |
ID of the connection to check |
| 748 |
|
| 749 |
request_options : typing.Optional[RequestOptions] |
| 750 |
Request-specific configuration. |
| 751 |
|
| 752 |
Returns |
| 753 |
------- |
| 754 |
HttpResponse[None] |
| 755 |
""" |
| 756 |
_response = self._client_wrapper.httpx_client.request( |
| 757 |
f"connections/{encode_path_param(id)}/status", |
| 758 |
method="GET", |
| 759 |
request_options=request_options, |
| 760 |
) |
| 761 |
try: |
| 762 |
if 200 <= _response.status_code < 300: |
| 763 |
return HttpResponse(response=_response, data=None) |
| 764 |
if _response.status_code == 400: |
| 765 |
raise BadRequestError( |
| 766 |
headers=dict(_response.headers), |
| 767 |
body=typing.cast( |
| 768 |
typing.Any, |
| 769 |
parse_obj_as( |
| 770 |
type_=typing.Any, |
| 771 |
object_=_response.json(), |
| 772 |
), |
| 773 |
), |
| 774 |
) |
| 775 |
if _response.status_code == 401: |
| 776 |
raise UnauthorizedError( |
| 777 |
headers=dict(_response.headers), |
| 778 |
body=typing.cast( |
| 779 |
typing.Any, |
| 780 |
parse_obj_as( |
| 781 |
type_=typing.Any, |
| 782 |
object_=_response.json(), |
| 783 |
), |
| 784 |
), |
| 785 |
) |
| 786 |
if _response.status_code == 403: |
| 787 |
raise ForbiddenError( |
| 788 |
headers=dict(_response.headers), |
| 789 |
body=typing.cast( |
| 790 |
typing.Any, |
| 791 |
parse_obj_as( |
| 792 |
type_=typing.Any, |
| 793 |
object_=_response.json(), |
| 794 |
), |
| 795 |
), |
| 796 |
) |
| 797 |
if _response.status_code == 404: |
| 798 |
raise NotFoundError( |
| 799 |
headers=dict(_response.headers), |
| 800 |
body=typing.cast( |
| 801 |
typing.Any, |
| 802 |
parse_obj_as( |
| 803 |
type_=typing.Any, |
| 804 |
object_=_response.json(), |
| 805 |
), |
| 806 |
), |
| 807 |
) |
| 808 |
if _response.status_code == 429: |
| 809 |
raise TooManyRequestsError( |
| 810 |
headers=dict(_response.headers), |
| 811 |
body=typing.cast( |
| 812 |
typing.Any, |
| 813 |
parse_obj_as( |
| 814 |
type_=typing.Any, |
| 815 |
object_=_response.json(), |
| 816 |
), |
| 817 |
), |
| 818 |
) |
| 819 |
_response_json = _response.json() |
| 820 |
except JSONDecodeError: |
| 821 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 822 |
except ValidationError as e: |
| 823 |
raise ParsingError( |
| 824 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 825 |
) |
| 826 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 827 |
|
| 828 |
|
| 829 |
class AsyncRawConnectionsClient: |
| 830 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 831 |
self._client_wrapper = client_wrapper |
| 832 |
|
| 833 |
async def list( |
| 834 |
self, |
| 835 |
*, |
| 836 |
from_: typing.Optional[str] = None, |
| 837 |
take: typing.Optional[int] = 50, |
| 838 |
strategy: typing.Optional[typing.Union[ConnectionStrategyEnum, typing.Sequence[ConnectionStrategyEnum]]] = None, |
| 839 |
name: typing.Optional[str] = None, |
| 840 |
fields: typing.Optional[str] = None, |
| 841 |
include_fields: typing.Optional[bool] = None, |
| 842 |
request_options: typing.Optional[RequestOptions] = None, |
| 843 |
) -> AsyncPager[ConnectionForList, ListConnectionsCheckpointPaginatedResponseContent]: |
| 844 |
""" |
| 845 |
Retrieves detailed list of all [connections](https://auth0.com/docs/authenticate/identity-providers) that match the specified strategy. If no strategy is provided, all connections within your tenant are retrieved. This action can accept a list of fields to include or exclude from the resulting list of connections. |
| 846 |
|
| 847 |
This endpoint supports two types of pagination: |
| 848 |
|
| 849 |
- Offset pagination |
| 850 |
- Checkpoint pagination |
| 851 |
|
| 852 |
Checkpoint pagination must be used if you need to retrieve more than 1000 connections. |
| 853 |
|
| 854 |
**Checkpoint Pagination** |
| 855 |
|
| 856 |
To search by checkpoint, use the following parameters: |
| 857 |
|
| 858 |
- `from`: Optional id from which to start selection. |
| 859 |
- `take`: The total amount of entries to retrieve when using the from parameter. Defaults to 50. |
| 860 |
|
| 861 |
**Note**: The first time you call this endpoint using checkpoint pagination, omit the `from` parameter. If there are more results, a `next` value is included in the response. You can use this for subsequent API calls. When `next` is no longer included in the response, no pages are remaining. |
| 862 |
|
| 863 |
Parameters |
| 864 |
---------- |
| 865 |
from_ : typing.Optional[str] |
| 866 |
Optional Id from which to start selection. |
| 867 |
|
| 868 |
take : typing.Optional[int] |
| 869 |
Number of results per page. Defaults to 50. |
| 870 |
|
| 871 |
strategy : typing.Optional[typing.Union[ConnectionStrategyEnum, typing.Sequence[ConnectionStrategyEnum]]] |
| 872 |
Provide strategies to only retrieve connections with such strategies |
| 873 |
|
| 874 |
name : typing.Optional[str] |
| 875 |
Provide the name of the connection to retrieve |
| 876 |
|
| 877 |
fields : typing.Optional[str] |
| 878 |
A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve all fields |
| 879 |
|
| 880 |
include_fields : typing.Optional[bool] |
| 881 |
<code>true</code> if the fields specified are to be included in the result, <code>false</code> otherwise (defaults to <code>true</code>) |
| 882 |
|
| 883 |
request_options : typing.Optional[RequestOptions] |
| 884 |
Request-specific configuration. |
| 885 |
|
| 886 |
Returns |
| 887 |
------- |
| 888 |
AsyncPager[ConnectionForList, ListConnectionsCheckpointPaginatedResponseContent] |
| 889 |
The connections were retrieved. |
| 890 |
""" |
| 891 |
_response = await self._client_wrapper.httpx_client.request( |
| 892 |
"connections", |
| 893 |
method="GET", |
| 894 |
params={ |
| 895 |
"from": from_, |
| 896 |
"take": take, |
| 897 |
"strategy": strategy, |
| 898 |
"name": name, |
| 899 |
"fields": fields, |
| 900 |
"include_fields": include_fields, |
| 901 |
}, |
| 902 |
request_options=request_options, |
| 903 |
) |
| 904 |
try: |
| 905 |
if 200 <= _response.status_code < 300: |
| 906 |
_parsed_response = typing.cast( |
| 907 |
ListConnectionsCheckpointPaginatedResponseContent, |
| 908 |
parse_obj_as( |
| 909 |
type_=ListConnectionsCheckpointPaginatedResponseContent, |
| 910 |
object_=_response.json(), |
| 911 |
), |
| 912 |
) |
| 913 |
_items = _parsed_response.connections |
| 914 |
_parsed_next = _parsed_response.next |
| 915 |
_has_next = _parsed_next is not None and _parsed_next != "" |
| 916 |
|
| 917 |
async def _get_next(): |
| 918 |
return await self.list( |
| 919 |
from_=_parsed_next, |
| 920 |
take=take, |
| 921 |
strategy=strategy, |
| 922 |
name=name, |
| 923 |
fields=fields, |
| 924 |
include_fields=include_fields, |
| 925 |
request_options=request_options, |
| 926 |
) |
| 927 |
|
| 928 |
return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) |
| 929 |
if _response.status_code == 400: |
| 930 |
raise BadRequestError( |
| 931 |
headers=dict(_response.headers), |
| 932 |
body=typing.cast( |
| 933 |
typing.Any, |
| 934 |
parse_obj_as( |
| 935 |
type_=typing.Any, |
| 936 |
object_=_response.json(), |
| 937 |
), |
| 938 |
), |
| 939 |
) |
| 940 |
if _response.status_code == 401: |
| 941 |
raise UnauthorizedError( |
| 942 |
headers=dict(_response.headers), |
| 943 |
body=typing.cast( |
| 944 |
typing.Any, |
| 945 |
parse_obj_as( |
| 946 |
type_=typing.Any, |
| 947 |
object_=_response.json(), |
| 948 |
), |
| 949 |
), |
| 950 |
) |
| 951 |
if _response.status_code == 403: |
| 952 |
raise ForbiddenError( |
| 953 |
headers=dict(_response.headers), |
| 954 |
body=typing.cast( |
| 955 |
typing.Any, |
| 956 |
parse_obj_as( |
| 957 |
type_=typing.Any, |
| 958 |
object_=_response.json(), |
| 959 |
), |
| 960 |
), |
| 961 |
) |
| 962 |
if _response.status_code == 429: |
| 963 |
raise TooManyRequestsError( |
| 964 |
headers=dict(_response.headers), |
| 965 |
body=typing.cast( |
| 966 |
typing.Any, |
| 967 |
parse_obj_as( |
| 968 |
type_=typing.Any, |
| 969 |
object_=_response.json(), |
| 970 |
), |
| 971 |
), |
| 972 |
) |
| 973 |
_response_json = _response.json() |
| 974 |
except JSONDecodeError: |
| 975 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 976 |
except ValidationError as e: |
| 977 |
raise ParsingError( |
| 978 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 979 |
) |
| 980 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 981 |
|
| 982 |
async def create( |
| 983 |
self, |
| 984 |
*, |
| 985 |
name: str, |
| 986 |
strategy: ConnectionIdentityProviderEnum, |
| 987 |
display_name: typing.Optional[str] = OMIT, |
| 988 |
options: typing.Optional[ConnectionPropertiesOptions] = OMIT, |
| 989 |
enabled_clients: typing.Optional[typing.Sequence[str]] = OMIT, |
| 990 |
is_domain_connection: typing.Optional[bool] = OMIT, |
| 991 |
show_as_button: typing.Optional[bool] = OMIT, |
| 992 |
realms: typing.Optional[typing.Sequence[str]] = OMIT, |
| 993 |
metadata: typing.Optional[ConnectionsMetadata] = OMIT, |
| 994 |
authentication: typing.Optional[ConnectionAuthenticationPurpose] = OMIT, |
| 995 |
connected_accounts: typing.Optional[ConnectionConnectedAccountsPurpose] = OMIT, |
| 996 |
cross_app_access_requesting_app: typing.Optional[CrossAppAccessRequestingApp] = OMIT, |
| 997 |
cross_app_access_resource_app: typing.Optional[CreateCrossAppAccessResourceApp] = OMIT, |
| 998 |
request_options: typing.Optional[RequestOptions] = None, |
| 999 |
) -> AsyncHttpResponse[CreateConnectionResponseContent]: |
| 1000 |
""" |
| 1001 |
Creates a new connection according to the JSON object received in `body`. |
| 1002 |
|
| 1003 |
**Note:** If a connection with the same name was recently deleted and had a large number of associated users, the deletion may still be processing. Creating a new connection with that name before the deletion completes may fail or produce unexpected results. |
| 1004 |
|
| 1005 |
Parameters |
| 1006 |
---------- |
| 1007 |
name : str |
| 1008 |
The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 |
| 1009 |
|
| 1010 |
strategy : ConnectionIdentityProviderEnum |
| 1011 |
|
| 1012 |
display_name : typing.Optional[str] |
| 1013 |
Connection name used in the new universal login experience |
| 1014 |
|
| 1015 |
options : typing.Optional[ConnectionPropertiesOptions] |
| 1016 |
|
| 1017 |
enabled_clients : typing.Optional[typing.Sequence[str]] |
| 1018 |
Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. |
| 1019 |
|
| 1020 |
is_domain_connection : typing.Optional[bool] |
| 1021 |
<code>true</code> promotes to a domain-level connection so that third-party applications can use it. <code>false</code> does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to <code>false</code>.) |
| 1022 |
|
| 1023 |
show_as_button : typing.Optional[bool] |
| 1024 |
Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. (Defaults to <code>false</code>.) |
| 1025 |
|
| 1026 |
realms : typing.Optional[typing.Sequence[str]] |
| 1027 |
Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. |
| 1028 |
|
| 1029 |
metadata : typing.Optional[ConnectionsMetadata] |
| 1030 |
|
| 1031 |
authentication : typing.Optional[ConnectionAuthenticationPurpose] |
| 1032 |
|
| 1033 |
connected_accounts : typing.Optional[ConnectionConnectedAccountsPurpose] |
| 1034 |
|
| 1035 |
cross_app_access_requesting_app : typing.Optional[CrossAppAccessRequestingApp] |
| 1036 |
|
| 1037 |
cross_app_access_resource_app : typing.Optional[CreateCrossAppAccessResourceApp] |
| 1038 |
|
| 1039 |
request_options : typing.Optional[RequestOptions] |
| 1040 |
Request-specific configuration. |
| 1041 |
|
| 1042 |
Returns |
| 1043 |
------- |
| 1044 |
AsyncHttpResponse[CreateConnectionResponseContent] |
| 1045 |
The connection was created. |
| 1046 |
""" |
| 1047 |
_response = await self._client_wrapper.httpx_client.request( |
| 1048 |
"connections", |
| 1049 |
method="POST", |
| 1050 |
json={ |
| 1051 |
"name": name, |
| 1052 |
"display_name": display_name, |
| 1053 |
"strategy": strategy, |
| 1054 |
"options": convert_and_respect_annotation_metadata( |
| 1055 |
object_=options, annotation=ConnectionPropertiesOptions, direction="write" |
| 1056 |
), |
| 1057 |
"enabled_clients": enabled_clients, |
| 1058 |
"is_domain_connection": is_domain_connection, |
| 1059 |
"show_as_button": show_as_button, |
| 1060 |
"realms": realms, |
| 1061 |
"metadata": metadata, |
| 1062 |
"authentication": convert_and_respect_annotation_metadata( |
| 1063 |
object_=authentication, annotation=ConnectionAuthenticationPurpose, direction="write" |
| 1064 |
), |
| 1065 |
"connected_accounts": convert_and_respect_annotation_metadata( |
| 1066 |
object_=connected_accounts, annotation=ConnectionConnectedAccountsPurpose, direction="write" |
| 1067 |
), |
| 1068 |
"cross_app_access_requesting_app": convert_and_respect_annotation_metadata( |
| 1069 |
object_=cross_app_access_requesting_app, annotation=CrossAppAccessRequestingApp, direction="write" |
| 1070 |
), |
| 1071 |
"cross_app_access_resource_app": convert_and_respect_annotation_metadata( |
| 1072 |
object_=cross_app_access_resource_app, annotation=CreateCrossAppAccessResourceApp, direction="write" |
| 1073 |
), |
| 1074 |
}, |
| 1075 |
headers={ |
| 1076 |
"content-type": "application/json", |
| 1077 |
}, |
| 1078 |
request_options=request_options, |
| 1079 |
omit=OMIT, |
| 1080 |
) |
| 1081 |
try: |
| 1082 |
if 200 <= _response.status_code < 300: |
| 1083 |
_data = typing.cast( |
| 1084 |
CreateConnectionResponseContent, |
| 1085 |
parse_obj_as( |
| 1086 |
type_=CreateConnectionResponseContent, |
| 1087 |
object_=_response.json(), |
| 1088 |
), |
| 1089 |
) |
| 1090 |
return AsyncHttpResponse(response=_response, data=_data) |
| 1091 |
if _response.status_code == 400: |
| 1092 |
raise BadRequestError( |
| 1093 |
headers=dict(_response.headers), |
| 1094 |
body=typing.cast( |
| 1095 |
typing.Any, |
| 1096 |
parse_obj_as( |
| 1097 |
type_=typing.Any, |
| 1098 |
object_=_response.json(), |
| 1099 |
), |
| 1100 |
), |
| 1101 |
) |
| 1102 |
if _response.status_code == 401: |
| 1103 |
raise UnauthorizedError( |
| 1104 |
headers=dict(_response.headers), |
| 1105 |
body=typing.cast( |
| 1106 |
typing.Any, |
| 1107 |
parse_obj_as( |
| 1108 |
type_=typing.Any, |
| 1109 |
object_=_response.json(), |
| 1110 |
), |
| 1111 |
), |
| 1112 |
) |
| 1113 |
if _response.status_code == 403: |
| 1114 |
raise ForbiddenError( |
| 1115 |
headers=dict(_response.headers), |
| 1116 |
body=typing.cast( |
| 1117 |
typing.Any, |
| 1118 |
parse_obj_as( |
| 1119 |
type_=typing.Any, |
| 1120 |
object_=_response.json(), |
| 1121 |
), |
| 1122 |
), |
| 1123 |
) |
| 1124 |
if _response.status_code == 409: |
| 1125 |
raise ConflictError( |
| 1126 |
headers=dict(_response.headers), |
| 1127 |
body=typing.cast( |
| 1128 |
typing.Any, |
| 1129 |
parse_obj_as( |
| 1130 |
type_=typing.Any, |
| 1131 |
object_=_response.json(), |
| 1132 |
), |
| 1133 |
), |
| 1134 |
) |
| 1135 |
if _response.status_code == 429: |
| 1136 |
raise TooManyRequestsError( |
| 1137 |
headers=dict(_response.headers), |
| 1138 |
body=typing.cast( |
| 1139 |
typing.Any, |
| 1140 |
parse_obj_as( |
| 1141 |
type_=typing.Any, |
| 1142 |
object_=_response.json(), |
| 1143 |
), |
| 1144 |
), |
| 1145 |
) |
| 1146 |
_response_json = _response.json() |
| 1147 |
except JSONDecodeError: |
| 1148 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1149 |
except ValidationError as e: |
| 1150 |
raise ParsingError( |
| 1151 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1152 |
) |
| 1153 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1154 |
|
| 1155 |
async def get( |
| 1156 |
self, |
| 1157 |
id: str, |
| 1158 |
*, |
| 1159 |
fields: typing.Optional[str] = None, |
| 1160 |
include_fields: typing.Optional[bool] = None, |
| 1161 |
request_options: typing.Optional[RequestOptions] = None, |
| 1162 |
) -> AsyncHttpResponse[GetConnectionResponseContent]: |
| 1163 |
""" |
| 1164 |
Retrieve details for a specified [connection](https://auth0.com/docs/authenticate/identity-providers) along with options that can be used for identity provider configuration. |
| 1165 |
|
| 1166 |
Parameters |
| 1167 |
---------- |
| 1168 |
id : str |
| 1169 |
The id of the connection to retrieve |
| 1170 |
|
| 1171 |
fields : typing.Optional[str] |
| 1172 |
A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve all fields |
| 1173 |
|
| 1174 |
include_fields : typing.Optional[bool] |
| 1175 |
<code>true</code> if the fields specified are to be included in the result, <code>false</code> otherwise (defaults to <code>true</code>) |
| 1176 |
|
| 1177 |
request_options : typing.Optional[RequestOptions] |
| 1178 |
Request-specific configuration. |
| 1179 |
|
| 1180 |
Returns |
| 1181 |
------- |
| 1182 |
AsyncHttpResponse[GetConnectionResponseContent] |
| 1183 |
The connection was retrieved. |
| 1184 |
""" |
| 1185 |
_response = await self._client_wrapper.httpx_client.request( |
| 1186 |
f"connections/{encode_path_param(id)}", |
| 1187 |
method="GET", |
| 1188 |
params={ |
| 1189 |
"fields": fields, |
| 1190 |
"include_fields": include_fields, |
| 1191 |
}, |
| 1192 |
request_options=request_options, |
| 1193 |
) |
| 1194 |
try: |
| 1195 |
if 200 <= _response.status_code < 300: |
| 1196 |
_data = typing.cast( |
| 1197 |
GetConnectionResponseContent, |
| 1198 |
parse_obj_as( |
| 1199 |
type_=GetConnectionResponseContent, |
| 1200 |
object_=_response.json(), |
| 1201 |
), |
| 1202 |
) |
| 1203 |
return AsyncHttpResponse(response=_response, data=_data) |
| 1204 |
if _response.status_code == 400: |
| 1205 |
raise BadRequestError( |
| 1206 |
headers=dict(_response.headers), |
| 1207 |
body=typing.cast( |
| 1208 |
typing.Any, |
| 1209 |
parse_obj_as( |
| 1210 |
type_=typing.Any, |
| 1211 |
object_=_response.json(), |
| 1212 |
), |
| 1213 |
), |
| 1214 |
) |
| 1215 |
if _response.status_code == 401: |
| 1216 |
raise UnauthorizedError( |
| 1217 |
headers=dict(_response.headers), |
| 1218 |
body=typing.cast( |
| 1219 |
typing.Any, |
| 1220 |
parse_obj_as( |
| 1221 |
type_=typing.Any, |
| 1222 |
object_=_response.json(), |
| 1223 |
), |
| 1224 |
), |
| 1225 |
) |
| 1226 |
if _response.status_code == 403: |
| 1227 |
raise ForbiddenError( |
| 1228 |
headers=dict(_response.headers), |
| 1229 |
body=typing.cast( |
| 1230 |
typing.Any, |
| 1231 |
parse_obj_as( |
| 1232 |
type_=typing.Any, |
| 1233 |
object_=_response.json(), |
| 1234 |
), |
| 1235 |
), |
| 1236 |
) |
| 1237 |
if _response.status_code == 404: |
| 1238 |
raise NotFoundError( |
| 1239 |
headers=dict(_response.headers), |
| 1240 |
body=typing.cast( |
| 1241 |
typing.Any, |
| 1242 |
parse_obj_as( |
| 1243 |
type_=typing.Any, |
| 1244 |
object_=_response.json(), |
| 1245 |
), |
| 1246 |
), |
| 1247 |
) |
| 1248 |
if _response.status_code == 429: |
| 1249 |
raise TooManyRequestsError( |
| 1250 |
headers=dict(_response.headers), |
| 1251 |
body=typing.cast( |
| 1252 |
typing.Any, |
| 1253 |
parse_obj_as( |
| 1254 |
type_=typing.Any, |
| 1255 |
object_=_response.json(), |
| 1256 |
), |
| 1257 |
), |
| 1258 |
) |
| 1259 |
_response_json = _response.json() |
| 1260 |
except JSONDecodeError: |
| 1261 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1262 |
except ValidationError as e: |
| 1263 |
raise ParsingError( |
| 1264 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1265 |
) |
| 1266 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1267 |
|
| 1268 |
async def delete( |
| 1269 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 1270 |
) -> AsyncHttpResponse[None]: |
| 1271 |
""" |
| 1272 |
Removes a specific [connection](https://auth0.com/docs/authenticate/identity-providers) from your tenant. This action cannot be undone. Once removed, users can no longer use this connection to authenticate. |
| 1273 |
|
| 1274 |
**Note:** If your connection has a large amount of users associated with it, please be aware that this operation can be long running after the response is returned and may impact concurrent [create connection](https://auth0.com/docs/api/management/v2/connections/post-connections) requests, if they use an identical connection name. |
| 1275 |
|
| 1276 |
Parameters |
| 1277 |
---------- |
| 1278 |
id : str |
| 1279 |
The id of the connection to delete |
| 1280 |
|
| 1281 |
request_options : typing.Optional[RequestOptions] |
| 1282 |
Request-specific configuration. |
| 1283 |
|
| 1284 |
Returns |
| 1285 |
------- |
| 1286 |
AsyncHttpResponse[None] |
| 1287 |
""" |
| 1288 |
_response = await self._client_wrapper.httpx_client.request( |
| 1289 |
f"connections/{encode_path_param(id)}", |
| 1290 |
method="DELETE", |
| 1291 |
request_options=request_options, |
| 1292 |
) |
| 1293 |
try: |
| 1294 |
if 200 <= _response.status_code < 300: |
| 1295 |
return AsyncHttpResponse(response=_response, data=None) |
| 1296 |
if _response.status_code == 400: |
| 1297 |
raise BadRequestError( |
| 1298 |
headers=dict(_response.headers), |
| 1299 |
body=typing.cast( |
| 1300 |
typing.Any, |
| 1301 |
parse_obj_as( |
| 1302 |
type_=typing.Any, |
| 1303 |
object_=_response.json(), |
| 1304 |
), |
| 1305 |
), |
| 1306 |
) |
| 1307 |
if _response.status_code == 401: |
| 1308 |
raise UnauthorizedError( |
| 1309 |
headers=dict(_response.headers), |
| 1310 |
body=typing.cast( |
| 1311 |
typing.Any, |
| 1312 |
parse_obj_as( |
| 1313 |
type_=typing.Any, |
| 1314 |
object_=_response.json(), |
| 1315 |
), |
| 1316 |
), |
| 1317 |
) |
| 1318 |
if _response.status_code == 403: |
| 1319 |
raise ForbiddenError( |
| 1320 |
headers=dict(_response.headers), |
| 1321 |
body=typing.cast( |
| 1322 |
typing.Any, |
| 1323 |
parse_obj_as( |
| 1324 |
type_=typing.Any, |
| 1325 |
object_=_response.json(), |
| 1326 |
), |
| 1327 |
), |
| 1328 |
) |
| 1329 |
if _response.status_code == 429: |
| 1330 |
raise TooManyRequestsError( |
| 1331 |
headers=dict(_response.headers), |
| 1332 |
body=typing.cast( |
| 1333 |
typing.Any, |
| 1334 |
parse_obj_as( |
| 1335 |
type_=typing.Any, |
| 1336 |
object_=_response.json(), |
| 1337 |
), |
| 1338 |
), |
| 1339 |
) |
| 1340 |
_response_json = _response.json() |
| 1341 |
except JSONDecodeError: |
| 1342 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1343 |
except ValidationError as e: |
| 1344 |
raise ParsingError( |
| 1345 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1346 |
) |
| 1347 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1348 |
|
| 1349 |
async def update( |
| 1350 |
self, |
| 1351 |
id: str, |
| 1352 |
*, |
| 1353 |
display_name: typing.Optional[str] = OMIT, |
| 1354 |
options: typing.Optional[UpdateConnectionOptions] = OMIT, |
| 1355 |
enabled_clients: typing.Optional[typing.Sequence[str]] = OMIT, |
| 1356 |
is_domain_connection: typing.Optional[bool] = OMIT, |
| 1357 |
show_as_button: typing.Optional[bool] = OMIT, |
| 1358 |
realms: typing.Optional[typing.Sequence[str]] = OMIT, |
| 1359 |
metadata: typing.Optional[ConnectionsMetadata] = OMIT, |
| 1360 |
authentication: typing.Optional[ConnectionAuthenticationPurpose] = OMIT, |
| 1361 |
connected_accounts: typing.Optional[ConnectionConnectedAccountsPurpose] = OMIT, |
| 1362 |
cross_app_access_requesting_app: typing.Optional[CrossAppAccessRequestingApp] = OMIT, |
| 1363 |
cross_app_access_resource_app: typing.Optional[UpdateCrossAppAccessResourceApp] = OMIT, |
| 1364 |
request_options: typing.Optional[RequestOptions] = None, |
| 1365 |
) -> AsyncHttpResponse[UpdateConnectionResponseContent]: |
| 1366 |
""" |
| 1367 |
Update details for a specific [connection](https://auth0.com/docs/authenticate/identity-providers), including option properties for identity provider configuration. |
| 1368 |
|
| 1369 |
**Note**: If you use the `options` parameter, the entire `options` object is overridden. To avoid partial data or other issues, ensure all parameters are present when using this option. |
| 1370 |
|
| 1371 |
Parameters |
| 1372 |
---------- |
| 1373 |
id : str |
| 1374 |
The id of the connection to update |
| 1375 |
|
| 1376 |
display_name : typing.Optional[str] |
| 1377 |
The connection name used in the new universal login experience. If display_name is not included in the request, the field will be overwritten with the name value. |
| 1378 |
|
| 1379 |
options : typing.Optional[UpdateConnectionOptions] |
| 1380 |
|
| 1381 |
enabled_clients : typing.Optional[typing.Sequence[str]] |
| 1382 |
DEPRECATED property. Use the PATCH /v2/connections/{id}/clients endpoint to enable or disable the connection for any clients. |
| 1383 |
|
| 1384 |
is_domain_connection : typing.Optional[bool] |
| 1385 |
<code>true</code> promotes to a domain-level connection so that third-party applications can use it. <code>false</code> does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to <code>false</code>.) |
| 1386 |
|
| 1387 |
show_as_button : typing.Optional[bool] |
| 1388 |
Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. (Defaults to <code>false</code>.) |
| 1389 |
|
| 1390 |
realms : typing.Optional[typing.Sequence[str]] |
| 1391 |
Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. |
| 1392 |
|
| 1393 |
metadata : typing.Optional[ConnectionsMetadata] |
| 1394 |
|
| 1395 |
authentication : typing.Optional[ConnectionAuthenticationPurpose] |
| 1396 |
|
| 1397 |
connected_accounts : typing.Optional[ConnectionConnectedAccountsPurpose] |
| 1398 |
|
| 1399 |
cross_app_access_requesting_app : typing.Optional[CrossAppAccessRequestingApp] |
| 1400 |
|
| 1401 |
cross_app_access_resource_app : typing.Optional[UpdateCrossAppAccessResourceApp] |
| 1402 |
|
| 1403 |
request_options : typing.Optional[RequestOptions] |
| 1404 |
Request-specific configuration. |
| 1405 |
|
| 1406 |
Returns |
| 1407 |
------- |
| 1408 |
AsyncHttpResponse[UpdateConnectionResponseContent] |
| 1409 |
The connection was updated. |
| 1410 |
""" |
| 1411 |
_response = await self._client_wrapper.httpx_client.request( |
| 1412 |
f"connections/{encode_path_param(id)}", |
| 1413 |
method="PATCH", |
| 1414 |
json={ |
| 1415 |
"display_name": display_name, |
| 1416 |
"options": convert_and_respect_annotation_metadata( |
| 1417 |
object_=options, annotation=typing.Optional[UpdateConnectionOptions], direction="write" |
| 1418 |
), |
| 1419 |
"enabled_clients": enabled_clients, |
| 1420 |
"is_domain_connection": is_domain_connection, |
| 1421 |
"show_as_button": show_as_button, |
| 1422 |
"realms": realms, |
| 1423 |
"metadata": metadata, |
| 1424 |
"authentication": convert_and_respect_annotation_metadata( |
| 1425 |
object_=authentication, annotation=ConnectionAuthenticationPurpose, direction="write" |
| 1426 |
), |
| 1427 |
"connected_accounts": convert_and_respect_annotation_metadata( |
| 1428 |
object_=connected_accounts, annotation=ConnectionConnectedAccountsPurpose, direction="write" |
| 1429 |
), |
| 1430 |
"cross_app_access_requesting_app": convert_and_respect_annotation_metadata( |
| 1431 |
object_=cross_app_access_requesting_app, annotation=CrossAppAccessRequestingApp, direction="write" |
| 1432 |
), |
| 1433 |
"cross_app_access_resource_app": convert_and_respect_annotation_metadata( |
| 1434 |
object_=cross_app_access_resource_app, |
| 1435 |
annotation=typing.Optional[UpdateCrossAppAccessResourceApp], |
| 1436 |
direction="write", |
| 1437 |
), |
| 1438 |
}, |
| 1439 |
headers={ |
| 1440 |
"content-type": "application/json", |
| 1441 |
}, |
| 1442 |
request_options=request_options, |
| 1443 |
omit=OMIT, |
| 1444 |
) |
| 1445 |
try: |
| 1446 |
if 200 <= _response.status_code < 300: |
| 1447 |
_data = typing.cast( |
| 1448 |
UpdateConnectionResponseContent, |
| 1449 |
parse_obj_as( |
| 1450 |
type_=UpdateConnectionResponseContent, |
| 1451 |
object_=_response.json(), |
| 1452 |
), |
| 1453 |
) |
| 1454 |
return AsyncHttpResponse(response=_response, data=_data) |
| 1455 |
if _response.status_code == 400: |
| 1456 |
raise BadRequestError( |
| 1457 |
headers=dict(_response.headers), |
| 1458 |
body=typing.cast( |
| 1459 |
typing.Any, |
| 1460 |
parse_obj_as( |
| 1461 |
type_=typing.Any, |
| 1462 |
object_=_response.json(), |
| 1463 |
), |
| 1464 |
), |
| 1465 |
) |
| 1466 |
if _response.status_code == 401: |
| 1467 |
raise UnauthorizedError( |
| 1468 |
headers=dict(_response.headers), |
| 1469 |
body=typing.cast( |
| 1470 |
typing.Any, |
| 1471 |
parse_obj_as( |
| 1472 |
type_=typing.Any, |
| 1473 |
object_=_response.json(), |
| 1474 |
), |
| 1475 |
), |
| 1476 |
) |
| 1477 |
if _response.status_code == 403: |
| 1478 |
raise ForbiddenError( |
| 1479 |
headers=dict(_response.headers), |
| 1480 |
body=typing.cast( |
| 1481 |
typing.Any, |
| 1482 |
parse_obj_as( |
| 1483 |
type_=typing.Any, |
| 1484 |
object_=_response.json(), |
| 1485 |
), |
| 1486 |
), |
| 1487 |
) |
| 1488 |
if _response.status_code == 404: |
| 1489 |
raise NotFoundError( |
| 1490 |
headers=dict(_response.headers), |
| 1491 |
body=typing.cast( |
| 1492 |
typing.Any, |
| 1493 |
parse_obj_as( |
| 1494 |
type_=typing.Any, |
| 1495 |
object_=_response.json(), |
| 1496 |
), |
| 1497 |
), |
| 1498 |
) |
| 1499 |
if _response.status_code == 409: |
| 1500 |
raise ConflictError( |
| 1501 |
headers=dict(_response.headers), |
| 1502 |
body=typing.cast( |
| 1503 |
typing.Any, |
| 1504 |
parse_obj_as( |
| 1505 |
type_=typing.Any, |
| 1506 |
object_=_response.json(), |
| 1507 |
), |
| 1508 |
), |
| 1509 |
) |
| 1510 |
if _response.status_code == 429: |
| 1511 |
raise TooManyRequestsError( |
| 1512 |
headers=dict(_response.headers), |
| 1513 |
body=typing.cast( |
| 1514 |
typing.Any, |
| 1515 |
parse_obj_as( |
| 1516 |
type_=typing.Any, |
| 1517 |
object_=_response.json(), |
| 1518 |
), |
| 1519 |
), |
| 1520 |
) |
| 1521 |
_response_json = _response.json() |
| 1522 |
except JSONDecodeError: |
| 1523 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1524 |
except ValidationError as e: |
| 1525 |
raise ParsingError( |
| 1526 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1527 |
) |
| 1528 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1529 |
|
| 1530 |
async def check_status( |
| 1531 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 1532 |
) -> AsyncHttpResponse[None]: |
| 1533 |
""" |
| 1534 |
Retrieves the status of an ad/ldap connection referenced by its `ID`. `200 OK` http status code response is returned when the connection is online, otherwise a `404` status code is returned along with an error message |
| 1535 |
|
| 1536 |
Parameters |
| 1537 |
---------- |
| 1538 |
id : str |
| 1539 |
ID of the connection to check |
| 1540 |
|
| 1541 |
request_options : typing.Optional[RequestOptions] |
| 1542 |
Request-specific configuration. |
| 1543 |
|
| 1544 |
Returns |
| 1545 |
------- |
| 1546 |
AsyncHttpResponse[None] |
| 1547 |
""" |
| 1548 |
_response = await self._client_wrapper.httpx_client.request( |
| 1549 |
f"connections/{encode_path_param(id)}/status", |
| 1550 |
method="GET", |
| 1551 |
request_options=request_options, |
| 1552 |
) |
| 1553 |
try: |
| 1554 |
if 200 <= _response.status_code < 300: |
| 1555 |
return AsyncHttpResponse(response=_response, data=None) |
| 1556 |
if _response.status_code == 400: |
| 1557 |
raise BadRequestError( |
| 1558 |
headers=dict(_response.headers), |
| 1559 |
body=typing.cast( |
| 1560 |
typing.Any, |
| 1561 |
parse_obj_as( |
| 1562 |
type_=typing.Any, |
| 1563 |
object_=_response.json(), |
| 1564 |
), |
| 1565 |
), |
| 1566 |
) |
| 1567 |
if _response.status_code == 401: |
| 1568 |
raise UnauthorizedError( |
| 1569 |
headers=dict(_response.headers), |
| 1570 |
body=typing.cast( |
| 1571 |
typing.Any, |
| 1572 |
parse_obj_as( |
| 1573 |
type_=typing.Any, |
| 1574 |
object_=_response.json(), |
| 1575 |
), |
| 1576 |
), |
| 1577 |
) |
| 1578 |
if _response.status_code == 403: |
| 1579 |
raise ForbiddenError( |
| 1580 |
headers=dict(_response.headers), |
| 1581 |
body=typing.cast( |
| 1582 |
typing.Any, |
| 1583 |
parse_obj_as( |
| 1584 |
type_=typing.Any, |
| 1585 |
object_=_response.json(), |
| 1586 |
), |
| 1587 |
), |
| 1588 |
) |
| 1589 |
if _response.status_code == 404: |
| 1590 |
raise NotFoundError( |
| 1591 |
headers=dict(_response.headers), |
| 1592 |
body=typing.cast( |
| 1593 |
typing.Any, |
| 1594 |
parse_obj_as( |
| 1595 |
type_=typing.Any, |
| 1596 |
object_=_response.json(), |
| 1597 |
), |
| 1598 |
), |
| 1599 |
) |
| 1600 |
if _response.status_code == 429: |
| 1601 |
raise TooManyRequestsError( |
| 1602 |
headers=dict(_response.headers), |
| 1603 |
body=typing.cast( |
| 1604 |
typing.Any, |
| 1605 |
parse_obj_as( |
| 1606 |
type_=typing.Any, |
| 1607 |
object_=_response.json(), |
| 1608 |
), |
| 1609 |
), |
| 1610 |
) |
| 1611 |
_response_json = _response.json() |
| 1612 |
except JSONDecodeError: |
| 1613 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1614 |
except ValidationError as e: |
| 1615 |
raise ParsingError( |
| 1616 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1617 |
) |
| 1618 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |