Skip to content

Commit ce01279

Browse files
authored
feat(serverless): https redirection (#1466)
1 parent 9a4e57d commit ce01279

File tree

2 files changed

+86
-12
lines changed

2 files changed

+86
-12
lines changed

api/container/v1beta1/container_sdk.go

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,40 @@ func NewAPI(client *scw.Client) *API {
5151
}
5252
}
5353

54+
type ContainerHTTPOption string
55+
56+
const (
57+
// ContainerHTTPOptionUnknownHTTPOption is [insert doc].
58+
ContainerHTTPOptionUnknownHTTPOption = ContainerHTTPOption("unknown_http_option")
59+
// ContainerHTTPOptionEnabled is [insert doc].
60+
ContainerHTTPOptionEnabled = ContainerHTTPOption("enabled")
61+
// ContainerHTTPOptionRedirected is [insert doc].
62+
ContainerHTTPOptionRedirected = ContainerHTTPOption("redirected")
63+
)
64+
65+
func (enum ContainerHTTPOption) String() string {
66+
if enum == "" {
67+
// return default value if empty
68+
return "unknown_http_option"
69+
}
70+
return string(enum)
71+
}
72+
73+
func (enum ContainerHTTPOption) MarshalJSON() ([]byte, error) {
74+
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
75+
}
76+
77+
func (enum *ContainerHTTPOption) UnmarshalJSON(data []byte) error {
78+
tmp := ""
79+
80+
if err := json.Unmarshal(data, &tmp); err != nil {
81+
return err
82+
}
83+
84+
*enum = ContainerHTTPOption(ContainerHTTPOption(tmp).String())
85+
return nil
86+
}
87+
5488
type ContainerPrivacy string
5589

5690
const (
@@ -638,13 +672,14 @@ type Container struct {
638672
Port uint32 `json:"port"`
639673

640674
SecretEnvironmentVariables []*SecretHashedValue `json:"secret_environment_variables"`
641-
// Deprecated: HTTPOption: configure how HTTP and HTTPS requests are handled
675+
// HTTPOption: configure how HTTP and HTTPS requests are handled
642676
//
643677
// possible values:
644678
// - redirected: Responds to HTTP request with a 302 redirect to ask the clients to use HTTPS.
645679
// - enabled: Serve both HTTP and HTTPS traffic.
646680
//
647-
HTTPOption *string `json:"http_option,omitempty"`
681+
// Default value: unknown_http_option
682+
HTTPOption ContainerHTTPOption `json:"http_option"`
648683

649684
Region scw.Region `json:"region"`
650685
}
@@ -1215,13 +1250,14 @@ type CreateContainerRequest struct {
12151250
Port *uint32 `json:"port"`
12161251

12171252
SecretEnvironmentVariables []*Secret `json:"secret_environment_variables"`
1218-
// Deprecated: HTTPOption: configure how HTTP and HTTPS requests are handled
1253+
// HTTPOption: configure how HTTP and HTTPS requests are handled
12191254
//
12201255
// possible values:
12211256
// - redirected: Responds to HTTP request with a 302 redirect to ask the clients to use HTTPS.
12221257
// - enabled: Serve both HTTP and HTTPS traffic.
12231258
//
1224-
HTTPOption *string `json:"http_option,omitempty"`
1259+
// Default value: unknown_http_option
1260+
HTTPOption ContainerHTTPOption `json:"http_option"`
12251261
}
12261262

12271263
// CreateContainer: create a new container
@@ -1298,13 +1334,14 @@ type UpdateContainerRequest struct {
12981334
Port *uint32 `json:"port"`
12991335

13001336
SecretEnvironmentVariables []*Secret `json:"secret_environment_variables"`
1301-
// Deprecated: HTTPOption: configure how HTTP and HTTPS requests are handled
1337+
// HTTPOption: configure how HTTP and HTTPS requests are handled
13021338
//
13031339
// possible values:
13041340
// - redirected: Responds to HTTP request with a 302 redirect to ask the clients to use HTTPS.
13051341
// - enabled: Serve both HTTP and HTTPS traffic.
13061342
//
1307-
HTTPOption *string `json:"http_option,omitempty"`
1343+
// Default value: unknown_http_option
1344+
HTTPOption ContainerHTTPOption `json:"http_option"`
13081345
}
13091346

13101347
// UpdateContainer: update an existing container

api/function/v1beta1/function_sdk.go

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,40 @@ func (enum *DomainStatus) UnmarshalJSON(data []byte) error {
133133
return nil
134134
}
135135

136+
type FunctionHTTPOption string
137+
138+
const (
139+
// FunctionHTTPOptionUnknownHTTPOption is [insert doc].
140+
FunctionHTTPOptionUnknownHTTPOption = FunctionHTTPOption("unknown_http_option")
141+
// FunctionHTTPOptionEnabled is [insert doc].
142+
FunctionHTTPOptionEnabled = FunctionHTTPOption("enabled")
143+
// FunctionHTTPOptionRedirected is [insert doc].
144+
FunctionHTTPOptionRedirected = FunctionHTTPOption("redirected")
145+
)
146+
147+
func (enum FunctionHTTPOption) String() string {
148+
if enum == "" {
149+
// return default value if empty
150+
return "unknown_http_option"
151+
}
152+
return string(enum)
153+
}
154+
155+
func (enum FunctionHTTPOption) MarshalJSON() ([]byte, error) {
156+
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
157+
}
158+
159+
func (enum *FunctionHTTPOption) UnmarshalJSON(data []byte) error {
160+
tmp := ""
161+
162+
if err := json.Unmarshal(data, &tmp); err != nil {
163+
return err
164+
}
165+
166+
*enum = FunctionHTTPOption(FunctionHTTPOption(tmp).String())
167+
return nil
168+
}
169+
136170
type FunctionPrivacy string
137171

138172
const (
@@ -967,13 +1001,14 @@ type Function struct {
9671001
SecretEnvironmentVariables []*SecretHashedValue `json:"secret_environment_variables"`
9681002

9691003
Region scw.Region `json:"region"`
970-
// Deprecated: HTTPOption: configure how HTTP and HTTPS requests are handled
1004+
// HTTPOption: configure how HTTP and HTTPS requests are handled
9711005
//
9721006
// possible values:
9731007
// - redirected: Responds to HTTP request with a 302 redirect to ask the clients to use HTTPS.
9741008
// - enabled: Serve both HTTP and HTTPS traffic.
9751009
//
976-
HTTPOption *string `json:"http_option,omitempty"`
1010+
// Default value: unknown_http_option
1011+
HTTPOption FunctionHTTPOption `json:"http_option"`
9771012

9781013
RuntimeMessage string `json:"runtime_message"`
9791014
}
@@ -1657,13 +1692,14 @@ type CreateFunctionRequest struct {
16571692
Description *string `json:"description"`
16581693

16591694
SecretEnvironmentVariables []*Secret `json:"secret_environment_variables"`
1660-
// Deprecated: HTTPOption: configure how HTTP and HTTPS requests are handled
1695+
// HTTPOption: configure how HTTP and HTTPS requests are handled
16611696
//
16621697
// possible values:
16631698
// - redirected: Responds to HTTP request with a 302 redirect to ask the clients to use HTTPS.
16641699
// - enabled: Serve both HTTP and HTTPS traffic.
16651700
//
1666-
HTTPOption *string `json:"http_option,omitempty"`
1701+
// Default value: unknown_http_option
1702+
HTTPOption FunctionHTTPOption `json:"http_option"`
16671703
}
16681704

16691705
// CreateFunction: create a new function
@@ -1736,13 +1772,14 @@ type UpdateFunctionRequest struct {
17361772
Description *string `json:"description"`
17371773

17381774
SecretEnvironmentVariables []*Secret `json:"secret_environment_variables"`
1739-
// Deprecated: HTTPOption: configure how HTTP and HTTPS requests are handled
1775+
// HTTPOption: configure how HTTP and HTTPS requests are handled
17401776
//
17411777
// possible values:
17421778
// - redirected: Responds to HTTP request with a 302 redirect to ask the clients to use HTTPS.
17431779
// - enabled: Serve both HTTP and HTTPS traffic.
17441780
//
1745-
HTTPOption *string `json:"http_option,omitempty"`
1781+
// Default value: unknown_http_option
1782+
HTTPOption FunctionHTTPOption `json:"http_option"`
17461783
}
17471784

17481785
// UpdateFunction: update an existing function

0 commit comments

Comments
 (0)