Skip to content

Commit b29bed7

Browse files
feat(lb): custom certificate (#262)
1 parent 8bd96cf commit b29bed7

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

api/lb/v1/lb_sdk.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ type CertificateType string
230230
const (
231231
// CertificateTypeLetsencryt is [insert doc].
232232
CertificateTypeLetsencryt = CertificateType("letsencryt")
233+
// CertificateTypeCustom is [insert doc].
234+
CertificateTypeCustom = CertificateType("custom")
233235
)
234236

235237
func (enum CertificateType) String() string {
@@ -822,7 +824,7 @@ type BackendServerStats struct {
822824

823825
// Certificate sSL certificate
824826
type Certificate struct {
825-
// Type type of certificate (custom coming soon)
827+
// Type type of certificate (Let's encrypt or custom)
826828
//
827829
// Default value: letsencryt
828830
Type CertificateType `json:"type"`
@@ -848,6 +850,12 @@ type Certificate struct {
848850
Name string `json:"name"`
849851
}
850852

853+
// CreateCertificateRequestCustomCertificate import a custom SSL certificate
854+
type CreateCertificateRequestCustomCertificate struct {
855+
// CertificateChain the full PEM-formatted include an entire certificate chain including public key, private key, and optionally certificate authorities.
856+
CertificateChain string `json:"certificate_chain"`
857+
}
858+
851859
// CreateCertificateRequestLetsencryptConfig generate a new SSL certificate using Let's Encrypt.
852860
type CreateCertificateRequestLetsencryptConfig struct {
853861
// CommonName main domain name of certificate (make sure this domain exists and resolves to your Load Balancer HA IP)
@@ -2913,21 +2921,26 @@ type CreateCertificateRequest struct {
29132921
// Name certificate name
29142922
Name string `json:"name"`
29152923
// Letsencrypt let's Encrypt type
2916-
// Precisely one of Letsencrypt must be set.
2924+
// Precisely one of CustomCertificate, Letsencrypt must be set.
29172925
Letsencrypt *CreateCertificateRequestLetsencryptConfig `json:"letsencrypt,omitempty"`
2926+
// CustomCertificate custom import certificate
2927+
// Precisely one of CustomCertificate, Letsencrypt must be set.
2928+
CustomCertificate *CreateCertificateRequestCustomCertificate `json:"custom_certificate,omitempty"`
29182929
}
29192930

29202931
func (m *CreateCertificateRequest) GetType() Type {
29212932
switch {
29222933
case m.Letsencrypt != nil:
29232934
return TypeLetsencrypt{*m.Letsencrypt}
2935+
case m.CustomCertificate != nil:
2936+
return TypeCustomCertificate{*m.CustomCertificate}
29242937
}
29252938
return nil
29262939
}
29272940

29282941
// CreateCertificate create Certificate
29292942
//
2930-
// Generate a new SSL certificate using Let's Encrypt (Custom certificates can be imported soon).
2943+
// Generate a new SSL certificate using Let's Encrypt or import your certificate.
29312944
func (s *API) CreateCertificate(req *CreateCertificateRequest, opts ...scw.RequestOption) (*Certificate, error) {
29322945
var err error
29332946

@@ -3290,3 +3303,10 @@ type TypeLetsencrypt struct {
32903303

32913304
func (TypeLetsencrypt) isType() {
32923305
}
3306+
3307+
type TypeCustomCertificate struct {
3308+
Value CreateCertificateRequestCustomCertificate
3309+
}
3310+
3311+
func (TypeCustomCertificate) isType() {
3312+
}

0 commit comments

Comments
 (0)