Skip to content

Commit

Permalink
fix: explicit fields for CreateSecurityGroupRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
si-mm committed Apr 26, 2024
1 parent 1aa267c commit cbab14e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cloud/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ type CreateVNCProxyRequest struct {

// CreateSecurityGroupRequest is the request body for POST /cloud/security-group.
type CreateSecurityGroupRequest struct {
Template string `json:"template"`
Name string `json:"name"`
}

// CloneSecurityGroupRequest is the request body for POST /cloud/security-group/{sg}/clone.
Expand Down
9 changes: 7 additions & 2 deletions cloud/service_sg.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cloud

import (
"context"
"fmt"
)

// SecurityGroupService owns the /cloud/security-group methods.
Expand Down Expand Up @@ -110,10 +111,14 @@ func (s SecurityGroupService) RenameSecurityGroup(ctx context.Context, id int, r
// CreateSecurityGroup creates a new security group.
func (s SecurityGroupService) CreateSecurityGroup(ctx context.Context, req CreateSecurityGroupRequest) (*CreateSecurityGroupResponse, error) {
var resp CreateSecurityGroupResponse

p := s.path(SecurityGroupPath)

if err := s.Post(ctx, p, req, &resp); err != nil {
tpl := fmt.Sprintf("NAME = %q", req.Name)
body := map[string]any{
"template": tpl,
}

if err := s.Post(ctx, p, body, &resp); err != nil {
return nil, err
}

Expand Down

0 comments on commit cbab14e

Please sign in to comment.