Skip to content

feat(edge_services): add route rule search endpoint #1068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -23,6 +23,7 @@
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
Expand Down Expand Up @@ -113,6 +114,7 @@
from .types import ListWafStagesResponse
from .types import Plan
from .types import SearchBackendStagesRequest
from .types import SearchRouteRulesRequest
from .types import SearchWafStagesRequest
from .types import SelectPlanRequest
from .types import SetHeadStageRequest
Expand Down Expand Up @@ -151,6 +153,7 @@
"RuleHttpMatchMethodFilter",
"RuleHttpMatchPathFilterPathFilterType",
"SearchBackendStagesRequestOrderBy",
"SearchRouteRulesRequestOrderBy",
"SearchWafStagesRequestOrderBy",
"WafStageMode",
"ScalewayLb",
Expand Down Expand Up @@ -241,6 +244,7 @@
"ListWafStagesResponse",
"Plan",
"SearchBackendStagesRequest",
"SearchRouteRulesRequest",
"SearchWafStagesRequest",
"SelectPlanRequest",
"SetHeadStageRequest",
Expand Down
42 changes: 42 additions & 0 deletions scaleway-async/scaleway_async/edge_services/v1beta1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ListWafStagesRequestOrderBy,
PlanName,
SearchBackendStagesRequestOrderBy,
SearchRouteRulesRequestOrderBy,
SearchWafStagesRequestOrderBy,
WafStageMode,
AddRouteRulesRequest,
Expand Down Expand Up @@ -2218,6 +2219,47 @@ async def add_route_rules(
self._throw_on_error(res)
return unmarshal_AddRouteRulesResponse(res.json())

async def search_route_rules(
self,
*,
order_by: Optional[SearchRouteRulesRequestOrderBy] = None,
page: Optional[int] = None,
page_size: Optional[int] = None,
organization_id: Optional[str] = None,
project_id: Optional[str] = None,
) -> ListRouteRulesResponse:
"""
List route rules.
List all route rules of an organization or project.
:param order_by:
:param page:
:param page_size:
:param organization_id:
:param project_id:
:return: :class:`ListRouteRulesResponse <ListRouteRulesResponse>`

Usage:
::

result = await api.search_route_rules()
"""

res = self._request(
"GET",
"/edge-services/v1beta1/search-route-rules",
params={
"order_by": order_by,
"organization_id": organization_id
or self.client.default_organization_id,
"page": page,
"page_size": page_size or self.client.default_page_size,
"project_id": project_id or self.client.default_project_id,
},
)

self._throw_on_error(res)
return unmarshal_ListRouteRulesResponse(res.json())

async def check_domain(
self,
*,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,10 @@ def unmarshal_ListRouteRulesResponse(data: Any) -> ListRouteRulesResponse:
[unmarshal_RouteRule(v) for v in field] if field is not None else None
)

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

return ListRouteRulesResponse(**args)


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


class SearchRouteRulesRequestOrderBy(str, Enum, metaclass=StrEnumMeta):
CREATED_AT_ASC = "created_at_asc"
CREATED_AT_DESC = "created_at_desc"

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


class SearchWafStagesRequestOrderBy(str, Enum, metaclass=StrEnumMeta):
CREATED_AT_ASC = "created_at_asc"
CREATED_AT_DESC = "created_at_desc"
Expand Down Expand Up @@ -1487,6 +1495,11 @@ class ListRouteRulesResponse:
List of rules to be checked against every HTTP request. The first matching rule will forward the request to its specified backend stage. If no rules are matched, the request is forwarded to the WAF stage defined by `waf_stage_id`.
"""

total_count: int
"""
Count of all route rules matching the requested criteria.
"""


@dataclass
class ListRouteStagesRequest:
Expand Down Expand Up @@ -1628,6 +1641,19 @@ class SearchBackendStagesRequest:
lb_id: Optional[str]


@dataclass
class SearchRouteRulesRequest:
order_by: Optional[SearchRouteRulesRequestOrderBy]

page: Optional[int]

page_size: Optional[int]

organization_id: Optional[str]

project_id: Optional[str]


@dataclass
class SearchWafStagesRequest:
order_by: Optional[SearchWafStagesRequestOrderBy]
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 @@ -23,6 +23,7 @@
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
Expand Down Expand Up @@ -113,6 +114,7 @@
from .types import ListWafStagesResponse
from .types import Plan
from .types import SearchBackendStagesRequest
from .types import SearchRouteRulesRequest
from .types import SearchWafStagesRequest
from .types import SelectPlanRequest
from .types import SetHeadStageRequest
Expand Down Expand Up @@ -151,6 +153,7 @@
"RuleHttpMatchMethodFilter",
"RuleHttpMatchPathFilterPathFilterType",
"SearchBackendStagesRequestOrderBy",
"SearchRouteRulesRequestOrderBy",
"SearchWafStagesRequestOrderBy",
"WafStageMode",
"ScalewayLb",
Expand Down Expand Up @@ -241,6 +244,7 @@
"ListWafStagesResponse",
"Plan",
"SearchBackendStagesRequest",
"SearchRouteRulesRequest",
"SearchWafStagesRequest",
"SelectPlanRequest",
"SetHeadStageRequest",
Expand Down
42 changes: 42 additions & 0 deletions scaleway/scaleway/edge_services/v1beta1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ListWafStagesRequestOrderBy,
PlanName,
SearchBackendStagesRequestOrderBy,
SearchRouteRulesRequestOrderBy,
SearchWafStagesRequestOrderBy,
WafStageMode,
AddRouteRulesRequest,
Expand Down Expand Up @@ -2216,6 +2217,47 @@ def add_route_rules(
self._throw_on_error(res)
return unmarshal_AddRouteRulesResponse(res.json())

def search_route_rules(
self,
*,
order_by: Optional[SearchRouteRulesRequestOrderBy] = None,
page: Optional[int] = None,
page_size: Optional[int] = None,
organization_id: Optional[str] = None,
project_id: Optional[str] = None,
) -> ListRouteRulesResponse:
"""
List route rules.
List all route rules of an organization or project.
:param order_by:
:param page:
:param page_size:
:param organization_id:
:param project_id:
:return: :class:`ListRouteRulesResponse <ListRouteRulesResponse>`

Usage:
::

result = api.search_route_rules()
"""

res = self._request(
"GET",
"/edge-services/v1beta1/search-route-rules",
params={
"order_by": order_by,
"organization_id": organization_id
or self.client.default_organization_id,
"page": page,
"page_size": page_size or self.client.default_page_size,
"project_id": project_id or self.client.default_project_id,
},
)

self._throw_on_error(res)
return unmarshal_ListRouteRulesResponse(res.json())

def check_domain(
self,
*,
Expand Down
4 changes: 4 additions & 0 deletions scaleway/scaleway/edge_services/v1beta1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,10 @@ def unmarshal_ListRouteRulesResponse(data: Any) -> ListRouteRulesResponse:
[unmarshal_RouteRule(v) for v in field] if field is not None else None
)

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

return ListRouteRulesResponse(**args)


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


class SearchRouteRulesRequestOrderBy(str, Enum, metaclass=StrEnumMeta):
CREATED_AT_ASC = "created_at_asc"
CREATED_AT_DESC = "created_at_desc"

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


class SearchWafStagesRequestOrderBy(str, Enum, metaclass=StrEnumMeta):
CREATED_AT_ASC = "created_at_asc"
CREATED_AT_DESC = "created_at_desc"
Expand Down Expand Up @@ -1487,6 +1495,11 @@ class ListRouteRulesResponse:
List of rules to be checked against every HTTP request. The first matching rule will forward the request to its specified backend stage. If no rules are matched, the request is forwarded to the WAF stage defined by `waf_stage_id`.
"""

total_count: int
"""
Count of all route rules matching the requested criteria.
"""


@dataclass
class ListRouteStagesRequest:
Expand Down Expand Up @@ -1628,6 +1641,19 @@ class SearchBackendStagesRequest:
lb_id: Optional[str]


@dataclass
class SearchRouteRulesRequest:
order_by: Optional[SearchRouteRulesRequestOrderBy]

page: Optional[int]

page_size: Optional[int]

organization_id: Optional[str]

project_id: Optional[str]


@dataclass
class SearchWafStagesRequest:
order_by: Optional[SearchWafStagesRequestOrderBy]
Expand Down
Loading