Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
from .types import PlanName
from .types import PurgeRequestStatus
from .content import PURGE_REQUEST_TRANSIENT_STATUSES
from .types import RuleHttpMatchHostFilterHostFilterType
from .types import RuleHttpMatchMethodFilter
from .types import RuleHttpMatchPathFilterPathFilterType
from .types import SearchBackendStagesRequestOrderBy
from .types import SearchRouteRulesRequestOrderBy
from .types import SearchWafStagesRequestOrderBy
from .types import WafStageMode
from .types import ScalewayLb
from .types import RuleHttpMatchHostFilter
from .types import RuleHttpMatchPathFilter
from .types import ScalewayLbBackendConfig
from .types import ScalewayS3BackendConfig
Expand Down Expand Up @@ -152,13 +154,15 @@
"PlanName",
"PurgeRequestStatus",
"PURGE_REQUEST_TRANSIENT_STATUSES",
"RuleHttpMatchHostFilterHostFilterType",
"RuleHttpMatchMethodFilter",
"RuleHttpMatchPathFilterPathFilterType",
"SearchBackendStagesRequestOrderBy",
"SearchRouteRulesRequestOrderBy",
"SearchWafStagesRequestOrderBy",
"WafStageMode",
"ScalewayLb",
"RuleHttpMatchHostFilter",
"RuleHttpMatchPathFilter",
"ScalewayLbBackendConfig",
"ScalewayS3BackendConfig",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
WafStage,
PipelineStages,
PurgeRequest,
RuleHttpMatchHostFilter,
RuleHttpMatchPathFilter,
RuleHttpMatch,
RouteRule,
Expand Down Expand Up @@ -874,6 +875,29 @@ def unmarshal_PurgeRequest(data: Any) -> PurgeRequest:
return PurgeRequest(**args)


def unmarshal_RuleHttpMatchHostFilter(data: Any) -> RuleHttpMatchHostFilter:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'RuleHttpMatchHostFilter' failed as data isn't a dictionary."
)

args: dict[str, Any] = {}

field = data.get("host_filter_type", None)
if field is not None:
args["host_filter_type"] = field
else:
args["host_filter_type"] = None

field = data.get("value", None)
if field is not None:
args["value"] = field
else:
args["value"] = None

return RuleHttpMatchHostFilter(**args)


def unmarshal_RuleHttpMatchPathFilter(data: Any) -> RuleHttpMatchPathFilter:
if not isinstance(data, dict):
raise TypeError(
Expand Down Expand Up @@ -921,6 +945,12 @@ def unmarshal_RuleHttpMatch(data: Any) -> RuleHttpMatch:
else:
args["path_filter"] = None

field = data.get("host_filter", None)
if field is not None:
args["host_filter"] = unmarshal_RuleHttpMatchHostFilter(field)
else:
args["host_filter"] = None

return RuleHttpMatch(**args)


Expand Down Expand Up @@ -1591,6 +1621,21 @@ def unmarshal_SetRouteRulesResponse(data: Any) -> SetRouteRulesResponse:
return SetRouteRulesResponse(**args)


def marshal_RuleHttpMatchHostFilter(
request: RuleHttpMatchHostFilter,
defaults: ProfileDefaults,
) -> dict[str, Any]:
output: dict[str, Any] = {}

if request.host_filter_type is not None:
output["host_filter_type"] = request.host_filter_type

if request.value is not None:
output["value"] = request.value

return output


def marshal_RuleHttpMatchPathFilter(
request: RuleHttpMatchPathFilter,
defaults: ProfileDefaults,
Expand Down Expand Up @@ -1620,6 +1665,11 @@ def marshal_RuleHttpMatch(
request.path_filter, defaults
)

if request.host_filter is not None:
output["host_filter"] = marshal_RuleHttpMatchHostFilter(
request.host_filter, defaults
)

return output


Expand Down
19 changes: 19 additions & 0 deletions scaleway-async/scaleway_async/edge_services/v1beta1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ def __str__(self) -> str:
return str(self.value)


class RuleHttpMatchHostFilterHostFilterType(str, Enum, metaclass=StrEnumMeta):
UNKNOWN_HOST_FILTER = "unknown_host_filter"
REGEX = "regex"

def __str__(self) -> str:
return str(self.value)


class RuleHttpMatchMethodFilter(str, Enum, metaclass=StrEnumMeta):
UNKNOWN_METHOD_FILTER = "unknown_method_filter"
GET = "get"
Expand Down Expand Up @@ -302,6 +310,12 @@ class ScalewayLb:
"""


@dataclass
class RuleHttpMatchHostFilter:
host_filter_type: RuleHttpMatchHostFilterHostFilterType
value: str


@dataclass
class RuleHttpMatchPathFilter:
path_filter_type: RuleHttpMatchPathFilterPathFilterType
Expand Down Expand Up @@ -395,6 +409,11 @@ class RuleHttpMatch:
HTTP URL path to filter for. A request whose path matches the given filter will be considered to match the rule. All paths will match if none is provided.
"""

host_filter: Optional[RuleHttpMatchHostFilter] = None
"""
Host to filter for. A request whose host matches the given filter will be considered to match the rule. All hosts will match if none is provided.
"""


@dataclass
class BackendStage:
Expand Down
4 changes: 4 additions & 0 deletions scaleway/scaleway/edge_services/v1beta1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
from .types import PlanName
from .types import PurgeRequestStatus
from .content import PURGE_REQUEST_TRANSIENT_STATUSES
from .types import RuleHttpMatchHostFilterHostFilterType
from .types import RuleHttpMatchMethodFilter
from .types import RuleHttpMatchPathFilterPathFilterType
from .types import SearchBackendStagesRequestOrderBy
from .types import SearchRouteRulesRequestOrderBy
from .types import SearchWafStagesRequestOrderBy
from .types import WafStageMode
from .types import ScalewayLb
from .types import RuleHttpMatchHostFilter
from .types import RuleHttpMatchPathFilter
from .types import ScalewayLbBackendConfig
from .types import ScalewayS3BackendConfig
Expand Down Expand Up @@ -152,13 +154,15 @@
"PlanName",
"PurgeRequestStatus",
"PURGE_REQUEST_TRANSIENT_STATUSES",
"RuleHttpMatchHostFilterHostFilterType",
"RuleHttpMatchMethodFilter",
"RuleHttpMatchPathFilterPathFilterType",
"SearchBackendStagesRequestOrderBy",
"SearchRouteRulesRequestOrderBy",
"SearchWafStagesRequestOrderBy",
"WafStageMode",
"ScalewayLb",
"RuleHttpMatchHostFilter",
"RuleHttpMatchPathFilter",
"ScalewayLbBackendConfig",
"ScalewayS3BackendConfig",
Expand Down
50 changes: 50 additions & 0 deletions scaleway/scaleway/edge_services/v1beta1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
WafStage,
PipelineStages,
PurgeRequest,
RuleHttpMatchHostFilter,
RuleHttpMatchPathFilter,
RuleHttpMatch,
RouteRule,
Expand Down Expand Up @@ -874,6 +875,29 @@ def unmarshal_PurgeRequest(data: Any) -> PurgeRequest:
return PurgeRequest(**args)


def unmarshal_RuleHttpMatchHostFilter(data: Any) -> RuleHttpMatchHostFilter:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'RuleHttpMatchHostFilter' failed as data isn't a dictionary."
)

args: dict[str, Any] = {}

field = data.get("host_filter_type", None)
if field is not None:
args["host_filter_type"] = field
else:
args["host_filter_type"] = None

field = data.get("value", None)
if field is not None:
args["value"] = field
else:
args["value"] = None

return RuleHttpMatchHostFilter(**args)


def unmarshal_RuleHttpMatchPathFilter(data: Any) -> RuleHttpMatchPathFilter:
if not isinstance(data, dict):
raise TypeError(
Expand Down Expand Up @@ -921,6 +945,12 @@ def unmarshal_RuleHttpMatch(data: Any) -> RuleHttpMatch:
else:
args["path_filter"] = None

field = data.get("host_filter", None)
if field is not None:
args["host_filter"] = unmarshal_RuleHttpMatchHostFilter(field)
else:
args["host_filter"] = None

return RuleHttpMatch(**args)


Expand Down Expand Up @@ -1591,6 +1621,21 @@ def unmarshal_SetRouteRulesResponse(data: Any) -> SetRouteRulesResponse:
return SetRouteRulesResponse(**args)


def marshal_RuleHttpMatchHostFilter(
request: RuleHttpMatchHostFilter,
defaults: ProfileDefaults,
) -> dict[str, Any]:
output: dict[str, Any] = {}

if request.host_filter_type is not None:
output["host_filter_type"] = request.host_filter_type

if request.value is not None:
output["value"] = request.value

return output


def marshal_RuleHttpMatchPathFilter(
request: RuleHttpMatchPathFilter,
defaults: ProfileDefaults,
Expand Down Expand Up @@ -1620,6 +1665,11 @@ def marshal_RuleHttpMatch(
request.path_filter, defaults
)

if request.host_filter is not None:
output["host_filter"] = marshal_RuleHttpMatchHostFilter(
request.host_filter, defaults
)

return output


Expand Down
19 changes: 19 additions & 0 deletions scaleway/scaleway/edge_services/v1beta1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ def __str__(self) -> str:
return str(self.value)


class RuleHttpMatchHostFilterHostFilterType(str, Enum, metaclass=StrEnumMeta):
UNKNOWN_HOST_FILTER = "unknown_host_filter"
REGEX = "regex"

def __str__(self) -> str:
return str(self.value)


class RuleHttpMatchMethodFilter(str, Enum, metaclass=StrEnumMeta):
UNKNOWN_METHOD_FILTER = "unknown_method_filter"
GET = "get"
Expand Down Expand Up @@ -302,6 +310,12 @@ class ScalewayLb:
"""


@dataclass
class RuleHttpMatchHostFilter:
host_filter_type: RuleHttpMatchHostFilterHostFilterType
value: str


@dataclass
class RuleHttpMatchPathFilter:
path_filter_type: RuleHttpMatchPathFilterPathFilterType
Expand Down Expand Up @@ -395,6 +409,11 @@ class RuleHttpMatch:
HTTP URL path to filter for. A request whose path matches the given filter will be considered to match the rule. All paths will match if none is provided.
"""

host_filter: Optional[RuleHttpMatchHostFilter] = None
"""
Host to filter for. A request whose host matches the given filter will be considered to match the rule. All hosts will match if none is provided.
"""


@dataclass
class BackendStage:
Expand Down
Loading