From cbab14e2d38a8644a856151ecd5a1962b9213cdf Mon Sep 17 00:00:00 2001 From: Miguel Moll Date: Fri, 26 Apr 2024 14:55:50 -0400 Subject: [PATCH] fix: explicit fields for CreateSecurityGroupRequest --- cloud/requests.go | 2 +- cloud/service_sg.go | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cloud/requests.go b/cloud/requests.go index f0a5ecb..4107fbb 100644 --- a/cloud/requests.go +++ b/cloud/requests.go @@ -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. diff --git a/cloud/service_sg.go b/cloud/service_sg.go index 176b64a..98152bb 100644 --- a/cloud/service_sg.go +++ b/cloud/service_sg.go @@ -2,6 +2,7 @@ package cloud import ( "context" + "fmt" ) // SecurityGroupService owns the /cloud/security-group methods. @@ -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 }