|
15 | 15 |
|
16 | 16 | import json |
17 | 17 | import pprint |
| 18 | +import re # noqa: F401 |
18 | 19 | from typing import Any, ClassVar, Dict, List, Optional, Set |
19 | 20 |
|
20 | | -from pydantic import BaseModel, ConfigDict, Field, StrictStr |
| 21 | +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator |
21 | 22 | from pydantic_core import to_jsonable_python |
22 | | -from typing_extensions import Self |
| 23 | +from typing_extensions import Annotated, Self |
23 | 24 |
|
24 | 25 |
|
25 | 26 | class LoadbalancerOptionAccessControl(BaseModel): |
26 | 27 | """ |
27 | | - Use this option to limit the IP ranges that can use the Application Load Balancer. |
| 28 | + Use this option to limit the IP ranges that can use the Application Load Balancer. Only one of `allowed_source_ranges` or `ip_block_list_name` may be set at the same time. |
28 | 29 | """ # noqa: E501 |
29 | 30 |
|
30 | 31 | allowed_source_ranges: Optional[List[StrictStr]] = Field( |
31 | 32 | default=None, |
32 | | - description="Application Load Balancer is accessible only from an IP address in this range", |
| 33 | + description="Application Load Balancer is accessible only from an IP address in this range. Mutually exclusive with `ipBlockListName`.", |
33 | 34 | alias="allowedSourceRanges", |
34 | 35 | ) |
35 | | - __properties: ClassVar[List[str]] = ["allowedSourceRanges"] |
| 36 | + ip_block_list_name: Optional[Annotated[str, Field(strict=True)]] = Field( |
| 37 | + default=None, |
| 38 | + description='Reference to an IP block list by name. Traffic originating from any IP in the referenced list is denied access to the Application Load Balancer. See "IP Lists API" for how to manage IP block lists. Mutually exclusive with `allowedSourceRanges`.', |
| 39 | + alias="ipBlockListName", |
| 40 | + ) |
| 41 | + __properties: ClassVar[List[str]] = ["allowedSourceRanges", "ipBlockListName"] |
| 42 | + |
| 43 | + @field_validator("ip_block_list_name") |
| 44 | + def ip_block_list_name_validate_regular_expression(cls, value): |
| 45 | + """Validates the regular expression""" |
| 46 | + if value is None: |
| 47 | + return value |
| 48 | + |
| 49 | + if not isinstance(value, str): |
| 50 | + value = str(value) |
| 51 | + |
| 52 | + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,49}[0-9a-z])?$", value): |
| 53 | + raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,49}[0-9a-z])?$/") |
| 54 | + return value |
36 | 55 |
|
37 | 56 | model_config = ConfigDict( |
38 | 57 | validate_by_name=True, |
@@ -82,5 +101,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: |
82 | 101 | if not isinstance(obj, dict): |
83 | 102 | return cls.model_validate(obj) |
84 | 103 |
|
85 | | - _obj = cls.model_validate({"allowedSourceRanges": obj.get("allowedSourceRanges")}) |
| 104 | + _obj = cls.model_validate( |
| 105 | + {"allowedSourceRanges": obj.get("allowedSourceRanges"), "ipBlockListName": obj.get("ipBlockListName")} |
| 106 | + ) |
86 | 107 | return _obj |
0 commit comments