github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/networking/v3/security/rules/results.go (about) 1 package rules 2 3 import "github.com/chnsz/golangsdk/pagination" 4 5 // SecurityGroupRule is a struct that represents the detail of the security group rule. 6 type SecurityGroupRule struct { 7 // Specifies the security group rule ID, which uniquely identifies the security group rule. 8 ID string `json:"id"` 9 // Provides supplementary information about the security group rule. 10 // The value can contain no more than 255 characters, including letters and digits. 11 Description string `json:"description"` 12 // Specifies the security group ID, which uniquely identifies the security group. 13 SecurityGroupId string `json:"security_group_id"` 14 // Specifies the direction of access control. 15 // Possible values are as follows: 16 // egress 17 // ingress 18 Direction string `json:"direction"` 19 // Specifies the protocol type. The value can be icmp, tcp, udp, icmpv6 or protocol number. 20 // If the parameter is left blank, all protocols are supported. 21 // When the protocol is icmpv6, the network type should be IPv6. 22 // when the protocol is icmp, the network type should be IPv4. 23 Protocol string `json:"protocol"` 24 // Specifies the IP protocol version. The value can be IPv4 or IPv6. 25 Ethertype string `json:"ethertype"` 26 // Port value range. 27 // Value range: support and single port (80), contiguous port (1-30) and discontinuous port (22, 3389, 80). 28 MultiPort string `json:"multiport"` 29 // Security group rules take effect policy. 30 // allow 31 // deny 32 // Default is deny. 33 Action string `json:"action"` 34 // Priority 35 // Value range: 1~100, 1 represents the highest priority. 36 Priority int `json:"priority"` 37 // Specifies the remote IP address. 38 // If the access control direction is set to egress, the parameter specifies the source IP address. 39 // If the access control direction is set to ingress, the parameter specifies the destination IP address. 40 // The value can be in the CIDR format or IP addresses. 41 // The parameter is exclusive with parameter remote_group_id. 42 RemoteIpPrefix string `json:"remote_ip_prefix"` 43 // Specifies the ID of the peer security group. 44 // The value is exclusive with parameter remote_ip_prefix. 45 RemoteGroupId string `json:"remote_group_id"` 46 // Remote address group ID. Mutually exclusive with remote_ip_prefix, remote_group_id parameters. 47 RemoteAddressGroupId string `json:"remote_address_group_id"` 48 // Security group rule creation time, in UTC format: yyyy-MM-ddTHH:mm:ss. 49 CreateAt string `json:"created_at"` 50 // Security group rule udpate time, in UTC format: yyyy-MM-ddTHH:mm:ss. 51 UpdateAt string `json:"updated_at"` 52 // ID of the project to which the security group rule belongs. 53 ProjectId string `json:"project_id"` 54 } 55 56 type SecurityGroupRulePage struct { 57 pagination.MarkerPageBase 58 } 59 60 // LastMarker method returns the last security group rule ID in a SecurityGroupRulePage. 61 func (p SecurityGroupRulePage) LastMarker() (string, error) { 62 secgroups, err := ExtractSecurityGroupRules(p) 63 if err != nil { 64 return "", err 65 } 66 if len(secgroups) == 0 { 67 return "", nil 68 } 69 return secgroups[len(secgroups)-1].ID, nil 70 } 71 72 // IsEmpty method checks whether the current SecurityGroupRulePage is empty. 73 func (p SecurityGroupRulePage) IsEmpty() (bool, error) { 74 secgroups, err := ExtractSecurityGroupRules(p) 75 return len(secgroups) == 0, err 76 } 77 78 // ExtractSecurityGroupRules is a method to extract the list of security group rule details. 79 func ExtractSecurityGroupRules(r pagination.Page) ([]SecurityGroupRule, error) { 80 var s []SecurityGroupRule 81 err := r.(SecurityGroupRulePage).Result.ExtractIntoSlicePtr(&s, "security_group_rules") 82 return s, err 83 }