security_group_rules

package
v3.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package security_group_rules contains functionality for working with ECL Security Group Rule resources.

Security Group Rules define specific ingress and egress traffic rules for Security Groups.

Example to List Security Group Rules

listOpts := security_group_rules.ListOpts{
	SecurityGroupID: "security-group-id",
}

allPages, err := security_group_rules.List(networkClient, listOpts).AllPages()
if err != nil {
	panic(err)
}

allRules, err := security_group_rules.ExtractSecurityGroupRules(allPages)
if err != nil {
	panic(err)
}

for _, rule := range allRules {
	fmt.Printf("%+v\n", rule)
}

Example to Create a Security Group Rule

createOpts := security_group_rules.CreateOpts{
	Direction:       "ingress",
	SecurityGroupID: "security-group-id",
	Ethertype:       "IPv4",
	Protocol:        "tcp",
	PortRangeMin:    &[]int{22}[0],
	PortRangeMax:    &[]int{22}[0],
	RemoteIPPrefix:  &[]string{"0.0.0.0/0"}[0],
}

rule, err := security_group_rules.Create(networkClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a Security Group Rule

ruleID := "rule-id"
err := security_group_rules.Delete(networkClient, ruleID).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractSecurityGroupRulesInto

func ExtractSecurityGroupRulesInto(r pagination.Page, v interface{}) error

func List

List returns a Pager which allows you to iterate over a collection of security group rules. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.

Types

type CreateOpts

type CreateOpts struct {
	Description     string  `json:"description,omitempty"`
	Direction       string  `json:"direction" required:"true"`
	Ethertype       string  `json:"ethertype,omitempty"`
	PortRangeMax    *int    `json:"port_range_max,omitempty"`
	PortRangeMin    *int    `json:"port_range_min,omitempty"`
	Protocol        string  `json:"protocol,omitempty"`
	RemoteGroupID   *string `json:"remote_group_id,omitempty"`
	RemoteIPPrefix  *string `json:"remote_ip_prefix,omitempty"`
	SecurityGroupID string  `json:"security_group_id" required:"true"`
	TenantID        string  `json:"tenant_id,omitempty"`
}

CreateOpts represents options used to create a security group rule.

func (CreateOpts) ToSecurityGroupRuleCreateMap

func (opts CreateOpts) ToSecurityGroupRuleCreateMap() (map[string]interface{}, error)

ToSecurityGroupRuleCreateMap builds a request body from CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToSecurityGroupRuleCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder allows extensions to add additional parameters to the Create request.

type CreateResult

type CreateResult struct {
	// contains filtered or unexported fields
}

func Create

Create accepts a CreateOpts struct and creates a new security group rule.

func (CreateResult) Extract

func (r CreateResult) Extract() (*SecurityGroupRule, error)

func (CreateResult) ExtractInto

func (r CreateResult) ExtractInto(v interface{}) error

type DeleteResult

type DeleteResult struct {
	eclcloud.ErrResult
}

func Delete

func Delete(c *eclcloud.ServiceClient, id string) (r DeleteResult)

Delete accepts a unique ID and deletes the security group rule associated with it.

type GetResult

type GetResult struct {
	// contains filtered or unexported fields
}

func Get

func Get(c *eclcloud.ServiceClient, id string) (r GetResult)

Get retrieves a specific security group rule based on its unique ID.

func (GetResult) Extract

func (r GetResult) Extract() (*SecurityGroupRule, error)

func (GetResult) ExtractInto

func (r GetResult) ExtractInto(v interface{}) error

type ListOpts

type ListOpts struct {
	Description     string `q:"description"`
	Direction       string `q:"direction"`
	Ethertype       string `q:"ethertype"`
	ID              string `q:"id"`
	PortRangeMax    int    `q:"port_range_max"`
	PortRangeMin    int    `q:"port_range_min"`
	Protocol        string `q:"protocol"`
	RemoteGroupID   string `q:"remote_group_id"`
	RemoteIPPrefix  string `q:"remote_ip_prefix"`
	SecurityGroupID string `q:"security_group_id"`
	TenantID        string `q:"tenant_id"`
}

ListOpts allows the filtering and sorting of paginated collections through the API. Filtering is achieved by passing in struct field values that map to the security group rule attributes you want to see returned.

func (ListOpts) ToSecurityGroupRuleListQuery

func (opts ListOpts) ToSecurityGroupRuleListQuery() (string, error)

ToSecurityGroupRuleListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToSecurityGroupRuleListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request.

type SecurityGroupRule

type SecurityGroupRule struct {
	Description     string  `json:"description"`
	Direction       string  `json:"direction"`
	Ethertype       string  `json:"ethertype"`
	ID              string  `json:"id"`
	PortRangeMax    *int    `json:"port_range_max"`
	PortRangeMin    *int    `json:"port_range_min"`
	Protocol        string  `json:"protocol"`
	RemoteGroupID   *string `json:"remote_group_id"`
	RemoteIPPrefix  *string `json:"remote_ip_prefix"`
	SecurityGroupID string  `json:"security_group_id"`
	TenantID        string  `json:"tenant_id"`
}

SecurityGroupRule represents a security group rule

func ExtractSecurityGroupRules

func ExtractSecurityGroupRules(r pagination.Page) ([]SecurityGroupRule, error)

type SecurityGroupRulePage

type SecurityGroupRulePage struct {
	pagination.LinkedPageBase
}

func (SecurityGroupRulePage) IsEmpty

func (r SecurityGroupRulePage) IsEmpty() (bool, error)

func (SecurityGroupRulePage) NextPageURL

func (r SecurityGroupRulePage) NextPageURL() (string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL