security_groups

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_groups contains functionality for working with ECL Security Group resources.

Security Groups provide a way to define network access rules to control inbound and outbound traffic to instances.

Example to List Security Groups

listOpts := security_groups.ListOpts{
	TenantID: "tenant-id",
}

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

allSecurityGroups, err := security_groups.ExtractSecurityGroups(allPages)
if err != nil {
	panic(err)
}

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

Example to Create a Security Group

createOpts := security_groups.CreateOpts{
	Name:        "example-security-group",
	Description: "Example security group",
}

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

Example to Update a Security Group

securityGroupID := "security-group-id"

name := "updated-name"
description := "updated description"
updateOpts := security_groups.UpdateOpts{
	Name:        &name,
	Description: &description,
}

sg, err := security_groups.Update(networkClient, securityGroupID, updateOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a Security Group

securityGroupID := "security-group-id"
err := security_groups.Delete(networkClient, securityGroupID).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractSecurityGroupsInto

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

func List

List returns a Pager which allows you to iterate over a collection of security groups. 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"`
	Name        string            `json:"name,omitempty"`
	Tags        map[string]string `json:"tags,omitempty"`
	TenantID    string            `json:"tenant_id,omitempty"`
}

CreateOpts represents options used to create a security group.

func (CreateOpts) ToSecurityGroupCreateMap

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

ToSecurityGroupCreateMap builds a request body from CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToSecurityGroupCreateMap() (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 using the values provided. This operation does not actually require a request body, i.e. the CreateOpts struct argument can be empty.

func (CreateResult) Extract

func (r CreateResult) Extract() (*SecurityGroup, 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 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 based on its unique ID.

func (GetResult) Extract

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

func (GetResult) ExtractInto

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

type ListOpts

type ListOpts struct {
	Description string `q:"description"`
	ID          string `q:"id"`
	Name        string `q:"name"`
	Status      string `q:"status"`
	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 attributes you want to see returned.

func (ListOpts) ToSecurityGroupListQuery

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

ToSecurityGroupListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

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

type SecurityGroup

type SecurityGroup struct {
	Description        string              `json:"description"`
	ID                 string              `json:"id"`
	Name               string              `json:"name"`
	SecurityGroupRules []SecurityGroupRule `json:"security_group_rules"`
	Status             string              `json:"status"`
	Tags               map[string]string   `json:"tags"`
	TenantID           string              `json:"tenant_id"`
}

SecurityGroup represents a security group

func ExtractSecurityGroups

func ExtractSecurityGroups(r pagination.Page) ([]SecurityGroup, error)

type SecurityGroupPage

type SecurityGroupPage struct {
	pagination.LinkedPageBase
}

func (SecurityGroupPage) IsEmpty

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

func (SecurityGroupPage) NextPageURL

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

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 rule within a security group

type UpdateOpts

type UpdateOpts struct {
	Description *string            `json:"description,omitempty"`
	Name        *string            `json:"name,omitempty"`
	Tags        *map[string]string `json:"tags,omitempty"`
}

UpdateOpts represents options used to update a security group.

func (UpdateOpts) ToSecurityGroupUpdateMap

func (opts UpdateOpts) ToSecurityGroupUpdateMap() (map[string]interface{}, error)

ToSecurityGroupUpdateMap builds a request body from UpdateOpts.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToSecurityGroupUpdateMap() (map[string]interface{}, error)
}

UpdateOptsBuilder allows extensions to add additional parameters to the Update request.

type UpdateResult

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

func Update

Update accepts a UpdateOpts struct and updates an existing security group using the values provided.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*SecurityGroup, error)

func (UpdateResult) ExtractInto

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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