Skip to content

Commit 7801f83

Browse files
authored
feat(lb): add redirect acl (#1513)
1 parent ef0129e commit 7801f83

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

api/lb/v1/lb_sdk.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,47 @@ func NewAPI(client *scw.Client) *API {
6363
}
6464
}
6565

66+
type ACLActionRedirectRedirectType string
67+
68+
const (
69+
// ACLActionRedirectRedirectTypeLocation is [insert doc].
70+
ACLActionRedirectRedirectTypeLocation = ACLActionRedirectRedirectType("location")
71+
// ACLActionRedirectRedirectTypeScheme is [insert doc].
72+
ACLActionRedirectRedirectTypeScheme = ACLActionRedirectRedirectType("scheme")
73+
)
74+
75+
func (enum ACLActionRedirectRedirectType) String() string {
76+
if enum == "" {
77+
// return default value if empty
78+
return "location"
79+
}
80+
return string(enum)
81+
}
82+
83+
func (enum ACLActionRedirectRedirectType) MarshalJSON() ([]byte, error) {
84+
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
85+
}
86+
87+
func (enum *ACLActionRedirectRedirectType) UnmarshalJSON(data []byte) error {
88+
tmp := ""
89+
90+
if err := json.Unmarshal(data, &tmp); err != nil {
91+
return err
92+
}
93+
94+
*enum = ACLActionRedirectRedirectType(ACLActionRedirectRedirectType(tmp).String())
95+
return nil
96+
}
97+
6698
type ACLActionType string
6799

68100
const (
69101
// ACLActionTypeAllow is [insert doc].
70102
ACLActionTypeAllow = ACLActionType("allow")
71103
// ACLActionTypeDeny is [insert doc].
72104
ACLActionTypeDeny = ACLActionType("deny")
105+
// ACLActionTypeRedirect is [insert doc].
106+
ACLActionTypeRedirect = ACLActionType("redirect")
73107
)
74108

75109
func (enum ACLActionType) String() string {
@@ -963,6 +997,29 @@ type ACLAction struct {
963997
//
964998
// Default value: allow
965999
Type ACLActionType `json:"type"`
1000+
// Redirect: redirect parameters when using an ACL with `redirect` action
1001+
Redirect *ACLActionRedirect `json:"redirect"`
1002+
}
1003+
1004+
// ACLActionRedirect: acl action redirect
1005+
type ACLActionRedirect struct {
1006+
// Type: redirect type
1007+
//
1008+
// Default value: location
1009+
Type ACLActionRedirectRedirectType `json:"type"`
1010+
// Target: redirect target (target URL for `location`, or target `scheme`)
1011+
//
1012+
// An URL can be used in case of a location redirect (e.g. `https://scaleway.com` will redirect to this same URL).
1013+
// 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.
1014+
// Placeholders can be used when using a `location` redirect in order to insert original request's parts, these are:
1015+
// - `{{ host }}` for the current request's Host header
1016+
// - `{{ query }}` for the current request's query string
1017+
// - `{{ path }}` for the current request's URL path
1018+
// - `{{ scheme }}` for the current request's scheme
1019+
//
1020+
Target string `json:"target"`
1021+
// Code: HTTP redirect code to use. Valid values are 301, 302, 303, 307 and 308. Default value is 302
1022+
Code *int32 `json:"code"`
9661023
}
9671024

9681025
// ACLMatch: acl match

0 commit comments

Comments
 (0)