| 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 ...errors.bad_request_error import BadRequestError |
| 15 |
from ...errors.forbidden_error import ForbiddenError |
| 16 |
from ...errors.not_found_error import NotFoundError |
| 17 |
from ...errors.too_many_requests_error import TooManyRequestsError |
| 18 |
from ...errors.unauthorized_error import UnauthorizedError |
| 19 |
from ...types.list_organization_members_paginated_response_content import ( |
| 20 |
ListOrganizationMembersPaginatedResponseContent, |
| 21 |
) |
| 22 |
from ...types.organization_member import OrganizationMember |
| 23 |
from pydantic import ValidationError |
| 24 |
|
| 25 |
|
| 26 |
OMIT = typing.cast(typing.Any, ...) |
| 27 |
|
| 28 |
|
| 29 |
class RawMembersClient: |
| 30 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 31 |
self._client_wrapper = client_wrapper |
| 32 |
|
| 33 |
def list( |
| 34 |
self, |
| 35 |
id: str, |
| 36 |
*, |
| 37 |
from_: typing.Optional[str] = None, |
| 38 |
take: typing.Optional[int] = 50, |
| 39 |
fields: typing.Optional[str] = None, |
| 40 |
include_fields: typing.Optional[bool] = None, |
| 41 |
request_options: typing.Optional[RequestOptions] = None, |
| 42 |
) -> SyncPager[OrganizationMember, ListOrganizationMembersPaginatedResponseContent]: |
| 43 |
""" |
| 44 |
List organization members. |
| 45 |
This endpoint is subject to eventual consistency. New users may not be immediately included in the response and deleted users may not be immediately removed from it. |
| 46 |
|
| 47 |
- Use the `fields` parameter to optionally define the specific member details retrieved. If `fields` is left blank, all fields (except roles) are returned. |
| 48 |
- Member roles are not sent by default. Use `fields=roles` to retrieve the roles assigned to each listed member. To use this parameter, you must include the `read:organization_member_roles` scope in the token. |
| 49 |
|
| 50 |
This endpoint supports two types of pagination: |
| 51 |
|
| 52 |
- Offset pagination |
| 53 |
- Checkpoint pagination |
| 54 |
|
| 55 |
Checkpoint pagination must be used if you need to retrieve more than 1000 organization members. |
| 56 |
|
| 57 |
**Checkpoint Pagination** |
| 58 |
|
| 59 |
To search by checkpoint, use the following parameters: - from: Optional id from which to start selection. - take: The total amount of entries to retrieve when using the from parameter. Defaults to 50. Note: The first time you call this endpoint using Checkpoint Pagination, you should omit the `from` parameter. If there are more results, a `next` value will be included in the response. You can use this for subsequent API calls. When `next` is no longer included in the response, this indicates there are no more pages remaining. |
| 60 |
|
| 61 |
Parameters |
| 62 |
---------- |
| 63 |
id : str |
| 64 |
Organization identifier. |
| 65 |
|
| 66 |
from_ : typing.Optional[str] |
| 67 |
Optional Id from which to start selection. |
| 68 |
|
| 69 |
take : typing.Optional[int] |
| 70 |
Number of results per page. Defaults to 50. |
| 71 |
|
| 72 |
fields : typing.Optional[str] |
| 73 |
Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields. |
| 74 |
|
| 75 |
include_fields : typing.Optional[bool] |
| 76 |
Whether specified fields are to be included (true) or excluded (false). |
| 77 |
|
| 78 |
request_options : typing.Optional[RequestOptions] |
| 79 |
Request-specific configuration. |
| 80 |
|
| 81 |
Returns |
| 82 |
------- |
| 83 |
SyncPager[OrganizationMember, ListOrganizationMembersPaginatedResponseContent] |
| 84 |
Members successfully retrieved. |
| 85 |
""" |
| 86 |
_response = self._client_wrapper.httpx_client.request( |
| 87 |
f"organizations/{encode_path_param(id)}/members", |
| 88 |
method="GET", |
| 89 |
params={ |
| 90 |
"from": from_, |
| 91 |
"take": take, |
| 92 |
"fields": fields, |
| 93 |
"include_fields": include_fields, |
| 94 |
}, |
| 95 |
request_options=request_options, |
| 96 |
) |
| 97 |
try: |
| 98 |
if 200 <= _response.status_code < 300: |
| 99 |
_parsed_response = typing.cast( |
| 100 |
ListOrganizationMembersPaginatedResponseContent, |
| 101 |
parse_obj_as( |
| 102 |
type_=ListOrganizationMembersPaginatedResponseContent, |
| 103 |
object_=_response.json(), |
| 104 |
), |
| 105 |
) |
| 106 |
_items = _parsed_response.members |
| 107 |
_parsed_next = _parsed_response.next |
| 108 |
_has_next = _parsed_next is not None and _parsed_next != "" |
| 109 |
_get_next = lambda: self.list( |
| 110 |
id, |
| 111 |
from_=_parsed_next, |
| 112 |
take=take, |
| 113 |
fields=fields, |
| 114 |
include_fields=include_fields, |
| 115 |
request_options=request_options, |
| 116 |
) |
| 117 |
return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) |
| 118 |
if _response.status_code == 400: |
| 119 |
raise BadRequestError( |
| 120 |
headers=dict(_response.headers), |
| 121 |
body=typing.cast( |
| 122 |
typing.Any, |
| 123 |
parse_obj_as( |
| 124 |
type_=typing.Any, |
| 125 |
object_=_response.json(), |
| 126 |
), |
| 127 |
), |
| 128 |
) |
| 129 |
if _response.status_code == 401: |
| 130 |
raise UnauthorizedError( |
| 131 |
headers=dict(_response.headers), |
| 132 |
body=typing.cast( |
| 133 |
typing.Any, |
| 134 |
parse_obj_as( |
| 135 |
type_=typing.Any, |
| 136 |
object_=_response.json(), |
| 137 |
), |
| 138 |
), |
| 139 |
) |
| 140 |
if _response.status_code == 403: |
| 141 |
raise ForbiddenError( |
| 142 |
headers=dict(_response.headers), |
| 143 |
body=typing.cast( |
| 144 |
typing.Any, |
| 145 |
parse_obj_as( |
| 146 |
type_=typing.Any, |
| 147 |
object_=_response.json(), |
| 148 |
), |
| 149 |
), |
| 150 |
) |
| 151 |
if _response.status_code == 404: |
| 152 |
raise NotFoundError( |
| 153 |
headers=dict(_response.headers), |
| 154 |
body=typing.cast( |
| 155 |
typing.Any, |
| 156 |
parse_obj_as( |
| 157 |
type_=typing.Any, |
| 158 |
object_=_response.json(), |
| 159 |
), |
| 160 |
), |
| 161 |
) |
| 162 |
if _response.status_code == 429: |
| 163 |
raise TooManyRequestsError( |
| 164 |
headers=dict(_response.headers), |
| 165 |
body=typing.cast( |
| 166 |
typing.Any, |
| 167 |
parse_obj_as( |
| 168 |
type_=typing.Any, |
| 169 |
object_=_response.json(), |
| 170 |
), |
| 171 |
), |
| 172 |
) |
| 173 |
_response_json = _response.json() |
| 174 |
except JSONDecodeError: |
| 175 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 176 |
except ValidationError as e: |
| 177 |
raise ParsingError( |
| 178 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 179 |
) |
| 180 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 181 |
|
| 182 |
def create( |
| 183 |
self, id: str, *, members: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None |
| 184 |
) -> HttpResponse[None]: |
| 185 |
""" |
| 186 |
Set one or more existing users as members of a specific [Organization](https://auth0.com/docs/manage-users/organizations). |
| 187 |
|
| 188 |
To add a user to an Organization through this action, the user must already exist in your tenant. If a user does not yet exist, you can [invite them to create an account](https://auth0.com/docs/manage-users/organizations/configure-organizations/invite-members), manually create them through the Auth0 Dashboard, or use the Management API. |
| 189 |
|
| 190 |
Parameters |
| 191 |
---------- |
| 192 |
id : str |
| 193 |
Organization identifier. |
| 194 |
|
| 195 |
members : typing.Sequence[str] |
| 196 |
List of user IDs to add to the organization as members. |
| 197 |
|
| 198 |
request_options : typing.Optional[RequestOptions] |
| 199 |
Request-specific configuration. |
| 200 |
|
| 201 |
Returns |
| 202 |
------- |
| 203 |
HttpResponse[None] |
| 204 |
""" |
| 205 |
_response = self._client_wrapper.httpx_client.request( |
| 206 |
f"organizations/{encode_path_param(id)}/members", |
| 207 |
method="POST", |
| 208 |
json={ |
| 209 |
"members": members, |
| 210 |
}, |
| 211 |
headers={ |
| 212 |
"content-type": "application/json", |
| 213 |
}, |
| 214 |
request_options=request_options, |
| 215 |
omit=OMIT, |
| 216 |
) |
| 217 |
try: |
| 218 |
if 200 <= _response.status_code < 300: |
| 219 |
return HttpResponse(response=_response, data=None) |
| 220 |
if _response.status_code == 400: |
| 221 |
raise BadRequestError( |
| 222 |
headers=dict(_response.headers), |
| 223 |
body=typing.cast( |
| 224 |
typing.Any, |
| 225 |
parse_obj_as( |
| 226 |
type_=typing.Any, |
| 227 |
object_=_response.json(), |
| 228 |
), |
| 229 |
), |
| 230 |
) |
| 231 |
if _response.status_code == 401: |
| 232 |
raise UnauthorizedError( |
| 233 |
headers=dict(_response.headers), |
| 234 |
body=typing.cast( |
| 235 |
typing.Any, |
| 236 |
parse_obj_as( |
| 237 |
type_=typing.Any, |
| 238 |
object_=_response.json(), |
| 239 |
), |
| 240 |
), |
| 241 |
) |
| 242 |
if _response.status_code == 403: |
| 243 |
raise ForbiddenError( |
| 244 |
headers=dict(_response.headers), |
| 245 |
body=typing.cast( |
| 246 |
typing.Any, |
| 247 |
parse_obj_as( |
| 248 |
type_=typing.Any, |
| 249 |
object_=_response.json(), |
| 250 |
), |
| 251 |
), |
| 252 |
) |
| 253 |
if _response.status_code == 429: |
| 254 |
raise TooManyRequestsError( |
| 255 |
headers=dict(_response.headers), |
| 256 |
body=typing.cast( |
| 257 |
typing.Any, |
| 258 |
parse_obj_as( |
| 259 |
type_=typing.Any, |
| 260 |
object_=_response.json(), |
| 261 |
), |
| 262 |
), |
| 263 |
) |
| 264 |
_response_json = _response.json() |
| 265 |
except JSONDecodeError: |
| 266 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 267 |
except ValidationError as e: |
| 268 |
raise ParsingError( |
| 269 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 270 |
) |
| 271 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 272 |
|
| 273 |
def delete( |
| 274 |
self, id: str, *, members: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None |
| 275 |
) -> HttpResponse[None]: |
| 276 |
""" |
| 277 |
Parameters |
| 278 |
---------- |
| 279 |
id : str |
| 280 |
Organization identifier. |
| 281 |
|
| 282 |
members : typing.Sequence[str] |
| 283 |
List of user IDs to remove from the organization. |
| 284 |
|
| 285 |
request_options : typing.Optional[RequestOptions] |
| 286 |
Request-specific configuration. |
| 287 |
|
| 288 |
Returns |
| 289 |
------- |
| 290 |
HttpResponse[None] |
| 291 |
""" |
| 292 |
_response = self._client_wrapper.httpx_client.request( |
| 293 |
f"organizations/{encode_path_param(id)}/members", |
| 294 |
method="DELETE", |
| 295 |
json={ |
| 296 |
"members": members, |
| 297 |
}, |
| 298 |
headers={ |
| 299 |
"content-type": "application/json", |
| 300 |
}, |
| 301 |
request_options=request_options, |
| 302 |
omit=OMIT, |
| 303 |
) |
| 304 |
try: |
| 305 |
if 200 <= _response.status_code < 300: |
| 306 |
return HttpResponse(response=_response, data=None) |
| 307 |
if _response.status_code == 400: |
| 308 |
raise BadRequestError( |
| 309 |
headers=dict(_response.headers), |
| 310 |
body=typing.cast( |
| 311 |
typing.Any, |
| 312 |
parse_obj_as( |
| 313 |
type_=typing.Any, |
| 314 |
object_=_response.json(), |
| 315 |
), |
| 316 |
), |
| 317 |
) |
| 318 |
if _response.status_code == 401: |
| 319 |
raise UnauthorizedError( |
| 320 |
headers=dict(_response.headers), |
| 321 |
body=typing.cast( |
| 322 |
typing.Any, |
| 323 |
parse_obj_as( |
| 324 |
type_=typing.Any, |
| 325 |
object_=_response.json(), |
| 326 |
), |
| 327 |
), |
| 328 |
) |
| 329 |
if _response.status_code == 403: |
| 330 |
raise ForbiddenError( |
| 331 |
headers=dict(_response.headers), |
| 332 |
body=typing.cast( |
| 333 |
typing.Any, |
| 334 |
parse_obj_as( |
| 335 |
type_=typing.Any, |
| 336 |
object_=_response.json(), |
| 337 |
), |
| 338 |
), |
| 339 |
) |
| 340 |
if _response.status_code == 429: |
| 341 |
raise TooManyRequestsError( |
| 342 |
headers=dict(_response.headers), |
| 343 |
body=typing.cast( |
| 344 |
typing.Any, |
| 345 |
parse_obj_as( |
| 346 |
type_=typing.Any, |
| 347 |
object_=_response.json(), |
| 348 |
), |
| 349 |
), |
| 350 |
) |
| 351 |
_response_json = _response.json() |
| 352 |
except JSONDecodeError: |
| 353 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 354 |
except ValidationError as e: |
| 355 |
raise ParsingError( |
| 356 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 357 |
) |
| 358 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 359 |
|
| 360 |
|
| 361 |
class AsyncRawMembersClient: |
| 362 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 363 |
self._client_wrapper = client_wrapper |
| 364 |
|
| 365 |
async def list( |
| 366 |
self, |
| 367 |
id: str, |
| 368 |
*, |
| 369 |
from_: typing.Optional[str] = None, |
| 370 |
take: typing.Optional[int] = 50, |
| 371 |
fields: typing.Optional[str] = None, |
| 372 |
include_fields: typing.Optional[bool] = None, |
| 373 |
request_options: typing.Optional[RequestOptions] = None, |
| 374 |
) -> AsyncPager[OrganizationMember, ListOrganizationMembersPaginatedResponseContent]: |
| 375 |
""" |
| 376 |
List organization members. |
| 377 |
This endpoint is subject to eventual consistency. New users may not be immediately included in the response and deleted users may not be immediately removed from it. |
| 378 |
|
| 379 |
- Use the `fields` parameter to optionally define the specific member details retrieved. If `fields` is left blank, all fields (except roles) are returned. |
| 380 |
- Member roles are not sent by default. Use `fields=roles` to retrieve the roles assigned to each listed member. To use this parameter, you must include the `read:organization_member_roles` scope in the token. |
| 381 |
|
| 382 |
This endpoint supports two types of pagination: |
| 383 |
|
| 384 |
- Offset pagination |
| 385 |
- Checkpoint pagination |
| 386 |
|
| 387 |
Checkpoint pagination must be used if you need to retrieve more than 1000 organization members. |
| 388 |
|
| 389 |
**Checkpoint Pagination** |
| 390 |
|
| 391 |
To search by checkpoint, use the following parameters: - from: Optional id from which to start selection. - take: The total amount of entries to retrieve when using the from parameter. Defaults to 50. Note: The first time you call this endpoint using Checkpoint Pagination, you should omit the `from` parameter. If there are more results, a `next` value will be included in the response. You can use this for subsequent API calls. When `next` is no longer included in the response, this indicates there are no more pages remaining. |
| 392 |
|
| 393 |
Parameters |
| 394 |
---------- |
| 395 |
id : str |
| 396 |
Organization identifier. |
| 397 |
|
| 398 |
from_ : typing.Optional[str] |
| 399 |
Optional Id from which to start selection. |
| 400 |
|
| 401 |
take : typing.Optional[int] |
| 402 |
Number of results per page. Defaults to 50. |
| 403 |
|
| 404 |
fields : typing.Optional[str] |
| 405 |
Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields. |
| 406 |
|
| 407 |
include_fields : typing.Optional[bool] |
| 408 |
Whether specified fields are to be included (true) or excluded (false). |
| 409 |
|
| 410 |
request_options : typing.Optional[RequestOptions] |
| 411 |
Request-specific configuration. |
| 412 |
|
| 413 |
Returns |
| 414 |
------- |
| 415 |
AsyncPager[OrganizationMember, ListOrganizationMembersPaginatedResponseContent] |
| 416 |
Members successfully retrieved. |
| 417 |
""" |
| 418 |
_response = await self._client_wrapper.httpx_client.request( |
| 419 |
f"organizations/{encode_path_param(id)}/members", |
| 420 |
method="GET", |
| 421 |
params={ |
| 422 |
"from": from_, |
| 423 |
"take": take, |
| 424 |
"fields": fields, |
| 425 |
"include_fields": include_fields, |
| 426 |
}, |
| 427 |
request_options=request_options, |
| 428 |
) |
| 429 |
try: |
| 430 |
if 200 <= _response.status_code < 300: |
| 431 |
_parsed_response = typing.cast( |
| 432 |
ListOrganizationMembersPaginatedResponseContent, |
| 433 |
parse_obj_as( |
| 434 |
type_=ListOrganizationMembersPaginatedResponseContent, |
| 435 |
object_=_response.json(), |
| 436 |
), |
| 437 |
) |
| 438 |
_items = _parsed_response.members |
| 439 |
_parsed_next = _parsed_response.next |
| 440 |
_has_next = _parsed_next is not None and _parsed_next != "" |
| 441 |
|
| 442 |
async def _get_next(): |
| 443 |
return await self.list( |
| 444 |
id, |
| 445 |
from_=_parsed_next, |
| 446 |
take=take, |
| 447 |
fields=fields, |
| 448 |
include_fields=include_fields, |
| 449 |
request_options=request_options, |
| 450 |
) |
| 451 |
|
| 452 |
return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) |
| 453 |
if _response.status_code == 400: |
| 454 |
raise BadRequestError( |
| 455 |
headers=dict(_response.headers), |
| 456 |
body=typing.cast( |
| 457 |
typing.Any, |
| 458 |
parse_obj_as( |
| 459 |
type_=typing.Any, |
| 460 |
object_=_response.json(), |
| 461 |
), |
| 462 |
), |
| 463 |
) |
| 464 |
if _response.status_code == 401: |
| 465 |
raise UnauthorizedError( |
| 466 |
headers=dict(_response.headers), |
| 467 |
body=typing.cast( |
| 468 |
typing.Any, |
| 469 |
parse_obj_as( |
| 470 |
type_=typing.Any, |
| 471 |
object_=_response.json(), |
| 472 |
), |
| 473 |
), |
| 474 |
) |
| 475 |
if _response.status_code == 403: |
| 476 |
raise ForbiddenError( |
| 477 |
headers=dict(_response.headers), |
| 478 |
body=typing.cast( |
| 479 |
typing.Any, |
| 480 |
parse_obj_as( |
| 481 |
type_=typing.Any, |
| 482 |
object_=_response.json(), |
| 483 |
), |
| 484 |
), |
| 485 |
) |
| 486 |
if _response.status_code == 404: |
| 487 |
raise NotFoundError( |
| 488 |
headers=dict(_response.headers), |
| 489 |
body=typing.cast( |
| 490 |
typing.Any, |
| 491 |
parse_obj_as( |
| 492 |
type_=typing.Any, |
| 493 |
object_=_response.json(), |
| 494 |
), |
| 495 |
), |
| 496 |
) |
| 497 |
if _response.status_code == 429: |
| 498 |
raise TooManyRequestsError( |
| 499 |
headers=dict(_response.headers), |
| 500 |
body=typing.cast( |
| 501 |
typing.Any, |
| 502 |
parse_obj_as( |
| 503 |
type_=typing.Any, |
| 504 |
object_=_response.json(), |
| 505 |
), |
| 506 |
), |
| 507 |
) |
| 508 |
_response_json = _response.json() |
| 509 |
except JSONDecodeError: |
| 510 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 511 |
except ValidationError as e: |
| 512 |
raise ParsingError( |
| 513 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 514 |
) |
| 515 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 516 |
|
| 517 |
async def create( |
| 518 |
self, id: str, *, members: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None |
| 519 |
) -> AsyncHttpResponse[None]: |
| 520 |
""" |
| 521 |
Set one or more existing users as members of a specific [Organization](https://auth0.com/docs/manage-users/organizations). |
| 522 |
|
| 523 |
To add a user to an Organization through this action, the user must already exist in your tenant. If a user does not yet exist, you can [invite them to create an account](https://auth0.com/docs/manage-users/organizations/configure-organizations/invite-members), manually create them through the Auth0 Dashboard, or use the Management API. |
| 524 |
|
| 525 |
Parameters |
| 526 |
---------- |
| 527 |
id : str |
| 528 |
Organization identifier. |
| 529 |
|
| 530 |
members : typing.Sequence[str] |
| 531 |
List of user IDs to add to the organization as members. |
| 532 |
|
| 533 |
request_options : typing.Optional[RequestOptions] |
| 534 |
Request-specific configuration. |
| 535 |
|
| 536 |
Returns |
| 537 |
------- |
| 538 |
AsyncHttpResponse[None] |
| 539 |
""" |
| 540 |
_response = await self._client_wrapper.httpx_client.request( |
| 541 |
f"organizations/{encode_path_param(id)}/members", |
| 542 |
method="POST", |
| 543 |
json={ |
| 544 |
"members": members, |
| 545 |
}, |
| 546 |
headers={ |
| 547 |
"content-type": "application/json", |
| 548 |
}, |
| 549 |
request_options=request_options, |
| 550 |
omit=OMIT, |
| 551 |
) |
| 552 |
try: |
| 553 |
if 200 <= _response.status_code < 300: |
| 554 |
return AsyncHttpResponse(response=_response, data=None) |
| 555 |
if _response.status_code == 400: |
| 556 |
raise BadRequestError( |
| 557 |
headers=dict(_response.headers), |
| 558 |
body=typing.cast( |
| 559 |
typing.Any, |
| 560 |
parse_obj_as( |
| 561 |
type_=typing.Any, |
| 562 |
object_=_response.json(), |
| 563 |
), |
| 564 |
), |
| 565 |
) |
| 566 |
if _response.status_code == 401: |
| 567 |
raise UnauthorizedError( |
| 568 |
headers=dict(_response.headers), |
| 569 |
body=typing.cast( |
| 570 |
typing.Any, |
| 571 |
parse_obj_as( |
| 572 |
type_=typing.Any, |
| 573 |
object_=_response.json(), |
| 574 |
), |
| 575 |
), |
| 576 |
) |
| 577 |
if _response.status_code == 403: |
| 578 |
raise ForbiddenError( |
| 579 |
headers=dict(_response.headers), |
| 580 |
body=typing.cast( |
| 581 |
typing.Any, |
| 582 |
parse_obj_as( |
| 583 |
type_=typing.Any, |
| 584 |
object_=_response.json(), |
| 585 |
), |
| 586 |
), |
| 587 |
) |
| 588 |
if _response.status_code == 429: |
| 589 |
raise TooManyRequestsError( |
| 590 |
headers=dict(_response.headers), |
| 591 |
body=typing.cast( |
| 592 |
typing.Any, |
| 593 |
parse_obj_as( |
| 594 |
type_=typing.Any, |
| 595 |
object_=_response.json(), |
| 596 |
), |
| 597 |
), |
| 598 |
) |
| 599 |
_response_json = _response.json() |
| 600 |
except JSONDecodeError: |
| 601 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 602 |
except ValidationError as e: |
| 603 |
raise ParsingError( |
| 604 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 605 |
) |
| 606 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 607 |
|
| 608 |
async def delete( |
| 609 |
self, id: str, *, members: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None |
| 610 |
) -> AsyncHttpResponse[None]: |
| 611 |
""" |
| 612 |
Parameters |
| 613 |
---------- |
| 614 |
id : str |
| 615 |
Organization identifier. |
| 616 |
|
| 617 |
members : typing.Sequence[str] |
| 618 |
List of user IDs to remove from the organization. |
| 619 |
|
| 620 |
request_options : typing.Optional[RequestOptions] |
| 621 |
Request-specific configuration. |
| 622 |
|
| 623 |
Returns |
| 624 |
------- |
| 625 |
AsyncHttpResponse[None] |
| 626 |
""" |
| 627 |
_response = await self._client_wrapper.httpx_client.request( |
| 628 |
f"organizations/{encode_path_param(id)}/members", |
| 629 |
method="DELETE", |
| 630 |
json={ |
| 631 |
"members": members, |
| 632 |
}, |
| 633 |
headers={ |
| 634 |
"content-type": "application/json", |
| 635 |
}, |
| 636 |
request_options=request_options, |
| 637 |
omit=OMIT, |
| 638 |
) |
| 639 |
try: |
| 640 |
if 200 <= _response.status_code < 300: |
| 641 |
return AsyncHttpResponse(response=_response, data=None) |
| 642 |
if _response.status_code == 400: |
| 643 |
raise BadRequestError( |
| 644 |
headers=dict(_response.headers), |
| 645 |
body=typing.cast( |
| 646 |
typing.Any, |
| 647 |
parse_obj_as( |
| 648 |
type_=typing.Any, |
| 649 |
object_=_response.json(), |
| 650 |
), |
| 651 |
), |
| 652 |
) |
| 653 |
if _response.status_code == 401: |
| 654 |
raise UnauthorizedError( |
| 655 |
headers=dict(_response.headers), |
| 656 |
body=typing.cast( |
| 657 |
typing.Any, |
| 658 |
parse_obj_as( |
| 659 |
type_=typing.Any, |
| 660 |
object_=_response.json(), |
| 661 |
), |
| 662 |
), |
| 663 |
) |
| 664 |
if _response.status_code == 403: |
| 665 |
raise ForbiddenError( |
| 666 |
headers=dict(_response.headers), |
| 667 |
body=typing.cast( |
| 668 |
typing.Any, |
| 669 |
parse_obj_as( |
| 670 |
type_=typing.Any, |
| 671 |
object_=_response.json(), |
| 672 |
), |
| 673 |
), |
| 674 |
) |
| 675 |
if _response.status_code == 429: |
| 676 |
raise TooManyRequestsError( |
| 677 |
headers=dict(_response.headers), |
| 678 |
body=typing.cast( |
| 679 |
typing.Any, |
| 680 |
parse_obj_as( |
| 681 |
type_=typing.Any, |
| 682 |
object_=_response.json(), |
| 683 |
), |
| 684 |
), |
| 685 |
) |
| 686 |
_response_json = _response.json() |
| 687 |
except JSONDecodeError: |
| 688 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 689 |
except ValidationError as e: |
| 690 |
raise ParsingError( |
| 691 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 692 |
) |
| 693 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |