Skip to content

Commit

Permalink
feat: add more rule fields
Browse files Browse the repository at this point in the history
  • Loading branch information
si-mm committed May 28, 2024
1 parent 7315e73 commit f2a4290
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 0 additions & 1 deletion cloud/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ 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
2 changes: 1 addition & 1 deletion cloud/service_sg.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (s SecurityGroupService) SecurityGroup(ctx context.Context, id int) (*Secur
return &resp, nil
}

// SecurityGroups returns information about all images.
// SecurityGroups returns information about all security groups.
func (s SecurityGroupService) SecurityGroups(ctx context.Context) (*SecurityGroupsResponse, error) {
var resp SecurityGroupsResponse

Expand Down
17 changes: 15 additions & 2 deletions cloud/sg.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ type SecurityGroupTemplate struct {

// SecurityGroupRule is the API payload based on the legacy xmlrpc backend.
type SecurityGroupRule struct {
Protocol string `json:"protocol" yaml:"protocol"`
RuleType string `json:"rule_type" yaml:"rule_type"`
ICMPType string `json:"icmp_type" yaml:"icmp_type"`
IP string `json:"ip" yaml:"ip"`
NetworkID string `json:"network_id" yaml:"network_id"`
Protocol string `json:"protocol" yaml:"protocol"`
Range string `json:"range" yaml:"range"`
RuleType string `json:"rule_type" yaml:"rule_type"`
Size string `json:"size" yaml:"size"`
}

// ParseTemplate returns a structured subset of the nested key x value pair map.
Expand Down Expand Up @@ -64,6 +69,14 @@ func newSecurityGroupRule(m map[string]any) *SecurityGroupRule {
r.Protocol = v
case "RULE_TYPE":
r.RuleType = v
case "IP":
r.IP = v
case "RANGE":
r.Range = v
case "ICMP_TYPE":
r.ICMPType = v
case "NETWORK_ID":
r.NetworkID = v
}
}
}
Expand Down

0 comments on commit f2a4290

Please sign in to comment.