| 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.parse_error import ParsingError |
| 11 |
from ..core.pydantic_utilities import parse_obj_as |
| 12 |
from ..core.request_options import RequestOptions |
| 13 |
from ..errors.bad_request_error import BadRequestError |
| 14 |
from ..errors.conflict_error import ConflictError |
| 15 |
from ..errors.forbidden_error import ForbiddenError |
| 16 |
from ..errors.not_found_error import NotFoundError |
| 17 |
from ..errors.too_many_requests_error import TooManyRequestsError |
| 18 |
from ..errors.unauthorized_error import UnauthorizedError |
| 19 |
from ..types.create_custom_domain_response_content import CreateCustomDomainResponseContent |
| 20 |
from ..types.custom_domain_custom_client_ip_header import CustomDomainCustomClientIpHeader |
| 21 |
from ..types.custom_domain_provisioning_type_enum import CustomDomainProvisioningTypeEnum |
| 22 |
from ..types.custom_domain_tls_policy_enum import CustomDomainTlsPolicyEnum |
| 23 |
from ..types.custom_domain_verification_method_enum import CustomDomainVerificationMethodEnum |
| 24 |
from ..types.domain_metadata import DomainMetadata |
| 25 |
from ..types.get_custom_domain_response_content import GetCustomDomainResponseContent |
| 26 |
from ..types.get_default_domain_response_content import GetDefaultDomainResponseContent |
| 27 |
from ..types.list_custom_domains_response_content import ListCustomDomainsResponseContent |
| 28 |
from ..types.test_custom_domain_response_content import TestCustomDomainResponseContent |
| 29 |
from ..types.update_custom_domain_response_content import UpdateCustomDomainResponseContent |
| 30 |
from ..types.update_default_domain_response_content import UpdateDefaultDomainResponseContent |
| 31 |
from ..types.verify_custom_domain_response_content import VerifyCustomDomainResponseContent |
| 32 |
from pydantic import ValidationError |
| 33 |
|
| 34 |
|
| 35 |
OMIT = typing.cast(typing.Any, ...) |
| 36 |
|
| 37 |
|
| 38 |
class RawCustomDomainsClient: |
| 39 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 40 |
self._client_wrapper = client_wrapper |
| 41 |
|
| 42 |
def list( |
| 43 |
self, |
| 44 |
*, |
| 45 |
q: typing.Optional[str] = None, |
| 46 |
fields: typing.Optional[str] = None, |
| 47 |
include_fields: typing.Optional[bool] = None, |
| 48 |
sort: typing.Optional[str] = None, |
| 49 |
request_options: typing.Optional[RequestOptions] = None, |
| 50 |
) -> HttpResponse[ListCustomDomainsResponseContent]: |
| 51 |
""" |
| 52 |
Retrieve details on [custom domains](https://auth0.com/docs/custom-domains). |
| 53 |
|
| 54 |
Parameters |
| 55 |
---------- |
| 56 |
q : typing.Optional[str] |
| 57 |
Query in <a href ="https://lucene.apache.org/core/2_9_4/queryparsersyntax.html">Lucene query string syntax</a>. |
| 58 |
|
| 59 |
fields : typing.Optional[str] |
| 60 |
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. |
| 61 |
|
| 62 |
include_fields : typing.Optional[bool] |
| 63 |
Whether specified fields are to be included (true) or excluded (false). |
| 64 |
|
| 65 |
sort : typing.Optional[str] |
| 66 |
Field to sort by. Only <code>domain:1</code> (ascending order by domain) is supported at this time. |
| 67 |
|
| 68 |
request_options : typing.Optional[RequestOptions] |
| 69 |
Request-specific configuration. |
| 70 |
|
| 71 |
Returns |
| 72 |
------- |
| 73 |
HttpResponse[ListCustomDomainsResponseContent] |
| 74 |
Custom domains successfully retrieved. |
| 75 |
""" |
| 76 |
_response = self._client_wrapper.httpx_client.request( |
| 77 |
"custom-domains", |
| 78 |
method="GET", |
| 79 |
params={ |
| 80 |
"q": q, |
| 81 |
"fields": fields, |
| 82 |
"include_fields": include_fields, |
| 83 |
"sort": sort, |
| 84 |
}, |
| 85 |
request_options=request_options, |
| 86 |
) |
| 87 |
try: |
| 88 |
if 200 <= _response.status_code < 300: |
| 89 |
_data = typing.cast( |
| 90 |
ListCustomDomainsResponseContent, |
| 91 |
parse_obj_as( |
| 92 |
type_=ListCustomDomainsResponseContent, |
| 93 |
object_=_response.json(), |
| 94 |
), |
| 95 |
) |
| 96 |
return HttpResponse(response=_response, data=_data) |
| 97 |
if _response.status_code == 401: |
| 98 |
raise UnauthorizedError( |
| 99 |
headers=dict(_response.headers), |
| 100 |
body=typing.cast( |
| 101 |
typing.Any, |
| 102 |
parse_obj_as( |
| 103 |
type_=typing.Any, |
| 104 |
object_=_response.json(), |
| 105 |
), |
| 106 |
), |
| 107 |
) |
| 108 |
if _response.status_code == 403: |
| 109 |
raise ForbiddenError( |
| 110 |
headers=dict(_response.headers), |
| 111 |
body=typing.cast( |
| 112 |
typing.Any, |
| 113 |
parse_obj_as( |
| 114 |
type_=typing.Any, |
| 115 |
object_=_response.json(), |
| 116 |
), |
| 117 |
), |
| 118 |
) |
| 119 |
if _response.status_code == 429: |
| 120 |
raise TooManyRequestsError( |
| 121 |
headers=dict(_response.headers), |
| 122 |
body=typing.cast( |
| 123 |
typing.Any, |
| 124 |
parse_obj_as( |
| 125 |
type_=typing.Any, |
| 126 |
object_=_response.json(), |
| 127 |
), |
| 128 |
), |
| 129 |
) |
| 130 |
_response_json = _response.json() |
| 131 |
except JSONDecodeError: |
| 132 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 133 |
except ValidationError as e: |
| 134 |
raise ParsingError( |
| 135 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 136 |
) |
| 137 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 138 |
|
| 139 |
def create( |
| 140 |
self, |
| 141 |
*, |
| 142 |
domain: str, |
| 143 |
type: CustomDomainProvisioningTypeEnum, |
| 144 |
verification_method: typing.Optional[CustomDomainVerificationMethodEnum] = OMIT, |
| 145 |
tls_policy: typing.Optional[CustomDomainTlsPolicyEnum] = OMIT, |
| 146 |
custom_client_ip_header: typing.Optional[CustomDomainCustomClientIpHeader] = OMIT, |
| 147 |
domain_metadata: typing.Optional[DomainMetadata] = OMIT, |
| 148 |
relying_party_identifier: typing.Optional[str] = OMIT, |
| 149 |
request_options: typing.Optional[RequestOptions] = None, |
| 150 |
) -> HttpResponse[CreateCustomDomainResponseContent]: |
| 151 |
""" |
| 152 |
Create a new custom domain. |
| 153 |
|
| 154 |
Note: The custom domain will need to be verified before it will accept |
| 155 |
requests. |
| 156 |
|
| 157 |
Optional attributes that can be updated: |
| 158 |
|
| 159 |
- custom_client_ip_header |
| 160 |
- tls_policy |
| 161 |
|
| 162 |
TLS Policies: |
| 163 |
|
| 164 |
- recommended - for modern usage this includes TLS 1.2 only |
| 165 |
|
| 166 |
Parameters |
| 167 |
---------- |
| 168 |
domain : str |
| 169 |
Domain name. |
| 170 |
|
| 171 |
type : CustomDomainProvisioningTypeEnum |
| 172 |
|
| 173 |
verification_method : typing.Optional[CustomDomainVerificationMethodEnum] |
| 174 |
|
| 175 |
tls_policy : typing.Optional[CustomDomainTlsPolicyEnum] |
| 176 |
|
| 177 |
custom_client_ip_header : typing.Optional[CustomDomainCustomClientIpHeader] |
| 178 |
|
| 179 |
domain_metadata : typing.Optional[DomainMetadata] |
| 180 |
|
| 181 |
relying_party_identifier : typing.Optional[str] |
| 182 |
Relying Party ID (rpId) to be used for Passkeys on this custom domain. If not provided, the full domain will be used. |
| 183 |
|
| 184 |
request_options : typing.Optional[RequestOptions] |
| 185 |
Request-specific configuration. |
| 186 |
|
| 187 |
Returns |
| 188 |
------- |
| 189 |
HttpResponse[CreateCustomDomainResponseContent] |
| 190 |
Custom domain successfully created (verification is pending). |
| 191 |
""" |
| 192 |
_response = self._client_wrapper.httpx_client.request( |
| 193 |
"custom-domains", |
| 194 |
method="POST", |
| 195 |
json={ |
| 196 |
"domain": domain, |
| 197 |
"type": type, |
| 198 |
"verification_method": verification_method, |
| 199 |
"tls_policy": tls_policy, |
| 200 |
"custom_client_ip_header": custom_client_ip_header, |
| 201 |
"domain_metadata": domain_metadata, |
| 202 |
"relying_party_identifier": relying_party_identifier, |
| 203 |
}, |
| 204 |
headers={ |
| 205 |
"content-type": "application/json", |
| 206 |
}, |
| 207 |
request_options=request_options, |
| 208 |
omit=OMIT, |
| 209 |
) |
| 210 |
try: |
| 211 |
if 200 <= _response.status_code < 300: |
| 212 |
_data = typing.cast( |
| 213 |
CreateCustomDomainResponseContent, |
| 214 |
parse_obj_as( |
| 215 |
type_=CreateCustomDomainResponseContent, |
| 216 |
object_=_response.json(), |
| 217 |
), |
| 218 |
) |
| 219 |
return HttpResponse(response=_response, data=_data) |
| 220 |
if _response.status_code == 400: |
| 221 |
raise BadRequestError( |
| 222 |
headers=dict(_response.headers), |
| 223 |
body=typing.cast( |
| 224 |
typing.Any, |
| 225 |
parse_obj_as( |
| 226 |
type_=typing.Any, |
| 227 |
object_=_response.json(), |
| 228 |
), |
| 229 |
), |
| 230 |
) |
| 231 |
if _response.status_code == 401: |
| 232 |
raise UnauthorizedError( |
| 233 |
headers=dict(_response.headers), |
| 234 |
body=typing.cast( |
| 235 |
typing.Any, |
| 236 |
parse_obj_as( |
| 237 |
type_=typing.Any, |
| 238 |
object_=_response.json(), |
| 239 |
), |
| 240 |
), |
| 241 |
) |
| 242 |
if _response.status_code == 403: |
| 243 |
raise ForbiddenError( |
| 244 |
headers=dict(_response.headers), |
| 245 |
body=typing.cast( |
| 246 |
typing.Any, |
| 247 |
parse_obj_as( |
| 248 |
type_=typing.Any, |
| 249 |
object_=_response.json(), |
| 250 |
), |
| 251 |
), |
| 252 |
) |
| 253 |
if _response.status_code == 409: |
| 254 |
raise ConflictError( |
| 255 |
headers=dict(_response.headers), |
| 256 |
body=typing.cast( |
| 257 |
typing.Any, |
| 258 |
parse_obj_as( |
| 259 |
type_=typing.Any, |
| 260 |
object_=_response.json(), |
| 261 |
), |
| 262 |
), |
| 263 |
) |
| 264 |
if _response.status_code == 429: |
| 265 |
raise TooManyRequestsError( |
| 266 |
headers=dict(_response.headers), |
| 267 |
body=typing.cast( |
| 268 |
typing.Any, |
| 269 |
parse_obj_as( |
| 270 |
type_=typing.Any, |
| 271 |
object_=_response.json(), |
| 272 |
), |
| 273 |
), |
| 274 |
) |
| 275 |
_response_json = _response.json() |
| 276 |
except JSONDecodeError: |
| 277 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 278 |
except ValidationError as e: |
| 279 |
raise ParsingError( |
| 280 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 281 |
) |
| 282 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 283 |
|
| 284 |
def get_default( |
| 285 |
self, *, request_options: typing.Optional[RequestOptions] = None |
| 286 |
) -> HttpResponse[GetDefaultDomainResponseContent]: |
| 287 |
""" |
| 288 |
Retrieve the tenant's default domain. |
| 289 |
|
| 290 |
Parameters |
| 291 |
---------- |
| 292 |
request_options : typing.Optional[RequestOptions] |
| 293 |
Request-specific configuration. |
| 294 |
|
| 295 |
Returns |
| 296 |
------- |
| 297 |
HttpResponse[GetDefaultDomainResponseContent] |
| 298 |
Default domain successfully retrieved. |
| 299 |
""" |
| 300 |
_response = self._client_wrapper.httpx_client.request( |
| 301 |
"custom-domains/default", |
| 302 |
method="GET", |
| 303 |
request_options=request_options, |
| 304 |
) |
| 305 |
try: |
| 306 |
if 200 <= _response.status_code < 300: |
| 307 |
_data = typing.cast( |
| 308 |
GetDefaultDomainResponseContent, |
| 309 |
parse_obj_as( |
| 310 |
type_=GetDefaultDomainResponseContent, |
| 311 |
object_=_response.json(), |
| 312 |
), |
| 313 |
) |
| 314 |
return HttpResponse(response=_response, data=_data) |
| 315 |
if _response.status_code == 401: |
| 316 |
raise UnauthorizedError( |
| 317 |
headers=dict(_response.headers), |
| 318 |
body=typing.cast( |
| 319 |
typing.Any, |
| 320 |
parse_obj_as( |
| 321 |
type_=typing.Any, |
| 322 |
object_=_response.json(), |
| 323 |
), |
| 324 |
), |
| 325 |
) |
| 326 |
if _response.status_code == 403: |
| 327 |
raise ForbiddenError( |
| 328 |
headers=dict(_response.headers), |
| 329 |
body=typing.cast( |
| 330 |
typing.Any, |
| 331 |
parse_obj_as( |
| 332 |
type_=typing.Any, |
| 333 |
object_=_response.json(), |
| 334 |
), |
| 335 |
), |
| 336 |
) |
| 337 |
if _response.status_code == 429: |
| 338 |
raise TooManyRequestsError( |
| 339 |
headers=dict(_response.headers), |
| 340 |
body=typing.cast( |
| 341 |
typing.Any, |
| 342 |
parse_obj_as( |
| 343 |
type_=typing.Any, |
| 344 |
object_=_response.json(), |
| 345 |
), |
| 346 |
), |
| 347 |
) |
| 348 |
_response_json = _response.json() |
| 349 |
except JSONDecodeError: |
| 350 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 351 |
except ValidationError as e: |
| 352 |
raise ParsingError( |
| 353 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 354 |
) |
| 355 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 356 |
|
| 357 |
def set_default( |
| 358 |
self, *, domain: str, request_options: typing.Optional[RequestOptions] = None |
| 359 |
) -> HttpResponse[UpdateDefaultDomainResponseContent]: |
| 360 |
""" |
| 361 |
Set the default custom domain for the tenant. |
| 362 |
|
| 363 |
Parameters |
| 364 |
---------- |
| 365 |
domain : str |
| 366 |
The domain to set as the default custom domain. Must be a verified custom domain or the canonical domain. |
| 367 |
|
| 368 |
request_options : typing.Optional[RequestOptions] |
| 369 |
Request-specific configuration. |
| 370 |
|
| 371 |
Returns |
| 372 |
------- |
| 373 |
HttpResponse[UpdateDefaultDomainResponseContent] |
| 374 |
Default custom domain set successfully. |
| 375 |
""" |
| 376 |
_response = self._client_wrapper.httpx_client.request( |
| 377 |
"custom-domains/default", |
| 378 |
method="PATCH", |
| 379 |
json={ |
| 380 |
"domain": domain, |
| 381 |
}, |
| 382 |
headers={ |
| 383 |
"content-type": "application/json", |
| 384 |
}, |
| 385 |
request_options=request_options, |
| 386 |
omit=OMIT, |
| 387 |
) |
| 388 |
try: |
| 389 |
if 200 <= _response.status_code < 300: |
| 390 |
_data = typing.cast( |
| 391 |
UpdateDefaultDomainResponseContent, |
| 392 |
parse_obj_as( |
| 393 |
type_=UpdateDefaultDomainResponseContent, |
| 394 |
object_=_response.json(), |
| 395 |
), |
| 396 |
) |
| 397 |
return HttpResponse(response=_response, data=_data) |
| 398 |
if _response.status_code == 400: |
| 399 |
raise BadRequestError( |
| 400 |
headers=dict(_response.headers), |
| 401 |
body=typing.cast( |
| 402 |
typing.Any, |
| 403 |
parse_obj_as( |
| 404 |
type_=typing.Any, |
| 405 |
object_=_response.json(), |
| 406 |
), |
| 407 |
), |
| 408 |
) |
| 409 |
if _response.status_code == 403: |
| 410 |
raise ForbiddenError( |
| 411 |
headers=dict(_response.headers), |
| 412 |
body=typing.cast( |
| 413 |
typing.Any, |
| 414 |
parse_obj_as( |
| 415 |
type_=typing.Any, |
| 416 |
object_=_response.json(), |
| 417 |
), |
| 418 |
), |
| 419 |
) |
| 420 |
_response_json = _response.json() |
| 421 |
except JSONDecodeError: |
| 422 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 423 |
except ValidationError as e: |
| 424 |
raise ParsingError( |
| 425 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 426 |
) |
| 427 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 428 |
|
| 429 |
def get( |
| 430 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 431 |
) -> HttpResponse[GetCustomDomainResponseContent]: |
| 432 |
""" |
| 433 |
Retrieve a custom domain configuration and status. |
| 434 |
|
| 435 |
Parameters |
| 436 |
---------- |
| 437 |
id : str |
| 438 |
ID of the custom domain to retrieve. |
| 439 |
|
| 440 |
request_options : typing.Optional[RequestOptions] |
| 441 |
Request-specific configuration. |
| 442 |
|
| 443 |
Returns |
| 444 |
------- |
| 445 |
HttpResponse[GetCustomDomainResponseContent] |
| 446 |
Custom domain successfully retrieved. |
| 447 |
""" |
| 448 |
_response = self._client_wrapper.httpx_client.request( |
| 449 |
f"custom-domains/{encode_path_param(id)}", |
| 450 |
method="GET", |
| 451 |
request_options=request_options, |
| 452 |
) |
| 453 |
try: |
| 454 |
if 200 <= _response.status_code < 300: |
| 455 |
_data = typing.cast( |
| 456 |
GetCustomDomainResponseContent, |
| 457 |
parse_obj_as( |
| 458 |
type_=GetCustomDomainResponseContent, |
| 459 |
object_=_response.json(), |
| 460 |
), |
| 461 |
) |
| 462 |
return HttpResponse(response=_response, data=_data) |
| 463 |
if _response.status_code == 400: |
| 464 |
raise BadRequestError( |
| 465 |
headers=dict(_response.headers), |
| 466 |
body=typing.cast( |
| 467 |
typing.Any, |
| 468 |
parse_obj_as( |
| 469 |
type_=typing.Any, |
| 470 |
object_=_response.json(), |
| 471 |
), |
| 472 |
), |
| 473 |
) |
| 474 |
if _response.status_code == 401: |
| 475 |
raise UnauthorizedError( |
| 476 |
headers=dict(_response.headers), |
| 477 |
body=typing.cast( |
| 478 |
typing.Any, |
| 479 |
parse_obj_as( |
| 480 |
type_=typing.Any, |
| 481 |
object_=_response.json(), |
| 482 |
), |
| 483 |
), |
| 484 |
) |
| 485 |
if _response.status_code == 403: |
| 486 |
raise ForbiddenError( |
| 487 |
headers=dict(_response.headers), |
| 488 |
body=typing.cast( |
| 489 |
typing.Any, |
| 490 |
parse_obj_as( |
| 491 |
type_=typing.Any, |
| 492 |
object_=_response.json(), |
| 493 |
), |
| 494 |
), |
| 495 |
) |
| 496 |
if _response.status_code == 404: |
| 497 |
raise NotFoundError( |
| 498 |
headers=dict(_response.headers), |
| 499 |
body=typing.cast( |
| 500 |
typing.Any, |
| 501 |
parse_obj_as( |
| 502 |
type_=typing.Any, |
| 503 |
object_=_response.json(), |
| 504 |
), |
| 505 |
), |
| 506 |
) |
| 507 |
if _response.status_code == 429: |
| 508 |
raise TooManyRequestsError( |
| 509 |
headers=dict(_response.headers), |
| 510 |
body=typing.cast( |
| 511 |
typing.Any, |
| 512 |
parse_obj_as( |
| 513 |
type_=typing.Any, |
| 514 |
object_=_response.json(), |
| 515 |
), |
| 516 |
), |
| 517 |
) |
| 518 |
_response_json = _response.json() |
| 519 |
except JSONDecodeError: |
| 520 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 521 |
except ValidationError as e: |
| 522 |
raise ParsingError( |
| 523 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 524 |
) |
| 525 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 526 |
|
| 527 |
def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: |
| 528 |
""" |
| 529 |
Delete a custom domain and stop serving requests for it. |
| 530 |
|
| 531 |
Parameters |
| 532 |
---------- |
| 533 |
id : str |
| 534 |
ID of the custom domain to delete. |
| 535 |
|
| 536 |
request_options : typing.Optional[RequestOptions] |
| 537 |
Request-specific configuration. |
| 538 |
|
| 539 |
Returns |
| 540 |
------- |
| 541 |
HttpResponse[None] |
| 542 |
""" |
| 543 |
_response = self._client_wrapper.httpx_client.request( |
| 544 |
f"custom-domains/{encode_path_param(id)}", |
| 545 |
method="DELETE", |
| 546 |
request_options=request_options, |
| 547 |
) |
| 548 |
try: |
| 549 |
if 200 <= _response.status_code < 300: |
| 550 |
return HttpResponse(response=_response, data=None) |
| 551 |
if _response.status_code == 400: |
| 552 |
raise BadRequestError( |
| 553 |
headers=dict(_response.headers), |
| 554 |
body=typing.cast( |
| 555 |
typing.Any, |
| 556 |
parse_obj_as( |
| 557 |
type_=typing.Any, |
| 558 |
object_=_response.json(), |
| 559 |
), |
| 560 |
), |
| 561 |
) |
| 562 |
if _response.status_code == 401: |
| 563 |
raise UnauthorizedError( |
| 564 |
headers=dict(_response.headers), |
| 565 |
body=typing.cast( |
| 566 |
typing.Any, |
| 567 |
parse_obj_as( |
| 568 |
type_=typing.Any, |
| 569 |
object_=_response.json(), |
| 570 |
), |
| 571 |
), |
| 572 |
) |
| 573 |
if _response.status_code == 403: |
| 574 |
raise ForbiddenError( |
| 575 |
headers=dict(_response.headers), |
| 576 |
body=typing.cast( |
| 577 |
typing.Any, |
| 578 |
parse_obj_as( |
| 579 |
type_=typing.Any, |
| 580 |
object_=_response.json(), |
| 581 |
), |
| 582 |
), |
| 583 |
) |
| 584 |
if _response.status_code == 409: |
| 585 |
raise ConflictError( |
| 586 |
headers=dict(_response.headers), |
| 587 |
body=typing.cast( |
| 588 |
typing.Any, |
| 589 |
parse_obj_as( |
| 590 |
type_=typing.Any, |
| 591 |
object_=_response.json(), |
| 592 |
), |
| 593 |
), |
| 594 |
) |
| 595 |
if _response.status_code == 429: |
| 596 |
raise TooManyRequestsError( |
| 597 |
headers=dict(_response.headers), |
| 598 |
body=typing.cast( |
| 599 |
typing.Any, |
| 600 |
parse_obj_as( |
| 601 |
type_=typing.Any, |
| 602 |
object_=_response.json(), |
| 603 |
), |
| 604 |
), |
| 605 |
) |
| 606 |
_response_json = _response.json() |
| 607 |
except JSONDecodeError: |
| 608 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 609 |
except ValidationError as e: |
| 610 |
raise ParsingError( |
| 611 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 612 |
) |
| 613 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 614 |
|
| 615 |
def update( |
| 616 |
self, |
| 617 |
id: str, |
| 618 |
*, |
| 619 |
tls_policy: typing.Optional[CustomDomainTlsPolicyEnum] = OMIT, |
| 620 |
custom_client_ip_header: typing.Optional[CustomDomainCustomClientIpHeader] = OMIT, |
| 621 |
domain_metadata: typing.Optional[DomainMetadata] = OMIT, |
| 622 |
relying_party_identifier: typing.Optional[str] = OMIT, |
| 623 |
request_options: typing.Optional[RequestOptions] = None, |
| 624 |
) -> HttpResponse[UpdateCustomDomainResponseContent]: |
| 625 |
""" |
| 626 |
Update a custom domain. |
| 627 |
|
| 628 |
These are the attributes that can be updated: |
| 629 |
|
| 630 |
- custom_client_ip_header |
| 631 |
- tls_policy |
| 632 |
|
| 633 |
**Updating CUSTOM_CLIENT_IP_HEADER for a custom domain** |
| 634 |
|
| 635 |
To update the `custom_client_ip_header` for a domain, the body to |
| 636 |
send should be: |
| 637 |
|
| 638 |
```json |
| 639 |
{ "custom_client_ip_header": "cf-connecting-ip" } |
| 640 |
``` |
| 641 |
|
| 642 |
**Updating TLS_POLICY for a custom domain** |
| 643 |
|
| 644 |
To update the `tls_policy` for a domain, the body to send should be: |
| 645 |
|
| 646 |
```json |
| 647 |
{ "tls_policy": "recommended" } |
| 648 |
``` |
| 649 |
|
| 650 |
TLS Policies: |
| 651 |
|
| 652 |
- recommended - for modern usage this includes TLS 1.2 only |
| 653 |
|
| 654 |
Some considerations: |
| 655 |
|
| 656 |
- The TLS ciphers and protocols available in each TLS policy follow industry recommendations, and may be updated occasionally. |
| 657 |
- The `compatible` TLS policy is no longer supported. |
| 658 |
|
| 659 |
Parameters |
| 660 |
---------- |
| 661 |
id : str |
| 662 |
The id of the custom domain to update |
| 663 |
|
| 664 |
tls_policy : typing.Optional[CustomDomainTlsPolicyEnum] |
| 665 |
recommended includes TLS 1.2 |
| 666 |
|
| 667 |
custom_client_ip_header : typing.Optional[CustomDomainCustomClientIpHeader] |
| 668 |
|
| 669 |
domain_metadata : typing.Optional[DomainMetadata] |
| 670 |
|
| 671 |
relying_party_identifier : typing.Optional[str] |
| 672 |
Relying Party ID (rpId) to be used for Passkeys on this custom domain. Set to null to remove the rpId and fall back to using the full domain. |
| 673 |
|
| 674 |
request_options : typing.Optional[RequestOptions] |
| 675 |
Request-specific configuration. |
| 676 |
|
| 677 |
Returns |
| 678 |
------- |
| 679 |
HttpResponse[UpdateCustomDomainResponseContent] |
| 680 |
Custom domain updated. |
| 681 |
""" |
| 682 |
_response = self._client_wrapper.httpx_client.request( |
| 683 |
f"custom-domains/{encode_path_param(id)}", |
| 684 |
method="PATCH", |
| 685 |
json={ |
| 686 |
"tls_policy": tls_policy, |
| 687 |
"custom_client_ip_header": custom_client_ip_header, |
| 688 |
"domain_metadata": domain_metadata, |
| 689 |
"relying_party_identifier": relying_party_identifier, |
| 690 |
}, |
| 691 |
headers={ |
| 692 |
"content-type": "application/json", |
| 693 |
}, |
| 694 |
request_options=request_options, |
| 695 |
omit=OMIT, |
| 696 |
) |
| 697 |
try: |
| 698 |
if 200 <= _response.status_code < 300: |
| 699 |
_data = typing.cast( |
| 700 |
UpdateCustomDomainResponseContent, |
| 701 |
parse_obj_as( |
| 702 |
type_=UpdateCustomDomainResponseContent, |
| 703 |
object_=_response.json(), |
| 704 |
), |
| 705 |
) |
| 706 |
return HttpResponse(response=_response, data=_data) |
| 707 |
if _response.status_code == 400: |
| 708 |
raise BadRequestError( |
| 709 |
headers=dict(_response.headers), |
| 710 |
body=typing.cast( |
| 711 |
typing.Any, |
| 712 |
parse_obj_as( |
| 713 |
type_=typing.Any, |
| 714 |
object_=_response.json(), |
| 715 |
), |
| 716 |
), |
| 717 |
) |
| 718 |
if _response.status_code == 401: |
| 719 |
raise UnauthorizedError( |
| 720 |
headers=dict(_response.headers), |
| 721 |
body=typing.cast( |
| 722 |
typing.Any, |
| 723 |
parse_obj_as( |
| 724 |
type_=typing.Any, |
| 725 |
object_=_response.json(), |
| 726 |
), |
| 727 |
), |
| 728 |
) |
| 729 |
if _response.status_code == 403: |
| 730 |
raise ForbiddenError( |
| 731 |
headers=dict(_response.headers), |
| 732 |
body=typing.cast( |
| 733 |
typing.Any, |
| 734 |
parse_obj_as( |
| 735 |
type_=typing.Any, |
| 736 |
object_=_response.json(), |
| 737 |
), |
| 738 |
), |
| 739 |
) |
| 740 |
if _response.status_code == 429: |
| 741 |
raise TooManyRequestsError( |
| 742 |
headers=dict(_response.headers), |
| 743 |
body=typing.cast( |
| 744 |
typing.Any, |
| 745 |
parse_obj_as( |
| 746 |
type_=typing.Any, |
| 747 |
object_=_response.json(), |
| 748 |
), |
| 749 |
), |
| 750 |
) |
| 751 |
_response_json = _response.json() |
| 752 |
except JSONDecodeError: |
| 753 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 754 |
except ValidationError as e: |
| 755 |
raise ParsingError( |
| 756 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 757 |
) |
| 758 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 759 |
|
| 760 |
def test( |
| 761 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 762 |
) -> HttpResponse[TestCustomDomainResponseContent]: |
| 763 |
""" |
| 764 |
Run the test process on a custom domain. |
| 765 |
|
| 766 |
Parameters |
| 767 |
---------- |
| 768 |
id : str |
| 769 |
ID of the custom domain to test. |
| 770 |
|
| 771 |
request_options : typing.Optional[RequestOptions] |
| 772 |
Request-specific configuration. |
| 773 |
|
| 774 |
Returns |
| 775 |
------- |
| 776 |
HttpResponse[TestCustomDomainResponseContent] |
| 777 |
Custom domain test successfully completed. |
| 778 |
""" |
| 779 |
_response = self._client_wrapper.httpx_client.request( |
| 780 |
f"custom-domains/{encode_path_param(id)}/test", |
| 781 |
method="POST", |
| 782 |
request_options=request_options, |
| 783 |
) |
| 784 |
try: |
| 785 |
if 200 <= _response.status_code < 300: |
| 786 |
_data = typing.cast( |
| 787 |
TestCustomDomainResponseContent, |
| 788 |
parse_obj_as( |
| 789 |
type_=TestCustomDomainResponseContent, |
| 790 |
object_=_response.json(), |
| 791 |
), |
| 792 |
) |
| 793 |
return HttpResponse(response=_response, data=_data) |
| 794 |
if _response.status_code == 400: |
| 795 |
raise BadRequestError( |
| 796 |
headers=dict(_response.headers), |
| 797 |
body=typing.cast( |
| 798 |
typing.Any, |
| 799 |
parse_obj_as( |
| 800 |
type_=typing.Any, |
| 801 |
object_=_response.json(), |
| 802 |
), |
| 803 |
), |
| 804 |
) |
| 805 |
if _response.status_code == 401: |
| 806 |
raise UnauthorizedError( |
| 807 |
headers=dict(_response.headers), |
| 808 |
body=typing.cast( |
| 809 |
typing.Any, |
| 810 |
parse_obj_as( |
| 811 |
type_=typing.Any, |
| 812 |
object_=_response.json(), |
| 813 |
), |
| 814 |
), |
| 815 |
) |
| 816 |
if _response.status_code == 403: |
| 817 |
raise ForbiddenError( |
| 818 |
headers=dict(_response.headers), |
| 819 |
body=typing.cast( |
| 820 |
typing.Any, |
| 821 |
parse_obj_as( |
| 822 |
type_=typing.Any, |
| 823 |
object_=_response.json(), |
| 824 |
), |
| 825 |
), |
| 826 |
) |
| 827 |
if _response.status_code == 404: |
| 828 |
raise NotFoundError( |
| 829 |
headers=dict(_response.headers), |
| 830 |
body=typing.cast( |
| 831 |
typing.Any, |
| 832 |
parse_obj_as( |
| 833 |
type_=typing.Any, |
| 834 |
object_=_response.json(), |
| 835 |
), |
| 836 |
), |
| 837 |
) |
| 838 |
if _response.status_code == 409: |
| 839 |
raise ConflictError( |
| 840 |
headers=dict(_response.headers), |
| 841 |
body=typing.cast( |
| 842 |
typing.Any, |
| 843 |
parse_obj_as( |
| 844 |
type_=typing.Any, |
| 845 |
object_=_response.json(), |
| 846 |
), |
| 847 |
), |
| 848 |
) |
| 849 |
_response_json = _response.json() |
| 850 |
except JSONDecodeError: |
| 851 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 852 |
except ValidationError as e: |
| 853 |
raise ParsingError( |
| 854 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 855 |
) |
| 856 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 857 |
|
| 858 |
def verify( |
| 859 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 860 |
) -> HttpResponse[VerifyCustomDomainResponseContent]: |
| 861 |
""" |
| 862 |
Run the verification process on a custom domain. |
| 863 |
|
| 864 |
Note: Check the `status` field to see its verification status. Once verification is complete, it may take up to 10 minutes before the custom domain can start accepting requests. |
| 865 |
|
| 866 |
For `self_managed_certs`, when the custom domain is verified for the first time, the response will also include the `cname_api_key` which you will need to configure your proxy. This key must be kept secret, and is used to validate the proxy requests. |
| 867 |
|
| 868 |
[Learn more](https://auth0.com/docs/custom-domains#step-2-verify-ownership) about verifying custom domains that use Auth0 Managed certificates. |
| 869 |
[Learn more](https://auth0.com/docs/custom-domains/self-managed-certificates#step-2-verify-ownership) about verifying custom domains that use Self Managed certificates. |
| 870 |
|
| 871 |
Parameters |
| 872 |
---------- |
| 873 |
id : str |
| 874 |
ID of the custom domain to verify. |
| 875 |
|
| 876 |
request_options : typing.Optional[RequestOptions] |
| 877 |
Request-specific configuration. |
| 878 |
|
| 879 |
Returns |
| 880 |
------- |
| 881 |
HttpResponse[VerifyCustomDomainResponseContent] |
| 882 |
Custom domain successfully verified. |
| 883 |
""" |
| 884 |
_response = self._client_wrapper.httpx_client.request( |
| 885 |
f"custom-domains/{encode_path_param(id)}/verify", |
| 886 |
method="POST", |
| 887 |
request_options=request_options, |
| 888 |
) |
| 889 |
try: |
| 890 |
if 200 <= _response.status_code < 300: |
| 891 |
_data = typing.cast( |
| 892 |
VerifyCustomDomainResponseContent, |
| 893 |
parse_obj_as( |
| 894 |
type_=VerifyCustomDomainResponseContent, |
| 895 |
object_=_response.json(), |
| 896 |
), |
| 897 |
) |
| 898 |
return HttpResponse(response=_response, data=_data) |
| 899 |
if _response.status_code == 400: |
| 900 |
raise BadRequestError( |
| 901 |
headers=dict(_response.headers), |
| 902 |
body=typing.cast( |
| 903 |
typing.Any, |
| 904 |
parse_obj_as( |
| 905 |
type_=typing.Any, |
| 906 |
object_=_response.json(), |
| 907 |
), |
| 908 |
), |
| 909 |
) |
| 910 |
if _response.status_code == 401: |
| 911 |
raise UnauthorizedError( |
| 912 |
headers=dict(_response.headers), |
| 913 |
body=typing.cast( |
| 914 |
typing.Any, |
| 915 |
parse_obj_as( |
| 916 |
type_=typing.Any, |
| 917 |
object_=_response.json(), |
| 918 |
), |
| 919 |
), |
| 920 |
) |
| 921 |
if _response.status_code == 403: |
| 922 |
raise ForbiddenError( |
| 923 |
headers=dict(_response.headers), |
| 924 |
body=typing.cast( |
| 925 |
typing.Any, |
| 926 |
parse_obj_as( |
| 927 |
type_=typing.Any, |
| 928 |
object_=_response.json(), |
| 929 |
), |
| 930 |
), |
| 931 |
) |
| 932 |
if _response.status_code == 404: |
| 933 |
raise NotFoundError( |
| 934 |
headers=dict(_response.headers), |
| 935 |
body=typing.cast( |
| 936 |
typing.Any, |
| 937 |
parse_obj_as( |
| 938 |
type_=typing.Any, |
| 939 |
object_=_response.json(), |
| 940 |
), |
| 941 |
), |
| 942 |
) |
| 943 |
if _response.status_code == 429: |
| 944 |
raise TooManyRequestsError( |
| 945 |
headers=dict(_response.headers), |
| 946 |
body=typing.cast( |
| 947 |
typing.Any, |
| 948 |
parse_obj_as( |
| 949 |
type_=typing.Any, |
| 950 |
object_=_response.json(), |
| 951 |
), |
| 952 |
), |
| 953 |
) |
| 954 |
_response_json = _response.json() |
| 955 |
except JSONDecodeError: |
| 956 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 957 |
except ValidationError as e: |
| 958 |
raise ParsingError( |
| 959 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 960 |
) |
| 961 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 962 |
|
| 963 |
|
| 964 |
class AsyncRawCustomDomainsClient: |
| 965 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 966 |
self._client_wrapper = client_wrapper |
| 967 |
|
| 968 |
async def list( |
| 969 |
self, |
| 970 |
*, |
| 971 |
q: typing.Optional[str] = None, |
| 972 |
fields: typing.Optional[str] = None, |
| 973 |
include_fields: typing.Optional[bool] = None, |
| 974 |
sort: typing.Optional[str] = None, |
| 975 |
request_options: typing.Optional[RequestOptions] = None, |
| 976 |
) -> AsyncHttpResponse[ListCustomDomainsResponseContent]: |
| 977 |
""" |
| 978 |
Retrieve details on [custom domains](https://auth0.com/docs/custom-domains). |
| 979 |
|
| 980 |
Parameters |
| 981 |
---------- |
| 982 |
q : typing.Optional[str] |
| 983 |
Query in <a href ="https://lucene.apache.org/core/2_9_4/queryparsersyntax.html">Lucene query string syntax</a>. |
| 984 |
|
| 985 |
fields : typing.Optional[str] |
| 986 |
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. |
| 987 |
|
| 988 |
include_fields : typing.Optional[bool] |
| 989 |
Whether specified fields are to be included (true) or excluded (false). |
| 990 |
|
| 991 |
sort : typing.Optional[str] |
| 992 |
Field to sort by. Only <code>domain:1</code> (ascending order by domain) is supported at this time. |
| 993 |
|
| 994 |
request_options : typing.Optional[RequestOptions] |
| 995 |
Request-specific configuration. |
| 996 |
|
| 997 |
Returns |
| 998 |
------- |
| 999 |
AsyncHttpResponse[ListCustomDomainsResponseContent] |
| 1000 |
Custom domains successfully retrieved. |
| 1001 |
""" |
| 1002 |
_response = await self._client_wrapper.httpx_client.request( |
| 1003 |
"custom-domains", |
| 1004 |
method="GET", |
| 1005 |
params={ |
| 1006 |
"q": q, |
| 1007 |
"fields": fields, |
| 1008 |
"include_fields": include_fields, |
| 1009 |
"sort": sort, |
| 1010 |
}, |
| 1011 |
request_options=request_options, |
| 1012 |
) |
| 1013 |
try: |
| 1014 |
if 200 <= _response.status_code < 300: |
| 1015 |
_data = typing.cast( |
| 1016 |
ListCustomDomainsResponseContent, |
| 1017 |
parse_obj_as( |
| 1018 |
type_=ListCustomDomainsResponseContent, |
| 1019 |
object_=_response.json(), |
| 1020 |
), |
| 1021 |
) |
| 1022 |
return AsyncHttpResponse(response=_response, data=_data) |
| 1023 |
if _response.status_code == 401: |
| 1024 |
raise UnauthorizedError( |
| 1025 |
headers=dict(_response.headers), |
| 1026 |
body=typing.cast( |
| 1027 |
typing.Any, |
| 1028 |
parse_obj_as( |
| 1029 |
type_=typing.Any, |
| 1030 |
object_=_response.json(), |
| 1031 |
), |
| 1032 |
), |
| 1033 |
) |
| 1034 |
if _response.status_code == 403: |
| 1035 |
raise ForbiddenError( |
| 1036 |
headers=dict(_response.headers), |
| 1037 |
body=typing.cast( |
| 1038 |
typing.Any, |
| 1039 |
parse_obj_as( |
| 1040 |
type_=typing.Any, |
| 1041 |
object_=_response.json(), |
| 1042 |
), |
| 1043 |
), |
| 1044 |
) |
| 1045 |
if _response.status_code == 429: |
| 1046 |
raise TooManyRequestsError( |
| 1047 |
headers=dict(_response.headers), |
| 1048 |
body=typing.cast( |
| 1049 |
typing.Any, |
| 1050 |
parse_obj_as( |
| 1051 |
type_=typing.Any, |
| 1052 |
object_=_response.json(), |
| 1053 |
), |
| 1054 |
), |
| 1055 |
) |
| 1056 |
_response_json = _response.json() |
| 1057 |
except JSONDecodeError: |
| 1058 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1059 |
except ValidationError as e: |
| 1060 |
raise ParsingError( |
| 1061 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1062 |
) |
| 1063 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1064 |
|
| 1065 |
async def create( |
| 1066 |
self, |
| 1067 |
*, |
| 1068 |
domain: str, |
| 1069 |
type: CustomDomainProvisioningTypeEnum, |
| 1070 |
verification_method: typing.Optional[CustomDomainVerificationMethodEnum] = OMIT, |
| 1071 |
tls_policy: typing.Optional[CustomDomainTlsPolicyEnum] = OMIT, |
| 1072 |
custom_client_ip_header: typing.Optional[CustomDomainCustomClientIpHeader] = OMIT, |
| 1073 |
domain_metadata: typing.Optional[DomainMetadata] = OMIT, |
| 1074 |
relying_party_identifier: typing.Optional[str] = OMIT, |
| 1075 |
request_options: typing.Optional[RequestOptions] = None, |
| 1076 |
) -> AsyncHttpResponse[CreateCustomDomainResponseContent]: |
| 1077 |
""" |
| 1078 |
Create a new custom domain. |
| 1079 |
|
| 1080 |
Note: The custom domain will need to be verified before it will accept |
| 1081 |
requests. |
| 1082 |
|
| 1083 |
Optional attributes that can be updated: |
| 1084 |
|
| 1085 |
- custom_client_ip_header |
| 1086 |
- tls_policy |
| 1087 |
|
| 1088 |
TLS Policies: |
| 1089 |
|
| 1090 |
- recommended - for modern usage this includes TLS 1.2 only |
| 1091 |
|
| 1092 |
Parameters |
| 1093 |
---------- |
| 1094 |
domain : str |
| 1095 |
Domain name. |
| 1096 |
|
| 1097 |
type : CustomDomainProvisioningTypeEnum |
| 1098 |
|
| 1099 |
verification_method : typing.Optional[CustomDomainVerificationMethodEnum] |
| 1100 |
|
| 1101 |
tls_policy : typing.Optional[CustomDomainTlsPolicyEnum] |
| 1102 |
|
| 1103 |
custom_client_ip_header : typing.Optional[CustomDomainCustomClientIpHeader] |
| 1104 |
|
| 1105 |
domain_metadata : typing.Optional[DomainMetadata] |
| 1106 |
|
| 1107 |
relying_party_identifier : typing.Optional[str] |
| 1108 |
Relying Party ID (rpId) to be used for Passkeys on this custom domain. If not provided, the full domain will be used. |
| 1109 |
|
| 1110 |
request_options : typing.Optional[RequestOptions] |
| 1111 |
Request-specific configuration. |
| 1112 |
|
| 1113 |
Returns |
| 1114 |
------- |
| 1115 |
AsyncHttpResponse[CreateCustomDomainResponseContent] |
| 1116 |
Custom domain successfully created (verification is pending). |
| 1117 |
""" |
| 1118 |
_response = await self._client_wrapper.httpx_client.request( |
| 1119 |
"custom-domains", |
| 1120 |
method="POST", |
| 1121 |
json={ |
| 1122 |
"domain": domain, |
| 1123 |
"type": type, |
| 1124 |
"verification_method": verification_method, |
| 1125 |
"tls_policy": tls_policy, |
| 1126 |
"custom_client_ip_header": custom_client_ip_header, |
| 1127 |
"domain_metadata": domain_metadata, |
| 1128 |
"relying_party_identifier": relying_party_identifier, |
| 1129 |
}, |
| 1130 |
headers={ |
| 1131 |
"content-type": "application/json", |
| 1132 |
}, |
| 1133 |
request_options=request_options, |
| 1134 |
omit=OMIT, |
| 1135 |
) |
| 1136 |
try: |
| 1137 |
if 200 <= _response.status_code < 300: |
| 1138 |
_data = typing.cast( |
| 1139 |
CreateCustomDomainResponseContent, |
| 1140 |
parse_obj_as( |
| 1141 |
type_=CreateCustomDomainResponseContent, |
| 1142 |
object_=_response.json(), |
| 1143 |
), |
| 1144 |
) |
| 1145 |
return AsyncHttpResponse(response=_response, data=_data) |
| 1146 |
if _response.status_code == 400: |
| 1147 |
raise BadRequestError( |
| 1148 |
headers=dict(_response.headers), |
| 1149 |
body=typing.cast( |
| 1150 |
typing.Any, |
| 1151 |
parse_obj_as( |
| 1152 |
type_=typing.Any, |
| 1153 |
object_=_response.json(), |
| 1154 |
), |
| 1155 |
), |
| 1156 |
) |
| 1157 |
if _response.status_code == 401: |
| 1158 |
raise UnauthorizedError( |
| 1159 |
headers=dict(_response.headers), |
| 1160 |
body=typing.cast( |
| 1161 |
typing.Any, |
| 1162 |
parse_obj_as( |
| 1163 |
type_=typing.Any, |
| 1164 |
object_=_response.json(), |
| 1165 |
), |
| 1166 |
), |
| 1167 |
) |
| 1168 |
if _response.status_code == 403: |
| 1169 |
raise ForbiddenError( |
| 1170 |
headers=dict(_response.headers), |
| 1171 |
body=typing.cast( |
| 1172 |
typing.Any, |
| 1173 |
parse_obj_as( |
| 1174 |
type_=typing.Any, |
| 1175 |
object_=_response.json(), |
| 1176 |
), |
| 1177 |
), |
| 1178 |
) |
| 1179 |
if _response.status_code == 409: |
| 1180 |
raise ConflictError( |
| 1181 |
headers=dict(_response.headers), |
| 1182 |
body=typing.cast( |
| 1183 |
typing.Any, |
| 1184 |
parse_obj_as( |
| 1185 |
type_=typing.Any, |
| 1186 |
object_=_response.json(), |
| 1187 |
), |
| 1188 |
), |
| 1189 |
) |
| 1190 |
if _response.status_code == 429: |
| 1191 |
raise TooManyRequestsError( |
| 1192 |
headers=dict(_response.headers), |
| 1193 |
body=typing.cast( |
| 1194 |
typing.Any, |
| 1195 |
parse_obj_as( |
| 1196 |
type_=typing.Any, |
| 1197 |
object_=_response.json(), |
| 1198 |
), |
| 1199 |
), |
| 1200 |
) |
| 1201 |
_response_json = _response.json() |
| 1202 |
except JSONDecodeError: |
| 1203 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1204 |
except ValidationError as e: |
| 1205 |
raise ParsingError( |
| 1206 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1207 |
) |
| 1208 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1209 |
|
| 1210 |
async def get_default( |
| 1211 |
self, *, request_options: typing.Optional[RequestOptions] = None |
| 1212 |
) -> AsyncHttpResponse[GetDefaultDomainResponseContent]: |
| 1213 |
""" |
| 1214 |
Retrieve the tenant's default domain. |
| 1215 |
|
| 1216 |
Parameters |
| 1217 |
---------- |
| 1218 |
request_options : typing.Optional[RequestOptions] |
| 1219 |
Request-specific configuration. |
| 1220 |
|
| 1221 |
Returns |
| 1222 |
------- |
| 1223 |
AsyncHttpResponse[GetDefaultDomainResponseContent] |
| 1224 |
Default domain successfully retrieved. |
| 1225 |
""" |
| 1226 |
_response = await self._client_wrapper.httpx_client.request( |
| 1227 |
"custom-domains/default", |
| 1228 |
method="GET", |
| 1229 |
request_options=request_options, |
| 1230 |
) |
| 1231 |
try: |
| 1232 |
if 200 <= _response.status_code < 300: |
| 1233 |
_data = typing.cast( |
| 1234 |
GetDefaultDomainResponseContent, |
| 1235 |
parse_obj_as( |
| 1236 |
type_=GetDefaultDomainResponseContent, |
| 1237 |
object_=_response.json(), |
| 1238 |
), |
| 1239 |
) |
| 1240 |
return AsyncHttpResponse(response=_response, data=_data) |
| 1241 |
if _response.status_code == 401: |
| 1242 |
raise UnauthorizedError( |
| 1243 |
headers=dict(_response.headers), |
| 1244 |
body=typing.cast( |
| 1245 |
typing.Any, |
| 1246 |
parse_obj_as( |
| 1247 |
type_=typing.Any, |
| 1248 |
object_=_response.json(), |
| 1249 |
), |
| 1250 |
), |
| 1251 |
) |
| 1252 |
if _response.status_code == 403: |
| 1253 |
raise ForbiddenError( |
| 1254 |
headers=dict(_response.headers), |
| 1255 |
body=typing.cast( |
| 1256 |
typing.Any, |
| 1257 |
parse_obj_as( |
| 1258 |
type_=typing.Any, |
| 1259 |
object_=_response.json(), |
| 1260 |
), |
| 1261 |
), |
| 1262 |
) |
| 1263 |
if _response.status_code == 429: |
| 1264 |
raise TooManyRequestsError( |
| 1265 |
headers=dict(_response.headers), |
| 1266 |
body=typing.cast( |
| 1267 |
typing.Any, |
| 1268 |
parse_obj_as( |
| 1269 |
type_=typing.Any, |
| 1270 |
object_=_response.json(), |
| 1271 |
), |
| 1272 |
), |
| 1273 |
) |
| 1274 |
_response_json = _response.json() |
| 1275 |
except JSONDecodeError: |
| 1276 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1277 |
except ValidationError as e: |
| 1278 |
raise ParsingError( |
| 1279 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1280 |
) |
| 1281 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1282 |
|
| 1283 |
async def set_default( |
| 1284 |
self, *, domain: str, request_options: typing.Optional[RequestOptions] = None |
| 1285 |
) -> AsyncHttpResponse[UpdateDefaultDomainResponseContent]: |
| 1286 |
""" |
| 1287 |
Set the default custom domain for the tenant. |
| 1288 |
|
| 1289 |
Parameters |
| 1290 |
---------- |
| 1291 |
domain : str |
| 1292 |
The domain to set as the default custom domain. Must be a verified custom domain or the canonical domain. |
| 1293 |
|
| 1294 |
request_options : typing.Optional[RequestOptions] |
| 1295 |
Request-specific configuration. |
| 1296 |
|
| 1297 |
Returns |
| 1298 |
------- |
| 1299 |
AsyncHttpResponse[UpdateDefaultDomainResponseContent] |
| 1300 |
Default custom domain set successfully. |
| 1301 |
""" |
| 1302 |
_response = await self._client_wrapper.httpx_client.request( |
| 1303 |
"custom-domains/default", |
| 1304 |
method="PATCH", |
| 1305 |
json={ |
| 1306 |
"domain": domain, |
| 1307 |
}, |
| 1308 |
headers={ |
| 1309 |
"content-type": "application/json", |
| 1310 |
}, |
| 1311 |
request_options=request_options, |
| 1312 |
omit=OMIT, |
| 1313 |
) |
| 1314 |
try: |
| 1315 |
if 200 <= _response.status_code < 300: |
| 1316 |
_data = typing.cast( |
| 1317 |
UpdateDefaultDomainResponseContent, |
| 1318 |
parse_obj_as( |
| 1319 |
type_=UpdateDefaultDomainResponseContent, |
| 1320 |
object_=_response.json(), |
| 1321 |
), |
| 1322 |
) |
| 1323 |
return AsyncHttpResponse(response=_response, data=_data) |
| 1324 |
if _response.status_code == 400: |
| 1325 |
raise BadRequestError( |
| 1326 |
headers=dict(_response.headers), |
| 1327 |
body=typing.cast( |
| 1328 |
typing.Any, |
| 1329 |
parse_obj_as( |
| 1330 |
type_=typing.Any, |
| 1331 |
object_=_response.json(), |
| 1332 |
), |
| 1333 |
), |
| 1334 |
) |
| 1335 |
if _response.status_code == 403: |
| 1336 |
raise ForbiddenError( |
| 1337 |
headers=dict(_response.headers), |
| 1338 |
body=typing.cast( |
| 1339 |
typing.Any, |
| 1340 |
parse_obj_as( |
| 1341 |
type_=typing.Any, |
| 1342 |
object_=_response.json(), |
| 1343 |
), |
| 1344 |
), |
| 1345 |
) |
| 1346 |
_response_json = _response.json() |
| 1347 |
except JSONDecodeError: |
| 1348 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1349 |
except ValidationError as e: |
| 1350 |
raise ParsingError( |
| 1351 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1352 |
) |
| 1353 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1354 |
|
| 1355 |
async def get( |
| 1356 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 1357 |
) -> AsyncHttpResponse[GetCustomDomainResponseContent]: |
| 1358 |
""" |
| 1359 |
Retrieve a custom domain configuration and status. |
| 1360 |
|
| 1361 |
Parameters |
| 1362 |
---------- |
| 1363 |
id : str |
| 1364 |
ID of the custom domain to retrieve. |
| 1365 |
|
| 1366 |
request_options : typing.Optional[RequestOptions] |
| 1367 |
Request-specific configuration. |
| 1368 |
|
| 1369 |
Returns |
| 1370 |
------- |
| 1371 |
AsyncHttpResponse[GetCustomDomainResponseContent] |
| 1372 |
Custom domain successfully retrieved. |
| 1373 |
""" |
| 1374 |
_response = await self._client_wrapper.httpx_client.request( |
| 1375 |
f"custom-domains/{encode_path_param(id)}", |
| 1376 |
method="GET", |
| 1377 |
request_options=request_options, |
| 1378 |
) |
| 1379 |
try: |
| 1380 |
if 200 <= _response.status_code < 300: |
| 1381 |
_data = typing.cast( |
| 1382 |
GetCustomDomainResponseContent, |
| 1383 |
parse_obj_as( |
| 1384 |
type_=GetCustomDomainResponseContent, |
| 1385 |
object_=_response.json(), |
| 1386 |
), |
| 1387 |
) |
| 1388 |
return AsyncHttpResponse(response=_response, data=_data) |
| 1389 |
if _response.status_code == 400: |
| 1390 |
raise BadRequestError( |
| 1391 |
headers=dict(_response.headers), |
| 1392 |
body=typing.cast( |
| 1393 |
typing.Any, |
| 1394 |
parse_obj_as( |
| 1395 |
type_=typing.Any, |
| 1396 |
object_=_response.json(), |
| 1397 |
), |
| 1398 |
), |
| 1399 |
) |
| 1400 |
if _response.status_code == 401: |
| 1401 |
raise UnauthorizedError( |
| 1402 |
headers=dict(_response.headers), |
| 1403 |
body=typing.cast( |
| 1404 |
typing.Any, |
| 1405 |
parse_obj_as( |
| 1406 |
type_=typing.Any, |
| 1407 |
object_=_response.json(), |
| 1408 |
), |
| 1409 |
), |
| 1410 |
) |
| 1411 |
if _response.status_code == 403: |
| 1412 |
raise ForbiddenError( |
| 1413 |
headers=dict(_response.headers), |
| 1414 |
body=typing.cast( |
| 1415 |
typing.Any, |
| 1416 |
parse_obj_as( |
| 1417 |
type_=typing.Any, |
| 1418 |
object_=_response.json(), |
| 1419 |
), |
| 1420 |
), |
| 1421 |
) |
| 1422 |
if _response.status_code == 404: |
| 1423 |
raise NotFoundError( |
| 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 == 429: |
| 1434 |
raise TooManyRequestsError( |
| 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 |
_response_json = _response.json() |
| 1445 |
except JSONDecodeError: |
| 1446 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1447 |
except ValidationError as e: |
| 1448 |
raise ParsingError( |
| 1449 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1450 |
) |
| 1451 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1452 |
|
| 1453 |
async def delete( |
| 1454 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 1455 |
) -> AsyncHttpResponse[None]: |
| 1456 |
""" |
| 1457 |
Delete a custom domain and stop serving requests for it. |
| 1458 |
|
| 1459 |
Parameters |
| 1460 |
---------- |
| 1461 |
id : str |
| 1462 |
ID of the custom domain to delete. |
| 1463 |
|
| 1464 |
request_options : typing.Optional[RequestOptions] |
| 1465 |
Request-specific configuration. |
| 1466 |
|
| 1467 |
Returns |
| 1468 |
------- |
| 1469 |
AsyncHttpResponse[None] |
| 1470 |
""" |
| 1471 |
_response = await self._client_wrapper.httpx_client.request( |
| 1472 |
f"custom-domains/{encode_path_param(id)}", |
| 1473 |
method="DELETE", |
| 1474 |
request_options=request_options, |
| 1475 |
) |
| 1476 |
try: |
| 1477 |
if 200 <= _response.status_code < 300: |
| 1478 |
return AsyncHttpResponse(response=_response, data=None) |
| 1479 |
if _response.status_code == 400: |
| 1480 |
raise BadRequestError( |
| 1481 |
headers=dict(_response.headers), |
| 1482 |
body=typing.cast( |
| 1483 |
typing.Any, |
| 1484 |
parse_obj_as( |
| 1485 |
type_=typing.Any, |
| 1486 |
object_=_response.json(), |
| 1487 |
), |
| 1488 |
), |
| 1489 |
) |
| 1490 |
if _response.status_code == 401: |
| 1491 |
raise UnauthorizedError( |
| 1492 |
headers=dict(_response.headers), |
| 1493 |
body=typing.cast( |
| 1494 |
typing.Any, |
| 1495 |
parse_obj_as( |
| 1496 |
type_=typing.Any, |
| 1497 |
object_=_response.json(), |
| 1498 |
), |
| 1499 |
), |
| 1500 |
) |
| 1501 |
if _response.status_code == 403: |
| 1502 |
raise ForbiddenError( |
| 1503 |
headers=dict(_response.headers), |
| 1504 |
body=typing.cast( |
| 1505 |
typing.Any, |
| 1506 |
parse_obj_as( |
| 1507 |
type_=typing.Any, |
| 1508 |
object_=_response.json(), |
| 1509 |
), |
| 1510 |
), |
| 1511 |
) |
| 1512 |
if _response.status_code == 409: |
| 1513 |
raise ConflictError( |
| 1514 |
headers=dict(_response.headers), |
| 1515 |
body=typing.cast( |
| 1516 |
typing.Any, |
| 1517 |
parse_obj_as( |
| 1518 |
type_=typing.Any, |
| 1519 |
object_=_response.json(), |
| 1520 |
), |
| 1521 |
), |
| 1522 |
) |
| 1523 |
if _response.status_code == 429: |
| 1524 |
raise TooManyRequestsError( |
| 1525 |
headers=dict(_response.headers), |
| 1526 |
body=typing.cast( |
| 1527 |
typing.Any, |
| 1528 |
parse_obj_as( |
| 1529 |
type_=typing.Any, |
| 1530 |
object_=_response.json(), |
| 1531 |
), |
| 1532 |
), |
| 1533 |
) |
| 1534 |
_response_json = _response.json() |
| 1535 |
except JSONDecodeError: |
| 1536 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1537 |
except ValidationError as e: |
| 1538 |
raise ParsingError( |
| 1539 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1540 |
) |
| 1541 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1542 |
|
| 1543 |
async def update( |
| 1544 |
self, |
| 1545 |
id: str, |
| 1546 |
*, |
| 1547 |
tls_policy: typing.Optional[CustomDomainTlsPolicyEnum] = OMIT, |
| 1548 |
custom_client_ip_header: typing.Optional[CustomDomainCustomClientIpHeader] = OMIT, |
| 1549 |
domain_metadata: typing.Optional[DomainMetadata] = OMIT, |
| 1550 |
relying_party_identifier: typing.Optional[str] = OMIT, |
| 1551 |
request_options: typing.Optional[RequestOptions] = None, |
| 1552 |
) -> AsyncHttpResponse[UpdateCustomDomainResponseContent]: |
| 1553 |
""" |
| 1554 |
Update a custom domain. |
| 1555 |
|
| 1556 |
These are the attributes that can be updated: |
| 1557 |
|
| 1558 |
- custom_client_ip_header |
| 1559 |
- tls_policy |
| 1560 |
|
| 1561 |
**Updating CUSTOM_CLIENT_IP_HEADER for a custom domain** |
| 1562 |
|
| 1563 |
To update the `custom_client_ip_header` for a domain, the body to |
| 1564 |
send should be: |
| 1565 |
|
| 1566 |
```json |
| 1567 |
{ "custom_client_ip_header": "cf-connecting-ip" } |
| 1568 |
``` |
| 1569 |
|
| 1570 |
**Updating TLS_POLICY for a custom domain** |
| 1571 |
|
| 1572 |
To update the `tls_policy` for a domain, the body to send should be: |
| 1573 |
|
| 1574 |
```json |
| 1575 |
{ "tls_policy": "recommended" } |
| 1576 |
``` |
| 1577 |
|
| 1578 |
TLS Policies: |
| 1579 |
|
| 1580 |
- recommended - for modern usage this includes TLS 1.2 only |
| 1581 |
|
| 1582 |
Some considerations: |
| 1583 |
|
| 1584 |
- The TLS ciphers and protocols available in each TLS policy follow industry recommendations, and may be updated occasionally. |
| 1585 |
- The `compatible` TLS policy is no longer supported. |
| 1586 |
|
| 1587 |
Parameters |
| 1588 |
---------- |
| 1589 |
id : str |
| 1590 |
The id of the custom domain to update |
| 1591 |
|
| 1592 |
tls_policy : typing.Optional[CustomDomainTlsPolicyEnum] |
| 1593 |
recommended includes TLS 1.2 |
| 1594 |
|
| 1595 |
custom_client_ip_header : typing.Optional[CustomDomainCustomClientIpHeader] |
| 1596 |
|
| 1597 |
domain_metadata : typing.Optional[DomainMetadata] |
| 1598 |
|
| 1599 |
relying_party_identifier : typing.Optional[str] |
| 1600 |
Relying Party ID (rpId) to be used for Passkeys on this custom domain. Set to null to remove the rpId and fall back to using the full domain. |
| 1601 |
|
| 1602 |
request_options : typing.Optional[RequestOptions] |
| 1603 |
Request-specific configuration. |
| 1604 |
|
| 1605 |
Returns |
| 1606 |
------- |
| 1607 |
AsyncHttpResponse[UpdateCustomDomainResponseContent] |
| 1608 |
Custom domain updated. |
| 1609 |
""" |
| 1610 |
_response = await self._client_wrapper.httpx_client.request( |
| 1611 |
f"custom-domains/{encode_path_param(id)}", |
| 1612 |
method="PATCH", |
| 1613 |
json={ |
| 1614 |
"tls_policy": tls_policy, |
| 1615 |
"custom_client_ip_header": custom_client_ip_header, |
| 1616 |
"domain_metadata": domain_metadata, |
| 1617 |
"relying_party_identifier": relying_party_identifier, |
| 1618 |
}, |
| 1619 |
headers={ |
| 1620 |
"content-type": "application/json", |
| 1621 |
}, |
| 1622 |
request_options=request_options, |
| 1623 |
omit=OMIT, |
| 1624 |
) |
| 1625 |
try: |
| 1626 |
if 200 <= _response.status_code < 300: |
| 1627 |
_data = typing.cast( |
| 1628 |
UpdateCustomDomainResponseContent, |
| 1629 |
parse_obj_as( |
| 1630 |
type_=UpdateCustomDomainResponseContent, |
| 1631 |
object_=_response.json(), |
| 1632 |
), |
| 1633 |
) |
| 1634 |
return AsyncHttpResponse(response=_response, data=_data) |
| 1635 |
if _response.status_code == 400: |
| 1636 |
raise BadRequestError( |
| 1637 |
headers=dict(_response.headers), |
| 1638 |
body=typing.cast( |
| 1639 |
typing.Any, |
| 1640 |
parse_obj_as( |
| 1641 |
type_=typing.Any, |
| 1642 |
object_=_response.json(), |
| 1643 |
), |
| 1644 |
), |
| 1645 |
) |
| 1646 |
if _response.status_code == 401: |
| 1647 |
raise UnauthorizedError( |
| 1648 |
headers=dict(_response.headers), |
| 1649 |
body=typing.cast( |
| 1650 |
typing.Any, |
| 1651 |
parse_obj_as( |
| 1652 |
type_=typing.Any, |
| 1653 |
object_=_response.json(), |
| 1654 |
), |
| 1655 |
), |
| 1656 |
) |
| 1657 |
if _response.status_code == 403: |
| 1658 |
raise ForbiddenError( |
| 1659 |
headers=dict(_response.headers), |
| 1660 |
body=typing.cast( |
| 1661 |
typing.Any, |
| 1662 |
parse_obj_as( |
| 1663 |
type_=typing.Any, |
| 1664 |
object_=_response.json(), |
| 1665 |
), |
| 1666 |
), |
| 1667 |
) |
| 1668 |
if _response.status_code == 429: |
| 1669 |
raise TooManyRequestsError( |
| 1670 |
headers=dict(_response.headers), |
| 1671 |
body=typing.cast( |
| 1672 |
typing.Any, |
| 1673 |
parse_obj_as( |
| 1674 |
type_=typing.Any, |
| 1675 |
object_=_response.json(), |
| 1676 |
), |
| 1677 |
), |
| 1678 |
) |
| 1679 |
_response_json = _response.json() |
| 1680 |
except JSONDecodeError: |
| 1681 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1682 |
except ValidationError as e: |
| 1683 |
raise ParsingError( |
| 1684 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1685 |
) |
| 1686 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1687 |
|
| 1688 |
async def test( |
| 1689 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 1690 |
) -> AsyncHttpResponse[TestCustomDomainResponseContent]: |
| 1691 |
""" |
| 1692 |
Run the test process on a custom domain. |
| 1693 |
|
| 1694 |
Parameters |
| 1695 |
---------- |
| 1696 |
id : str |
| 1697 |
ID of the custom domain to test. |
| 1698 |
|
| 1699 |
request_options : typing.Optional[RequestOptions] |
| 1700 |
Request-specific configuration. |
| 1701 |
|
| 1702 |
Returns |
| 1703 |
------- |
| 1704 |
AsyncHttpResponse[TestCustomDomainResponseContent] |
| 1705 |
Custom domain test successfully completed. |
| 1706 |
""" |
| 1707 |
_response = await self._client_wrapper.httpx_client.request( |
| 1708 |
f"custom-domains/{encode_path_param(id)}/test", |
| 1709 |
method="POST", |
| 1710 |
request_options=request_options, |
| 1711 |
) |
| 1712 |
try: |
| 1713 |
if 200 <= _response.status_code < 300: |
| 1714 |
_data = typing.cast( |
| 1715 |
TestCustomDomainResponseContent, |
| 1716 |
parse_obj_as( |
| 1717 |
type_=TestCustomDomainResponseContent, |
| 1718 |
object_=_response.json(), |
| 1719 |
), |
| 1720 |
) |
| 1721 |
return AsyncHttpResponse(response=_response, data=_data) |
| 1722 |
if _response.status_code == 400: |
| 1723 |
raise BadRequestError( |
| 1724 |
headers=dict(_response.headers), |
| 1725 |
body=typing.cast( |
| 1726 |
typing.Any, |
| 1727 |
parse_obj_as( |
| 1728 |
type_=typing.Any, |
| 1729 |
object_=_response.json(), |
| 1730 |
), |
| 1731 |
), |
| 1732 |
) |
| 1733 |
if _response.status_code == 401: |
| 1734 |
raise UnauthorizedError( |
| 1735 |
headers=dict(_response.headers), |
| 1736 |
body=typing.cast( |
| 1737 |
typing.Any, |
| 1738 |
parse_obj_as( |
| 1739 |
type_=typing.Any, |
| 1740 |
object_=_response.json(), |
| 1741 |
), |
| 1742 |
), |
| 1743 |
) |
| 1744 |
if _response.status_code == 403: |
| 1745 |
raise ForbiddenError( |
| 1746 |
headers=dict(_response.headers), |
| 1747 |
body=typing.cast( |
| 1748 |
typing.Any, |
| 1749 |
parse_obj_as( |
| 1750 |
type_=typing.Any, |
| 1751 |
object_=_response.json(), |
| 1752 |
), |
| 1753 |
), |
| 1754 |
) |
| 1755 |
if _response.status_code == 404: |
| 1756 |
raise NotFoundError( |
| 1757 |
headers=dict(_response.headers), |
| 1758 |
body=typing.cast( |
| 1759 |
typing.Any, |
| 1760 |
parse_obj_as( |
| 1761 |
type_=typing.Any, |
| 1762 |
object_=_response.json(), |
| 1763 |
), |
| 1764 |
), |
| 1765 |
) |
| 1766 |
if _response.status_code == 409: |
| 1767 |
raise ConflictError( |
| 1768 |
headers=dict(_response.headers), |
| 1769 |
body=typing.cast( |
| 1770 |
typing.Any, |
| 1771 |
parse_obj_as( |
| 1772 |
type_=typing.Any, |
| 1773 |
object_=_response.json(), |
| 1774 |
), |
| 1775 |
), |
| 1776 |
) |
| 1777 |
_response_json = _response.json() |
| 1778 |
except JSONDecodeError: |
| 1779 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1780 |
except ValidationError as e: |
| 1781 |
raise ParsingError( |
| 1782 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1783 |
) |
| 1784 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1785 |
|
| 1786 |
async def verify( |
| 1787 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 1788 |
) -> AsyncHttpResponse[VerifyCustomDomainResponseContent]: |
| 1789 |
""" |
| 1790 |
Run the verification process on a custom domain. |
| 1791 |
|
| 1792 |
Note: Check the `status` field to see its verification status. Once verification is complete, it may take up to 10 minutes before the custom domain can start accepting requests. |
| 1793 |
|
| 1794 |
For `self_managed_certs`, when the custom domain is verified for the first time, the response will also include the `cname_api_key` which you will need to configure your proxy. This key must be kept secret, and is used to validate the proxy requests. |
| 1795 |
|
| 1796 |
[Learn more](https://auth0.com/docs/custom-domains#step-2-verify-ownership) about verifying custom domains that use Auth0 Managed certificates. |
| 1797 |
[Learn more](https://auth0.com/docs/custom-domains/self-managed-certificates#step-2-verify-ownership) about verifying custom domains that use Self Managed certificates. |
| 1798 |
|
| 1799 |
Parameters |
| 1800 |
---------- |
| 1801 |
id : str |
| 1802 |
ID of the custom domain to verify. |
| 1803 |
|
| 1804 |
request_options : typing.Optional[RequestOptions] |
| 1805 |
Request-specific configuration. |
| 1806 |
|
| 1807 |
Returns |
| 1808 |
------- |
| 1809 |
AsyncHttpResponse[VerifyCustomDomainResponseContent] |
| 1810 |
Custom domain successfully verified. |
| 1811 |
""" |
| 1812 |
_response = await self._client_wrapper.httpx_client.request( |
| 1813 |
f"custom-domains/{encode_path_param(id)}/verify", |
| 1814 |
method="POST", |
| 1815 |
request_options=request_options, |
| 1816 |
) |
| 1817 |
try: |
| 1818 |
if 200 <= _response.status_code < 300: |
| 1819 |
_data = typing.cast( |
| 1820 |
VerifyCustomDomainResponseContent, |
| 1821 |
parse_obj_as( |
| 1822 |
type_=VerifyCustomDomainResponseContent, |
| 1823 |
object_=_response.json(), |
| 1824 |
), |
| 1825 |
) |
| 1826 |
return AsyncHttpResponse(response=_response, data=_data) |
| 1827 |
if _response.status_code == 400: |
| 1828 |
raise BadRequestError( |
| 1829 |
headers=dict(_response.headers), |
| 1830 |
body=typing.cast( |
| 1831 |
typing.Any, |
| 1832 |
parse_obj_as( |
| 1833 |
type_=typing.Any, |
| 1834 |
object_=_response.json(), |
| 1835 |
), |
| 1836 |
), |
| 1837 |
) |
| 1838 |
if _response.status_code == 401: |
| 1839 |
raise UnauthorizedError( |
| 1840 |
headers=dict(_response.headers), |
| 1841 |
body=typing.cast( |
| 1842 |
typing.Any, |
| 1843 |
parse_obj_as( |
| 1844 |
type_=typing.Any, |
| 1845 |
object_=_response.json(), |
| 1846 |
), |
| 1847 |
), |
| 1848 |
) |
| 1849 |
if _response.status_code == 403: |
| 1850 |
raise ForbiddenError( |
| 1851 |
headers=dict(_response.headers), |
| 1852 |
body=typing.cast( |
| 1853 |
typing.Any, |
| 1854 |
parse_obj_as( |
| 1855 |
type_=typing.Any, |
| 1856 |
object_=_response.json(), |
| 1857 |
), |
| 1858 |
), |
| 1859 |
) |
| 1860 |
if _response.status_code == 404: |
| 1861 |
raise NotFoundError( |
| 1862 |
headers=dict(_response.headers), |
| 1863 |
body=typing.cast( |
| 1864 |
typing.Any, |
| 1865 |
parse_obj_as( |
| 1866 |
type_=typing.Any, |
| 1867 |
object_=_response.json(), |
| 1868 |
), |
| 1869 |
), |
| 1870 |
) |
| 1871 |
if _response.status_code == 429: |
| 1872 |
raise TooManyRequestsError( |
| 1873 |
headers=dict(_response.headers), |
| 1874 |
body=typing.cast( |
| 1875 |
typing.Any, |
| 1876 |
parse_obj_as( |
| 1877 |
type_=typing.Any, |
| 1878 |
object_=_response.json(), |
| 1879 |
), |
| 1880 |
), |
| 1881 |
) |
| 1882 |
_response_json = _response.json() |
| 1883 |
except JSONDecodeError: |
| 1884 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1885 |
except ValidationError as e: |
| 1886 |
raise ParsingError( |
| 1887 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1888 |
) |
| 1889 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |