Skip to content

Commit 71cdff6

Browse files
feat(edge_services): add route rule search endpoint (#1068)
Co-authored-by: Rémy Léone <rleone@scaleway.com>
1 parent 0b942bc commit 71cdff6

File tree

8 files changed

+152
-0
lines changed

8 files changed

+152
-0
lines changed

scaleway-async/scaleway_async/edge_services/v1beta1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from .types import RuleHttpMatchMethodFilter
2424
from .types import RuleHttpMatchPathFilterPathFilterType
2525
from .types import SearchBackendStagesRequestOrderBy
26+
from .types import SearchRouteRulesRequestOrderBy
2627
from .types import SearchWafStagesRequestOrderBy
2728
from .types import WafStageMode
2829
from .types import ScalewayLb
@@ -113,6 +114,7 @@
113114
from .types import ListWafStagesResponse
114115
from .types import Plan
115116
from .types import SearchBackendStagesRequest
117+
from .types import SearchRouteRulesRequest
116118
from .types import SearchWafStagesRequest
117119
from .types import SelectPlanRequest
118120
from .types import SetHeadStageRequest
@@ -151,6 +153,7 @@
151153
"RuleHttpMatchMethodFilter",
152154
"RuleHttpMatchPathFilterPathFilterType",
153155
"SearchBackendStagesRequestOrderBy",
156+
"SearchRouteRulesRequestOrderBy",
154157
"SearchWafStagesRequestOrderBy",
155158
"WafStageMode",
156159
"ScalewayLb",
@@ -241,6 +244,7 @@
241244
"ListWafStagesResponse",
242245
"Plan",
243246
"SearchBackendStagesRequest",
247+
"SearchRouteRulesRequest",
244248
"SearchWafStagesRequest",
245249
"SelectPlanRequest",
246250
"SetHeadStageRequest",

scaleway-async/scaleway_async/edge_services/v1beta1/api.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
ListWafStagesRequestOrderBy,
2323
PlanName,
2424
SearchBackendStagesRequestOrderBy,
25+
SearchRouteRulesRequestOrderBy,
2526
SearchWafStagesRequestOrderBy,
2627
WafStageMode,
2728
AddRouteRulesRequest,
@@ -2218,6 +2219,47 @@ async def add_route_rules(
22182219
self._throw_on_error(res)
22192220
return unmarshal_AddRouteRulesResponse(res.json())
22202221

2222+
async def search_route_rules(
2223+
self,
2224+
*,
2225+
order_by: Optional[SearchRouteRulesRequestOrderBy] = None,
2226+
page: Optional[int] = None,
2227+
page_size: Optional[int] = None,
2228+
organization_id: Optional[str] = None,
2229+
project_id: Optional[str] = None,
2230+
) -> ListRouteRulesResponse:
2231+
"""
2232+
List route rules.
2233+
List all route rules of an organization or project.
2234+
:param order_by:
2235+
:param page:
2236+
:param page_size:
2237+
:param organization_id:
2238+
:param project_id:
2239+
:return: :class:`ListRouteRulesResponse <ListRouteRulesResponse>`
2240+
2241+
Usage:
2242+
::
2243+
2244+
result = await api.search_route_rules()
2245+
"""
2246+
2247+
res = self._request(
2248+
"GET",
2249+
"/edge-services/v1beta1/search-route-rules",
2250+
params={
2251+
"order_by": order_by,
2252+
"organization_id": organization_id
2253+
or self.client.default_organization_id,
2254+
"page": page,
2255+
"page_size": page_size or self.client.default_page_size,
2256+
"project_id": project_id or self.client.default_project_id,
2257+
},
2258+
)
2259+
2260+
self._throw_on_error(res)
2261+
return unmarshal_ListRouteRulesResponse(res.json())
2262+
22212263
async def check_domain(
22222264
self,
22232265
*,

scaleway-async/scaleway_async/edge_services/v1beta1/marshalling.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,10 @@ def unmarshal_ListRouteRulesResponse(data: Any) -> ListRouteRulesResponse:
11871187
[unmarshal_RouteRule(v) for v in field] if field is not None else None
11881188
)
11891189

1190+
field = data.get("total_count", None)
1191+
if field is not None:
1192+
args["total_count"] = field
1193+
11901194
return ListRouteRulesResponse(**args)
11911195

11921196

scaleway-async/scaleway_async/edge_services/v1beta1/types.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,14 @@ def __str__(self) -> str:
239239
return str(self.value)
240240

241241

242+
class SearchRouteRulesRequestOrderBy(str, Enum, metaclass=StrEnumMeta):
243+
CREATED_AT_ASC = "created_at_asc"
244+
CREATED_AT_DESC = "created_at_desc"
245+
246+
def __str__(self) -> str:
247+
return str(self.value)
248+
249+
242250
class SearchWafStagesRequestOrderBy(str, Enum, metaclass=StrEnumMeta):
243251
CREATED_AT_ASC = "created_at_asc"
244252
CREATED_AT_DESC = "created_at_desc"
@@ -1487,6 +1495,11 @@ class ListRouteRulesResponse:
14871495
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`.
14881496
"""
14891497

1498+
total_count: int
1499+
"""
1500+
Count of all route rules matching the requested criteria.
1501+
"""
1502+
14901503

14911504
@dataclass
14921505
class ListRouteStagesRequest:
@@ -1628,6 +1641,19 @@ class SearchBackendStagesRequest:
16281641
lb_id: Optional[str]
16291642

16301643

1644+
@dataclass
1645+
class SearchRouteRulesRequest:
1646+
order_by: Optional[SearchRouteRulesRequestOrderBy]
1647+
1648+
page: Optional[int]
1649+
1650+
page_size: Optional[int]
1651+
1652+
organization_id: Optional[str]
1653+
1654+
project_id: Optional[str]
1655+
1656+
16311657
@dataclass
16321658
class SearchWafStagesRequest:
16331659
order_by: Optional[SearchWafStagesRequestOrderBy]

scaleway/scaleway/edge_services/v1beta1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from .types import RuleHttpMatchMethodFilter
2424
from .types import RuleHttpMatchPathFilterPathFilterType
2525
from .types import SearchBackendStagesRequestOrderBy
26+
from .types import SearchRouteRulesRequestOrderBy
2627
from .types import SearchWafStagesRequestOrderBy
2728
from .types import WafStageMode
2829
from .types import ScalewayLb
@@ -113,6 +114,7 @@
113114
from .types import ListWafStagesResponse
114115
from .types import Plan
115116
from .types import SearchBackendStagesRequest
117+
from .types import SearchRouteRulesRequest
116118
from .types import SearchWafStagesRequest
117119
from .types import SelectPlanRequest
118120
from .types import SetHeadStageRequest
@@ -151,6 +153,7 @@
151153
"RuleHttpMatchMethodFilter",
152154
"RuleHttpMatchPathFilterPathFilterType",
153155
"SearchBackendStagesRequestOrderBy",
156+
"SearchRouteRulesRequestOrderBy",
154157
"SearchWafStagesRequestOrderBy",
155158
"WafStageMode",
156159
"ScalewayLb",
@@ -241,6 +244,7 @@
241244
"ListWafStagesResponse",
242245
"Plan",
243246
"SearchBackendStagesRequest",
247+
"SearchRouteRulesRequest",
244248
"SearchWafStagesRequest",
245249
"SelectPlanRequest",
246250
"SetHeadStageRequest",

scaleway/scaleway/edge_services/v1beta1/api.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
ListWafStagesRequestOrderBy,
2323
PlanName,
2424
SearchBackendStagesRequestOrderBy,
25+
SearchRouteRulesRequestOrderBy,
2526
SearchWafStagesRequestOrderBy,
2627
WafStageMode,
2728
AddRouteRulesRequest,
@@ -2216,6 +2217,47 @@ def add_route_rules(
22162217
self._throw_on_error(res)
22172218
return unmarshal_AddRouteRulesResponse(res.json())
22182219

2220+
def search_route_rules(
2221+
self,
2222+
*,
2223+
order_by: Optional[SearchRouteRulesRequestOrderBy] = None,
2224+
page: Optional[int] = None,
2225+
page_size: Optional[int] = None,
2226+
organization_id: Optional[str] = None,
2227+
project_id: Optional[str] = None,
2228+
) -> ListRouteRulesResponse:
2229+
"""
2230+
List route rules.
2231+
List all route rules of an organization or project.
2232+
:param order_by:
2233+
:param page:
2234+
:param page_size:
2235+
:param organization_id:
2236+
:param project_id:
2237+
:return: :class:`ListRouteRulesResponse <ListRouteRulesResponse>`
2238+
2239+
Usage:
2240+
::
2241+
2242+
result = api.search_route_rules()
2243+
"""
2244+
2245+
res = self._request(
2246+
"GET",
2247+
"/edge-services/v1beta1/search-route-rules",
2248+
params={
2249+
"order_by": order_by,
2250+
"organization_id": organization_id
2251+
or self.client.default_organization_id,
2252+
"page": page,
2253+
"page_size": page_size or self.client.default_page_size,
2254+
"project_id": project_id or self.client.default_project_id,
2255+
},
2256+
)
2257+
2258+
self._throw_on_error(res)
2259+
return unmarshal_ListRouteRulesResponse(res.json())
2260+
22192261
def check_domain(
22202262
self,
22212263
*,

scaleway/scaleway/edge_services/v1beta1/marshalling.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,10 @@ def unmarshal_ListRouteRulesResponse(data: Any) -> ListRouteRulesResponse:
11871187
[unmarshal_RouteRule(v) for v in field] if field is not None else None
11881188
)
11891189

1190+
field = data.get("total_count", None)
1191+
if field is not None:
1192+
args["total_count"] = field
1193+
11901194
return ListRouteRulesResponse(**args)
11911195

11921196

scaleway/scaleway/edge_services/v1beta1/types.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,14 @@ def __str__(self) -> str:
239239
return str(self.value)
240240

241241

242+
class SearchRouteRulesRequestOrderBy(str, Enum, metaclass=StrEnumMeta):
243+
CREATED_AT_ASC = "created_at_asc"
244+
CREATED_AT_DESC = "created_at_desc"
245+
246+
def __str__(self) -> str:
247+
return str(self.value)
248+
249+
242250
class SearchWafStagesRequestOrderBy(str, Enum, metaclass=StrEnumMeta):
243251
CREATED_AT_ASC = "created_at_asc"
244252
CREATED_AT_DESC = "created_at_desc"
@@ -1487,6 +1495,11 @@ class ListRouteRulesResponse:
14871495
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`.
14881496
"""
14891497

1498+
total_count: int
1499+
"""
1500+
Count of all route rules matching the requested criteria.
1501+
"""
1502+
14901503

14911504
@dataclass
14921505
class ListRouteStagesRequest:
@@ -1628,6 +1641,19 @@ class SearchBackendStagesRequest:
16281641
lb_id: Optional[str]
16291642

16301643

1644+
@dataclass
1645+
class SearchRouteRulesRequest:
1646+
order_by: Optional[SearchRouteRulesRequestOrderBy]
1647+
1648+
page: Optional[int]
1649+
1650+
page_size: Optional[int]
1651+
1652+
organization_id: Optional[str]
1653+
1654+
project_id: Optional[str]
1655+
1656+
16311657
@dataclass
16321658
class SearchWafStagesRequest:
16331659
order_by: Optional[SearchWafStagesRequestOrderBy]

0 commit comments

Comments
 (0)