Skip to content

Commit

Permalink
CDI-908: upd SSL certs
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-lukyanchyk committed Nov 28, 2024
1 parent 28abd49 commit 7a3a1f1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
9 changes: 9 additions & 0 deletions sslcerts/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ func (s *Service) Get(ctx context.Context, id int64) (*Cert, error) {
return &cert, nil
}

func (s *Service) Update(ctx context.Context, id int64, req *UpdateRequest) (*Cert, error) {
var cert Cert
if err := s.r.Request(ctx, http.MethodPatch, fmt.Sprintf("/cdn/sslData/%d", id), req, &cert); err != nil {
return nil, fmt.Errorf("request: %w", err)
}

return &cert, nil
}

func (s *Service) Delete(ctx context.Context, id int64) error {
if err := s.r.Request(ctx, http.MethodDelete, fmt.Sprintf("/cdn/sslData/%d", id), nil, nil); err != nil {
return fmt.Errorf("request: %w", err)
Expand Down
17 changes: 13 additions & 4 deletions sslcerts/sslcerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
type SSLCertService interface {
Create(ctx context.Context, req *CreateRequest) (*Cert, error)
Get(ctx context.Context, id int64) (*Cert, error)
Update(ctx context.Context, id int64, req *UpdateRequest) (*Cert, error)
Delete(ctx context.Context, id int64) error
}

Expand All @@ -24,8 +25,16 @@ type Cert struct {
}

type CreateRequest struct {
Name string `json:"name"`
Cert string `json:"sslCertificate"`
PrivateKey string `json:"sslPrivateKey"`
Automated bool `json:"automated"`
Name string `json:"name"`
Cert string `json:"sslCertificate"`
PrivateKey string `json:"sslPrivateKey"`
Automated bool `json:"automated"`
ValidateRootCA bool `json:"validate_root_ca,omitempty"`
}

type UpdateRequest struct {
Name string `json:"name,omitempty"`
Cert string `json:"sslCertificate,omitempty"`
PrivateKey string `json:"sslPrivateKey,omitempty"`
ValidateRootCA bool `json:"validate_root_ca,omitempty"`
}

0 comments on commit 7a3a1f1

Please sign in to comment.