Skip to content

Commit cbaea91

Browse files
authored
feat(lb): add redirect acl (#28)
1 parent f96ca88 commit cbaea91

File tree

6 files changed

+172
-0
lines changed

6 files changed

+172
-0
lines changed

scaleway-async/scaleway_async/lb/v1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# This file was automatically generated. DO NOT EDIT.
22
# If you have any remark or suggestion do not hesitate to open an issue.
3+
from .types import AclActionRedirectRedirectType
34
from .types import AclActionType
45
from .types import AclHttpFilter
56
from .types import BackendServerStatsHealthCheckStatus
@@ -26,6 +27,7 @@
2627
from .types import StickySessionsType
2728
from .types import Acl
2829
from .types import AclAction
30+
from .types import AclActionRedirect
2931
from .types import AclMatch
3032
from .types import AclSpec
3133
from .types import Backend
@@ -75,6 +77,7 @@
7577
from .api import LbZonedV1API
7678

7779
__all__ = [
80+
"AclActionRedirectRedirectType",
7881
"AclActionType",
7982
"AclHttpFilter",
8083
"BackendServerStatsHealthCheckStatus",
@@ -101,6 +104,7 @@
101104
"StickySessionsType",
102105
"Acl",
103106
"AclAction",
107+
"AclActionRedirect",
104108
"AclMatch",
105109
"AclSpec",
106110
"Backend",

scaleway-async/scaleway_async/lb/v1/marshalling.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
)
1111
from dateutil import parser
1212
from .types import (
13+
AclActionRedirectRedirectType,
1314
AclActionType,
1415
AclHttpFilter,
1516
ForwardPortAlgorithm,
@@ -20,6 +21,7 @@
2021
StickySessionsType,
2122
Acl,
2223
AclAction,
24+
AclActionRedirect,
2325
AclMatch,
2426
AclSpec,
2527
Backend,
@@ -475,6 +477,26 @@ def unmarshal_Lb(data: Any) -> Lb:
475477
return Lb(**args)
476478

477479

480+
def unmarshal_AclActionRedirect(data: Any) -> AclActionRedirect:
481+
if type(data) is not dict:
482+
raise TypeError(
483+
f"Unmarshalling the type 'AclActionRedirect' failed as data isn't a dictionary."
484+
)
485+
486+
args: Dict[str, Any] = {}
487+
488+
field = data.get("code")
489+
args["code"] = field
490+
491+
field = data.get("target")
492+
args["target"] = field
493+
494+
field = data.get("type_")
495+
args["type_"] = field
496+
497+
return AclActionRedirect(**args)
498+
499+
478500
def unmarshal_Backend(data: Any) -> Backend:
479501
if type(data) is not dict:
480502
raise TypeError(
@@ -607,6 +629,9 @@ def unmarshal_AclAction(data: Any) -> AclAction:
607629

608630
args: Dict[str, Any] = {}
609631

632+
field = data.get("redirect")
633+
args["redirect"] = unmarshal_AclActionRedirect(field) if field is not None else None
634+
610635
field = data.get("type_")
611636
args["type_"] = field
612637

@@ -1109,11 +1134,25 @@ def unmarshal_SetAclsResponse(data: Any) -> SetAclsResponse:
11091134
return SetAclsResponse(**args)
11101135

11111136

1137+
def marshal_AclActionRedirect(
1138+
request: AclActionRedirect,
1139+
defaults: ProfileDefaults,
1140+
) -> Dict[str, Any]:
1141+
return {
1142+
"code": request.code,
1143+
"target": request.target,
1144+
"type": AclActionRedirectRedirectType(request.type_),
1145+
}
1146+
1147+
11121148
def marshal_AclAction(
11131149
request: AclAction,
11141150
defaults: ProfileDefaults,
11151151
) -> Dict[str, Any]:
11161152
return {
1153+
"redirect": marshal_AclActionRedirect(request.redirect, defaults)
1154+
if request.redirect is not None
1155+
else None,
11171156
"type": AclActionType(request.type_),
11181157
}
11191158

scaleway-async/scaleway_async/lb/v1/types.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,18 @@
1313
)
1414

1515

16+
class AclActionRedirectRedirectType(str, Enum):
17+
LOCATION = "location"
18+
SCHEME = "scheme"
19+
20+
def __str__(self) -> str:
21+
return str(self.value)
22+
23+
1624
class AclActionType(str, Enum):
1725
ALLOW = "allow"
1826
DENY = "deny"
27+
REDIRECT = "redirect"
1928

2029
def __str__(self) -> str:
2130
return str(self.value)
@@ -326,6 +335,40 @@ class AclAction:
326335
The action type
327336
"""
328337

338+
redirect: Optional[AclActionRedirect]
339+
"""
340+
Redirect parameters when using an ACL with `redirect` action
341+
"""
342+
343+
344+
@dataclass
345+
class AclActionRedirect:
346+
"""
347+
Acl action redirect
348+
"""
349+
350+
type_: AclActionRedirectRedirectType
351+
"""
352+
Redirect type
353+
"""
354+
355+
target: str
356+
"""
357+
An URL can be used in case of a location redirect (e.g. `https://scaleway.com` will redirect to this same URL).
358+
A scheme name (e.g. `https`, `http`, `ftp`, `git`) will replace the request's original scheme. This can be useful to implement HTTP to HTTPS redirects.
359+
Placeholders can be used when using a `location` redirect in order to insert original request's parts, these are:
360+
- `{{ host }}` for the current request's Host header
361+
- `{{ query }}` for the current request's query string
362+
- `{{ path }}` for the current request's URL path
363+
- `{{ scheme }}` for the current request's scheme
364+
365+
"""
366+
367+
code: Optional[int]
368+
"""
369+
HTTP redirect code to use. Valid values are 301, 302, 303, 307 and 308. Default value is 302
370+
"""
371+
329372

330373
@dataclass
331374
class AclMatch:

scaleway/scaleway/lb/v1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# This file was automatically generated. DO NOT EDIT.
22
# If you have any remark or suggestion do not hesitate to open an issue.
3+
from .types import AclActionRedirectRedirectType
34
from .types import AclActionType
45
from .types import AclHttpFilter
56
from .types import BackendServerStatsHealthCheckStatus
@@ -26,6 +27,7 @@
2627
from .types import StickySessionsType
2728
from .types import Acl
2829
from .types import AclAction
30+
from .types import AclActionRedirect
2931
from .types import AclMatch
3032
from .types import AclSpec
3133
from .types import Backend
@@ -75,6 +77,7 @@
7577
from .api import LbZonedV1API
7678

7779
__all__ = [
80+
"AclActionRedirectRedirectType",
7881
"AclActionType",
7982
"AclHttpFilter",
8083
"BackendServerStatsHealthCheckStatus",
@@ -101,6 +104,7 @@
101104
"StickySessionsType",
102105
"Acl",
103106
"AclAction",
107+
"AclActionRedirect",
104108
"AclMatch",
105109
"AclSpec",
106110
"Backend",

scaleway/scaleway/lb/v1/marshalling.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
)
1111
from dateutil import parser
1212
from .types import (
13+
AclActionRedirectRedirectType,
1314
AclActionType,
1415
AclHttpFilter,
1516
ForwardPortAlgorithm,
@@ -20,6 +21,7 @@
2021
StickySessionsType,
2122
Acl,
2223
AclAction,
24+
AclActionRedirect,
2325
AclMatch,
2426
AclSpec,
2527
Backend,
@@ -475,6 +477,26 @@ def unmarshal_Lb(data: Any) -> Lb:
475477
return Lb(**args)
476478

477479

480+
def unmarshal_AclActionRedirect(data: Any) -> AclActionRedirect:
481+
if type(data) is not dict:
482+
raise TypeError(
483+
f"Unmarshalling the type 'AclActionRedirect' failed as data isn't a dictionary."
484+
)
485+
486+
args: Dict[str, Any] = {}
487+
488+
field = data.get("code")
489+
args["code"] = field
490+
491+
field = data.get("target")
492+
args["target"] = field
493+
494+
field = data.get("type_")
495+
args["type_"] = field
496+
497+
return AclActionRedirect(**args)
498+
499+
478500
def unmarshal_Backend(data: Any) -> Backend:
479501
if type(data) is not dict:
480502
raise TypeError(
@@ -607,6 +629,9 @@ def unmarshal_AclAction(data: Any) -> AclAction:
607629

608630
args: Dict[str, Any] = {}
609631

632+
field = data.get("redirect")
633+
args["redirect"] = unmarshal_AclActionRedirect(field) if field is not None else None
634+
610635
field = data.get("type_")
611636
args["type_"] = field
612637

@@ -1109,11 +1134,25 @@ def unmarshal_SetAclsResponse(data: Any) -> SetAclsResponse:
11091134
return SetAclsResponse(**args)
11101135

11111136

1137+
def marshal_AclActionRedirect(
1138+
request: AclActionRedirect,
1139+
defaults: ProfileDefaults,
1140+
) -> Dict[str, Any]:
1141+
return {
1142+
"code": request.code,
1143+
"target": request.target,
1144+
"type": AclActionRedirectRedirectType(request.type_),
1145+
}
1146+
1147+
11121148
def marshal_AclAction(
11131149
request: AclAction,
11141150
defaults: ProfileDefaults,
11151151
) -> Dict[str, Any]:
11161152
return {
1153+
"redirect": marshal_AclActionRedirect(request.redirect, defaults)
1154+
if request.redirect is not None
1155+
else None,
11171156
"type": AclActionType(request.type_),
11181157
}
11191158

scaleway/scaleway/lb/v1/types.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,18 @@
1313
)
1414

1515

16+
class AclActionRedirectRedirectType(str, Enum):
17+
LOCATION = "location"
18+
SCHEME = "scheme"
19+
20+
def __str__(self) -> str:
21+
return str(self.value)
22+
23+
1624
class AclActionType(str, Enum):
1725
ALLOW = "allow"
1826
DENY = "deny"
27+
REDIRECT = "redirect"
1928

2029
def __str__(self) -> str:
2130
return str(self.value)
@@ -326,6 +335,40 @@ class AclAction:
326335
The action type
327336
"""
328337

338+
redirect: Optional[AclActionRedirect]
339+
"""
340+
Redirect parameters when using an ACL with `redirect` action
341+
"""
342+
343+
344+
@dataclass
345+
class AclActionRedirect:
346+
"""
347+
Acl action redirect
348+
"""
349+
350+
type_: AclActionRedirectRedirectType
351+
"""
352+
Redirect type
353+
"""
354+
355+
target: str
356+
"""
357+
An URL can be used in case of a location redirect (e.g. `https://scaleway.com` will redirect to this same URL).
358+
A scheme name (e.g. `https`, `http`, `ftp`, `git`) will replace the request's original scheme. This can be useful to implement HTTP to HTTPS redirects.
359+
Placeholders can be used when using a `location` redirect in order to insert original request's parts, these are:
360+
- `{{ host }}` for the current request's Host header
361+
- `{{ query }}` for the current request's query string
362+
- `{{ path }}` for the current request's URL path
363+
- `{{ scheme }}` for the current request's scheme
364+
365+
"""
366+
367+
code: Optional[int]
368+
"""
369+
HTTP redirect code to use. Valid values are 301, 302, 303, 307 and 308. Default value is 302
370+
"""
371+
329372

330373
@dataclass
331374
class AclMatch:

0 commit comments

Comments
 (0)