| 1 |
|
| 2 |
|
| 3 |
import typing |
| 4 |
from json.decoder import JSONDecodeError |
| 5 |
|
| 6 |
from ..core.api_error import ApiError |
| 7 |
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper |
| 8 |
from ..core.http_response import AsyncHttpResponse, HttpResponse |
| 9 |
from ..core.jsonable_encoder import encode_path_param |
| 10 |
from ..core.pagination import AsyncPager, SyncPager |
| 11 |
from ..core.parse_error import ParsingError |
| 12 |
from ..core.pydantic_utilities import parse_obj_as |
| 13 |
from ..core.request_options import RequestOptions |
| 14 |
from ..core.serialization import convert_and_respect_annotation_metadata |
| 15 |
from ..errors.bad_request_error import BadRequestError |
| 16 |
from ..errors.conflict_error import ConflictError |
| 17 |
from ..errors.forbidden_error import ForbiddenError |
| 18 |
from ..errors.not_found_error import NotFoundError |
| 19 |
from ..errors.too_many_requests_error import TooManyRequestsError |
| 20 |
from ..errors.unauthorized_error import UnauthorizedError |
| 21 |
from ..types.create_resource_server_response_content import CreateResourceServerResponseContent |
| 22 |
from ..types.get_resource_server_response_content import GetResourceServerResponseContent |
| 23 |
from ..types.list_resource_server_offset_paginated_response_content import ( |
| 24 |
ListResourceServerOffsetPaginatedResponseContent, |
| 25 |
) |
| 26 |
from ..types.resource_server import ResourceServer |
| 27 |
from ..types.resource_server_authorization_policy import ResourceServerAuthorizationPolicy |
| 28 |
from ..types.resource_server_consent_policy_enum import ResourceServerConsentPolicyEnum |
| 29 |
from ..types.resource_server_proof_of_possession import ResourceServerProofOfPossession |
| 30 |
from ..types.resource_server_scope import ResourceServerScope |
| 31 |
from ..types.resource_server_subject_type_authorization import ResourceServerSubjectTypeAuthorization |
| 32 |
from ..types.resource_server_token_dialect_schema_enum import ResourceServerTokenDialectSchemaEnum |
| 33 |
from ..types.resource_server_token_encryption import ResourceServerTokenEncryption |
| 34 |
from ..types.signing_algorithm_enum import SigningAlgorithmEnum |
| 35 |
from ..types.update_resource_server_response_content import UpdateResourceServerResponseContent |
| 36 |
from pydantic import ValidationError |
| 37 |
|
| 38 |
|
| 39 |
OMIT = typing.cast(typing.Any, ...) |
| 40 |
|
| 41 |
|
| 42 |
class RawResourceServersClient: |
| 43 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 44 |
self._client_wrapper = client_wrapper |
| 45 |
|
| 46 |
def list( |
| 47 |
self, |
| 48 |
*, |
| 49 |
identifiers: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, |
| 50 |
page: typing.Optional[int] = 0, |
| 51 |
per_page: typing.Optional[int] = 50, |
| 52 |
include_totals: typing.Optional[bool] = True, |
| 53 |
include_fields: typing.Optional[bool] = None, |
| 54 |
request_options: typing.Optional[RequestOptions] = None, |
| 55 |
) -> SyncPager[ResourceServer, ListResourceServerOffsetPaginatedResponseContent]: |
| 56 |
""" |
| 57 |
Retrieve details of all APIs associated with your tenant. |
| 58 |
|
| 59 |
Parameters |
| 60 |
---------- |
| 61 |
identifiers : typing.Optional[typing.Union[str, typing.Sequence[str]]] |
| 62 |
An optional filter on the resource server identifier. Must be URL encoded and may be specified multiple times (max 10).<br /><b>e.g.</b> <i>../resource-servers?identifiers=id1&identifiers=id2</i> |
| 63 |
|
| 64 |
page : typing.Optional[int] |
| 65 |
Page index of the results to return. First page is 0. |
| 66 |
|
| 67 |
per_page : typing.Optional[int] |
| 68 |
Number of results per page. |
| 69 |
|
| 70 |
include_totals : typing.Optional[bool] |
| 71 |
Return results inside an object that contains the total result count (true) or as a direct array of results (false, default). |
| 72 |
|
| 73 |
include_fields : typing.Optional[bool] |
| 74 |
Whether specified fields are to be included (true) or excluded (false). |
| 75 |
|
| 76 |
request_options : typing.Optional[RequestOptions] |
| 77 |
Request-specific configuration. |
| 78 |
|
| 79 |
Returns |
| 80 |
------- |
| 81 |
SyncPager[ResourceServer, ListResourceServerOffsetPaginatedResponseContent] |
| 82 |
Resource servers successfully retrieved. |
| 83 |
""" |
| 84 |
page = page if page is not None else 0 |
| 85 |
|
| 86 |
_response = self._client_wrapper.httpx_client.request( |
| 87 |
"resource-servers", |
| 88 |
method="GET", |
| 89 |
params={ |
| 90 |
"identifiers": identifiers, |
| 91 |
"page": page, |
| 92 |
"per_page": per_page, |
| 93 |
"include_totals": include_totals, |
| 94 |
"include_fields": include_fields, |
| 95 |
}, |
| 96 |
request_options=request_options, |
| 97 |
) |
| 98 |
try: |
| 99 |
if 200 <= _response.status_code < 300: |
| 100 |
_parsed_response = typing.cast( |
| 101 |
ListResourceServerOffsetPaginatedResponseContent, |
| 102 |
parse_obj_as( |
| 103 |
type_=ListResourceServerOffsetPaginatedResponseContent, |
| 104 |
object_=_response.json(), |
| 105 |
), |
| 106 |
) |
| 107 |
_items = _parsed_response.resource_servers |
| 108 |
_has_next = len(_items or []) > 0 |
| 109 |
_get_next = lambda: self.list( |
| 110 |
identifiers=identifiers, |
| 111 |
page=page + 1, |
| 112 |
per_page=per_page, |
| 113 |
include_totals=include_totals, |
| 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 == 429: |
| 152 |
raise TooManyRequestsError( |
| 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 |
_response_json = _response.json() |
| 163 |
except JSONDecodeError: |
| 164 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 165 |
except ValidationError as e: |
| 166 |
raise ParsingError( |
| 167 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 168 |
) |
| 169 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 170 |
|
| 171 |
def create( |
| 172 |
self, |
| 173 |
*, |
| 174 |
identifier: str, |
| 175 |
name: typing.Optional[str] = OMIT, |
| 176 |
scopes: typing.Optional[typing.Sequence[ResourceServerScope]] = OMIT, |
| 177 |
signing_alg: typing.Optional[SigningAlgorithmEnum] = OMIT, |
| 178 |
signing_secret: typing.Optional[str] = OMIT, |
| 179 |
allow_offline_access: typing.Optional[bool] = OMIT, |
| 180 |
allow_online_access: typing.Optional[bool] = OMIT, |
| 181 |
allow_online_access_with_ephemeral_sessions: typing.Optional[bool] = OMIT, |
| 182 |
token_lifetime: typing.Optional[int] = OMIT, |
| 183 |
token_dialect: typing.Optional[ResourceServerTokenDialectSchemaEnum] = OMIT, |
| 184 |
skip_consent_for_verifiable_first_party_clients: typing.Optional[bool] = OMIT, |
| 185 |
enforce_policies: typing.Optional[bool] = OMIT, |
| 186 |
token_encryption: typing.Optional[ResourceServerTokenEncryption] = OMIT, |
| 187 |
consent_policy: typing.Optional[ResourceServerConsentPolicyEnum] = OMIT, |
| 188 |
authorization_details: typing.Optional[typing.Sequence[typing.Any]] = OMIT, |
| 189 |
proof_of_possession: typing.Optional[ResourceServerProofOfPossession] = OMIT, |
| 190 |
subject_type_authorization: typing.Optional[ResourceServerSubjectTypeAuthorization] = OMIT, |
| 191 |
authorization_policy: typing.Optional[ResourceServerAuthorizationPolicy] = OMIT, |
| 192 |
request_options: typing.Optional[RequestOptions] = None, |
| 193 |
) -> HttpResponse[CreateResourceServerResponseContent]: |
| 194 |
""" |
| 195 |
Create a new API associated with your tenant. Note that all new APIs must be registered with Auth0. For more information, read <a href="https://www.auth0.com/docs/get-started/apis"> APIs</a>. |
| 196 |
|
| 197 |
Parameters |
| 198 |
---------- |
| 199 |
identifier : str |
| 200 |
Unique identifier for the API used as the audience parameter on authorization calls. Can not be changed once set. |
| 201 |
|
| 202 |
name : typing.Optional[str] |
| 203 |
Friendly name for this resource server. Can not contain `<` or `>` characters. |
| 204 |
|
| 205 |
scopes : typing.Optional[typing.Sequence[ResourceServerScope]] |
| 206 |
List of permissions (scopes) that this API uses. |
| 207 |
|
| 208 |
signing_alg : typing.Optional[SigningAlgorithmEnum] |
| 209 |
|
| 210 |
signing_secret : typing.Optional[str] |
| 211 |
Secret used to sign tokens when using symmetric algorithms (HS256). |
| 212 |
|
| 213 |
allow_offline_access : typing.Optional[bool] |
| 214 |
Whether refresh tokens can be issued for this API (true) or not (false). |
| 215 |
|
| 216 |
allow_online_access : typing.Optional[bool] |
| 217 |
Whether Online Refresh Tokens can be issued for this API (true) or not (false). |
| 218 |
|
| 219 |
allow_online_access_with_ephemeral_sessions : typing.Optional[bool] |
| 220 |
Whether Online Refresh Tokens can be issued even when sessions are configured as ephemeral (true) or not (false). |
| 221 |
|
| 222 |
token_lifetime : typing.Optional[int] |
| 223 |
Expiration value (in seconds) for access tokens issued for this API from the token endpoint. |
| 224 |
|
| 225 |
token_dialect : typing.Optional[ResourceServerTokenDialectSchemaEnum] |
| 226 |
|
| 227 |
skip_consent_for_verifiable_first_party_clients : typing.Optional[bool] |
| 228 |
Whether to skip user consent for applications flagged as first party (true) or not (false). |
| 229 |
|
| 230 |
enforce_policies : typing.Optional[bool] |
| 231 |
Whether to enforce authorization policies (true) or to ignore them (false). |
| 232 |
|
| 233 |
token_encryption : typing.Optional[ResourceServerTokenEncryption] |
| 234 |
|
| 235 |
consent_policy : typing.Optional[ResourceServerConsentPolicyEnum] |
| 236 |
|
| 237 |
authorization_details : typing.Optional[typing.Sequence[typing.Any]] |
| 238 |
|
| 239 |
proof_of_possession : typing.Optional[ResourceServerProofOfPossession] |
| 240 |
|
| 241 |
subject_type_authorization : typing.Optional[ResourceServerSubjectTypeAuthorization] |
| 242 |
|
| 243 |
authorization_policy : typing.Optional[ResourceServerAuthorizationPolicy] |
| 244 |
|
| 245 |
request_options : typing.Optional[RequestOptions] |
| 246 |
Request-specific configuration. |
| 247 |
|
| 248 |
Returns |
| 249 |
------- |
| 250 |
HttpResponse[CreateResourceServerResponseContent] |
| 251 |
Resource server successfully created. |
| 252 |
""" |
| 253 |
_response = self._client_wrapper.httpx_client.request( |
| 254 |
"resource-servers", |
| 255 |
method="POST", |
| 256 |
json={ |
| 257 |
"name": name, |
| 258 |
"identifier": identifier, |
| 259 |
"scopes": convert_and_respect_annotation_metadata( |
| 260 |
object_=scopes, annotation=typing.Sequence[ResourceServerScope], direction="write" |
| 261 |
), |
| 262 |
"signing_alg": signing_alg, |
| 263 |
"signing_secret": signing_secret, |
| 264 |
"allow_offline_access": allow_offline_access, |
| 265 |
"allow_online_access": allow_online_access, |
| 266 |
"allow_online_access_with_ephemeral_sessions": allow_online_access_with_ephemeral_sessions, |
| 267 |
"token_lifetime": token_lifetime, |
| 268 |
"token_dialect": token_dialect, |
| 269 |
"skip_consent_for_verifiable_first_party_clients": skip_consent_for_verifiable_first_party_clients, |
| 270 |
"enforce_policies": enforce_policies, |
| 271 |
"token_encryption": convert_and_respect_annotation_metadata( |
| 272 |
object_=token_encryption, |
| 273 |
annotation=typing.Optional[ResourceServerTokenEncryption], |
| 274 |
direction="write", |
| 275 |
), |
| 276 |
"consent_policy": consent_policy, |
| 277 |
"authorization_details": authorization_details, |
| 278 |
"proof_of_possession": convert_and_respect_annotation_metadata( |
| 279 |
object_=proof_of_possession, |
| 280 |
annotation=typing.Optional[ResourceServerProofOfPossession], |
| 281 |
direction="write", |
| 282 |
), |
| 283 |
"subject_type_authorization": convert_and_respect_annotation_metadata( |
| 284 |
object_=subject_type_authorization, |
| 285 |
annotation=ResourceServerSubjectTypeAuthorization, |
| 286 |
direction="write", |
| 287 |
), |
| 288 |
"authorization_policy": convert_and_respect_annotation_metadata( |
| 289 |
object_=authorization_policy, |
| 290 |
annotation=typing.Optional[ResourceServerAuthorizationPolicy], |
| 291 |
direction="write", |
| 292 |
), |
| 293 |
}, |
| 294 |
headers={ |
| 295 |
"content-type": "application/json", |
| 296 |
}, |
| 297 |
request_options=request_options, |
| 298 |
omit=OMIT, |
| 299 |
) |
| 300 |
try: |
| 301 |
if 200 <= _response.status_code < 300: |
| 302 |
_data = typing.cast( |
| 303 |
CreateResourceServerResponseContent, |
| 304 |
parse_obj_as( |
| 305 |
type_=CreateResourceServerResponseContent, |
| 306 |
object_=_response.json(), |
| 307 |
), |
| 308 |
) |
| 309 |
return HttpResponse(response=_response, data=_data) |
| 310 |
if _response.status_code == 400: |
| 311 |
raise BadRequestError( |
| 312 |
headers=dict(_response.headers), |
| 313 |
body=typing.cast( |
| 314 |
typing.Any, |
| 315 |
parse_obj_as( |
| 316 |
type_=typing.Any, |
| 317 |
object_=_response.json(), |
| 318 |
), |
| 319 |
), |
| 320 |
) |
| 321 |
if _response.status_code == 401: |
| 322 |
raise UnauthorizedError( |
| 323 |
headers=dict(_response.headers), |
| 324 |
body=typing.cast( |
| 325 |
typing.Any, |
| 326 |
parse_obj_as( |
| 327 |
type_=typing.Any, |
| 328 |
object_=_response.json(), |
| 329 |
), |
| 330 |
), |
| 331 |
) |
| 332 |
if _response.status_code == 403: |
| 333 |
raise ForbiddenError( |
| 334 |
headers=dict(_response.headers), |
| 335 |
body=typing.cast( |
| 336 |
typing.Any, |
| 337 |
parse_obj_as( |
| 338 |
type_=typing.Any, |
| 339 |
object_=_response.json(), |
| 340 |
), |
| 341 |
), |
| 342 |
) |
| 343 |
if _response.status_code == 409: |
| 344 |
raise ConflictError( |
| 345 |
headers=dict(_response.headers), |
| 346 |
body=typing.cast( |
| 347 |
typing.Any, |
| 348 |
parse_obj_as( |
| 349 |
type_=typing.Any, |
| 350 |
object_=_response.json(), |
| 351 |
), |
| 352 |
), |
| 353 |
) |
| 354 |
if _response.status_code == 429: |
| 355 |
raise TooManyRequestsError( |
| 356 |
headers=dict(_response.headers), |
| 357 |
body=typing.cast( |
| 358 |
typing.Any, |
| 359 |
parse_obj_as( |
| 360 |
type_=typing.Any, |
| 361 |
object_=_response.json(), |
| 362 |
), |
| 363 |
), |
| 364 |
) |
| 365 |
_response_json = _response.json() |
| 366 |
except JSONDecodeError: |
| 367 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 368 |
except ValidationError as e: |
| 369 |
raise ParsingError( |
| 370 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 371 |
) |
| 372 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 373 |
|
| 374 |
def get( |
| 375 |
self, |
| 376 |
id: str, |
| 377 |
*, |
| 378 |
include_fields: typing.Optional[bool] = None, |
| 379 |
request_options: typing.Optional[RequestOptions] = None, |
| 380 |
) -> HttpResponse[GetResourceServerResponseContent]: |
| 381 |
""" |
| 382 |
Retrieve <a href="https://auth0.com/docs/apis">API</a> details with the given ID. |
| 383 |
|
| 384 |
Parameters |
| 385 |
---------- |
| 386 |
id : str |
| 387 |
ID or audience of the resource server to retrieve. |
| 388 |
|
| 389 |
include_fields : typing.Optional[bool] |
| 390 |
Whether specified fields are to be included (true) or excluded (false). |
| 391 |
|
| 392 |
request_options : typing.Optional[RequestOptions] |
| 393 |
Request-specific configuration. |
| 394 |
|
| 395 |
Returns |
| 396 |
------- |
| 397 |
HttpResponse[GetResourceServerResponseContent] |
| 398 |
Resource server successfully retrieved. |
| 399 |
""" |
| 400 |
_response = self._client_wrapper.httpx_client.request( |
| 401 |
f"resource-servers/{encode_path_param(id)}", |
| 402 |
method="GET", |
| 403 |
params={ |
| 404 |
"include_fields": include_fields, |
| 405 |
}, |
| 406 |
request_options=request_options, |
| 407 |
) |
| 408 |
try: |
| 409 |
if 200 <= _response.status_code < 300: |
| 410 |
_data = typing.cast( |
| 411 |
GetResourceServerResponseContent, |
| 412 |
parse_obj_as( |
| 413 |
type_=GetResourceServerResponseContent, |
| 414 |
object_=_response.json(), |
| 415 |
), |
| 416 |
) |
| 417 |
return HttpResponse(response=_response, data=_data) |
| 418 |
if _response.status_code == 400: |
| 419 |
raise BadRequestError( |
| 420 |
headers=dict(_response.headers), |
| 421 |
body=typing.cast( |
| 422 |
typing.Any, |
| 423 |
parse_obj_as( |
| 424 |
type_=typing.Any, |
| 425 |
object_=_response.json(), |
| 426 |
), |
| 427 |
), |
| 428 |
) |
| 429 |
if _response.status_code == 401: |
| 430 |
raise UnauthorizedError( |
| 431 |
headers=dict(_response.headers), |
| 432 |
body=typing.cast( |
| 433 |
typing.Any, |
| 434 |
parse_obj_as( |
| 435 |
type_=typing.Any, |
| 436 |
object_=_response.json(), |
| 437 |
), |
| 438 |
), |
| 439 |
) |
| 440 |
if _response.status_code == 403: |
| 441 |
raise ForbiddenError( |
| 442 |
headers=dict(_response.headers), |
| 443 |
body=typing.cast( |
| 444 |
typing.Any, |
| 445 |
parse_obj_as( |
| 446 |
type_=typing.Any, |
| 447 |
object_=_response.json(), |
| 448 |
), |
| 449 |
), |
| 450 |
) |
| 451 |
if _response.status_code == 404: |
| 452 |
raise NotFoundError( |
| 453 |
headers=dict(_response.headers), |
| 454 |
body=typing.cast( |
| 455 |
typing.Any, |
| 456 |
parse_obj_as( |
| 457 |
type_=typing.Any, |
| 458 |
object_=_response.json(), |
| 459 |
), |
| 460 |
), |
| 461 |
) |
| 462 |
if _response.status_code == 429: |
| 463 |
raise TooManyRequestsError( |
| 464 |
headers=dict(_response.headers), |
| 465 |
body=typing.cast( |
| 466 |
typing.Any, |
| 467 |
parse_obj_as( |
| 468 |
type_=typing.Any, |
| 469 |
object_=_response.json(), |
| 470 |
), |
| 471 |
), |
| 472 |
) |
| 473 |
_response_json = _response.json() |
| 474 |
except JSONDecodeError: |
| 475 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 476 |
except ValidationError as e: |
| 477 |
raise ParsingError( |
| 478 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 479 |
) |
| 480 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 481 |
|
| 482 |
def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: |
| 483 |
""" |
| 484 |
Delete an existing API by ID. For more information, read <a href="https://www.auth0.com/docs/get-started/apis/api-settings">API Settings</a>. |
| 485 |
|
| 486 |
Parameters |
| 487 |
---------- |
| 488 |
id : str |
| 489 |
ID or the audience of the resource server to delete. |
| 490 |
|
| 491 |
request_options : typing.Optional[RequestOptions] |
| 492 |
Request-specific configuration. |
| 493 |
|
| 494 |
Returns |
| 495 |
------- |
| 496 |
HttpResponse[None] |
| 497 |
""" |
| 498 |
_response = self._client_wrapper.httpx_client.request( |
| 499 |
f"resource-servers/{encode_path_param(id)}", |
| 500 |
method="DELETE", |
| 501 |
request_options=request_options, |
| 502 |
) |
| 503 |
try: |
| 504 |
if 200 <= _response.status_code < 300: |
| 505 |
return HttpResponse(response=_response, data=None) |
| 506 |
if _response.status_code == 400: |
| 507 |
raise BadRequestError( |
| 508 |
headers=dict(_response.headers), |
| 509 |
body=typing.cast( |
| 510 |
typing.Any, |
| 511 |
parse_obj_as( |
| 512 |
type_=typing.Any, |
| 513 |
object_=_response.json(), |
| 514 |
), |
| 515 |
), |
| 516 |
) |
| 517 |
if _response.status_code == 401: |
| 518 |
raise UnauthorizedError( |
| 519 |
headers=dict(_response.headers), |
| 520 |
body=typing.cast( |
| 521 |
typing.Any, |
| 522 |
parse_obj_as( |
| 523 |
type_=typing.Any, |
| 524 |
object_=_response.json(), |
| 525 |
), |
| 526 |
), |
| 527 |
) |
| 528 |
if _response.status_code == 403: |
| 529 |
raise ForbiddenError( |
| 530 |
headers=dict(_response.headers), |
| 531 |
body=typing.cast( |
| 532 |
typing.Any, |
| 533 |
parse_obj_as( |
| 534 |
type_=typing.Any, |
| 535 |
object_=_response.json(), |
| 536 |
), |
| 537 |
), |
| 538 |
) |
| 539 |
if _response.status_code == 429: |
| 540 |
raise TooManyRequestsError( |
| 541 |
headers=dict(_response.headers), |
| 542 |
body=typing.cast( |
| 543 |
typing.Any, |
| 544 |
parse_obj_as( |
| 545 |
type_=typing.Any, |
| 546 |
object_=_response.json(), |
| 547 |
), |
| 548 |
), |
| 549 |
) |
| 550 |
_response_json = _response.json() |
| 551 |
except JSONDecodeError: |
| 552 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 553 |
except ValidationError as e: |
| 554 |
raise ParsingError( |
| 555 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 556 |
) |
| 557 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 558 |
|
| 559 |
def update( |
| 560 |
self, |
| 561 |
id: str, |
| 562 |
*, |
| 563 |
name: typing.Optional[str] = OMIT, |
| 564 |
scopes: typing.Optional[typing.Sequence[ResourceServerScope]] = OMIT, |
| 565 |
signing_alg: typing.Optional[SigningAlgorithmEnum] = OMIT, |
| 566 |
signing_secret: typing.Optional[str] = OMIT, |
| 567 |
skip_consent_for_verifiable_first_party_clients: typing.Optional[bool] = OMIT, |
| 568 |
allow_offline_access: typing.Optional[bool] = OMIT, |
| 569 |
allow_online_access: typing.Optional[bool] = OMIT, |
| 570 |
allow_online_access_with_ephemeral_sessions: typing.Optional[bool] = OMIT, |
| 571 |
token_lifetime: typing.Optional[int] = OMIT, |
| 572 |
token_dialect: typing.Optional[ResourceServerTokenDialectSchemaEnum] = OMIT, |
| 573 |
enforce_policies: typing.Optional[bool] = OMIT, |
| 574 |
token_encryption: typing.Optional[ResourceServerTokenEncryption] = OMIT, |
| 575 |
consent_policy: typing.Optional[ResourceServerConsentPolicyEnum] = OMIT, |
| 576 |
authorization_details: typing.Optional[typing.Sequence[typing.Any]] = OMIT, |
| 577 |
proof_of_possession: typing.Optional[ResourceServerProofOfPossession] = OMIT, |
| 578 |
subject_type_authorization: typing.Optional[ResourceServerSubjectTypeAuthorization] = OMIT, |
| 579 |
authorization_policy: typing.Optional[ResourceServerAuthorizationPolicy] = OMIT, |
| 580 |
request_options: typing.Optional[RequestOptions] = None, |
| 581 |
) -> HttpResponse[UpdateResourceServerResponseContent]: |
| 582 |
""" |
| 583 |
Change an existing API setting by resource server ID. For more information, read <a href="https://www.auth0.com/docs/get-started/apis/api-settings">API Settings</a>. |
| 584 |
|
| 585 |
Parameters |
| 586 |
---------- |
| 587 |
id : str |
| 588 |
ID or audience of the resource server to update. |
| 589 |
|
| 590 |
name : typing.Optional[str] |
| 591 |
Friendly name for this resource server. Can not contain `<` or `>` characters. |
| 592 |
|
| 593 |
scopes : typing.Optional[typing.Sequence[ResourceServerScope]] |
| 594 |
List of permissions (scopes) that this API uses. |
| 595 |
|
| 596 |
signing_alg : typing.Optional[SigningAlgorithmEnum] |
| 597 |
|
| 598 |
signing_secret : typing.Optional[str] |
| 599 |
Secret used to sign tokens when using symmetric algorithms (HS256). |
| 600 |
|
| 601 |
skip_consent_for_verifiable_first_party_clients : typing.Optional[bool] |
| 602 |
Whether to skip user consent for applications flagged as first party (true) or not (false). |
| 603 |
|
| 604 |
allow_offline_access : typing.Optional[bool] |
| 605 |
Whether refresh tokens can be issued for this API (true) or not (false). |
| 606 |
|
| 607 |
allow_online_access : typing.Optional[bool] |
| 608 |
Whether Online Refresh Tokens can be issued for this API (true) or not (false). |
| 609 |
|
| 610 |
allow_online_access_with_ephemeral_sessions : typing.Optional[bool] |
| 611 |
Whether Online Refresh Tokens can be issued even when sessions are configured as ephemeral (true) or not (false). |
| 612 |
|
| 613 |
token_lifetime : typing.Optional[int] |
| 614 |
Expiration value (in seconds) for access tokens issued for this API from the token endpoint. |
| 615 |
|
| 616 |
token_dialect : typing.Optional[ResourceServerTokenDialectSchemaEnum] |
| 617 |
|
| 618 |
enforce_policies : typing.Optional[bool] |
| 619 |
Whether authorization policies are enforced (true) or not enforced (false). |
| 620 |
|
| 621 |
token_encryption : typing.Optional[ResourceServerTokenEncryption] |
| 622 |
|
| 623 |
consent_policy : typing.Optional[ResourceServerConsentPolicyEnum] |
| 624 |
|
| 625 |
authorization_details : typing.Optional[typing.Sequence[typing.Any]] |
| 626 |
|
| 627 |
proof_of_possession : typing.Optional[ResourceServerProofOfPossession] |
| 628 |
|
| 629 |
subject_type_authorization : typing.Optional[ResourceServerSubjectTypeAuthorization] |
| 630 |
|
| 631 |
authorization_policy : typing.Optional[ResourceServerAuthorizationPolicy] |
| 632 |
|
| 633 |
request_options : typing.Optional[RequestOptions] |
| 634 |
Request-specific configuration. |
| 635 |
|
| 636 |
Returns |
| 637 |
------- |
| 638 |
HttpResponse[UpdateResourceServerResponseContent] |
| 639 |
Resource server successfully updated. |
| 640 |
""" |
| 641 |
_response = self._client_wrapper.httpx_client.request( |
| 642 |
f"resource-servers/{encode_path_param(id)}", |
| 643 |
method="PATCH", |
| 644 |
json={ |
| 645 |
"name": name, |
| 646 |
"scopes": convert_and_respect_annotation_metadata( |
| 647 |
object_=scopes, annotation=typing.Sequence[ResourceServerScope], direction="write" |
| 648 |
), |
| 649 |
"signing_alg": signing_alg, |
| 650 |
"signing_secret": signing_secret, |
| 651 |
"skip_consent_for_verifiable_first_party_clients": skip_consent_for_verifiable_first_party_clients, |
| 652 |
"allow_offline_access": allow_offline_access, |
| 653 |
"allow_online_access": allow_online_access, |
| 654 |
"allow_online_access_with_ephemeral_sessions": allow_online_access_with_ephemeral_sessions, |
| 655 |
"token_lifetime": token_lifetime, |
| 656 |
"token_dialect": token_dialect, |
| 657 |
"enforce_policies": enforce_policies, |
| 658 |
"token_encryption": convert_and_respect_annotation_metadata( |
| 659 |
object_=token_encryption, |
| 660 |
annotation=typing.Optional[ResourceServerTokenEncryption], |
| 661 |
direction="write", |
| 662 |
), |
| 663 |
"consent_policy": consent_policy, |
| 664 |
"authorization_details": authorization_details, |
| 665 |
"proof_of_possession": convert_and_respect_annotation_metadata( |
| 666 |
object_=proof_of_possession, |
| 667 |
annotation=typing.Optional[ResourceServerProofOfPossession], |
| 668 |
direction="write", |
| 669 |
), |
| 670 |
"subject_type_authorization": convert_and_respect_annotation_metadata( |
| 671 |
object_=subject_type_authorization, |
| 672 |
annotation=ResourceServerSubjectTypeAuthorization, |
| 673 |
direction="write", |
| 674 |
), |
| 675 |
"authorization_policy": convert_and_respect_annotation_metadata( |
| 676 |
object_=authorization_policy, |
| 677 |
annotation=typing.Optional[ResourceServerAuthorizationPolicy], |
| 678 |
direction="write", |
| 679 |
), |
| 680 |
}, |
| 681 |
headers={ |
| 682 |
"content-type": "application/json", |
| 683 |
}, |
| 684 |
request_options=request_options, |
| 685 |
omit=OMIT, |
| 686 |
) |
| 687 |
try: |
| 688 |
if 200 <= _response.status_code < 300: |
| 689 |
_data = typing.cast( |
| 690 |
UpdateResourceServerResponseContent, |
| 691 |
parse_obj_as( |
| 692 |
type_=UpdateResourceServerResponseContent, |
| 693 |
object_=_response.json(), |
| 694 |
), |
| 695 |
) |
| 696 |
return HttpResponse(response=_response, data=_data) |
| 697 |
if _response.status_code == 400: |
| 698 |
raise BadRequestError( |
| 699 |
headers=dict(_response.headers), |
| 700 |
body=typing.cast( |
| 701 |
typing.Any, |
| 702 |
parse_obj_as( |
| 703 |
type_=typing.Any, |
| 704 |
object_=_response.json(), |
| 705 |
), |
| 706 |
), |
| 707 |
) |
| 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 == 409: |
| 731 |
raise ConflictError( |
| 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 |
if _response.status_code == 429: |
| 742 |
raise TooManyRequestsError( |
| 743 |
headers=dict(_response.headers), |
| 744 |
body=typing.cast( |
| 745 |
typing.Any, |
| 746 |
parse_obj_as( |
| 747 |
type_=typing.Any, |
| 748 |
object_=_response.json(), |
| 749 |
), |
| 750 |
), |
| 751 |
) |
| 752 |
_response_json = _response.json() |
| 753 |
except JSONDecodeError: |
| 754 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 755 |
except ValidationError as e: |
| 756 |
raise ParsingError( |
| 757 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 758 |
) |
| 759 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 760 |
|
| 761 |
|
| 762 |
class AsyncRawResourceServersClient: |
| 763 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 764 |
self._client_wrapper = client_wrapper |
| 765 |
|
| 766 |
async def list( |
| 767 |
self, |
| 768 |
*, |
| 769 |
identifiers: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, |
| 770 |
page: typing.Optional[int] = 0, |
| 771 |
per_page: typing.Optional[int] = 50, |
| 772 |
include_totals: typing.Optional[bool] = True, |
| 773 |
include_fields: typing.Optional[bool] = None, |
| 774 |
request_options: typing.Optional[RequestOptions] = None, |
| 775 |
) -> AsyncPager[ResourceServer, ListResourceServerOffsetPaginatedResponseContent]: |
| 776 |
""" |
| 777 |
Retrieve details of all APIs associated with your tenant. |
| 778 |
|
| 779 |
Parameters |
| 780 |
---------- |
| 781 |
identifiers : typing.Optional[typing.Union[str, typing.Sequence[str]]] |
| 782 |
An optional filter on the resource server identifier. Must be URL encoded and may be specified multiple times (max 10).<br /><b>e.g.</b> <i>../resource-servers?identifiers=id1&identifiers=id2</i> |
| 783 |
|
| 784 |
page : typing.Optional[int] |
| 785 |
Page index of the results to return. First page is 0. |
| 786 |
|
| 787 |
per_page : typing.Optional[int] |
| 788 |
Number of results per page. |
| 789 |
|
| 790 |
include_totals : typing.Optional[bool] |
| 791 |
Return results inside an object that contains the total result count (true) or as a direct array of results (false, default). |
| 792 |
|
| 793 |
include_fields : typing.Optional[bool] |
| 794 |
Whether specified fields are to be included (true) or excluded (false). |
| 795 |
|
| 796 |
request_options : typing.Optional[RequestOptions] |
| 797 |
Request-specific configuration. |
| 798 |
|
| 799 |
Returns |
| 800 |
------- |
| 801 |
AsyncPager[ResourceServer, ListResourceServerOffsetPaginatedResponseContent] |
| 802 |
Resource servers successfully retrieved. |
| 803 |
""" |
| 804 |
page = page if page is not None else 0 |
| 805 |
|
| 806 |
_response = await self._client_wrapper.httpx_client.request( |
| 807 |
"resource-servers", |
| 808 |
method="GET", |
| 809 |
params={ |
| 810 |
"identifiers": identifiers, |
| 811 |
"page": page, |
| 812 |
"per_page": per_page, |
| 813 |
"include_totals": include_totals, |
| 814 |
"include_fields": include_fields, |
| 815 |
}, |
| 816 |
request_options=request_options, |
| 817 |
) |
| 818 |
try: |
| 819 |
if 200 <= _response.status_code < 300: |
| 820 |
_parsed_response = typing.cast( |
| 821 |
ListResourceServerOffsetPaginatedResponseContent, |
| 822 |
parse_obj_as( |
| 823 |
type_=ListResourceServerOffsetPaginatedResponseContent, |
| 824 |
object_=_response.json(), |
| 825 |
), |
| 826 |
) |
| 827 |
_items = _parsed_response.resource_servers |
| 828 |
_has_next = len(_items or []) > 0 |
| 829 |
|
| 830 |
async def _get_next(): |
| 831 |
return await self.list( |
| 832 |
identifiers=identifiers, |
| 833 |
page=page + 1, |
| 834 |
per_page=per_page, |
| 835 |
include_totals=include_totals, |
| 836 |
include_fields=include_fields, |
| 837 |
request_options=request_options, |
| 838 |
) |
| 839 |
|
| 840 |
return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) |
| 841 |
if _response.status_code == 400: |
| 842 |
raise BadRequestError( |
| 843 |
headers=dict(_response.headers), |
| 844 |
body=typing.cast( |
| 845 |
typing.Any, |
| 846 |
parse_obj_as( |
| 847 |
type_=typing.Any, |
| 848 |
object_=_response.json(), |
| 849 |
), |
| 850 |
), |
| 851 |
) |
| 852 |
if _response.status_code == 401: |
| 853 |
raise UnauthorizedError( |
| 854 |
headers=dict(_response.headers), |
| 855 |
body=typing.cast( |
| 856 |
typing.Any, |
| 857 |
parse_obj_as( |
| 858 |
type_=typing.Any, |
| 859 |
object_=_response.json(), |
| 860 |
), |
| 861 |
), |
| 862 |
) |
| 863 |
if _response.status_code == 403: |
| 864 |
raise ForbiddenError( |
| 865 |
headers=dict(_response.headers), |
| 866 |
body=typing.cast( |
| 867 |
typing.Any, |
| 868 |
parse_obj_as( |
| 869 |
type_=typing.Any, |
| 870 |
object_=_response.json(), |
| 871 |
), |
| 872 |
), |
| 873 |
) |
| 874 |
if _response.status_code == 429: |
| 875 |
raise TooManyRequestsError( |
| 876 |
headers=dict(_response.headers), |
| 877 |
body=typing.cast( |
| 878 |
typing.Any, |
| 879 |
parse_obj_as( |
| 880 |
type_=typing.Any, |
| 881 |
object_=_response.json(), |
| 882 |
), |
| 883 |
), |
| 884 |
) |
| 885 |
_response_json = _response.json() |
| 886 |
except JSONDecodeError: |
| 887 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 888 |
except ValidationError as e: |
| 889 |
raise ParsingError( |
| 890 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 891 |
) |
| 892 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 893 |
|
| 894 |
async def create( |
| 895 |
self, |
| 896 |
*, |
| 897 |
identifier: str, |
| 898 |
name: typing.Optional[str] = OMIT, |
| 899 |
scopes: typing.Optional[typing.Sequence[ResourceServerScope]] = OMIT, |
| 900 |
signing_alg: typing.Optional[SigningAlgorithmEnum] = OMIT, |
| 901 |
signing_secret: typing.Optional[str] = OMIT, |
| 902 |
allow_offline_access: typing.Optional[bool] = OMIT, |
| 903 |
allow_online_access: typing.Optional[bool] = OMIT, |
| 904 |
allow_online_access_with_ephemeral_sessions: typing.Optional[bool] = OMIT, |
| 905 |
token_lifetime: typing.Optional[int] = OMIT, |
| 906 |
token_dialect: typing.Optional[ResourceServerTokenDialectSchemaEnum] = OMIT, |
| 907 |
skip_consent_for_verifiable_first_party_clients: typing.Optional[bool] = OMIT, |
| 908 |
enforce_policies: typing.Optional[bool] = OMIT, |
| 909 |
token_encryption: typing.Optional[ResourceServerTokenEncryption] = OMIT, |
| 910 |
consent_policy: typing.Optional[ResourceServerConsentPolicyEnum] = OMIT, |
| 911 |
authorization_details: typing.Optional[typing.Sequence[typing.Any]] = OMIT, |
| 912 |
proof_of_possession: typing.Optional[ResourceServerProofOfPossession] = OMIT, |
| 913 |
subject_type_authorization: typing.Optional[ResourceServerSubjectTypeAuthorization] = OMIT, |
| 914 |
authorization_policy: typing.Optional[ResourceServerAuthorizationPolicy] = OMIT, |
| 915 |
request_options: typing.Optional[RequestOptions] = None, |
| 916 |
) -> AsyncHttpResponse[CreateResourceServerResponseContent]: |
| 917 |
""" |
| 918 |
Create a new API associated with your tenant. Note that all new APIs must be registered with Auth0. For more information, read <a href="https://www.auth0.com/docs/get-started/apis"> APIs</a>. |
| 919 |
|
| 920 |
Parameters |
| 921 |
---------- |
| 922 |
identifier : str |
| 923 |
Unique identifier for the API used as the audience parameter on authorization calls. Can not be changed once set. |
| 924 |
|
| 925 |
name : typing.Optional[str] |
| 926 |
Friendly name for this resource server. Can not contain `<` or `>` characters. |
| 927 |
|
| 928 |
scopes : typing.Optional[typing.Sequence[ResourceServerScope]] |
| 929 |
List of permissions (scopes) that this API uses. |
| 930 |
|
| 931 |
signing_alg : typing.Optional[SigningAlgorithmEnum] |
| 932 |
|
| 933 |
signing_secret : typing.Optional[str] |
| 934 |
Secret used to sign tokens when using symmetric algorithms (HS256). |
| 935 |
|
| 936 |
allow_offline_access : typing.Optional[bool] |
| 937 |
Whether refresh tokens can be issued for this API (true) or not (false). |
| 938 |
|
| 939 |
allow_online_access : typing.Optional[bool] |
| 940 |
Whether Online Refresh Tokens can be issued for this API (true) or not (false). |
| 941 |
|
| 942 |
allow_online_access_with_ephemeral_sessions : typing.Optional[bool] |
| 943 |
Whether Online Refresh Tokens can be issued even when sessions are configured as ephemeral (true) or not (false). |
| 944 |
|
| 945 |
token_lifetime : typing.Optional[int] |
| 946 |
Expiration value (in seconds) for access tokens issued for this API from the token endpoint. |
| 947 |
|
| 948 |
token_dialect : typing.Optional[ResourceServerTokenDialectSchemaEnum] |
| 949 |
|
| 950 |
skip_consent_for_verifiable_first_party_clients : typing.Optional[bool] |
| 951 |
Whether to skip user consent for applications flagged as first party (true) or not (false). |
| 952 |
|
| 953 |
enforce_policies : typing.Optional[bool] |
| 954 |
Whether to enforce authorization policies (true) or to ignore them (false). |
| 955 |
|
| 956 |
token_encryption : typing.Optional[ResourceServerTokenEncryption] |
| 957 |
|
| 958 |
consent_policy : typing.Optional[ResourceServerConsentPolicyEnum] |
| 959 |
|
| 960 |
authorization_details : typing.Optional[typing.Sequence[typing.Any]] |
| 961 |
|
| 962 |
proof_of_possession : typing.Optional[ResourceServerProofOfPossession] |
| 963 |
|
| 964 |
subject_type_authorization : typing.Optional[ResourceServerSubjectTypeAuthorization] |
| 965 |
|
| 966 |
authorization_policy : typing.Optional[ResourceServerAuthorizationPolicy] |
| 967 |
|
| 968 |
request_options : typing.Optional[RequestOptions] |
| 969 |
Request-specific configuration. |
| 970 |
|
| 971 |
Returns |
| 972 |
------- |
| 973 |
AsyncHttpResponse[CreateResourceServerResponseContent] |
| 974 |
Resource server successfully created. |
| 975 |
""" |
| 976 |
_response = await self._client_wrapper.httpx_client.request( |
| 977 |
"resource-servers", |
| 978 |
method="POST", |
| 979 |
json={ |
| 980 |
"name": name, |
| 981 |
"identifier": identifier, |
| 982 |
"scopes": convert_and_respect_annotation_metadata( |
| 983 |
object_=scopes, annotation=typing.Sequence[ResourceServerScope], direction="write" |
| 984 |
), |
| 985 |
"signing_alg": signing_alg, |
| 986 |
"signing_secret": signing_secret, |
| 987 |
"allow_offline_access": allow_offline_access, |
| 988 |
"allow_online_access": allow_online_access, |
| 989 |
"allow_online_access_with_ephemeral_sessions": allow_online_access_with_ephemeral_sessions, |
| 990 |
"token_lifetime": token_lifetime, |
| 991 |
"token_dialect": token_dialect, |
| 992 |
"skip_consent_for_verifiable_first_party_clients": skip_consent_for_verifiable_first_party_clients, |
| 993 |
"enforce_policies": enforce_policies, |
| 994 |
"token_encryption": convert_and_respect_annotation_metadata( |
| 995 |
object_=token_encryption, |
| 996 |
annotation=typing.Optional[ResourceServerTokenEncryption], |
| 997 |
direction="write", |
| 998 |
), |
| 999 |
"consent_policy": consent_policy, |
| 1000 |
"authorization_details": authorization_details, |
| 1001 |
"proof_of_possession": convert_and_respect_annotation_metadata( |
| 1002 |
object_=proof_of_possession, |
| 1003 |
annotation=typing.Optional[ResourceServerProofOfPossession], |
| 1004 |
direction="write", |
| 1005 |
), |
| 1006 |
"subject_type_authorization": convert_and_respect_annotation_metadata( |
| 1007 |
object_=subject_type_authorization, |
| 1008 |
annotation=ResourceServerSubjectTypeAuthorization, |
| 1009 |
direction="write", |
| 1010 |
), |
| 1011 |
"authorization_policy": convert_and_respect_annotation_metadata( |
| 1012 |
object_=authorization_policy, |
| 1013 |
annotation=typing.Optional[ResourceServerAuthorizationPolicy], |
| 1014 |
direction="write", |
| 1015 |
), |
| 1016 |
}, |
| 1017 |
headers={ |
| 1018 |
"content-type": "application/json", |
| 1019 |
}, |
| 1020 |
request_options=request_options, |
| 1021 |
omit=OMIT, |
| 1022 |
) |
| 1023 |
try: |
| 1024 |
if 200 <= _response.status_code < 300: |
| 1025 |
_data = typing.cast( |
| 1026 |
CreateResourceServerResponseContent, |
| 1027 |
parse_obj_as( |
| 1028 |
type_=CreateResourceServerResponseContent, |
| 1029 |
object_=_response.json(), |
| 1030 |
), |
| 1031 |
) |
| 1032 |
return AsyncHttpResponse(response=_response, data=_data) |
| 1033 |
if _response.status_code == 400: |
| 1034 |
raise BadRequestError( |
| 1035 |
headers=dict(_response.headers), |
| 1036 |
body=typing.cast( |
| 1037 |
typing.Any, |
| 1038 |
parse_obj_as( |
| 1039 |
type_=typing.Any, |
| 1040 |
object_=_response.json(), |
| 1041 |
), |
| 1042 |
), |
| 1043 |
) |
| 1044 |
if _response.status_code == 401: |
| 1045 |
raise UnauthorizedError( |
| 1046 |
headers=dict(_response.headers), |
| 1047 |
body=typing.cast( |
| 1048 |
typing.Any, |
| 1049 |
parse_obj_as( |
| 1050 |
type_=typing.Any, |
| 1051 |
object_=_response.json(), |
| 1052 |
), |
| 1053 |
), |
| 1054 |
) |
| 1055 |
if _response.status_code == 403: |
| 1056 |
raise ForbiddenError( |
| 1057 |
headers=dict(_response.headers), |
| 1058 |
body=typing.cast( |
| 1059 |
typing.Any, |
| 1060 |
parse_obj_as( |
| 1061 |
type_=typing.Any, |
| 1062 |
object_=_response.json(), |
| 1063 |
), |
| 1064 |
), |
| 1065 |
) |
| 1066 |
if _response.status_code == 409: |
| 1067 |
raise ConflictError( |
| 1068 |
headers=dict(_response.headers), |
| 1069 |
body=typing.cast( |
| 1070 |
typing.Any, |
| 1071 |
parse_obj_as( |
| 1072 |
type_=typing.Any, |
| 1073 |
object_=_response.json(), |
| 1074 |
), |
| 1075 |
), |
| 1076 |
) |
| 1077 |
if _response.status_code == 429: |
| 1078 |
raise TooManyRequestsError( |
| 1079 |
headers=dict(_response.headers), |
| 1080 |
body=typing.cast( |
| 1081 |
typing.Any, |
| 1082 |
parse_obj_as( |
| 1083 |
type_=typing.Any, |
| 1084 |
object_=_response.json(), |
| 1085 |
), |
| 1086 |
), |
| 1087 |
) |
| 1088 |
_response_json = _response.json() |
| 1089 |
except JSONDecodeError: |
| 1090 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1091 |
except ValidationError as e: |
| 1092 |
raise ParsingError( |
| 1093 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1094 |
) |
| 1095 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1096 |
|
| 1097 |
async def get( |
| 1098 |
self, |
| 1099 |
id: str, |
| 1100 |
*, |
| 1101 |
include_fields: typing.Optional[bool] = None, |
| 1102 |
request_options: typing.Optional[RequestOptions] = None, |
| 1103 |
) -> AsyncHttpResponse[GetResourceServerResponseContent]: |
| 1104 |
""" |
| 1105 |
Retrieve <a href="https://auth0.com/docs/apis">API</a> details with the given ID. |
| 1106 |
|
| 1107 |
Parameters |
| 1108 |
---------- |
| 1109 |
id : str |
| 1110 |
ID or audience of the resource server to retrieve. |
| 1111 |
|
| 1112 |
include_fields : typing.Optional[bool] |
| 1113 |
Whether specified fields are to be included (true) or excluded (false). |
| 1114 |
|
| 1115 |
request_options : typing.Optional[RequestOptions] |
| 1116 |
Request-specific configuration. |
| 1117 |
|
| 1118 |
Returns |
| 1119 |
------- |
| 1120 |
AsyncHttpResponse[GetResourceServerResponseContent] |
| 1121 |
Resource server successfully retrieved. |
| 1122 |
""" |
| 1123 |
_response = await self._client_wrapper.httpx_client.request( |
| 1124 |
f"resource-servers/{encode_path_param(id)}", |
| 1125 |
method="GET", |
| 1126 |
params={ |
| 1127 |
"include_fields": include_fields, |
| 1128 |
}, |
| 1129 |
request_options=request_options, |
| 1130 |
) |
| 1131 |
try: |
| 1132 |
if 200 <= _response.status_code < 300: |
| 1133 |
_data = typing.cast( |
| 1134 |
GetResourceServerResponseContent, |
| 1135 |
parse_obj_as( |
| 1136 |
type_=GetResourceServerResponseContent, |
| 1137 |
object_=_response.json(), |
| 1138 |
), |
| 1139 |
) |
| 1140 |
return AsyncHttpResponse(response=_response, data=_data) |
| 1141 |
if _response.status_code == 400: |
| 1142 |
raise BadRequestError( |
| 1143 |
headers=dict(_response.headers), |
| 1144 |
body=typing.cast( |
| 1145 |
typing.Any, |
| 1146 |
parse_obj_as( |
| 1147 |
type_=typing.Any, |
| 1148 |
object_=_response.json(), |
| 1149 |
), |
| 1150 |
), |
| 1151 |
) |
| 1152 |
if _response.status_code == 401: |
| 1153 |
raise UnauthorizedError( |
| 1154 |
headers=dict(_response.headers), |
| 1155 |
body=typing.cast( |
| 1156 |
typing.Any, |
| 1157 |
parse_obj_as( |
| 1158 |
type_=typing.Any, |
| 1159 |
object_=_response.json(), |
| 1160 |
), |
| 1161 |
), |
| 1162 |
) |
| 1163 |
if _response.status_code == 403: |
| 1164 |
raise ForbiddenError( |
| 1165 |
headers=dict(_response.headers), |
| 1166 |
body=typing.cast( |
| 1167 |
typing.Any, |
| 1168 |
parse_obj_as( |
| 1169 |
type_=typing.Any, |
| 1170 |
object_=_response.json(), |
| 1171 |
), |
| 1172 |
), |
| 1173 |
) |
| 1174 |
if _response.status_code == 404: |
| 1175 |
raise NotFoundError( |
| 1176 |
headers=dict(_response.headers), |
| 1177 |
body=typing.cast( |
| 1178 |
typing.Any, |
| 1179 |
parse_obj_as( |
| 1180 |
type_=typing.Any, |
| 1181 |
object_=_response.json(), |
| 1182 |
), |
| 1183 |
), |
| 1184 |
) |
| 1185 |
if _response.status_code == 429: |
| 1186 |
raise TooManyRequestsError( |
| 1187 |
headers=dict(_response.headers), |
| 1188 |
body=typing.cast( |
| 1189 |
typing.Any, |
| 1190 |
parse_obj_as( |
| 1191 |
type_=typing.Any, |
| 1192 |
object_=_response.json(), |
| 1193 |
), |
| 1194 |
), |
| 1195 |
) |
| 1196 |
_response_json = _response.json() |
| 1197 |
except JSONDecodeError: |
| 1198 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1199 |
except ValidationError as e: |
| 1200 |
raise ParsingError( |
| 1201 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1202 |
) |
| 1203 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1204 |
|
| 1205 |
async def delete( |
| 1206 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 1207 |
) -> AsyncHttpResponse[None]: |
| 1208 |
""" |
| 1209 |
Delete an existing API by ID. For more information, read <a href="https://www.auth0.com/docs/get-started/apis/api-settings">API Settings</a>. |
| 1210 |
|
| 1211 |
Parameters |
| 1212 |
---------- |
| 1213 |
id : str |
| 1214 |
ID or the audience of the resource server to delete. |
| 1215 |
|
| 1216 |
request_options : typing.Optional[RequestOptions] |
| 1217 |
Request-specific configuration. |
| 1218 |
|
| 1219 |
Returns |
| 1220 |
------- |
| 1221 |
AsyncHttpResponse[None] |
| 1222 |
""" |
| 1223 |
_response = await self._client_wrapper.httpx_client.request( |
| 1224 |
f"resource-servers/{encode_path_param(id)}", |
| 1225 |
method="DELETE", |
| 1226 |
request_options=request_options, |
| 1227 |
) |
| 1228 |
try: |
| 1229 |
if 200 <= _response.status_code < 300: |
| 1230 |
return AsyncHttpResponse(response=_response, data=None) |
| 1231 |
if _response.status_code == 400: |
| 1232 |
raise BadRequestError( |
| 1233 |
headers=dict(_response.headers), |
| 1234 |
body=typing.cast( |
| 1235 |
typing.Any, |
| 1236 |
parse_obj_as( |
| 1237 |
type_=typing.Any, |
| 1238 |
object_=_response.json(), |
| 1239 |
), |
| 1240 |
), |
| 1241 |
) |
| 1242 |
if _response.status_code == 401: |
| 1243 |
raise UnauthorizedError( |
| 1244 |
headers=dict(_response.headers), |
| 1245 |
body=typing.cast( |
| 1246 |
typing.Any, |
| 1247 |
parse_obj_as( |
| 1248 |
type_=typing.Any, |
| 1249 |
object_=_response.json(), |
| 1250 |
), |
| 1251 |
), |
| 1252 |
) |
| 1253 |
if _response.status_code == 403: |
| 1254 |
raise ForbiddenError( |
| 1255 |
headers=dict(_response.headers), |
| 1256 |
body=typing.cast( |
| 1257 |
typing.Any, |
| 1258 |
parse_obj_as( |
| 1259 |
type_=typing.Any, |
| 1260 |
object_=_response.json(), |
| 1261 |
), |
| 1262 |
), |
| 1263 |
) |
| 1264 |
if _response.status_code == 429: |
| 1265 |
raise TooManyRequestsError( |
| 1266 |
headers=dict(_response.headers), |
| 1267 |
body=typing.cast( |
| 1268 |
typing.Any, |
| 1269 |
parse_obj_as( |
| 1270 |
type_=typing.Any, |
| 1271 |
object_=_response.json(), |
| 1272 |
), |
| 1273 |
), |
| 1274 |
) |
| 1275 |
_response_json = _response.json() |
| 1276 |
except JSONDecodeError: |
| 1277 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1278 |
except ValidationError as e: |
| 1279 |
raise ParsingError( |
| 1280 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1281 |
) |
| 1282 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1283 |
|
| 1284 |
async def update( |
| 1285 |
self, |
| 1286 |
id: str, |
| 1287 |
*, |
| 1288 |
name: typing.Optional[str] = OMIT, |
| 1289 |
scopes: typing.Optional[typing.Sequence[ResourceServerScope]] = OMIT, |
| 1290 |
signing_alg: typing.Optional[SigningAlgorithmEnum] = OMIT, |
| 1291 |
signing_secret: typing.Optional[str] = OMIT, |
| 1292 |
skip_consent_for_verifiable_first_party_clients: typing.Optional[bool] = OMIT, |
| 1293 |
allow_offline_access: typing.Optional[bool] = OMIT, |
| 1294 |
allow_online_access: typing.Optional[bool] = OMIT, |
| 1295 |
allow_online_access_with_ephemeral_sessions: typing.Optional[bool] = OMIT, |
| 1296 |
token_lifetime: typing.Optional[int] = OMIT, |
| 1297 |
token_dialect: typing.Optional[ResourceServerTokenDialectSchemaEnum] = OMIT, |
| 1298 |
enforce_policies: typing.Optional[bool] = OMIT, |
| 1299 |
token_encryption: typing.Optional[ResourceServerTokenEncryption] = OMIT, |
| 1300 |
consent_policy: typing.Optional[ResourceServerConsentPolicyEnum] = OMIT, |
| 1301 |
authorization_details: typing.Optional[typing.Sequence[typing.Any]] = OMIT, |
| 1302 |
proof_of_possession: typing.Optional[ResourceServerProofOfPossession] = OMIT, |
| 1303 |
subject_type_authorization: typing.Optional[ResourceServerSubjectTypeAuthorization] = OMIT, |
| 1304 |
authorization_policy: typing.Optional[ResourceServerAuthorizationPolicy] = OMIT, |
| 1305 |
request_options: typing.Optional[RequestOptions] = None, |
| 1306 |
) -> AsyncHttpResponse[UpdateResourceServerResponseContent]: |
| 1307 |
""" |
| 1308 |
Change an existing API setting by resource server ID. For more information, read <a href="https://www.auth0.com/docs/get-started/apis/api-settings">API Settings</a>. |
| 1309 |
|
| 1310 |
Parameters |
| 1311 |
---------- |
| 1312 |
id : str |
| 1313 |
ID or audience of the resource server to update. |
| 1314 |
|
| 1315 |
name : typing.Optional[str] |
| 1316 |
Friendly name for this resource server. Can not contain `<` or `>` characters. |
| 1317 |
|
| 1318 |
scopes : typing.Optional[typing.Sequence[ResourceServerScope]] |
| 1319 |
List of permissions (scopes) that this API uses. |
| 1320 |
|
| 1321 |
signing_alg : typing.Optional[SigningAlgorithmEnum] |
| 1322 |
|
| 1323 |
signing_secret : typing.Optional[str] |
| 1324 |
Secret used to sign tokens when using symmetric algorithms (HS256). |
| 1325 |
|
| 1326 |
skip_consent_for_verifiable_first_party_clients : typing.Optional[bool] |
| 1327 |
Whether to skip user consent for applications flagged as first party (true) or not (false). |
| 1328 |
|
| 1329 |
allow_offline_access : typing.Optional[bool] |
| 1330 |
Whether refresh tokens can be issued for this API (true) or not (false). |
| 1331 |
|
| 1332 |
allow_online_access : typing.Optional[bool] |
| 1333 |
Whether Online Refresh Tokens can be issued for this API (true) or not (false). |
| 1334 |
|
| 1335 |
allow_online_access_with_ephemeral_sessions : typing.Optional[bool] |
| 1336 |
Whether Online Refresh Tokens can be issued even when sessions are configured as ephemeral (true) or not (false). |
| 1337 |
|
| 1338 |
token_lifetime : typing.Optional[int] |
| 1339 |
Expiration value (in seconds) for access tokens issued for this API from the token endpoint. |
| 1340 |
|
| 1341 |
token_dialect : typing.Optional[ResourceServerTokenDialectSchemaEnum] |
| 1342 |
|
| 1343 |
enforce_policies : typing.Optional[bool] |
| 1344 |
Whether authorization policies are enforced (true) or not enforced (false). |
| 1345 |
|
| 1346 |
token_encryption : typing.Optional[ResourceServerTokenEncryption] |
| 1347 |
|
| 1348 |
consent_policy : typing.Optional[ResourceServerConsentPolicyEnum] |
| 1349 |
|
| 1350 |
authorization_details : typing.Optional[typing.Sequence[typing.Any]] |
| 1351 |
|
| 1352 |
proof_of_possession : typing.Optional[ResourceServerProofOfPossession] |
| 1353 |
|
| 1354 |
subject_type_authorization : typing.Optional[ResourceServerSubjectTypeAuthorization] |
| 1355 |
|
| 1356 |
authorization_policy : typing.Optional[ResourceServerAuthorizationPolicy] |
| 1357 |
|
| 1358 |
request_options : typing.Optional[RequestOptions] |
| 1359 |
Request-specific configuration. |
| 1360 |
|
| 1361 |
Returns |
| 1362 |
------- |
| 1363 |
AsyncHttpResponse[UpdateResourceServerResponseContent] |
| 1364 |
Resource server successfully updated. |
| 1365 |
""" |
| 1366 |
_response = await self._client_wrapper.httpx_client.request( |
| 1367 |
f"resource-servers/{encode_path_param(id)}", |
| 1368 |
method="PATCH", |
| 1369 |
json={ |
| 1370 |
"name": name, |
| 1371 |
"scopes": convert_and_respect_annotation_metadata( |
| 1372 |
object_=scopes, annotation=typing.Sequence[ResourceServerScope], direction="write" |
| 1373 |
), |
| 1374 |
"signing_alg": signing_alg, |
| 1375 |
"signing_secret": signing_secret, |
| 1376 |
"skip_consent_for_verifiable_first_party_clients": skip_consent_for_verifiable_first_party_clients, |
| 1377 |
"allow_offline_access": allow_offline_access, |
| 1378 |
"allow_online_access": allow_online_access, |
| 1379 |
"allow_online_access_with_ephemeral_sessions": allow_online_access_with_ephemeral_sessions, |
| 1380 |
"token_lifetime": token_lifetime, |
| 1381 |
"token_dialect": token_dialect, |
| 1382 |
"enforce_policies": enforce_policies, |
| 1383 |
"token_encryption": convert_and_respect_annotation_metadata( |
| 1384 |
object_=token_encryption, |
| 1385 |
annotation=typing.Optional[ResourceServerTokenEncryption], |
| 1386 |
direction="write", |
| 1387 |
), |
| 1388 |
"consent_policy": consent_policy, |
| 1389 |
"authorization_details": authorization_details, |
| 1390 |
"proof_of_possession": convert_and_respect_annotation_metadata( |
| 1391 |
object_=proof_of_possession, |
| 1392 |
annotation=typing.Optional[ResourceServerProofOfPossession], |
| 1393 |
direction="write", |
| 1394 |
), |
| 1395 |
"subject_type_authorization": convert_and_respect_annotation_metadata( |
| 1396 |
object_=subject_type_authorization, |
| 1397 |
annotation=ResourceServerSubjectTypeAuthorization, |
| 1398 |
direction="write", |
| 1399 |
), |
| 1400 |
"authorization_policy": convert_and_respect_annotation_metadata( |
| 1401 |
object_=authorization_policy, |
| 1402 |
annotation=typing.Optional[ResourceServerAuthorizationPolicy], |
| 1403 |
direction="write", |
| 1404 |
), |
| 1405 |
}, |
| 1406 |
headers={ |
| 1407 |
"content-type": "application/json", |
| 1408 |
}, |
| 1409 |
request_options=request_options, |
| 1410 |
omit=OMIT, |
| 1411 |
) |
| 1412 |
try: |
| 1413 |
if 200 <= _response.status_code < 300: |
| 1414 |
_data = typing.cast( |
| 1415 |
UpdateResourceServerResponseContent, |
| 1416 |
parse_obj_as( |
| 1417 |
type_=UpdateResourceServerResponseContent, |
| 1418 |
object_=_response.json(), |
| 1419 |
), |
| 1420 |
) |
| 1421 |
return AsyncHttpResponse(response=_response, data=_data) |
| 1422 |
if _response.status_code == 400: |
| 1423 |
raise BadRequestError( |
| 1424 |
headers=dict(_response.headers), |
| 1425 |
body=typing.cast( |
| 1426 |
typing.Any, |
| 1427 |
parse_obj_as( |
| 1428 |
type_=typing.Any, |
| 1429 |
object_=_response.json(), |
| 1430 |
), |
| 1431 |
), |
| 1432 |
) |
| 1433 |
if _response.status_code == 401: |
| 1434 |
raise UnauthorizedError( |
| 1435 |
headers=dict(_response.headers), |
| 1436 |
body=typing.cast( |
| 1437 |
typing.Any, |
| 1438 |
parse_obj_as( |
| 1439 |
type_=typing.Any, |
| 1440 |
object_=_response.json(), |
| 1441 |
), |
| 1442 |
), |
| 1443 |
) |
| 1444 |
if _response.status_code == 403: |
| 1445 |
raise ForbiddenError( |
| 1446 |
headers=dict(_response.headers), |
| 1447 |
body=typing.cast( |
| 1448 |
typing.Any, |
| 1449 |
parse_obj_as( |
| 1450 |
type_=typing.Any, |
| 1451 |
object_=_response.json(), |
| 1452 |
), |
| 1453 |
), |
| 1454 |
) |
| 1455 |
if _response.status_code == 409: |
| 1456 |
raise ConflictError( |
| 1457 |
headers=dict(_response.headers), |
| 1458 |
body=typing.cast( |
| 1459 |
typing.Any, |
| 1460 |
parse_obj_as( |
| 1461 |
type_=typing.Any, |
| 1462 |
object_=_response.json(), |
| 1463 |
), |
| 1464 |
), |
| 1465 |
) |
| 1466 |
if _response.status_code == 429: |
| 1467 |
raise TooManyRequestsError( |
| 1468 |
headers=dict(_response.headers), |
| 1469 |
body=typing.cast( |
| 1470 |
typing.Any, |
| 1471 |
parse_obj_as( |
| 1472 |
type_=typing.Any, |
| 1473 |
object_=_response.json(), |
| 1474 |
), |
| 1475 |
), |
| 1476 |
) |
| 1477 |
_response_json = _response.json() |
| 1478 |
except JSONDecodeError: |
| 1479 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1480 |
except ValidationError as e: |
| 1481 |
raise ParsingError( |
| 1482 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1483 |
) |
| 1484 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |