| 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.client_grant_allow_any_organization_enum import ClientGrantAllowAnyOrganizationEnum |
| 21 |
from ..types.client_grant_default_for_enum import ClientGrantDefaultForEnum |
| 22 |
from ..types.client_grant_organization_nullable_usage_enum import ClientGrantOrganizationNullableUsageEnum |
| 23 |
from ..types.client_grant_organization_usage_enum import ClientGrantOrganizationUsageEnum |
| 24 |
from ..types.client_grant_response_content import ClientGrantResponseContent |
| 25 |
from ..types.client_grant_subject_type_enum import ClientGrantSubjectTypeEnum |
| 26 |
from ..types.create_client_grant_response_content import CreateClientGrantResponseContent |
| 27 |
from ..types.get_client_grant_response_content import GetClientGrantResponseContent |
| 28 |
from ..types.list_client_grant_paginated_response_content import ListClientGrantPaginatedResponseContent |
| 29 |
from ..types.update_client_grant_response_content import UpdateClientGrantResponseContent |
| 30 |
from pydantic import ValidationError |
| 31 |
|
| 32 |
|
| 33 |
OMIT = typing.cast(typing.Any, ...) |
| 34 |
|
| 35 |
|
| 36 |
class RawClientGrantsClient: |
| 37 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 38 |
self._client_wrapper = client_wrapper |
| 39 |
|
| 40 |
def list( |
| 41 |
self, |
| 42 |
*, |
| 43 |
from_: typing.Optional[str] = None, |
| 44 |
take: typing.Optional[int] = 50, |
| 45 |
audience: typing.Optional[str] = None, |
| 46 |
client_id: typing.Optional[str] = None, |
| 47 |
allow_any_organization: typing.Optional[ClientGrantAllowAnyOrganizationEnum] = None, |
| 48 |
subject_type: typing.Optional[ClientGrantSubjectTypeEnum] = None, |
| 49 |
default_for: typing.Optional[ClientGrantDefaultForEnum] = None, |
| 50 |
request_options: typing.Optional[RequestOptions] = None, |
| 51 |
) -> SyncPager[ClientGrantResponseContent, ListClientGrantPaginatedResponseContent]: |
| 52 |
""" |
| 53 |
Retrieve a list of [client grants](https://auth0.com/docs/get-started/applications/application-access-to-apis-client-grants), including the scopes associated with the application/API pair. |
| 54 |
|
| 55 |
Parameters |
| 56 |
---------- |
| 57 |
from_ : typing.Optional[str] |
| 58 |
Optional Id from which to start selection. |
| 59 |
|
| 60 |
take : typing.Optional[int] |
| 61 |
Number of results per page. Defaults to 50. |
| 62 |
|
| 63 |
audience : typing.Optional[str] |
| 64 |
Optional filter on audience. |
| 65 |
|
| 66 |
client_id : typing.Optional[str] |
| 67 |
Optional filter on client_id. |
| 68 |
|
| 69 |
allow_any_organization : typing.Optional[ClientGrantAllowAnyOrganizationEnum] |
| 70 |
Optional filter on allow_any_organization. |
| 71 |
|
| 72 |
subject_type : typing.Optional[ClientGrantSubjectTypeEnum] |
| 73 |
The type of application access the client grant allows. |
| 74 |
|
| 75 |
default_for : typing.Optional[ClientGrantDefaultForEnum] |
| 76 |
Applies this client grant as the default for all clients in the specified group. The only accepted value is <a href="https://auth0.com/docs/get-started/applications/application-access-to-apis-client-grants#default-permissions-for-third-party-applications">`third_party_clients`</a>, which applies the grant to all third-party clients. Per-client grants for the same audience take precedence. Mutually exclusive with `client_id`. |
| 77 |
|
| 78 |
request_options : typing.Optional[RequestOptions] |
| 79 |
Request-specific configuration. |
| 80 |
|
| 81 |
Returns |
| 82 |
------- |
| 83 |
SyncPager[ClientGrantResponseContent, ListClientGrantPaginatedResponseContent] |
| 84 |
Client grants successfully retrieved. |
| 85 |
""" |
| 86 |
_response = self._client_wrapper.httpx_client.request( |
| 87 |
"client-grants", |
| 88 |
method="GET", |
| 89 |
params={ |
| 90 |
"from": from_, |
| 91 |
"take": take, |
| 92 |
"audience": audience, |
| 93 |
"client_id": client_id, |
| 94 |
"allow_any_organization": allow_any_organization, |
| 95 |
"subject_type": subject_type, |
| 96 |
"default_for": default_for, |
| 97 |
}, |
| 98 |
request_options=request_options, |
| 99 |
) |
| 100 |
try: |
| 101 |
if 200 <= _response.status_code < 300: |
| 102 |
_parsed_response = typing.cast( |
| 103 |
ListClientGrantPaginatedResponseContent, |
| 104 |
parse_obj_as( |
| 105 |
type_=ListClientGrantPaginatedResponseContent, |
| 106 |
object_=_response.json(), |
| 107 |
), |
| 108 |
) |
| 109 |
_items = _parsed_response.client_grants |
| 110 |
_parsed_next = _parsed_response.next |
| 111 |
_has_next = _parsed_next is not None and _parsed_next != "" |
| 112 |
_get_next = lambda: self.list( |
| 113 |
from_=_parsed_next, |
| 114 |
take=take, |
| 115 |
audience=audience, |
| 116 |
client_id=client_id, |
| 117 |
allow_any_organization=allow_any_organization, |
| 118 |
subject_type=subject_type, |
| 119 |
default_for=default_for, |
| 120 |
request_options=request_options, |
| 121 |
) |
| 122 |
return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) |
| 123 |
if _response.status_code == 401: |
| 124 |
raise UnauthorizedError( |
| 125 |
headers=dict(_response.headers), |
| 126 |
body=typing.cast( |
| 127 |
typing.Any, |
| 128 |
parse_obj_as( |
| 129 |
type_=typing.Any, |
| 130 |
object_=_response.json(), |
| 131 |
), |
| 132 |
), |
| 133 |
) |
| 134 |
if _response.status_code == 403: |
| 135 |
raise ForbiddenError( |
| 136 |
headers=dict(_response.headers), |
| 137 |
body=typing.cast( |
| 138 |
typing.Any, |
| 139 |
parse_obj_as( |
| 140 |
type_=typing.Any, |
| 141 |
object_=_response.json(), |
| 142 |
), |
| 143 |
), |
| 144 |
) |
| 145 |
if _response.status_code == 429: |
| 146 |
raise TooManyRequestsError( |
| 147 |
headers=dict(_response.headers), |
| 148 |
body=typing.cast( |
| 149 |
typing.Any, |
| 150 |
parse_obj_as( |
| 151 |
type_=typing.Any, |
| 152 |
object_=_response.json(), |
| 153 |
), |
| 154 |
), |
| 155 |
) |
| 156 |
_response_json = _response.json() |
| 157 |
except JSONDecodeError: |
| 158 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 159 |
except ValidationError as e: |
| 160 |
raise ParsingError( |
| 161 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 162 |
) |
| 163 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 164 |
|
| 165 |
def create( |
| 166 |
self, |
| 167 |
*, |
| 168 |
audience: str, |
| 169 |
client_id: typing.Optional[str] = OMIT, |
| 170 |
default_for: typing.Optional[ClientGrantDefaultForEnum] = OMIT, |
| 171 |
organization_usage: typing.Optional[ClientGrantOrganizationUsageEnum] = OMIT, |
| 172 |
allow_any_organization: typing.Optional[bool] = OMIT, |
| 173 |
scope: typing.Optional[typing.Sequence[str]] = OMIT, |
| 174 |
subject_type: typing.Optional[ClientGrantSubjectTypeEnum] = OMIT, |
| 175 |
authorization_details_types: typing.Optional[typing.Sequence[str]] = OMIT, |
| 176 |
allow_all_scopes: typing.Optional[bool] = OMIT, |
| 177 |
request_options: typing.Optional[RequestOptions] = None, |
| 178 |
) -> HttpResponse[CreateClientGrantResponseContent]: |
| 179 |
""" |
| 180 |
Create a client grant for a machine-to-machine login flow. To learn more, read [Client Credential Flow](https://www.auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow). |
| 181 |
|
| 182 |
Parameters |
| 183 |
---------- |
| 184 |
audience : str |
| 185 |
The audience (API identifier) of this client grant |
| 186 |
|
| 187 |
client_id : typing.Optional[str] |
| 188 |
ID of the client. |
| 189 |
|
| 190 |
default_for : typing.Optional[ClientGrantDefaultForEnum] |
| 191 |
|
| 192 |
organization_usage : typing.Optional[ClientGrantOrganizationUsageEnum] |
| 193 |
|
| 194 |
allow_any_organization : typing.Optional[bool] |
| 195 |
If enabled, any organization can be used with this grant. If disabled (default), the grant must be explicitly assigned to the desired organizations. |
| 196 |
|
| 197 |
scope : typing.Optional[typing.Sequence[str]] |
| 198 |
Scopes allowed for this client grant. |
| 199 |
|
| 200 |
subject_type : typing.Optional[ClientGrantSubjectTypeEnum] |
| 201 |
|
| 202 |
authorization_details_types : typing.Optional[typing.Sequence[str]] |
| 203 |
Types of authorization_details allowed for this client grant. |
| 204 |
|
| 205 |
allow_all_scopes : typing.Optional[bool] |
| 206 |
If enabled, all scopes configured on the resource server are allowed for this grant. |
| 207 |
|
| 208 |
request_options : typing.Optional[RequestOptions] |
| 209 |
Request-specific configuration. |
| 210 |
|
| 211 |
Returns |
| 212 |
------- |
| 213 |
HttpResponse[CreateClientGrantResponseContent] |
| 214 |
Client grant successfully created. |
| 215 |
""" |
| 216 |
_response = self._client_wrapper.httpx_client.request( |
| 217 |
"client-grants", |
| 218 |
method="POST", |
| 219 |
json={ |
| 220 |
"client_id": client_id, |
| 221 |
"audience": audience, |
| 222 |
"default_for": default_for, |
| 223 |
"organization_usage": organization_usage, |
| 224 |
"allow_any_organization": allow_any_organization, |
| 225 |
"scope": scope, |
| 226 |
"subject_type": subject_type, |
| 227 |
"authorization_details_types": authorization_details_types, |
| 228 |
"allow_all_scopes": allow_all_scopes, |
| 229 |
}, |
| 230 |
headers={ |
| 231 |
"content-type": "application/json", |
| 232 |
}, |
| 233 |
request_options=request_options, |
| 234 |
omit=OMIT, |
| 235 |
) |
| 236 |
try: |
| 237 |
if 200 <= _response.status_code < 300: |
| 238 |
_data = typing.cast( |
| 239 |
CreateClientGrantResponseContent, |
| 240 |
parse_obj_as( |
| 241 |
type_=CreateClientGrantResponseContent, |
| 242 |
object_=_response.json(), |
| 243 |
), |
| 244 |
) |
| 245 |
return HttpResponse(response=_response, data=_data) |
| 246 |
if _response.status_code == 400: |
| 247 |
raise BadRequestError( |
| 248 |
headers=dict(_response.headers), |
| 249 |
body=typing.cast( |
| 250 |
typing.Any, |
| 251 |
parse_obj_as( |
| 252 |
type_=typing.Any, |
| 253 |
object_=_response.json(), |
| 254 |
), |
| 255 |
), |
| 256 |
) |
| 257 |
if _response.status_code == 401: |
| 258 |
raise UnauthorizedError( |
| 259 |
headers=dict(_response.headers), |
| 260 |
body=typing.cast( |
| 261 |
typing.Any, |
| 262 |
parse_obj_as( |
| 263 |
type_=typing.Any, |
| 264 |
object_=_response.json(), |
| 265 |
), |
| 266 |
), |
| 267 |
) |
| 268 |
if _response.status_code == 403: |
| 269 |
raise ForbiddenError( |
| 270 |
headers=dict(_response.headers), |
| 271 |
body=typing.cast( |
| 272 |
typing.Any, |
| 273 |
parse_obj_as( |
| 274 |
type_=typing.Any, |
| 275 |
object_=_response.json(), |
| 276 |
), |
| 277 |
), |
| 278 |
) |
| 279 |
if _response.status_code == 404: |
| 280 |
raise NotFoundError( |
| 281 |
headers=dict(_response.headers), |
| 282 |
body=typing.cast( |
| 283 |
typing.Any, |
| 284 |
parse_obj_as( |
| 285 |
type_=typing.Any, |
| 286 |
object_=_response.json(), |
| 287 |
), |
| 288 |
), |
| 289 |
) |
| 290 |
if _response.status_code == 409: |
| 291 |
raise ConflictError( |
| 292 |
headers=dict(_response.headers), |
| 293 |
body=typing.cast( |
| 294 |
typing.Any, |
| 295 |
parse_obj_as( |
| 296 |
type_=typing.Any, |
| 297 |
object_=_response.json(), |
| 298 |
), |
| 299 |
), |
| 300 |
) |
| 301 |
if _response.status_code == 429: |
| 302 |
raise TooManyRequestsError( |
| 303 |
headers=dict(_response.headers), |
| 304 |
body=typing.cast( |
| 305 |
typing.Any, |
| 306 |
parse_obj_as( |
| 307 |
type_=typing.Any, |
| 308 |
object_=_response.json(), |
| 309 |
), |
| 310 |
), |
| 311 |
) |
| 312 |
_response_json = _response.json() |
| 313 |
except JSONDecodeError: |
| 314 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 315 |
except ValidationError as e: |
| 316 |
raise ParsingError( |
| 317 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 318 |
) |
| 319 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 320 |
|
| 321 |
def get( |
| 322 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 323 |
) -> HttpResponse[GetClientGrantResponseContent]: |
| 324 |
""" |
| 325 |
Retrieve a single [client grant](https://auth0.com/docs/get-started/applications/application-access-to-apis-client-grants), including the |
| 326 |
scopes associated with the application/API pair. |
| 327 |
|
| 328 |
Parameters |
| 329 |
---------- |
| 330 |
id : str |
| 331 |
The ID of the client grant to retrieve. |
| 332 |
|
| 333 |
request_options : typing.Optional[RequestOptions] |
| 334 |
Request-specific configuration. |
| 335 |
|
| 336 |
Returns |
| 337 |
------- |
| 338 |
HttpResponse[GetClientGrantResponseContent] |
| 339 |
Client grant successfully retrieved. |
| 340 |
""" |
| 341 |
_response = self._client_wrapper.httpx_client.request( |
| 342 |
f"client-grants/{encode_path_param(id)}", |
| 343 |
method="GET", |
| 344 |
request_options=request_options, |
| 345 |
) |
| 346 |
try: |
| 347 |
if 200 <= _response.status_code < 300: |
| 348 |
_data = typing.cast( |
| 349 |
GetClientGrantResponseContent, |
| 350 |
parse_obj_as( |
| 351 |
type_=GetClientGrantResponseContent, |
| 352 |
object_=_response.json(), |
| 353 |
), |
| 354 |
) |
| 355 |
return HttpResponse(response=_response, data=_data) |
| 356 |
if _response.status_code == 401: |
| 357 |
raise UnauthorizedError( |
| 358 |
headers=dict(_response.headers), |
| 359 |
body=typing.cast( |
| 360 |
typing.Any, |
| 361 |
parse_obj_as( |
| 362 |
type_=typing.Any, |
| 363 |
object_=_response.json(), |
| 364 |
), |
| 365 |
), |
| 366 |
) |
| 367 |
if _response.status_code == 403: |
| 368 |
raise ForbiddenError( |
| 369 |
headers=dict(_response.headers), |
| 370 |
body=typing.cast( |
| 371 |
typing.Any, |
| 372 |
parse_obj_as( |
| 373 |
type_=typing.Any, |
| 374 |
object_=_response.json(), |
| 375 |
), |
| 376 |
), |
| 377 |
) |
| 378 |
if _response.status_code == 404: |
| 379 |
raise NotFoundError( |
| 380 |
headers=dict(_response.headers), |
| 381 |
body=typing.cast( |
| 382 |
typing.Any, |
| 383 |
parse_obj_as( |
| 384 |
type_=typing.Any, |
| 385 |
object_=_response.json(), |
| 386 |
), |
| 387 |
), |
| 388 |
) |
| 389 |
if _response.status_code == 429: |
| 390 |
raise TooManyRequestsError( |
| 391 |
headers=dict(_response.headers), |
| 392 |
body=typing.cast( |
| 393 |
typing.Any, |
| 394 |
parse_obj_as( |
| 395 |
type_=typing.Any, |
| 396 |
object_=_response.json(), |
| 397 |
), |
| 398 |
), |
| 399 |
) |
| 400 |
_response_json = _response.json() |
| 401 |
except JSONDecodeError: |
| 402 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 403 |
except ValidationError as e: |
| 404 |
raise ParsingError( |
| 405 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 406 |
) |
| 407 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 408 |
|
| 409 |
def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: |
| 410 |
""" |
| 411 |
Delete the [Client Credential Flow](https://www.auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow) from your machine-to-machine application. |
| 412 |
|
| 413 |
Parameters |
| 414 |
---------- |
| 415 |
id : str |
| 416 |
ID of the client grant to delete. |
| 417 |
|
| 418 |
request_options : typing.Optional[RequestOptions] |
| 419 |
Request-specific configuration. |
| 420 |
|
| 421 |
Returns |
| 422 |
------- |
| 423 |
HttpResponse[None] |
| 424 |
""" |
| 425 |
_response = self._client_wrapper.httpx_client.request( |
| 426 |
f"client-grants/{encode_path_param(id)}", |
| 427 |
method="DELETE", |
| 428 |
request_options=request_options, |
| 429 |
) |
| 430 |
try: |
| 431 |
if 200 <= _response.status_code < 300: |
| 432 |
return HttpResponse(response=_response, data=None) |
| 433 |
if _response.status_code == 400: |
| 434 |
raise BadRequestError( |
| 435 |
headers=dict(_response.headers), |
| 436 |
body=typing.cast( |
| 437 |
typing.Any, |
| 438 |
parse_obj_as( |
| 439 |
type_=typing.Any, |
| 440 |
object_=_response.json(), |
| 441 |
), |
| 442 |
), |
| 443 |
) |
| 444 |
if _response.status_code == 401: |
| 445 |
raise UnauthorizedError( |
| 446 |
headers=dict(_response.headers), |
| 447 |
body=typing.cast( |
| 448 |
typing.Any, |
| 449 |
parse_obj_as( |
| 450 |
type_=typing.Any, |
| 451 |
object_=_response.json(), |
| 452 |
), |
| 453 |
), |
| 454 |
) |
| 455 |
if _response.status_code == 403: |
| 456 |
raise ForbiddenError( |
| 457 |
headers=dict(_response.headers), |
| 458 |
body=typing.cast( |
| 459 |
typing.Any, |
| 460 |
parse_obj_as( |
| 461 |
type_=typing.Any, |
| 462 |
object_=_response.json(), |
| 463 |
), |
| 464 |
), |
| 465 |
) |
| 466 |
if _response.status_code == 429: |
| 467 |
raise TooManyRequestsError( |
| 468 |
headers=dict(_response.headers), |
| 469 |
body=typing.cast( |
| 470 |
typing.Any, |
| 471 |
parse_obj_as( |
| 472 |
type_=typing.Any, |
| 473 |
object_=_response.json(), |
| 474 |
), |
| 475 |
), |
| 476 |
) |
| 477 |
_response_json = _response.json() |
| 478 |
except JSONDecodeError: |
| 479 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 480 |
except ValidationError as e: |
| 481 |
raise ParsingError( |
| 482 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 483 |
) |
| 484 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 485 |
|
| 486 |
def update( |
| 487 |
self, |
| 488 |
id: str, |
| 489 |
*, |
| 490 |
scope: typing.Optional[typing.Sequence[str]] = OMIT, |
| 491 |
organization_usage: typing.Optional[ClientGrantOrganizationNullableUsageEnum] = OMIT, |
| 492 |
allow_any_organization: typing.Optional[bool] = OMIT, |
| 493 |
authorization_details_types: typing.Optional[typing.Sequence[str]] = OMIT, |
| 494 |
allow_all_scopes: typing.Optional[bool] = OMIT, |
| 495 |
request_options: typing.Optional[RequestOptions] = None, |
| 496 |
) -> HttpResponse[UpdateClientGrantResponseContent]: |
| 497 |
""" |
| 498 |
Update a client grant. |
| 499 |
|
| 500 |
Parameters |
| 501 |
---------- |
| 502 |
id : str |
| 503 |
ID of the client grant to update. |
| 504 |
|
| 505 |
scope : typing.Optional[typing.Sequence[str]] |
| 506 |
Scopes allowed for this client grant. |
| 507 |
|
| 508 |
organization_usage : typing.Optional[ClientGrantOrganizationNullableUsageEnum] |
| 509 |
|
| 510 |
allow_any_organization : typing.Optional[bool] |
| 511 |
Controls allowing any organization to be used with this grant |
| 512 |
|
| 513 |
authorization_details_types : typing.Optional[typing.Sequence[str]] |
| 514 |
Types of authorization_details allowed for this client grant. |
| 515 |
|
| 516 |
allow_all_scopes : typing.Optional[bool] |
| 517 |
If enabled, all scopes configured on the resource server are allowed for this grant. |
| 518 |
|
| 519 |
request_options : typing.Optional[RequestOptions] |
| 520 |
Request-specific configuration. |
| 521 |
|
| 522 |
Returns |
| 523 |
------- |
| 524 |
HttpResponse[UpdateClientGrantResponseContent] |
| 525 |
Client grant successfully updated. |
| 526 |
""" |
| 527 |
_response = self._client_wrapper.httpx_client.request( |
| 528 |
f"client-grants/{encode_path_param(id)}", |
| 529 |
method="PATCH", |
| 530 |
json={ |
| 531 |
"scope": scope, |
| 532 |
"organization_usage": organization_usage, |
| 533 |
"allow_any_organization": allow_any_organization, |
| 534 |
"authorization_details_types": authorization_details_types, |
| 535 |
"allow_all_scopes": allow_all_scopes, |
| 536 |
}, |
| 537 |
headers={ |
| 538 |
"content-type": "application/json", |
| 539 |
}, |
| 540 |
request_options=request_options, |
| 541 |
omit=OMIT, |
| 542 |
) |
| 543 |
try: |
| 544 |
if 200 <= _response.status_code < 300: |
| 545 |
_data = typing.cast( |
| 546 |
UpdateClientGrantResponseContent, |
| 547 |
parse_obj_as( |
| 548 |
type_=UpdateClientGrantResponseContent, |
| 549 |
object_=_response.json(), |
| 550 |
), |
| 551 |
) |
| 552 |
return HttpResponse(response=_response, data=_data) |
| 553 |
if _response.status_code == 400: |
| 554 |
raise BadRequestError( |
| 555 |
headers=dict(_response.headers), |
| 556 |
body=typing.cast( |
| 557 |
typing.Any, |
| 558 |
parse_obj_as( |
| 559 |
type_=typing.Any, |
| 560 |
object_=_response.json(), |
| 561 |
), |
| 562 |
), |
| 563 |
) |
| 564 |
if _response.status_code == 401: |
| 565 |
raise UnauthorizedError( |
| 566 |
headers=dict(_response.headers), |
| 567 |
body=typing.cast( |
| 568 |
typing.Any, |
| 569 |
parse_obj_as( |
| 570 |
type_=typing.Any, |
| 571 |
object_=_response.json(), |
| 572 |
), |
| 573 |
), |
| 574 |
) |
| 575 |
if _response.status_code == 403: |
| 576 |
raise ForbiddenError( |
| 577 |
headers=dict(_response.headers), |
| 578 |
body=typing.cast( |
| 579 |
typing.Any, |
| 580 |
parse_obj_as( |
| 581 |
type_=typing.Any, |
| 582 |
object_=_response.json(), |
| 583 |
), |
| 584 |
), |
| 585 |
) |
| 586 |
if _response.status_code == 404: |
| 587 |
raise NotFoundError( |
| 588 |
headers=dict(_response.headers), |
| 589 |
body=typing.cast( |
| 590 |
typing.Any, |
| 591 |
parse_obj_as( |
| 592 |
type_=typing.Any, |
| 593 |
object_=_response.json(), |
| 594 |
), |
| 595 |
), |
| 596 |
) |
| 597 |
if _response.status_code == 429: |
| 598 |
raise TooManyRequestsError( |
| 599 |
headers=dict(_response.headers), |
| 600 |
body=typing.cast( |
| 601 |
typing.Any, |
| 602 |
parse_obj_as( |
| 603 |
type_=typing.Any, |
| 604 |
object_=_response.json(), |
| 605 |
), |
| 606 |
), |
| 607 |
) |
| 608 |
_response_json = _response.json() |
| 609 |
except JSONDecodeError: |
| 610 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 611 |
except ValidationError as e: |
| 612 |
raise ParsingError( |
| 613 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 614 |
) |
| 615 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 616 |
|
| 617 |
|
| 618 |
class AsyncRawClientGrantsClient: |
| 619 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 620 |
self._client_wrapper = client_wrapper |
| 621 |
|
| 622 |
async def list( |
| 623 |
self, |
| 624 |
*, |
| 625 |
from_: typing.Optional[str] = None, |
| 626 |
take: typing.Optional[int] = 50, |
| 627 |
audience: typing.Optional[str] = None, |
| 628 |
client_id: typing.Optional[str] = None, |
| 629 |
allow_any_organization: typing.Optional[ClientGrantAllowAnyOrganizationEnum] = None, |
| 630 |
subject_type: typing.Optional[ClientGrantSubjectTypeEnum] = None, |
| 631 |
default_for: typing.Optional[ClientGrantDefaultForEnum] = None, |
| 632 |
request_options: typing.Optional[RequestOptions] = None, |
| 633 |
) -> AsyncPager[ClientGrantResponseContent, ListClientGrantPaginatedResponseContent]: |
| 634 |
""" |
| 635 |
Retrieve a list of [client grants](https://auth0.com/docs/get-started/applications/application-access-to-apis-client-grants), including the scopes associated with the application/API pair. |
| 636 |
|
| 637 |
Parameters |
| 638 |
---------- |
| 639 |
from_ : typing.Optional[str] |
| 640 |
Optional Id from which to start selection. |
| 641 |
|
| 642 |
take : typing.Optional[int] |
| 643 |
Number of results per page. Defaults to 50. |
| 644 |
|
| 645 |
audience : typing.Optional[str] |
| 646 |
Optional filter on audience. |
| 647 |
|
| 648 |
client_id : typing.Optional[str] |
| 649 |
Optional filter on client_id. |
| 650 |
|
| 651 |
allow_any_organization : typing.Optional[ClientGrantAllowAnyOrganizationEnum] |
| 652 |
Optional filter on allow_any_organization. |
| 653 |
|
| 654 |
subject_type : typing.Optional[ClientGrantSubjectTypeEnum] |
| 655 |
The type of application access the client grant allows. |
| 656 |
|
| 657 |
default_for : typing.Optional[ClientGrantDefaultForEnum] |
| 658 |
Applies this client grant as the default for all clients in the specified group. The only accepted value is <a href="https://auth0.com/docs/get-started/applications/application-access-to-apis-client-grants#default-permissions-for-third-party-applications">`third_party_clients`</a>, which applies the grant to all third-party clients. Per-client grants for the same audience take precedence. Mutually exclusive with `client_id`. |
| 659 |
|
| 660 |
request_options : typing.Optional[RequestOptions] |
| 661 |
Request-specific configuration. |
| 662 |
|
| 663 |
Returns |
| 664 |
------- |
| 665 |
AsyncPager[ClientGrantResponseContent, ListClientGrantPaginatedResponseContent] |
| 666 |
Client grants successfully retrieved. |
| 667 |
""" |
| 668 |
_response = await self._client_wrapper.httpx_client.request( |
| 669 |
"client-grants", |
| 670 |
method="GET", |
| 671 |
params={ |
| 672 |
"from": from_, |
| 673 |
"take": take, |
| 674 |
"audience": audience, |
| 675 |
"client_id": client_id, |
| 676 |
"allow_any_organization": allow_any_organization, |
| 677 |
"subject_type": subject_type, |
| 678 |
"default_for": default_for, |
| 679 |
}, |
| 680 |
request_options=request_options, |
| 681 |
) |
| 682 |
try: |
| 683 |
if 200 <= _response.status_code < 300: |
| 684 |
_parsed_response = typing.cast( |
| 685 |
ListClientGrantPaginatedResponseContent, |
| 686 |
parse_obj_as( |
| 687 |
type_=ListClientGrantPaginatedResponseContent, |
| 688 |
object_=_response.json(), |
| 689 |
), |
| 690 |
) |
| 691 |
_items = _parsed_response.client_grants |
| 692 |
_parsed_next = _parsed_response.next |
| 693 |
_has_next = _parsed_next is not None and _parsed_next != "" |
| 694 |
|
| 695 |
async def _get_next(): |
| 696 |
return await self.list( |
| 697 |
from_=_parsed_next, |
| 698 |
take=take, |
| 699 |
audience=audience, |
| 700 |
client_id=client_id, |
| 701 |
allow_any_organization=allow_any_organization, |
| 702 |
subject_type=subject_type, |
| 703 |
default_for=default_for, |
| 704 |
request_options=request_options, |
| 705 |
) |
| 706 |
|
| 707 |
return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) |
| 708 |
if _response.status_code == 401: |
| 709 |
raise UnauthorizedError( |
| 710 |
headers=dict(_response.headers), |
| 711 |
body=typing.cast( |
| 712 |
typing.Any, |
| 713 |
parse_obj_as( |
| 714 |
type_=typing.Any, |
| 715 |
object_=_response.json(), |
| 716 |
), |
| 717 |
), |
| 718 |
) |
| 719 |
if _response.status_code == 403: |
| 720 |
raise ForbiddenError( |
| 721 |
headers=dict(_response.headers), |
| 722 |
body=typing.cast( |
| 723 |
typing.Any, |
| 724 |
parse_obj_as( |
| 725 |
type_=typing.Any, |
| 726 |
object_=_response.json(), |
| 727 |
), |
| 728 |
), |
| 729 |
) |
| 730 |
if _response.status_code == 429: |
| 731 |
raise TooManyRequestsError( |
| 732 |
headers=dict(_response.headers), |
| 733 |
body=typing.cast( |
| 734 |
typing.Any, |
| 735 |
parse_obj_as( |
| 736 |
type_=typing.Any, |
| 737 |
object_=_response.json(), |
| 738 |
), |
| 739 |
), |
| 740 |
) |
| 741 |
_response_json = _response.json() |
| 742 |
except JSONDecodeError: |
| 743 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 744 |
except ValidationError as e: |
| 745 |
raise ParsingError( |
| 746 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 747 |
) |
| 748 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 749 |
|
| 750 |
async def create( |
| 751 |
self, |
| 752 |
*, |
| 753 |
audience: str, |
| 754 |
client_id: typing.Optional[str] = OMIT, |
| 755 |
default_for: typing.Optional[ClientGrantDefaultForEnum] = OMIT, |
| 756 |
organization_usage: typing.Optional[ClientGrantOrganizationUsageEnum] = OMIT, |
| 757 |
allow_any_organization: typing.Optional[bool] = OMIT, |
| 758 |
scope: typing.Optional[typing.Sequence[str]] = OMIT, |
| 759 |
subject_type: typing.Optional[ClientGrantSubjectTypeEnum] = OMIT, |
| 760 |
authorization_details_types: typing.Optional[typing.Sequence[str]] = OMIT, |
| 761 |
allow_all_scopes: typing.Optional[bool] = OMIT, |
| 762 |
request_options: typing.Optional[RequestOptions] = None, |
| 763 |
) -> AsyncHttpResponse[CreateClientGrantResponseContent]: |
| 764 |
""" |
| 765 |
Create a client grant for a machine-to-machine login flow. To learn more, read [Client Credential Flow](https://www.auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow). |
| 766 |
|
| 767 |
Parameters |
| 768 |
---------- |
| 769 |
audience : str |
| 770 |
The audience (API identifier) of this client grant |
| 771 |
|
| 772 |
client_id : typing.Optional[str] |
| 773 |
ID of the client. |
| 774 |
|
| 775 |
default_for : typing.Optional[ClientGrantDefaultForEnum] |
| 776 |
|
| 777 |
organization_usage : typing.Optional[ClientGrantOrganizationUsageEnum] |
| 778 |
|
| 779 |
allow_any_organization : typing.Optional[bool] |
| 780 |
If enabled, any organization can be used with this grant. If disabled (default), the grant must be explicitly assigned to the desired organizations. |
| 781 |
|
| 782 |
scope : typing.Optional[typing.Sequence[str]] |
| 783 |
Scopes allowed for this client grant. |
| 784 |
|
| 785 |
subject_type : typing.Optional[ClientGrantSubjectTypeEnum] |
| 786 |
|
| 787 |
authorization_details_types : typing.Optional[typing.Sequence[str]] |
| 788 |
Types of authorization_details allowed for this client grant. |
| 789 |
|
| 790 |
allow_all_scopes : typing.Optional[bool] |
| 791 |
If enabled, all scopes configured on the resource server are allowed for this grant. |
| 792 |
|
| 793 |
request_options : typing.Optional[RequestOptions] |
| 794 |
Request-specific configuration. |
| 795 |
|
| 796 |
Returns |
| 797 |
------- |
| 798 |
AsyncHttpResponse[CreateClientGrantResponseContent] |
| 799 |
Client grant successfully created. |
| 800 |
""" |
| 801 |
_response = await self._client_wrapper.httpx_client.request( |
| 802 |
"client-grants", |
| 803 |
method="POST", |
| 804 |
json={ |
| 805 |
"client_id": client_id, |
| 806 |
"audience": audience, |
| 807 |
"default_for": default_for, |
| 808 |
"organization_usage": organization_usage, |
| 809 |
"allow_any_organization": allow_any_organization, |
| 810 |
"scope": scope, |
| 811 |
"subject_type": subject_type, |
| 812 |
"authorization_details_types": authorization_details_types, |
| 813 |
"allow_all_scopes": allow_all_scopes, |
| 814 |
}, |
| 815 |
headers={ |
| 816 |
"content-type": "application/json", |
| 817 |
}, |
| 818 |
request_options=request_options, |
| 819 |
omit=OMIT, |
| 820 |
) |
| 821 |
try: |
| 822 |
if 200 <= _response.status_code < 300: |
| 823 |
_data = typing.cast( |
| 824 |
CreateClientGrantResponseContent, |
| 825 |
parse_obj_as( |
| 826 |
type_=CreateClientGrantResponseContent, |
| 827 |
object_=_response.json(), |
| 828 |
), |
| 829 |
) |
| 830 |
return AsyncHttpResponse(response=_response, data=_data) |
| 831 |
if _response.status_code == 400: |
| 832 |
raise BadRequestError( |
| 833 |
headers=dict(_response.headers), |
| 834 |
body=typing.cast( |
| 835 |
typing.Any, |
| 836 |
parse_obj_as( |
| 837 |
type_=typing.Any, |
| 838 |
object_=_response.json(), |
| 839 |
), |
| 840 |
), |
| 841 |
) |
| 842 |
if _response.status_code == 401: |
| 843 |
raise UnauthorizedError( |
| 844 |
headers=dict(_response.headers), |
| 845 |
body=typing.cast( |
| 846 |
typing.Any, |
| 847 |
parse_obj_as( |
| 848 |
type_=typing.Any, |
| 849 |
object_=_response.json(), |
| 850 |
), |
| 851 |
), |
| 852 |
) |
| 853 |
if _response.status_code == 403: |
| 854 |
raise ForbiddenError( |
| 855 |
headers=dict(_response.headers), |
| 856 |
body=typing.cast( |
| 857 |
typing.Any, |
| 858 |
parse_obj_as( |
| 859 |
type_=typing.Any, |
| 860 |
object_=_response.json(), |
| 861 |
), |
| 862 |
), |
| 863 |
) |
| 864 |
if _response.status_code == 404: |
| 865 |
raise NotFoundError( |
| 866 |
headers=dict(_response.headers), |
| 867 |
body=typing.cast( |
| 868 |
typing.Any, |
| 869 |
parse_obj_as( |
| 870 |
type_=typing.Any, |
| 871 |
object_=_response.json(), |
| 872 |
), |
| 873 |
), |
| 874 |
) |
| 875 |
if _response.status_code == 409: |
| 876 |
raise ConflictError( |
| 877 |
headers=dict(_response.headers), |
| 878 |
body=typing.cast( |
| 879 |
typing.Any, |
| 880 |
parse_obj_as( |
| 881 |
type_=typing.Any, |
| 882 |
object_=_response.json(), |
| 883 |
), |
| 884 |
), |
| 885 |
) |
| 886 |
if _response.status_code == 429: |
| 887 |
raise TooManyRequestsError( |
| 888 |
headers=dict(_response.headers), |
| 889 |
body=typing.cast( |
| 890 |
typing.Any, |
| 891 |
parse_obj_as( |
| 892 |
type_=typing.Any, |
| 893 |
object_=_response.json(), |
| 894 |
), |
| 895 |
), |
| 896 |
) |
| 897 |
_response_json = _response.json() |
| 898 |
except JSONDecodeError: |
| 899 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 900 |
except ValidationError as e: |
| 901 |
raise ParsingError( |
| 902 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 903 |
) |
| 904 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 905 |
|
| 906 |
async def get( |
| 907 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 908 |
) -> AsyncHttpResponse[GetClientGrantResponseContent]: |
| 909 |
""" |
| 910 |
Retrieve a single [client grant](https://auth0.com/docs/get-started/applications/application-access-to-apis-client-grants), including the |
| 911 |
scopes associated with the application/API pair. |
| 912 |
|
| 913 |
Parameters |
| 914 |
---------- |
| 915 |
id : str |
| 916 |
The ID of the client grant to retrieve. |
| 917 |
|
| 918 |
request_options : typing.Optional[RequestOptions] |
| 919 |
Request-specific configuration. |
| 920 |
|
| 921 |
Returns |
| 922 |
------- |
| 923 |
AsyncHttpResponse[GetClientGrantResponseContent] |
| 924 |
Client grant successfully retrieved. |
| 925 |
""" |
| 926 |
_response = await self._client_wrapper.httpx_client.request( |
| 927 |
f"client-grants/{encode_path_param(id)}", |
| 928 |
method="GET", |
| 929 |
request_options=request_options, |
| 930 |
) |
| 931 |
try: |
| 932 |
if 200 <= _response.status_code < 300: |
| 933 |
_data = typing.cast( |
| 934 |
GetClientGrantResponseContent, |
| 935 |
parse_obj_as( |
| 936 |
type_=GetClientGrantResponseContent, |
| 937 |
object_=_response.json(), |
| 938 |
), |
| 939 |
) |
| 940 |
return AsyncHttpResponse(response=_response, data=_data) |
| 941 |
if _response.status_code == 401: |
| 942 |
raise UnauthorizedError( |
| 943 |
headers=dict(_response.headers), |
| 944 |
body=typing.cast( |
| 945 |
typing.Any, |
| 946 |
parse_obj_as( |
| 947 |
type_=typing.Any, |
| 948 |
object_=_response.json(), |
| 949 |
), |
| 950 |
), |
| 951 |
) |
| 952 |
if _response.status_code == 403: |
| 953 |
raise ForbiddenError( |
| 954 |
headers=dict(_response.headers), |
| 955 |
body=typing.cast( |
| 956 |
typing.Any, |
| 957 |
parse_obj_as( |
| 958 |
type_=typing.Any, |
| 959 |
object_=_response.json(), |
| 960 |
), |
| 961 |
), |
| 962 |
) |
| 963 |
if _response.status_code == 404: |
| 964 |
raise NotFoundError( |
| 965 |
headers=dict(_response.headers), |
| 966 |
body=typing.cast( |
| 967 |
typing.Any, |
| 968 |
parse_obj_as( |
| 969 |
type_=typing.Any, |
| 970 |
object_=_response.json(), |
| 971 |
), |
| 972 |
), |
| 973 |
) |
| 974 |
if _response.status_code == 429: |
| 975 |
raise TooManyRequestsError( |
| 976 |
headers=dict(_response.headers), |
| 977 |
body=typing.cast( |
| 978 |
typing.Any, |
| 979 |
parse_obj_as( |
| 980 |
type_=typing.Any, |
| 981 |
object_=_response.json(), |
| 982 |
), |
| 983 |
), |
| 984 |
) |
| 985 |
_response_json = _response.json() |
| 986 |
except JSONDecodeError: |
| 987 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 988 |
except ValidationError as e: |
| 989 |
raise ParsingError( |
| 990 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 991 |
) |
| 992 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 993 |
|
| 994 |
async def delete( |
| 995 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 996 |
) -> AsyncHttpResponse[None]: |
| 997 |
""" |
| 998 |
Delete the [Client Credential Flow](https://www.auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow) from your machine-to-machine application. |
| 999 |
|
| 1000 |
Parameters |
| 1001 |
---------- |
| 1002 |
id : str |
| 1003 |
ID of the client grant to delete. |
| 1004 |
|
| 1005 |
request_options : typing.Optional[RequestOptions] |
| 1006 |
Request-specific configuration. |
| 1007 |
|
| 1008 |
Returns |
| 1009 |
------- |
| 1010 |
AsyncHttpResponse[None] |
| 1011 |
""" |
| 1012 |
_response = await self._client_wrapper.httpx_client.request( |
| 1013 |
f"client-grants/{encode_path_param(id)}", |
| 1014 |
method="DELETE", |
| 1015 |
request_options=request_options, |
| 1016 |
) |
| 1017 |
try: |
| 1018 |
if 200 <= _response.status_code < 300: |
| 1019 |
return AsyncHttpResponse(response=_response, data=None) |
| 1020 |
if _response.status_code == 400: |
| 1021 |
raise BadRequestError( |
| 1022 |
headers=dict(_response.headers), |
| 1023 |
body=typing.cast( |
| 1024 |
typing.Any, |
| 1025 |
parse_obj_as( |
| 1026 |
type_=typing.Any, |
| 1027 |
object_=_response.json(), |
| 1028 |
), |
| 1029 |
), |
| 1030 |
) |
| 1031 |
if _response.status_code == 401: |
| 1032 |
raise UnauthorizedError( |
| 1033 |
headers=dict(_response.headers), |
| 1034 |
body=typing.cast( |
| 1035 |
typing.Any, |
| 1036 |
parse_obj_as( |
| 1037 |
type_=typing.Any, |
| 1038 |
object_=_response.json(), |
| 1039 |
), |
| 1040 |
), |
| 1041 |
) |
| 1042 |
if _response.status_code == 403: |
| 1043 |
raise ForbiddenError( |
| 1044 |
headers=dict(_response.headers), |
| 1045 |
body=typing.cast( |
| 1046 |
typing.Any, |
| 1047 |
parse_obj_as( |
| 1048 |
type_=typing.Any, |
| 1049 |
object_=_response.json(), |
| 1050 |
), |
| 1051 |
), |
| 1052 |
) |
| 1053 |
if _response.status_code == 429: |
| 1054 |
raise TooManyRequestsError( |
| 1055 |
headers=dict(_response.headers), |
| 1056 |
body=typing.cast( |
| 1057 |
typing.Any, |
| 1058 |
parse_obj_as( |
| 1059 |
type_=typing.Any, |
| 1060 |
object_=_response.json(), |
| 1061 |
), |
| 1062 |
), |
| 1063 |
) |
| 1064 |
_response_json = _response.json() |
| 1065 |
except JSONDecodeError: |
| 1066 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1067 |
except ValidationError as e: |
| 1068 |
raise ParsingError( |
| 1069 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1070 |
) |
| 1071 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1072 |
|
| 1073 |
async def update( |
| 1074 |
self, |
| 1075 |
id: str, |
| 1076 |
*, |
| 1077 |
scope: typing.Optional[typing.Sequence[str]] = OMIT, |
| 1078 |
organization_usage: typing.Optional[ClientGrantOrganizationNullableUsageEnum] = OMIT, |
| 1079 |
allow_any_organization: typing.Optional[bool] = OMIT, |
| 1080 |
authorization_details_types: typing.Optional[typing.Sequence[str]] = OMIT, |
| 1081 |
allow_all_scopes: typing.Optional[bool] = OMIT, |
| 1082 |
request_options: typing.Optional[RequestOptions] = None, |
| 1083 |
) -> AsyncHttpResponse[UpdateClientGrantResponseContent]: |
| 1084 |
""" |
| 1085 |
Update a client grant. |
| 1086 |
|
| 1087 |
Parameters |
| 1088 |
---------- |
| 1089 |
id : str |
| 1090 |
ID of the client grant to update. |
| 1091 |
|
| 1092 |
scope : typing.Optional[typing.Sequence[str]] |
| 1093 |
Scopes allowed for this client grant. |
| 1094 |
|
| 1095 |
organization_usage : typing.Optional[ClientGrantOrganizationNullableUsageEnum] |
| 1096 |
|
| 1097 |
allow_any_organization : typing.Optional[bool] |
| 1098 |
Controls allowing any organization to be used with this grant |
| 1099 |
|
| 1100 |
authorization_details_types : typing.Optional[typing.Sequence[str]] |
| 1101 |
Types of authorization_details allowed for this client grant. |
| 1102 |
|
| 1103 |
allow_all_scopes : typing.Optional[bool] |
| 1104 |
If enabled, all scopes configured on the resource server are allowed for this grant. |
| 1105 |
|
| 1106 |
request_options : typing.Optional[RequestOptions] |
| 1107 |
Request-specific configuration. |
| 1108 |
|
| 1109 |
Returns |
| 1110 |
------- |
| 1111 |
AsyncHttpResponse[UpdateClientGrantResponseContent] |
| 1112 |
Client grant successfully updated. |
| 1113 |
""" |
| 1114 |
_response = await self._client_wrapper.httpx_client.request( |
| 1115 |
f"client-grants/{encode_path_param(id)}", |
| 1116 |
method="PATCH", |
| 1117 |
json={ |
| 1118 |
"scope": scope, |
| 1119 |
"organization_usage": organization_usage, |
| 1120 |
"allow_any_organization": allow_any_organization, |
| 1121 |
"authorization_details_types": authorization_details_types, |
| 1122 |
"allow_all_scopes": allow_all_scopes, |
| 1123 |
}, |
| 1124 |
headers={ |
| 1125 |
"content-type": "application/json", |
| 1126 |
}, |
| 1127 |
request_options=request_options, |
| 1128 |
omit=OMIT, |
| 1129 |
) |
| 1130 |
try: |
| 1131 |
if 200 <= _response.status_code < 300: |
| 1132 |
_data = typing.cast( |
| 1133 |
UpdateClientGrantResponseContent, |
| 1134 |
parse_obj_as( |
| 1135 |
type_=UpdateClientGrantResponseContent, |
| 1136 |
object_=_response.json(), |
| 1137 |
), |
| 1138 |
) |
| 1139 |
return AsyncHttpResponse(response=_response, data=_data) |
| 1140 |
if _response.status_code == 400: |
| 1141 |
raise BadRequestError( |
| 1142 |
headers=dict(_response.headers), |
| 1143 |
body=typing.cast( |
| 1144 |
typing.Any, |
| 1145 |
parse_obj_as( |
| 1146 |
type_=typing.Any, |
| 1147 |
object_=_response.json(), |
| 1148 |
), |
| 1149 |
), |
| 1150 |
) |
| 1151 |
if _response.status_code == 401: |
| 1152 |
raise UnauthorizedError( |
| 1153 |
headers=dict(_response.headers), |
| 1154 |
body=typing.cast( |
| 1155 |
typing.Any, |
| 1156 |
parse_obj_as( |
| 1157 |
type_=typing.Any, |
| 1158 |
object_=_response.json(), |
| 1159 |
), |
| 1160 |
), |
| 1161 |
) |
| 1162 |
if _response.status_code == 403: |
| 1163 |
raise ForbiddenError( |
| 1164 |
headers=dict(_response.headers), |
| 1165 |
body=typing.cast( |
| 1166 |
typing.Any, |
| 1167 |
parse_obj_as( |
| 1168 |
type_=typing.Any, |
| 1169 |
object_=_response.json(), |
| 1170 |
), |
| 1171 |
), |
| 1172 |
) |
| 1173 |
if _response.status_code == 404: |
| 1174 |
raise NotFoundError( |
| 1175 |
headers=dict(_response.headers), |
| 1176 |
body=typing.cast( |
| 1177 |
typing.Any, |
| 1178 |
parse_obj_as( |
| 1179 |
type_=typing.Any, |
| 1180 |
object_=_response.json(), |
| 1181 |
), |
| 1182 |
), |
| 1183 |
) |
| 1184 |
if _response.status_code == 429: |
| 1185 |
raise TooManyRequestsError( |
| 1186 |
headers=dict(_response.headers), |
| 1187 |
body=typing.cast( |
| 1188 |
typing.Any, |
| 1189 |
parse_obj_as( |
| 1190 |
type_=typing.Any, |
| 1191 |
object_=_response.json(), |
| 1192 |
), |
| 1193 |
), |
| 1194 |
) |
| 1195 |
_response_json = _response.json() |
| 1196 |
except JSONDecodeError: |
| 1197 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1198 |
except ValidationError as e: |
| 1199 |
raise ParsingError( |
| 1200 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1201 |
) |
| 1202 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |