| 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.conflict_error import ConflictError |
| 16 |
from ....errors.forbidden_error import ForbiddenError |
| 17 |
from ....errors.not_found_error import NotFoundError |
| 18 |
from ....errors.too_many_requests_error import TooManyRequestsError |
| 19 |
from ....errors.unauthorized_error import UnauthorizedError |
| 20 |
from ....types.list_organization_member_roles_offset_paginated_response_content import ( |
| 21 |
ListOrganizationMemberRolesOffsetPaginatedResponseContent, |
| 22 |
) |
| 23 |
from ....types.role import Role |
| 24 |
from pydantic import ValidationError |
| 25 |
|
| 26 |
|
| 27 |
OMIT = typing.cast(typing.Any, ...) |
| 28 |
|
| 29 |
|
| 30 |
class RawRolesClient: |
| 31 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 32 |
self._client_wrapper = client_wrapper |
| 33 |
|
| 34 |
def list( |
| 35 |
self, |
| 36 |
id: str, |
| 37 |
user_id: str, |
| 38 |
*, |
| 39 |
page: typing.Optional[int] = 0, |
| 40 |
per_page: typing.Optional[int] = 50, |
| 41 |
include_totals: typing.Optional[bool] = True, |
| 42 |
request_options: typing.Optional[RequestOptions] = None, |
| 43 |
) -> SyncPager[Role, ListOrganizationMemberRolesOffsetPaginatedResponseContent]: |
| 44 |
""" |
| 45 |
Retrieve detailed list of roles assigned to a given user within the context of a specific Organization. |
| 46 |
|
| 47 |
Users can be members of multiple Organizations with unique roles assigned for each membership. This action only returns the roles associated with the specified Organization; any roles assigned to the user within other Organizations are not included. |
| 48 |
|
| 49 |
Parameters |
| 50 |
---------- |
| 51 |
id : str |
| 52 |
Organization identifier. |
| 53 |
|
| 54 |
user_id : str |
| 55 |
ID of the user to associate roles with. |
| 56 |
|
| 57 |
page : typing.Optional[int] |
| 58 |
Page index of the results to return. First page is 0. |
| 59 |
|
| 60 |
per_page : typing.Optional[int] |
| 61 |
Number of results per page. Defaults to 50. |
| 62 |
|
| 63 |
include_totals : typing.Optional[bool] |
| 64 |
Return results inside an object that contains the total result count (true) or as a direct array of results (false, default). |
| 65 |
|
| 66 |
request_options : typing.Optional[RequestOptions] |
| 67 |
Request-specific configuration. |
| 68 |
|
| 69 |
Returns |
| 70 |
------- |
| 71 |
SyncPager[Role, ListOrganizationMemberRolesOffsetPaginatedResponseContent] |
| 72 |
Roles successfully retrieved. |
| 73 |
""" |
| 74 |
page = page if page is not None else 0 |
| 75 |
|
| 76 |
_response = self._client_wrapper.httpx_client.request( |
| 77 |
f"organizations/{encode_path_param(id)}/members/{encode_path_param(user_id)}/roles", |
| 78 |
method="GET", |
| 79 |
params={ |
| 80 |
"page": page, |
| 81 |
"per_page": per_page, |
| 82 |
"include_totals": include_totals, |
| 83 |
}, |
| 84 |
request_options=request_options, |
| 85 |
) |
| 86 |
try: |
| 87 |
if 200 <= _response.status_code < 300: |
| 88 |
_parsed_response = typing.cast( |
| 89 |
ListOrganizationMemberRolesOffsetPaginatedResponseContent, |
| 90 |
parse_obj_as( |
| 91 |
type_=ListOrganizationMemberRolesOffsetPaginatedResponseContent, |
| 92 |
object_=_response.json(), |
| 93 |
), |
| 94 |
) |
| 95 |
_items = _parsed_response.roles |
| 96 |
_has_next = len(_items or []) > 0 |
| 97 |
_get_next = lambda: self.list( |
| 98 |
id, |
| 99 |
user_id, |
| 100 |
page=page + 1, |
| 101 |
per_page=per_page, |
| 102 |
include_totals=include_totals, |
| 103 |
request_options=request_options, |
| 104 |
) |
| 105 |
return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) |
| 106 |
if _response.status_code == 400: |
| 107 |
raise BadRequestError( |
| 108 |
headers=dict(_response.headers), |
| 109 |
body=typing.cast( |
| 110 |
typing.Any, |
| 111 |
parse_obj_as( |
| 112 |
type_=typing.Any, |
| 113 |
object_=_response.json(), |
| 114 |
), |
| 115 |
), |
| 116 |
) |
| 117 |
if _response.status_code == 401: |
| 118 |
raise UnauthorizedError( |
| 119 |
headers=dict(_response.headers), |
| 120 |
body=typing.cast( |
| 121 |
typing.Any, |
| 122 |
parse_obj_as( |
| 123 |
type_=typing.Any, |
| 124 |
object_=_response.json(), |
| 125 |
), |
| 126 |
), |
| 127 |
) |
| 128 |
if _response.status_code == 403: |
| 129 |
raise ForbiddenError( |
| 130 |
headers=dict(_response.headers), |
| 131 |
body=typing.cast( |
| 132 |
typing.Any, |
| 133 |
parse_obj_as( |
| 134 |
type_=typing.Any, |
| 135 |
object_=_response.json(), |
| 136 |
), |
| 137 |
), |
| 138 |
) |
| 139 |
if _response.status_code == 404: |
| 140 |
raise NotFoundError( |
| 141 |
headers=dict(_response.headers), |
| 142 |
body=typing.cast( |
| 143 |
typing.Any, |
| 144 |
parse_obj_as( |
| 145 |
type_=typing.Any, |
| 146 |
object_=_response.json(), |
| 147 |
), |
| 148 |
), |
| 149 |
) |
| 150 |
if _response.status_code == 429: |
| 151 |
raise TooManyRequestsError( |
| 152 |
headers=dict(_response.headers), |
| 153 |
body=typing.cast( |
| 154 |
typing.Any, |
| 155 |
parse_obj_as( |
| 156 |
type_=typing.Any, |
| 157 |
object_=_response.json(), |
| 158 |
), |
| 159 |
), |
| 160 |
) |
| 161 |
_response_json = _response.json() |
| 162 |
except JSONDecodeError: |
| 163 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 164 |
except ValidationError as e: |
| 165 |
raise ParsingError( |
| 166 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 167 |
) |
| 168 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 169 |
|
| 170 |
def assign( |
| 171 |
self, |
| 172 |
id: str, |
| 173 |
user_id: str, |
| 174 |
*, |
| 175 |
roles: typing.Sequence[str], |
| 176 |
request_options: typing.Optional[RequestOptions] = None, |
| 177 |
) -> HttpResponse[None]: |
| 178 |
""" |
| 179 |
Assign one or more [roles](https://auth0.com/docs/manage-users/access-control/rbac) to a user to determine their access for a specific Organization. |
| 180 |
|
| 181 |
Users can be members of multiple Organizations with unique roles assigned for each membership. This action assigns roles to a user only for the specified Organization. Roles cannot be assigned to a user across multiple Organizations in the same call. |
| 182 |
|
| 183 |
Parameters |
| 184 |
---------- |
| 185 |
id : str |
| 186 |
Organization identifier. |
| 187 |
|
| 188 |
user_id : str |
| 189 |
ID of the user to associate roles with. |
| 190 |
|
| 191 |
roles : typing.Sequence[str] |
| 192 |
List of roles IDs to associated with the user. |
| 193 |
|
| 194 |
request_options : typing.Optional[RequestOptions] |
| 195 |
Request-specific configuration. |
| 196 |
|
| 197 |
Returns |
| 198 |
------- |
| 199 |
HttpResponse[None] |
| 200 |
""" |
| 201 |
_response = self._client_wrapper.httpx_client.request( |
| 202 |
f"organizations/{encode_path_param(id)}/members/{encode_path_param(user_id)}/roles", |
| 203 |
method="POST", |
| 204 |
json={ |
| 205 |
"roles": roles, |
| 206 |
}, |
| 207 |
headers={ |
| 208 |
"content-type": "application/json", |
| 209 |
}, |
| 210 |
request_options=request_options, |
| 211 |
omit=OMIT, |
| 212 |
) |
| 213 |
try: |
| 214 |
if 200 <= _response.status_code < 300: |
| 215 |
return HttpResponse(response=_response, data=None) |
| 216 |
if _response.status_code == 400: |
| 217 |
raise BadRequestError( |
| 218 |
headers=dict(_response.headers), |
| 219 |
body=typing.cast( |
| 220 |
typing.Any, |
| 221 |
parse_obj_as( |
| 222 |
type_=typing.Any, |
| 223 |
object_=_response.json(), |
| 224 |
), |
| 225 |
), |
| 226 |
) |
| 227 |
if _response.status_code == 401: |
| 228 |
raise UnauthorizedError( |
| 229 |
headers=dict(_response.headers), |
| 230 |
body=typing.cast( |
| 231 |
typing.Any, |
| 232 |
parse_obj_as( |
| 233 |
type_=typing.Any, |
| 234 |
object_=_response.json(), |
| 235 |
), |
| 236 |
), |
| 237 |
) |
| 238 |
if _response.status_code == 403: |
| 239 |
raise ForbiddenError( |
| 240 |
headers=dict(_response.headers), |
| 241 |
body=typing.cast( |
| 242 |
typing.Any, |
| 243 |
parse_obj_as( |
| 244 |
type_=typing.Any, |
| 245 |
object_=_response.json(), |
| 246 |
), |
| 247 |
), |
| 248 |
) |
| 249 |
if _response.status_code == 409: |
| 250 |
raise ConflictError( |
| 251 |
headers=dict(_response.headers), |
| 252 |
body=typing.cast( |
| 253 |
typing.Any, |
| 254 |
parse_obj_as( |
| 255 |
type_=typing.Any, |
| 256 |
object_=_response.json(), |
| 257 |
), |
| 258 |
), |
| 259 |
) |
| 260 |
if _response.status_code == 429: |
| 261 |
raise TooManyRequestsError( |
| 262 |
headers=dict(_response.headers), |
| 263 |
body=typing.cast( |
| 264 |
typing.Any, |
| 265 |
parse_obj_as( |
| 266 |
type_=typing.Any, |
| 267 |
object_=_response.json(), |
| 268 |
), |
| 269 |
), |
| 270 |
) |
| 271 |
_response_json = _response.json() |
| 272 |
except JSONDecodeError: |
| 273 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 274 |
except ValidationError as e: |
| 275 |
raise ParsingError( |
| 276 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 277 |
) |
| 278 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 279 |
|
| 280 |
def delete( |
| 281 |
self, |
| 282 |
id: str, |
| 283 |
user_id: str, |
| 284 |
*, |
| 285 |
roles: typing.Sequence[str], |
| 286 |
request_options: typing.Optional[RequestOptions] = None, |
| 287 |
) -> HttpResponse[None]: |
| 288 |
""" |
| 289 |
Remove one or more Organization-specific [roles](https://auth0.com/docs/manage-users/access-control/rbac) from a given user. |
| 290 |
|
| 291 |
Users can be members of multiple Organizations with unique roles assigned for each membership. This action removes roles from a user in relation to the specified Organization. Roles assigned to the user within a different Organization cannot be managed in the same call. |
| 292 |
|
| 293 |
Parameters |
| 294 |
---------- |
| 295 |
id : str |
| 296 |
Organization identifier. |
| 297 |
|
| 298 |
user_id : str |
| 299 |
User ID of the organization member to remove roles from. |
| 300 |
|
| 301 |
roles : typing.Sequence[str] |
| 302 |
List of roles IDs associated with the organization member to remove. |
| 303 |
|
| 304 |
request_options : typing.Optional[RequestOptions] |
| 305 |
Request-specific configuration. |
| 306 |
|
| 307 |
Returns |
| 308 |
------- |
| 309 |
HttpResponse[None] |
| 310 |
""" |
| 311 |
_response = self._client_wrapper.httpx_client.request( |
| 312 |
f"organizations/{encode_path_param(id)}/members/{encode_path_param(user_id)}/roles", |
| 313 |
method="DELETE", |
| 314 |
json={ |
| 315 |
"roles": roles, |
| 316 |
}, |
| 317 |
headers={ |
| 318 |
"content-type": "application/json", |
| 319 |
}, |
| 320 |
request_options=request_options, |
| 321 |
omit=OMIT, |
| 322 |
) |
| 323 |
try: |
| 324 |
if 200 <= _response.status_code < 300: |
| 325 |
return HttpResponse(response=_response, data=None) |
| 326 |
if _response.status_code == 400: |
| 327 |
raise BadRequestError( |
| 328 |
headers=dict(_response.headers), |
| 329 |
body=typing.cast( |
| 330 |
typing.Any, |
| 331 |
parse_obj_as( |
| 332 |
type_=typing.Any, |
| 333 |
object_=_response.json(), |
| 334 |
), |
| 335 |
), |
| 336 |
) |
| 337 |
if _response.status_code == 401: |
| 338 |
raise UnauthorizedError( |
| 339 |
headers=dict(_response.headers), |
| 340 |
body=typing.cast( |
| 341 |
typing.Any, |
| 342 |
parse_obj_as( |
| 343 |
type_=typing.Any, |
| 344 |
object_=_response.json(), |
| 345 |
), |
| 346 |
), |
| 347 |
) |
| 348 |
if _response.status_code == 403: |
| 349 |
raise ForbiddenError( |
| 350 |
headers=dict(_response.headers), |
| 351 |
body=typing.cast( |
| 352 |
typing.Any, |
| 353 |
parse_obj_as( |
| 354 |
type_=typing.Any, |
| 355 |
object_=_response.json(), |
| 356 |
), |
| 357 |
), |
| 358 |
) |
| 359 |
if _response.status_code == 429: |
| 360 |
raise TooManyRequestsError( |
| 361 |
headers=dict(_response.headers), |
| 362 |
body=typing.cast( |
| 363 |
typing.Any, |
| 364 |
parse_obj_as( |
| 365 |
type_=typing.Any, |
| 366 |
object_=_response.json(), |
| 367 |
), |
| 368 |
), |
| 369 |
) |
| 370 |
_response_json = _response.json() |
| 371 |
except JSONDecodeError: |
| 372 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 373 |
except ValidationError as e: |
| 374 |
raise ParsingError( |
| 375 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 376 |
) |
| 377 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 378 |
|
| 379 |
|
| 380 |
class AsyncRawRolesClient: |
| 381 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 382 |
self._client_wrapper = client_wrapper |
| 383 |
|
| 384 |
async def list( |
| 385 |
self, |
| 386 |
id: str, |
| 387 |
user_id: str, |
| 388 |
*, |
| 389 |
page: typing.Optional[int] = 0, |
| 390 |
per_page: typing.Optional[int] = 50, |
| 391 |
include_totals: typing.Optional[bool] = True, |
| 392 |
request_options: typing.Optional[RequestOptions] = None, |
| 393 |
) -> AsyncPager[Role, ListOrganizationMemberRolesOffsetPaginatedResponseContent]: |
| 394 |
""" |
| 395 |
Retrieve detailed list of roles assigned to a given user within the context of a specific Organization. |
| 396 |
|
| 397 |
Users can be members of multiple Organizations with unique roles assigned for each membership. This action only returns the roles associated with the specified Organization; any roles assigned to the user within other Organizations are not included. |
| 398 |
|
| 399 |
Parameters |
| 400 |
---------- |
| 401 |
id : str |
| 402 |
Organization identifier. |
| 403 |
|
| 404 |
user_id : str |
| 405 |
ID of the user to associate roles with. |
| 406 |
|
| 407 |
page : typing.Optional[int] |
| 408 |
Page index of the results to return. First page is 0. |
| 409 |
|
| 410 |
per_page : typing.Optional[int] |
| 411 |
Number of results per page. Defaults to 50. |
| 412 |
|
| 413 |
include_totals : typing.Optional[bool] |
| 414 |
Return results inside an object that contains the total result count (true) or as a direct array of results (false, default). |
| 415 |
|
| 416 |
request_options : typing.Optional[RequestOptions] |
| 417 |
Request-specific configuration. |
| 418 |
|
| 419 |
Returns |
| 420 |
------- |
| 421 |
AsyncPager[Role, ListOrganizationMemberRolesOffsetPaginatedResponseContent] |
| 422 |
Roles successfully retrieved. |
| 423 |
""" |
| 424 |
page = page if page is not None else 0 |
| 425 |
|
| 426 |
_response = await self._client_wrapper.httpx_client.request( |
| 427 |
f"organizations/{encode_path_param(id)}/members/{encode_path_param(user_id)}/roles", |
| 428 |
method="GET", |
| 429 |
params={ |
| 430 |
"page": page, |
| 431 |
"per_page": per_page, |
| 432 |
"include_totals": include_totals, |
| 433 |
}, |
| 434 |
request_options=request_options, |
| 435 |
) |
| 436 |
try: |
| 437 |
if 200 <= _response.status_code < 300: |
| 438 |
_parsed_response = typing.cast( |
| 439 |
ListOrganizationMemberRolesOffsetPaginatedResponseContent, |
| 440 |
parse_obj_as( |
| 441 |
type_=ListOrganizationMemberRolesOffsetPaginatedResponseContent, |
| 442 |
object_=_response.json(), |
| 443 |
), |
| 444 |
) |
| 445 |
_items = _parsed_response.roles |
| 446 |
_has_next = len(_items or []) > 0 |
| 447 |
|
| 448 |
async def _get_next(): |
| 449 |
return await self.list( |
| 450 |
id, |
| 451 |
user_id, |
| 452 |
page=page + 1, |
| 453 |
per_page=per_page, |
| 454 |
include_totals=include_totals, |
| 455 |
request_options=request_options, |
| 456 |
) |
| 457 |
|
| 458 |
return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) |
| 459 |
if _response.status_code == 400: |
| 460 |
raise BadRequestError( |
| 461 |
headers=dict(_response.headers), |
| 462 |
body=typing.cast( |
| 463 |
typing.Any, |
| 464 |
parse_obj_as( |
| 465 |
type_=typing.Any, |
| 466 |
object_=_response.json(), |
| 467 |
), |
| 468 |
), |
| 469 |
) |
| 470 |
if _response.status_code == 401: |
| 471 |
raise UnauthorizedError( |
| 472 |
headers=dict(_response.headers), |
| 473 |
body=typing.cast( |
| 474 |
typing.Any, |
| 475 |
parse_obj_as( |
| 476 |
type_=typing.Any, |
| 477 |
object_=_response.json(), |
| 478 |
), |
| 479 |
), |
| 480 |
) |
| 481 |
if _response.status_code == 403: |
| 482 |
raise ForbiddenError( |
| 483 |
headers=dict(_response.headers), |
| 484 |
body=typing.cast( |
| 485 |
typing.Any, |
| 486 |
parse_obj_as( |
| 487 |
type_=typing.Any, |
| 488 |
object_=_response.json(), |
| 489 |
), |
| 490 |
), |
| 491 |
) |
| 492 |
if _response.status_code == 404: |
| 493 |
raise NotFoundError( |
| 494 |
headers=dict(_response.headers), |
| 495 |
body=typing.cast( |
| 496 |
typing.Any, |
| 497 |
parse_obj_as( |
| 498 |
type_=typing.Any, |
| 499 |
object_=_response.json(), |
| 500 |
), |
| 501 |
), |
| 502 |
) |
| 503 |
if _response.status_code == 429: |
| 504 |
raise TooManyRequestsError( |
| 505 |
headers=dict(_response.headers), |
| 506 |
body=typing.cast( |
| 507 |
typing.Any, |
| 508 |
parse_obj_as( |
| 509 |
type_=typing.Any, |
| 510 |
object_=_response.json(), |
| 511 |
), |
| 512 |
), |
| 513 |
) |
| 514 |
_response_json = _response.json() |
| 515 |
except JSONDecodeError: |
| 516 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 517 |
except ValidationError as e: |
| 518 |
raise ParsingError( |
| 519 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 520 |
) |
| 521 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 522 |
|
| 523 |
async def assign( |
| 524 |
self, |
| 525 |
id: str, |
| 526 |
user_id: str, |
| 527 |
*, |
| 528 |
roles: typing.Sequence[str], |
| 529 |
request_options: typing.Optional[RequestOptions] = None, |
| 530 |
) -> AsyncHttpResponse[None]: |
| 531 |
""" |
| 532 |
Assign one or more [roles](https://auth0.com/docs/manage-users/access-control/rbac) to a user to determine their access for a specific Organization. |
| 533 |
|
| 534 |
Users can be members of multiple Organizations with unique roles assigned for each membership. This action assigns roles to a user only for the specified Organization. Roles cannot be assigned to a user across multiple Organizations in the same call. |
| 535 |
|
| 536 |
Parameters |
| 537 |
---------- |
| 538 |
id : str |
| 539 |
Organization identifier. |
| 540 |
|
| 541 |
user_id : str |
| 542 |
ID of the user to associate roles with. |
| 543 |
|
| 544 |
roles : typing.Sequence[str] |
| 545 |
List of roles IDs to associated with the user. |
| 546 |
|
| 547 |
request_options : typing.Optional[RequestOptions] |
| 548 |
Request-specific configuration. |
| 549 |
|
| 550 |
Returns |
| 551 |
------- |
| 552 |
AsyncHttpResponse[None] |
| 553 |
""" |
| 554 |
_response = await self._client_wrapper.httpx_client.request( |
| 555 |
f"organizations/{encode_path_param(id)}/members/{encode_path_param(user_id)}/roles", |
| 556 |
method="POST", |
| 557 |
json={ |
| 558 |
"roles": roles, |
| 559 |
}, |
| 560 |
headers={ |
| 561 |
"content-type": "application/json", |
| 562 |
}, |
| 563 |
request_options=request_options, |
| 564 |
omit=OMIT, |
| 565 |
) |
| 566 |
try: |
| 567 |
if 200 <= _response.status_code < 300: |
| 568 |
return AsyncHttpResponse(response=_response, data=None) |
| 569 |
if _response.status_code == 400: |
| 570 |
raise BadRequestError( |
| 571 |
headers=dict(_response.headers), |
| 572 |
body=typing.cast( |
| 573 |
typing.Any, |
| 574 |
parse_obj_as( |
| 575 |
type_=typing.Any, |
| 576 |
object_=_response.json(), |
| 577 |
), |
| 578 |
), |
| 579 |
) |
| 580 |
if _response.status_code == 401: |
| 581 |
raise UnauthorizedError( |
| 582 |
headers=dict(_response.headers), |
| 583 |
body=typing.cast( |
| 584 |
typing.Any, |
| 585 |
parse_obj_as( |
| 586 |
type_=typing.Any, |
| 587 |
object_=_response.json(), |
| 588 |
), |
| 589 |
), |
| 590 |
) |
| 591 |
if _response.status_code == 403: |
| 592 |
raise ForbiddenError( |
| 593 |
headers=dict(_response.headers), |
| 594 |
body=typing.cast( |
| 595 |
typing.Any, |
| 596 |
parse_obj_as( |
| 597 |
type_=typing.Any, |
| 598 |
object_=_response.json(), |
| 599 |
), |
| 600 |
), |
| 601 |
) |
| 602 |
if _response.status_code == 409: |
| 603 |
raise ConflictError( |
| 604 |
headers=dict(_response.headers), |
| 605 |
body=typing.cast( |
| 606 |
typing.Any, |
| 607 |
parse_obj_as( |
| 608 |
type_=typing.Any, |
| 609 |
object_=_response.json(), |
| 610 |
), |
| 611 |
), |
| 612 |
) |
| 613 |
if _response.status_code == 429: |
| 614 |
raise TooManyRequestsError( |
| 615 |
headers=dict(_response.headers), |
| 616 |
body=typing.cast( |
| 617 |
typing.Any, |
| 618 |
parse_obj_as( |
| 619 |
type_=typing.Any, |
| 620 |
object_=_response.json(), |
| 621 |
), |
| 622 |
), |
| 623 |
) |
| 624 |
_response_json = _response.json() |
| 625 |
except JSONDecodeError: |
| 626 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 627 |
except ValidationError as e: |
| 628 |
raise ParsingError( |
| 629 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 630 |
) |
| 631 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 632 |
|
| 633 |
async def delete( |
| 634 |
self, |
| 635 |
id: str, |
| 636 |
user_id: str, |
| 637 |
*, |
| 638 |
roles: typing.Sequence[str], |
| 639 |
request_options: typing.Optional[RequestOptions] = None, |
| 640 |
) -> AsyncHttpResponse[None]: |
| 641 |
""" |
| 642 |
Remove one or more Organization-specific [roles](https://auth0.com/docs/manage-users/access-control/rbac) from a given user. |
| 643 |
|
| 644 |
Users can be members of multiple Organizations with unique roles assigned for each membership. This action removes roles from a user in relation to the specified Organization. Roles assigned to the user within a different Organization cannot be managed in the same call. |
| 645 |
|
| 646 |
Parameters |
| 647 |
---------- |
| 648 |
id : str |
| 649 |
Organization identifier. |
| 650 |
|
| 651 |
user_id : str |
| 652 |
User ID of the organization member to remove roles from. |
| 653 |
|
| 654 |
roles : typing.Sequence[str] |
| 655 |
List of roles IDs associated with the organization member to remove. |
| 656 |
|
| 657 |
request_options : typing.Optional[RequestOptions] |
| 658 |
Request-specific configuration. |
| 659 |
|
| 660 |
Returns |
| 661 |
------- |
| 662 |
AsyncHttpResponse[None] |
| 663 |
""" |
| 664 |
_response = await self._client_wrapper.httpx_client.request( |
| 665 |
f"organizations/{encode_path_param(id)}/members/{encode_path_param(user_id)}/roles", |
| 666 |
method="DELETE", |
| 667 |
json={ |
| 668 |
"roles": roles, |
| 669 |
}, |
| 670 |
headers={ |
| 671 |
"content-type": "application/json", |
| 672 |
}, |
| 673 |
request_options=request_options, |
| 674 |
omit=OMIT, |
| 675 |
) |
| 676 |
try: |
| 677 |
if 200 <= _response.status_code < 300: |
| 678 |
return AsyncHttpResponse(response=_response, data=None) |
| 679 |
if _response.status_code == 400: |
| 680 |
raise BadRequestError( |
| 681 |
headers=dict(_response.headers), |
| 682 |
body=typing.cast( |
| 683 |
typing.Any, |
| 684 |
parse_obj_as( |
| 685 |
type_=typing.Any, |
| 686 |
object_=_response.json(), |
| 687 |
), |
| 688 |
), |
| 689 |
) |
| 690 |
if _response.status_code == 401: |
| 691 |
raise UnauthorizedError( |
| 692 |
headers=dict(_response.headers), |
| 693 |
body=typing.cast( |
| 694 |
typing.Any, |
| 695 |
parse_obj_as( |
| 696 |
type_=typing.Any, |
| 697 |
object_=_response.json(), |
| 698 |
), |
| 699 |
), |
| 700 |
) |
| 701 |
if _response.status_code == 403: |
| 702 |
raise ForbiddenError( |
| 703 |
headers=dict(_response.headers), |
| 704 |
body=typing.cast( |
| 705 |
typing.Any, |
| 706 |
parse_obj_as( |
| 707 |
type_=typing.Any, |
| 708 |
object_=_response.json(), |
| 709 |
), |
| 710 |
), |
| 711 |
) |
| 712 |
if _response.status_code == 429: |
| 713 |
raise TooManyRequestsError( |
| 714 |
headers=dict(_response.headers), |
| 715 |
body=typing.cast( |
| 716 |
typing.Any, |
| 717 |
parse_obj_as( |
| 718 |
type_=typing.Any, |
| 719 |
object_=_response.json(), |
| 720 |
), |
| 721 |
), |
| 722 |
) |
| 723 |
_response_json = _response.json() |
| 724 |
except JSONDecodeError: |
| 725 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 726 |
except ValidationError as e: |
| 727 |
raise ParsingError( |
| 728 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 729 |
) |
| 730 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |