| 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.forbidden_error import ForbiddenError |
| 17 |
from ...errors.not_found_error import NotFoundError |
| 18 |
from ...errors.payment_required_error import PaymentRequiredError |
| 19 |
from ...errors.too_many_requests_error import TooManyRequestsError |
| 20 |
from ...errors.unauthorized_error import UnauthorizedError |
| 21 |
from ...types.acul_configs import AculConfigs |
| 22 |
from ...types.acul_context_configuration import AculContextConfiguration |
| 23 |
from ...types.acul_filters import AculFilters |
| 24 |
from ...types.acul_head_tag import AculHeadTag |
| 25 |
from ...types.acul_rendering_mode_enum import AculRenderingModeEnum |
| 26 |
from ...types.bulk_update_acul_response_content import BulkUpdateAculResponseContent |
| 27 |
from ...types.get_acul_response_content import GetAculResponseContent |
| 28 |
from ...types.list_aculs_offset_paginated_response_content import ListAculsOffsetPaginatedResponseContent |
| 29 |
from ...types.list_aculs_response_content_item import ListAculsResponseContentItem |
| 30 |
from ...types.prompt_group_name_enum import PromptGroupNameEnum |
| 31 |
from ...types.screen_group_name_enum import ScreenGroupNameEnum |
| 32 |
from ...types.update_acul_response_content import UpdateAculResponseContent |
| 33 |
from pydantic import ValidationError |
| 34 |
|
| 35 |
|
| 36 |
OMIT = typing.cast(typing.Any, ...) |
| 37 |
|
| 38 |
|
| 39 |
class RawRenderingClient: |
| 40 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 41 |
self._client_wrapper = client_wrapper |
| 42 |
|
| 43 |
def list( |
| 44 |
self, |
| 45 |
*, |
| 46 |
fields: typing.Optional[str] = None, |
| 47 |
include_fields: typing.Optional[bool] = None, |
| 48 |
page: typing.Optional[int] = 0, |
| 49 |
per_page: typing.Optional[int] = 50, |
| 50 |
include_totals: typing.Optional[bool] = True, |
| 51 |
prompt: typing.Optional[str] = None, |
| 52 |
screen: typing.Optional[str] = None, |
| 53 |
rendering_mode: typing.Optional[AculRenderingModeEnum] = None, |
| 54 |
request_options: typing.Optional[RequestOptions] = None, |
| 55 |
) -> SyncPager[ListAculsResponseContentItem, ListAculsOffsetPaginatedResponseContent]: |
| 56 |
""" |
| 57 |
Get render setting configurations for all screens. |
| 58 |
|
| 59 |
Parameters |
| 60 |
---------- |
| 61 |
fields : typing.Optional[str] |
| 62 |
Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields. |
| 63 |
|
| 64 |
include_fields : typing.Optional[bool] |
| 65 |
Whether specified fields are to be included (default: true) or excluded (false). |
| 66 |
|
| 67 |
page : typing.Optional[int] |
| 68 |
Page index of the results to return. First page is 0. |
| 69 |
|
| 70 |
per_page : typing.Optional[int] |
| 71 |
Number of results per page. Maximum value is 100, default value is 50. |
| 72 |
|
| 73 |
include_totals : typing.Optional[bool] |
| 74 |
Return results inside an object that contains the total configuration count (true) or as a direct array of results (false, default). |
| 75 |
|
| 76 |
prompt : typing.Optional[str] |
| 77 |
Name of the prompt to filter by |
| 78 |
|
| 79 |
screen : typing.Optional[str] |
| 80 |
Name of the screen to filter by |
| 81 |
|
| 82 |
rendering_mode : typing.Optional[AculRenderingModeEnum] |
| 83 |
Rendering mode to filter by |
| 84 |
|
| 85 |
request_options : typing.Optional[RequestOptions] |
| 86 |
Request-specific configuration. |
| 87 |
|
| 88 |
Returns |
| 89 |
------- |
| 90 |
SyncPager[ListAculsResponseContentItem, ListAculsOffsetPaginatedResponseContent] |
| 91 |
ACUL settings successfully retrieved. |
| 92 |
""" |
| 93 |
page = page if page is not None else 0 |
| 94 |
|
| 95 |
_response = self._client_wrapper.httpx_client.request( |
| 96 |
"prompts/rendering", |
| 97 |
method="GET", |
| 98 |
params={ |
| 99 |
"fields": fields, |
| 100 |
"include_fields": include_fields, |
| 101 |
"page": page, |
| 102 |
"per_page": per_page, |
| 103 |
"include_totals": include_totals, |
| 104 |
"prompt": prompt, |
| 105 |
"screen": screen, |
| 106 |
"rendering_mode": rendering_mode, |
| 107 |
}, |
| 108 |
request_options=request_options, |
| 109 |
) |
| 110 |
try: |
| 111 |
if 200 <= _response.status_code < 300: |
| 112 |
_parsed_response = typing.cast( |
| 113 |
ListAculsOffsetPaginatedResponseContent, |
| 114 |
parse_obj_as( |
| 115 |
type_=ListAculsOffsetPaginatedResponseContent, |
| 116 |
object_=_response.json(), |
| 117 |
), |
| 118 |
) |
| 119 |
_items = _parsed_response.configs |
| 120 |
_has_next = len(_items or []) > 0 |
| 121 |
_get_next = lambda: self.list( |
| 122 |
fields=fields, |
| 123 |
include_fields=include_fields, |
| 124 |
page=page + 1, |
| 125 |
per_page=per_page, |
| 126 |
include_totals=include_totals, |
| 127 |
prompt=prompt, |
| 128 |
screen=screen, |
| 129 |
rendering_mode=rendering_mode, |
| 130 |
request_options=request_options, |
| 131 |
) |
| 132 |
return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) |
| 133 |
if _response.status_code == 400: |
| 134 |
raise BadRequestError( |
| 135 |
headers=dict(_response.headers), |
| 136 |
body=typing.cast( |
| 137 |
typing.Any, |
| 138 |
parse_obj_as( |
| 139 |
type_=typing.Any, |
| 140 |
object_=_response.json(), |
| 141 |
), |
| 142 |
), |
| 143 |
) |
| 144 |
if _response.status_code == 401: |
| 145 |
raise UnauthorizedError( |
| 146 |
headers=dict(_response.headers), |
| 147 |
body=typing.cast( |
| 148 |
typing.Any, |
| 149 |
parse_obj_as( |
| 150 |
type_=typing.Any, |
| 151 |
object_=_response.json(), |
| 152 |
), |
| 153 |
), |
| 154 |
) |
| 155 |
if _response.status_code == 402: |
| 156 |
raise PaymentRequiredError( |
| 157 |
headers=dict(_response.headers), |
| 158 |
body=typing.cast( |
| 159 |
typing.Any, |
| 160 |
parse_obj_as( |
| 161 |
type_=typing.Any, |
| 162 |
object_=_response.json(), |
| 163 |
), |
| 164 |
), |
| 165 |
) |
| 166 |
if _response.status_code == 403: |
| 167 |
raise ForbiddenError( |
| 168 |
headers=dict(_response.headers), |
| 169 |
body=typing.cast( |
| 170 |
typing.Any, |
| 171 |
parse_obj_as( |
| 172 |
type_=typing.Any, |
| 173 |
object_=_response.json(), |
| 174 |
), |
| 175 |
), |
| 176 |
) |
| 177 |
if _response.status_code == 429: |
| 178 |
raise TooManyRequestsError( |
| 179 |
headers=dict(_response.headers), |
| 180 |
body=typing.cast( |
| 181 |
typing.Any, |
| 182 |
parse_obj_as( |
| 183 |
type_=typing.Any, |
| 184 |
object_=_response.json(), |
| 185 |
), |
| 186 |
), |
| 187 |
) |
| 188 |
_response_json = _response.json() |
| 189 |
except JSONDecodeError: |
| 190 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 191 |
except ValidationError as e: |
| 192 |
raise ParsingError( |
| 193 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 194 |
) |
| 195 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 196 |
|
| 197 |
def bulk_update( |
| 198 |
self, *, configs: AculConfigs, request_options: typing.Optional[RequestOptions] = None |
| 199 |
) -> HttpResponse[BulkUpdateAculResponseContent]: |
| 200 |
""" |
| 201 |
Learn more about [configuring render settings](https://auth0.com/docs/customize/login-pages/advanced-customizations/getting-started/configure-acul-screens) for advanced customization. |
| 202 |
|
| 203 |
Parameters |
| 204 |
---------- |
| 205 |
configs : AculConfigs |
| 206 |
|
| 207 |
request_options : typing.Optional[RequestOptions] |
| 208 |
Request-specific configuration. |
| 209 |
|
| 210 |
Returns |
| 211 |
------- |
| 212 |
HttpResponse[BulkUpdateAculResponseContent] |
| 213 |
ACUL settings successfully updated. |
| 214 |
""" |
| 215 |
_response = self._client_wrapper.httpx_client.request( |
| 216 |
"prompts/rendering", |
| 217 |
method="PATCH", |
| 218 |
json={ |
| 219 |
"configs": convert_and_respect_annotation_metadata( |
| 220 |
object_=configs, annotation=AculConfigs, direction="write" |
| 221 |
), |
| 222 |
}, |
| 223 |
headers={ |
| 224 |
"content-type": "application/json", |
| 225 |
}, |
| 226 |
request_options=request_options, |
| 227 |
omit=OMIT, |
| 228 |
) |
| 229 |
try: |
| 230 |
if 200 <= _response.status_code < 300: |
| 231 |
_data = typing.cast( |
| 232 |
BulkUpdateAculResponseContent, |
| 233 |
parse_obj_as( |
| 234 |
type_=BulkUpdateAculResponseContent, |
| 235 |
object_=_response.json(), |
| 236 |
), |
| 237 |
) |
| 238 |
return HttpResponse(response=_response, data=_data) |
| 239 |
if _response.status_code == 400: |
| 240 |
raise BadRequestError( |
| 241 |
headers=dict(_response.headers), |
| 242 |
body=typing.cast( |
| 243 |
typing.Any, |
| 244 |
parse_obj_as( |
| 245 |
type_=typing.Any, |
| 246 |
object_=_response.json(), |
| 247 |
), |
| 248 |
), |
| 249 |
) |
| 250 |
if _response.status_code == 401: |
| 251 |
raise UnauthorizedError( |
| 252 |
headers=dict(_response.headers), |
| 253 |
body=typing.cast( |
| 254 |
typing.Any, |
| 255 |
parse_obj_as( |
| 256 |
type_=typing.Any, |
| 257 |
object_=_response.json(), |
| 258 |
), |
| 259 |
), |
| 260 |
) |
| 261 |
if _response.status_code == 402: |
| 262 |
raise PaymentRequiredError( |
| 263 |
headers=dict(_response.headers), |
| 264 |
body=typing.cast( |
| 265 |
typing.Any, |
| 266 |
parse_obj_as( |
| 267 |
type_=typing.Any, |
| 268 |
object_=_response.json(), |
| 269 |
), |
| 270 |
), |
| 271 |
) |
| 272 |
if _response.status_code == 403: |
| 273 |
raise ForbiddenError( |
| 274 |
headers=dict(_response.headers), |
| 275 |
body=typing.cast( |
| 276 |
typing.Any, |
| 277 |
parse_obj_as( |
| 278 |
type_=typing.Any, |
| 279 |
object_=_response.json(), |
| 280 |
), |
| 281 |
), |
| 282 |
) |
| 283 |
if _response.status_code == 429: |
| 284 |
raise TooManyRequestsError( |
| 285 |
headers=dict(_response.headers), |
| 286 |
body=typing.cast( |
| 287 |
typing.Any, |
| 288 |
parse_obj_as( |
| 289 |
type_=typing.Any, |
| 290 |
object_=_response.json(), |
| 291 |
), |
| 292 |
), |
| 293 |
) |
| 294 |
_response_json = _response.json() |
| 295 |
except JSONDecodeError: |
| 296 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 297 |
except ValidationError as e: |
| 298 |
raise ParsingError( |
| 299 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 300 |
) |
| 301 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 302 |
|
| 303 |
def get( |
| 304 |
self, |
| 305 |
prompt: PromptGroupNameEnum, |
| 306 |
screen: ScreenGroupNameEnum, |
| 307 |
*, |
| 308 |
request_options: typing.Optional[RequestOptions] = None, |
| 309 |
) -> HttpResponse[GetAculResponseContent]: |
| 310 |
""" |
| 311 |
Get render settings for a screen. |
| 312 |
|
| 313 |
Parameters |
| 314 |
---------- |
| 315 |
prompt : PromptGroupNameEnum |
| 316 |
Name of the prompt |
| 317 |
|
| 318 |
screen : ScreenGroupNameEnum |
| 319 |
Name of the screen |
| 320 |
|
| 321 |
request_options : typing.Optional[RequestOptions] |
| 322 |
Request-specific configuration. |
| 323 |
|
| 324 |
Returns |
| 325 |
------- |
| 326 |
HttpResponse[GetAculResponseContent] |
| 327 |
ACUL settings successfully retrieved. |
| 328 |
""" |
| 329 |
_response = self._client_wrapper.httpx_client.request( |
| 330 |
f"prompts/{encode_path_param(prompt)}/screen/{encode_path_param(screen)}/rendering", |
| 331 |
method="GET", |
| 332 |
request_options=request_options, |
| 333 |
) |
| 334 |
try: |
| 335 |
if 200 <= _response.status_code < 300: |
| 336 |
_data = typing.cast( |
| 337 |
GetAculResponseContent, |
| 338 |
parse_obj_as( |
| 339 |
type_=GetAculResponseContent, |
| 340 |
object_=_response.json(), |
| 341 |
), |
| 342 |
) |
| 343 |
return HttpResponse(response=_response, data=_data) |
| 344 |
if _response.status_code == 400: |
| 345 |
raise BadRequestError( |
| 346 |
headers=dict(_response.headers), |
| 347 |
body=typing.cast( |
| 348 |
typing.Any, |
| 349 |
parse_obj_as( |
| 350 |
type_=typing.Any, |
| 351 |
object_=_response.json(), |
| 352 |
), |
| 353 |
), |
| 354 |
) |
| 355 |
if _response.status_code == 401: |
| 356 |
raise UnauthorizedError( |
| 357 |
headers=dict(_response.headers), |
| 358 |
body=typing.cast( |
| 359 |
typing.Any, |
| 360 |
parse_obj_as( |
| 361 |
type_=typing.Any, |
| 362 |
object_=_response.json(), |
| 363 |
), |
| 364 |
), |
| 365 |
) |
| 366 |
if _response.status_code == 402: |
| 367 |
raise PaymentRequiredError( |
| 368 |
headers=dict(_response.headers), |
| 369 |
body=typing.cast( |
| 370 |
typing.Any, |
| 371 |
parse_obj_as( |
| 372 |
type_=typing.Any, |
| 373 |
object_=_response.json(), |
| 374 |
), |
| 375 |
), |
| 376 |
) |
| 377 |
if _response.status_code == 403: |
| 378 |
raise ForbiddenError( |
| 379 |
headers=dict(_response.headers), |
| 380 |
body=typing.cast( |
| 381 |
typing.Any, |
| 382 |
parse_obj_as( |
| 383 |
type_=typing.Any, |
| 384 |
object_=_response.json(), |
| 385 |
), |
| 386 |
), |
| 387 |
) |
| 388 |
if _response.status_code == 404: |
| 389 |
raise NotFoundError( |
| 390 |
headers=dict(_response.headers), |
| 391 |
body=typing.cast( |
| 392 |
typing.Any, |
| 393 |
parse_obj_as( |
| 394 |
type_=typing.Any, |
| 395 |
object_=_response.json(), |
| 396 |
), |
| 397 |
), |
| 398 |
) |
| 399 |
if _response.status_code == 429: |
| 400 |
raise TooManyRequestsError( |
| 401 |
headers=dict(_response.headers), |
| 402 |
body=typing.cast( |
| 403 |
typing.Any, |
| 404 |
parse_obj_as( |
| 405 |
type_=typing.Any, |
| 406 |
object_=_response.json(), |
| 407 |
), |
| 408 |
), |
| 409 |
) |
| 410 |
_response_json = _response.json() |
| 411 |
except JSONDecodeError: |
| 412 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 413 |
except ValidationError as e: |
| 414 |
raise ParsingError( |
| 415 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 416 |
) |
| 417 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 418 |
|
| 419 |
def update( |
| 420 |
self, |
| 421 |
prompt: PromptGroupNameEnum, |
| 422 |
screen: ScreenGroupNameEnum, |
| 423 |
*, |
| 424 |
rendering_mode: typing.Optional[AculRenderingModeEnum] = OMIT, |
| 425 |
context_configuration: typing.Optional[AculContextConfiguration] = OMIT, |
| 426 |
default_head_tags_disabled: typing.Optional[bool] = OMIT, |
| 427 |
use_page_template: typing.Optional[bool] = OMIT, |
| 428 |
head_tags: typing.Optional[typing.Sequence[AculHeadTag]] = OMIT, |
| 429 |
filters: typing.Optional[AculFilters] = OMIT, |
| 430 |
request_options: typing.Optional[RequestOptions] = None, |
| 431 |
) -> HttpResponse[UpdateAculResponseContent]: |
| 432 |
""" |
| 433 |
Learn more about [configuring render settings](https://auth0.com/docs/customize/login-pages/advanced-customizations/getting-started/configure-acul-screens) for advanced customization. |
| 434 |
|
| 435 |
Parameters |
| 436 |
---------- |
| 437 |
prompt : PromptGroupNameEnum |
| 438 |
Name of the prompt |
| 439 |
|
| 440 |
screen : ScreenGroupNameEnum |
| 441 |
Name of the screen |
| 442 |
|
| 443 |
rendering_mode : typing.Optional[AculRenderingModeEnum] |
| 444 |
Rendering mode |
| 445 |
|
| 446 |
context_configuration : typing.Optional[AculContextConfiguration] |
| 447 |
|
| 448 |
default_head_tags_disabled : typing.Optional[bool] |
| 449 |
Override Universal Login default head tags |
| 450 |
|
| 451 |
use_page_template : typing.Optional[bool] |
| 452 |
Use page template with ACUL |
| 453 |
|
| 454 |
head_tags : typing.Optional[typing.Sequence[AculHeadTag]] |
| 455 |
An array of head tags |
| 456 |
|
| 457 |
filters : typing.Optional[AculFilters] |
| 458 |
|
| 459 |
request_options : typing.Optional[RequestOptions] |
| 460 |
Request-specific configuration. |
| 461 |
|
| 462 |
Returns |
| 463 |
------- |
| 464 |
HttpResponse[UpdateAculResponseContent] |
| 465 |
ACUL settings successfully updated. |
| 466 |
""" |
| 467 |
_response = self._client_wrapper.httpx_client.request( |
| 468 |
f"prompts/{encode_path_param(prompt)}/screen/{encode_path_param(screen)}/rendering", |
| 469 |
method="PATCH", |
| 470 |
json={ |
| 471 |
"rendering_mode": rendering_mode, |
| 472 |
"context_configuration": convert_and_respect_annotation_metadata( |
| 473 |
object_=context_configuration, |
| 474 |
annotation=typing.Optional[AculContextConfiguration], |
| 475 |
direction="write", |
| 476 |
), |
| 477 |
"default_head_tags_disabled": default_head_tags_disabled, |
| 478 |
"use_page_template": use_page_template, |
| 479 |
"head_tags": convert_and_respect_annotation_metadata( |
| 480 |
object_=head_tags, annotation=typing.Optional[typing.Sequence[AculHeadTag]], direction="write" |
| 481 |
), |
| 482 |
"filters": convert_and_respect_annotation_metadata( |
| 483 |
object_=filters, annotation=typing.Optional[AculFilters], direction="write" |
| 484 |
), |
| 485 |
}, |
| 486 |
headers={ |
| 487 |
"content-type": "application/json", |
| 488 |
}, |
| 489 |
request_options=request_options, |
| 490 |
omit=OMIT, |
| 491 |
) |
| 492 |
try: |
| 493 |
if 200 <= _response.status_code < 300: |
| 494 |
_data = typing.cast( |
| 495 |
UpdateAculResponseContent, |
| 496 |
parse_obj_as( |
| 497 |
type_=UpdateAculResponseContent, |
| 498 |
object_=_response.json(), |
| 499 |
), |
| 500 |
) |
| 501 |
return HttpResponse(response=_response, data=_data) |
| 502 |
if _response.status_code == 400: |
| 503 |
raise BadRequestError( |
| 504 |
headers=dict(_response.headers), |
| 505 |
body=typing.cast( |
| 506 |
typing.Any, |
| 507 |
parse_obj_as( |
| 508 |
type_=typing.Any, |
| 509 |
object_=_response.json(), |
| 510 |
), |
| 511 |
), |
| 512 |
) |
| 513 |
if _response.status_code == 401: |
| 514 |
raise UnauthorizedError( |
| 515 |
headers=dict(_response.headers), |
| 516 |
body=typing.cast( |
| 517 |
typing.Any, |
| 518 |
parse_obj_as( |
| 519 |
type_=typing.Any, |
| 520 |
object_=_response.json(), |
| 521 |
), |
| 522 |
), |
| 523 |
) |
| 524 |
if _response.status_code == 402: |
| 525 |
raise PaymentRequiredError( |
| 526 |
headers=dict(_response.headers), |
| 527 |
body=typing.cast( |
| 528 |
typing.Any, |
| 529 |
parse_obj_as( |
| 530 |
type_=typing.Any, |
| 531 |
object_=_response.json(), |
| 532 |
), |
| 533 |
), |
| 534 |
) |
| 535 |
if _response.status_code == 403: |
| 536 |
raise ForbiddenError( |
| 537 |
headers=dict(_response.headers), |
| 538 |
body=typing.cast( |
| 539 |
typing.Any, |
| 540 |
parse_obj_as( |
| 541 |
type_=typing.Any, |
| 542 |
object_=_response.json(), |
| 543 |
), |
| 544 |
), |
| 545 |
) |
| 546 |
if _response.status_code == 429: |
| 547 |
raise TooManyRequestsError( |
| 548 |
headers=dict(_response.headers), |
| 549 |
body=typing.cast( |
| 550 |
typing.Any, |
| 551 |
parse_obj_as( |
| 552 |
type_=typing.Any, |
| 553 |
object_=_response.json(), |
| 554 |
), |
| 555 |
), |
| 556 |
) |
| 557 |
_response_json = _response.json() |
| 558 |
except JSONDecodeError: |
| 559 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 560 |
except ValidationError as e: |
| 561 |
raise ParsingError( |
| 562 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 563 |
) |
| 564 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 565 |
|
| 566 |
|
| 567 |
class AsyncRawRenderingClient: |
| 568 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 569 |
self._client_wrapper = client_wrapper |
| 570 |
|
| 571 |
async def list( |
| 572 |
self, |
| 573 |
*, |
| 574 |
fields: typing.Optional[str] = None, |
| 575 |
include_fields: typing.Optional[bool] = None, |
| 576 |
page: typing.Optional[int] = 0, |
| 577 |
per_page: typing.Optional[int] = 50, |
| 578 |
include_totals: typing.Optional[bool] = True, |
| 579 |
prompt: typing.Optional[str] = None, |
| 580 |
screen: typing.Optional[str] = None, |
| 581 |
rendering_mode: typing.Optional[AculRenderingModeEnum] = None, |
| 582 |
request_options: typing.Optional[RequestOptions] = None, |
| 583 |
) -> AsyncPager[ListAculsResponseContentItem, ListAculsOffsetPaginatedResponseContent]: |
| 584 |
""" |
| 585 |
Get render setting configurations for all screens. |
| 586 |
|
| 587 |
Parameters |
| 588 |
---------- |
| 589 |
fields : typing.Optional[str] |
| 590 |
Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields. |
| 591 |
|
| 592 |
include_fields : typing.Optional[bool] |
| 593 |
Whether specified fields are to be included (default: true) or excluded (false). |
| 594 |
|
| 595 |
page : typing.Optional[int] |
| 596 |
Page index of the results to return. First page is 0. |
| 597 |
|
| 598 |
per_page : typing.Optional[int] |
| 599 |
Number of results per page. Maximum value is 100, default value is 50. |
| 600 |
|
| 601 |
include_totals : typing.Optional[bool] |
| 602 |
Return results inside an object that contains the total configuration count (true) or as a direct array of results (false, default). |
| 603 |
|
| 604 |
prompt : typing.Optional[str] |
| 605 |
Name of the prompt to filter by |
| 606 |
|
| 607 |
screen : typing.Optional[str] |
| 608 |
Name of the screen to filter by |
| 609 |
|
| 610 |
rendering_mode : typing.Optional[AculRenderingModeEnum] |
| 611 |
Rendering mode to filter by |
| 612 |
|
| 613 |
request_options : typing.Optional[RequestOptions] |
| 614 |
Request-specific configuration. |
| 615 |
|
| 616 |
Returns |
| 617 |
------- |
| 618 |
AsyncPager[ListAculsResponseContentItem, ListAculsOffsetPaginatedResponseContent] |
| 619 |
ACUL settings successfully retrieved. |
| 620 |
""" |
| 621 |
page = page if page is not None else 0 |
| 622 |
|
| 623 |
_response = await self._client_wrapper.httpx_client.request( |
| 624 |
"prompts/rendering", |
| 625 |
method="GET", |
| 626 |
params={ |
| 627 |
"fields": fields, |
| 628 |
"include_fields": include_fields, |
| 629 |
"page": page, |
| 630 |
"per_page": per_page, |
| 631 |
"include_totals": include_totals, |
| 632 |
"prompt": prompt, |
| 633 |
"screen": screen, |
| 634 |
"rendering_mode": rendering_mode, |
| 635 |
}, |
| 636 |
request_options=request_options, |
| 637 |
) |
| 638 |
try: |
| 639 |
if 200 <= _response.status_code < 300: |
| 640 |
_parsed_response = typing.cast( |
| 641 |
ListAculsOffsetPaginatedResponseContent, |
| 642 |
parse_obj_as( |
| 643 |
type_=ListAculsOffsetPaginatedResponseContent, |
| 644 |
object_=_response.json(), |
| 645 |
), |
| 646 |
) |
| 647 |
_items = _parsed_response.configs |
| 648 |
_has_next = len(_items or []) > 0 |
| 649 |
|
| 650 |
async def _get_next(): |
| 651 |
return await self.list( |
| 652 |
fields=fields, |
| 653 |
include_fields=include_fields, |
| 654 |
page=page + 1, |
| 655 |
per_page=per_page, |
| 656 |
include_totals=include_totals, |
| 657 |
prompt=prompt, |
| 658 |
screen=screen, |
| 659 |
rendering_mode=rendering_mode, |
| 660 |
request_options=request_options, |
| 661 |
) |
| 662 |
|
| 663 |
return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) |
| 664 |
if _response.status_code == 400: |
| 665 |
raise BadRequestError( |
| 666 |
headers=dict(_response.headers), |
| 667 |
body=typing.cast( |
| 668 |
typing.Any, |
| 669 |
parse_obj_as( |
| 670 |
type_=typing.Any, |
| 671 |
object_=_response.json(), |
| 672 |
), |
| 673 |
), |
| 674 |
) |
| 675 |
if _response.status_code == 401: |
| 676 |
raise UnauthorizedError( |
| 677 |
headers=dict(_response.headers), |
| 678 |
body=typing.cast( |
| 679 |
typing.Any, |
| 680 |
parse_obj_as( |
| 681 |
type_=typing.Any, |
| 682 |
object_=_response.json(), |
| 683 |
), |
| 684 |
), |
| 685 |
) |
| 686 |
if _response.status_code == 402: |
| 687 |
raise PaymentRequiredError( |
| 688 |
headers=dict(_response.headers), |
| 689 |
body=typing.cast( |
| 690 |
typing.Any, |
| 691 |
parse_obj_as( |
| 692 |
type_=typing.Any, |
| 693 |
object_=_response.json(), |
| 694 |
), |
| 695 |
), |
| 696 |
) |
| 697 |
if _response.status_code == 403: |
| 698 |
raise ForbiddenError( |
| 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 == 429: |
| 709 |
raise TooManyRequestsError( |
| 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 |
_response_json = _response.json() |
| 720 |
except JSONDecodeError: |
| 721 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 722 |
except ValidationError as e: |
| 723 |
raise ParsingError( |
| 724 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 725 |
) |
| 726 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 727 |
|
| 728 |
async def bulk_update( |
| 729 |
self, *, configs: AculConfigs, request_options: typing.Optional[RequestOptions] = None |
| 730 |
) -> AsyncHttpResponse[BulkUpdateAculResponseContent]: |
| 731 |
""" |
| 732 |
Learn more about [configuring render settings](https://auth0.com/docs/customize/login-pages/advanced-customizations/getting-started/configure-acul-screens) for advanced customization. |
| 733 |
|
| 734 |
Parameters |
| 735 |
---------- |
| 736 |
configs : AculConfigs |
| 737 |
|
| 738 |
request_options : typing.Optional[RequestOptions] |
| 739 |
Request-specific configuration. |
| 740 |
|
| 741 |
Returns |
| 742 |
------- |
| 743 |
AsyncHttpResponse[BulkUpdateAculResponseContent] |
| 744 |
ACUL settings successfully updated. |
| 745 |
""" |
| 746 |
_response = await self._client_wrapper.httpx_client.request( |
| 747 |
"prompts/rendering", |
| 748 |
method="PATCH", |
| 749 |
json={ |
| 750 |
"configs": convert_and_respect_annotation_metadata( |
| 751 |
object_=configs, annotation=AculConfigs, direction="write" |
| 752 |
), |
| 753 |
}, |
| 754 |
headers={ |
| 755 |
"content-type": "application/json", |
| 756 |
}, |
| 757 |
request_options=request_options, |
| 758 |
omit=OMIT, |
| 759 |
) |
| 760 |
try: |
| 761 |
if 200 <= _response.status_code < 300: |
| 762 |
_data = typing.cast( |
| 763 |
BulkUpdateAculResponseContent, |
| 764 |
parse_obj_as( |
| 765 |
type_=BulkUpdateAculResponseContent, |
| 766 |
object_=_response.json(), |
| 767 |
), |
| 768 |
) |
| 769 |
return AsyncHttpResponse(response=_response, data=_data) |
| 770 |
if _response.status_code == 400: |
| 771 |
raise BadRequestError( |
| 772 |
headers=dict(_response.headers), |
| 773 |
body=typing.cast( |
| 774 |
typing.Any, |
| 775 |
parse_obj_as( |
| 776 |
type_=typing.Any, |
| 777 |
object_=_response.json(), |
| 778 |
), |
| 779 |
), |
| 780 |
) |
| 781 |
if _response.status_code == 401: |
| 782 |
raise UnauthorizedError( |
| 783 |
headers=dict(_response.headers), |
| 784 |
body=typing.cast( |
| 785 |
typing.Any, |
| 786 |
parse_obj_as( |
| 787 |
type_=typing.Any, |
| 788 |
object_=_response.json(), |
| 789 |
), |
| 790 |
), |
| 791 |
) |
| 792 |
if _response.status_code == 402: |
| 793 |
raise PaymentRequiredError( |
| 794 |
headers=dict(_response.headers), |
| 795 |
body=typing.cast( |
| 796 |
typing.Any, |
| 797 |
parse_obj_as( |
| 798 |
type_=typing.Any, |
| 799 |
object_=_response.json(), |
| 800 |
), |
| 801 |
), |
| 802 |
) |
| 803 |
if _response.status_code == 403: |
| 804 |
raise ForbiddenError( |
| 805 |
headers=dict(_response.headers), |
| 806 |
body=typing.cast( |
| 807 |
typing.Any, |
| 808 |
parse_obj_as( |
| 809 |
type_=typing.Any, |
| 810 |
object_=_response.json(), |
| 811 |
), |
| 812 |
), |
| 813 |
) |
| 814 |
if _response.status_code == 429: |
| 815 |
raise TooManyRequestsError( |
| 816 |
headers=dict(_response.headers), |
| 817 |
body=typing.cast( |
| 818 |
typing.Any, |
| 819 |
parse_obj_as( |
| 820 |
type_=typing.Any, |
| 821 |
object_=_response.json(), |
| 822 |
), |
| 823 |
), |
| 824 |
) |
| 825 |
_response_json = _response.json() |
| 826 |
except JSONDecodeError: |
| 827 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 828 |
except ValidationError as e: |
| 829 |
raise ParsingError( |
| 830 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 831 |
) |
| 832 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 833 |
|
| 834 |
async def get( |
| 835 |
self, |
| 836 |
prompt: PromptGroupNameEnum, |
| 837 |
screen: ScreenGroupNameEnum, |
| 838 |
*, |
| 839 |
request_options: typing.Optional[RequestOptions] = None, |
| 840 |
) -> AsyncHttpResponse[GetAculResponseContent]: |
| 841 |
""" |
| 842 |
Get render settings for a screen. |
| 843 |
|
| 844 |
Parameters |
| 845 |
---------- |
| 846 |
prompt : PromptGroupNameEnum |
| 847 |
Name of the prompt |
| 848 |
|
| 849 |
screen : ScreenGroupNameEnum |
| 850 |
Name of the screen |
| 851 |
|
| 852 |
request_options : typing.Optional[RequestOptions] |
| 853 |
Request-specific configuration. |
| 854 |
|
| 855 |
Returns |
| 856 |
------- |
| 857 |
AsyncHttpResponse[GetAculResponseContent] |
| 858 |
ACUL settings successfully retrieved. |
| 859 |
""" |
| 860 |
_response = await self._client_wrapper.httpx_client.request( |
| 861 |
f"prompts/{encode_path_param(prompt)}/screen/{encode_path_param(screen)}/rendering", |
| 862 |
method="GET", |
| 863 |
request_options=request_options, |
| 864 |
) |
| 865 |
try: |
| 866 |
if 200 <= _response.status_code < 300: |
| 867 |
_data = typing.cast( |
| 868 |
GetAculResponseContent, |
| 869 |
parse_obj_as( |
| 870 |
type_=GetAculResponseContent, |
| 871 |
object_=_response.json(), |
| 872 |
), |
| 873 |
) |
| 874 |
return AsyncHttpResponse(response=_response, data=_data) |
| 875 |
if _response.status_code == 400: |
| 876 |
raise BadRequestError( |
| 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 == 401: |
| 887 |
raise UnauthorizedError( |
| 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 |
if _response.status_code == 402: |
| 898 |
raise PaymentRequiredError( |
| 899 |
headers=dict(_response.headers), |
| 900 |
body=typing.cast( |
| 901 |
typing.Any, |
| 902 |
parse_obj_as( |
| 903 |
type_=typing.Any, |
| 904 |
object_=_response.json(), |
| 905 |
), |
| 906 |
), |
| 907 |
) |
| 908 |
if _response.status_code == 403: |
| 909 |
raise ForbiddenError( |
| 910 |
headers=dict(_response.headers), |
| 911 |
body=typing.cast( |
| 912 |
typing.Any, |
| 913 |
parse_obj_as( |
| 914 |
type_=typing.Any, |
| 915 |
object_=_response.json(), |
| 916 |
), |
| 917 |
), |
| 918 |
) |
| 919 |
if _response.status_code == 404: |
| 920 |
raise NotFoundError( |
| 921 |
headers=dict(_response.headers), |
| 922 |
body=typing.cast( |
| 923 |
typing.Any, |
| 924 |
parse_obj_as( |
| 925 |
type_=typing.Any, |
| 926 |
object_=_response.json(), |
| 927 |
), |
| 928 |
), |
| 929 |
) |
| 930 |
if _response.status_code == 429: |
| 931 |
raise TooManyRequestsError( |
| 932 |
headers=dict(_response.headers), |
| 933 |
body=typing.cast( |
| 934 |
typing.Any, |
| 935 |
parse_obj_as( |
| 936 |
type_=typing.Any, |
| 937 |
object_=_response.json(), |
| 938 |
), |
| 939 |
), |
| 940 |
) |
| 941 |
_response_json = _response.json() |
| 942 |
except JSONDecodeError: |
| 943 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 944 |
except ValidationError as e: |
| 945 |
raise ParsingError( |
| 946 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 947 |
) |
| 948 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 949 |
|
| 950 |
async def update( |
| 951 |
self, |
| 952 |
prompt: PromptGroupNameEnum, |
| 953 |
screen: ScreenGroupNameEnum, |
| 954 |
*, |
| 955 |
rendering_mode: typing.Optional[AculRenderingModeEnum] = OMIT, |
| 956 |
context_configuration: typing.Optional[AculContextConfiguration] = OMIT, |
| 957 |
default_head_tags_disabled: typing.Optional[bool] = OMIT, |
| 958 |
use_page_template: typing.Optional[bool] = OMIT, |
| 959 |
head_tags: typing.Optional[typing.Sequence[AculHeadTag]] = OMIT, |
| 960 |
filters: typing.Optional[AculFilters] = OMIT, |
| 961 |
request_options: typing.Optional[RequestOptions] = None, |
| 962 |
) -> AsyncHttpResponse[UpdateAculResponseContent]: |
| 963 |
""" |
| 964 |
Learn more about [configuring render settings](https://auth0.com/docs/customize/login-pages/advanced-customizations/getting-started/configure-acul-screens) for advanced customization. |
| 965 |
|
| 966 |
Parameters |
| 967 |
---------- |
| 968 |
prompt : PromptGroupNameEnum |
| 969 |
Name of the prompt |
| 970 |
|
| 971 |
screen : ScreenGroupNameEnum |
| 972 |
Name of the screen |
| 973 |
|
| 974 |
rendering_mode : typing.Optional[AculRenderingModeEnum] |
| 975 |
Rendering mode |
| 976 |
|
| 977 |
context_configuration : typing.Optional[AculContextConfiguration] |
| 978 |
|
| 979 |
default_head_tags_disabled : typing.Optional[bool] |
| 980 |
Override Universal Login default head tags |
| 981 |
|
| 982 |
use_page_template : typing.Optional[bool] |
| 983 |
Use page template with ACUL |
| 984 |
|
| 985 |
head_tags : typing.Optional[typing.Sequence[AculHeadTag]] |
| 986 |
An array of head tags |
| 987 |
|
| 988 |
filters : typing.Optional[AculFilters] |
| 989 |
|
| 990 |
request_options : typing.Optional[RequestOptions] |
| 991 |
Request-specific configuration. |
| 992 |
|
| 993 |
Returns |
| 994 |
------- |
| 995 |
AsyncHttpResponse[UpdateAculResponseContent] |
| 996 |
ACUL settings successfully updated. |
| 997 |
""" |
| 998 |
_response = await self._client_wrapper.httpx_client.request( |
| 999 |
f"prompts/{encode_path_param(prompt)}/screen/{encode_path_param(screen)}/rendering", |
| 1000 |
method="PATCH", |
| 1001 |
json={ |
| 1002 |
"rendering_mode": rendering_mode, |
| 1003 |
"context_configuration": convert_and_respect_annotation_metadata( |
| 1004 |
object_=context_configuration, |
| 1005 |
annotation=typing.Optional[AculContextConfiguration], |
| 1006 |
direction="write", |
| 1007 |
), |
| 1008 |
"default_head_tags_disabled": default_head_tags_disabled, |
| 1009 |
"use_page_template": use_page_template, |
| 1010 |
"head_tags": convert_and_respect_annotation_metadata( |
| 1011 |
object_=head_tags, annotation=typing.Optional[typing.Sequence[AculHeadTag]], direction="write" |
| 1012 |
), |
| 1013 |
"filters": convert_and_respect_annotation_metadata( |
| 1014 |
object_=filters, annotation=typing.Optional[AculFilters], 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 |
UpdateAculResponseContent, |
| 1027 |
parse_obj_as( |
| 1028 |
type_=UpdateAculResponseContent, |
| 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 == 402: |
| 1056 |
raise PaymentRequiredError( |
| 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 == 403: |
| 1067 |
raise ForbiddenError( |
| 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) |