securitygroups

package
v0.6.28 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractMetadataInto

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

func ExtractSecurityGroupInstances

func ExtractSecurityGroupInstances(r pagination.Page) ([]instances.Instance, error)

ExtractSecurityGroupInstances accepts a Page struct, specifically a SecurityGroupInstancesPage struct, and extracts the elements into a slice of Instance structs. In other words, a generic collection is mapped into a relevant slice.

func ExtractSecurityGroupInstancesInto

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

func ExtractSecurityGroupsInto

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

func IDFromName

func IDFromName(client *gcorecloud.ServiceClient, name string) (string, error)

IDFromName is a convenience function that returns a security group's ID, given its name.

func ListAllInstances

func ListAllInstances(c *gcorecloud.ServiceClient, securityGroupID string) ([]instances.Instance, error)

ListAllInstances returns all instances for SG

func ListInstances

func ListInstances(c *gcorecloud.ServiceClient, securityGroupID string) pagination.Pager

ListInstances returns page of instances for SG

func MetadataList

func MetadataList(client *gcorecloud.ServiceClient, id string) pagination.Pager

Types

type CreateOpts

type CreateOpts struct {
	SecurityGroup CreateSecurityGroupOpts `json:"security_group" required:"true"`
	Instances     []string                `json:"instances,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 request.

type CreateResult

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

CreateResult represents the result of a create operation. Call its Extract method to interpret it as a SecurityGroup.

func Create

Create accepts a CreateOpts struct and creates a new security group using the values provided.

func (CreateResult) Extract

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

Extract is a function that accepts a result and extracts a security group resource.

func (CreateResult) ExtractInto

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

type CreateRuleOptsBuilder

type CreateRuleOptsBuilder interface {
	ToRuleCreateMap() (map[string]interface{}, error)
}

CreateRuleOptsBuilder allows extensions to add additional parameters to the request.

type CreateRuleResult

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

CreateRuleResult represents the result of a create operation. Call its Extract method to interpret it as a SecurityGroupRule.

func AddRule

func AddRule(c *gcorecloud.ServiceClient, securityGroupID string, opts CreateRuleOptsBuilder) (r CreateRuleResult)

AddRule accepts a CreateSecurityGroupRuleOpts struct and add rule to existed group.

func (CreateRuleResult) Extract

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

Extract is a function that accepts a result and extracts a security group rule resource.

func (CreateRuleResult) ExtractInto

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

type CreateSecurityGroupOpts

type CreateSecurityGroupOpts struct {
	Name               string                        `json:"name" required:"true"`
	Description        *string                       `json:"description,omitempty"`
	SecurityGroupRules []CreateSecurityGroupRuleOpts `json:"security_group_rules"`
	Metadata           map[string]interface{}        `json:"metadata,omitempty"`
}

type CreateSecurityGroupRuleOpts

type CreateSecurityGroupRuleOpts struct {
	Direction       types.RuleDirection `json:"direction" required:"true"`
	EtherType       types.EtherType     `json:"ethertype,omitempty" required:"true"`
	Protocol        types.Protocol      `json:"protocol,omitempty" required:"true"`
	SecurityGroupID *string             `json:"security_group_id,omitempty"`
	RemoteGroupID   *string             `json:"remote_group_id,omitempty"`
	PortRangeMax    *int                `json:"port_range_max,omitempty"`
	PortRangeMin    *int                `json:"port_range_min,omitempty"`
	Description     *string             `json:"description,omitempty"`
	RemoteIPPrefix  *string             `json:"remote_ip_prefix,omitempty"`
}

CreateSecurityGroupRuleOpts represents options used to create a security group rule.

func (CreateSecurityGroupRuleOpts) ToRuleCreateMap

func (opts CreateSecurityGroupRuleOpts) ToRuleCreateMap() (map[string]interface{}, error)

ToRuleCreateMap builds a request body from CreateSecurityGroupRuleOpts.

type DeepCopyOpts

type DeepCopyOpts struct {
	Name string `json:"name" required:"true"`
}

DeepCopyOpts represents options used to deep copy a security group.

func (DeepCopyOpts) ToDeepCopyMap

func (opts DeepCopyOpts) ToDeepCopyMap() (map[string]interface{}, error)

ToDeepCopyMap builds a request body from DeepCopyOpts.

type DeepCopyOptsBuilder

type DeepCopyOptsBuilder interface {
	ToDeepCopyMap() (map[string]interface{}, error)
}

DeepCopyOptsBuilder allows extensions to add additional parameters to the request.

type DeepCopyResult

type DeepCopyResult struct {
	gcorecloud.ErrResult
}

DeepCopyResult represents the result of a deep copy operation

func DeepCopy

func DeepCopy(c *gcorecloud.ServiceClient, securityGroupID string, opts DeepCopyOptsBuilder) (r DeepCopyResult)

DeepCopy accepts a DeepCopyOpts struct and create a deep copy of security group.

type DeleteResult

type DeleteResult struct {
	gcorecloud.ErrResult
}

DeleteResult represents the result of a delete operation

func Delete

func Delete(c *gcorecloud.ServiceClient, securityGroupID 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
}

GetResult represents the result of a get operation. Call its Extract method to interpret it as a SecurityGroup.

func Get

func Get(c *gcorecloud.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)

Extract is a function that accepts a result and extracts a security group resource.

func (GetResult) ExtractInto

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

type ListOpts

type ListOpts struct {
	MetadataK  string            `q:"metadata_k" validate:"omitempty"`
	MetadataKV map[string]string `q:"metadata_kv" validate:"omitempty"`
}

ListOpts allows the filtering and sorting of paginated collections through the API.

func (ListOpts) ToSecurityGroupListQuery

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

ToSequirityGroupListQuery 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 Metadata

type Metadata struct {
	Key      string `json:"key"`
	Value    string `json:"value"`
	ReadOnly bool   `json:"read_only"`
}

func ExtractMetadata

func ExtractMetadata(r pagination.Page) ([]Metadata, error)

ExtractMetadata accepts a Page struct, specifically a MetadataPage struct, and extracts the elements into a slice of securitygroups metadata structs. In other words, a generic collection is mapped into a relevant slice.

func MetadataListAll

func MetadataListAll(client *gcorecloud.ServiceClient, id string) ([]Metadata, error)

type MetadataActionResult

type MetadataActionResult struct {
	gcorecloud.ErrResult
}

MetadataActionResult represents the result of a create, delete or update operation(no content)

func MetadataCreateOrUpdate

func MetadataCreateOrUpdate(client *gcorecloud.ServiceClient, id string, opts map[string]interface{}) (r MetadataActionResult)

MetadataCreateOrUpdate creates or update a metadata for an security group.

func MetadataDelete

func MetadataDelete(client *gcorecloud.ServiceClient, id string, key string) (r MetadataActionResult)

MetadataDelete deletes defined metadata key for a security group.

func MetadataReplace

func MetadataReplace(client *gcorecloud.ServiceClient, id string, opts map[string]interface{}) (r MetadataActionResult)

MetadataReplace replace a metadata for an security group.

type MetadataPage

type MetadataPage struct {
	pagination.LinkedPageBase
}

MetadataPage is the page returned by a pager when traversing over a collection of instance metadata objects.

func (MetadataPage) IsEmpty

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

IsEmpty checks whether a MetadataPage struct is empty.

type MetadataResult

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

MetadataResult represents the result of a get operation

func MetadataGet

func MetadataGet(client *gcorecloud.ServiceClient, id string, key string) (r MetadataResult)

MetadataGet gets defined metadata key for a security group.

func (MetadataResult) Extract

func (r MetadataResult) Extract() (*Metadata, error)

func (MetadataResult) ExtractInto

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

type SecurityGroup

type SecurityGroup struct {
	Name               string                   `json:"name"`
	Description        string                   `json:"description"`
	ID                 string                   `json:"id"`
	CreatedAt          gcorecloud.JSONRFC3339Z  `json:"created_at"`
	UpdatedAt          *gcorecloud.JSONRFC3339Z `json:"updated_at"`
	RevisionNumber     int                      `json:"revision_number"`
	SecurityGroupRules []SecurityGroupRule      `json:"security_group_rules"`
	ProjectID          int                      `json:"project_id"`
	RegionID           int                      `json:"region_id"`
	Region             string                   `json:"region"`
	Tags               []string                 `json:"tags"`
	Metadata           []Metadata               `json:"metadata"`
}

SecurityGroup represents a security group.

func ExtractSecurityGroups

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

ExtractSecurityGroup accepts a Page struct, specifically a SecurityGroupPage struct, and extracts the elements into a slice of SecurityGroup structs. In other words, a generic collection is mapped into a relevant slice.

func ListAll

ListAll returns all SGs

type SecurityGroupInstancesPage

type SecurityGroupInstancesPage struct {
	pagination.LinkedPageBase
}

SecurityGroupInstancesPage is the page returned by a pager when traversing over a collection of security group instances.

func (SecurityGroupInstancesPage) IsEmpty

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

IsEmpty checks whether a SecurityGroupInstancesPage struct is empty.

func (SecurityGroupInstancesPage) NextPageURL

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

NextPageURL is invoked when a paginated collection of security group instances has reached the end of a page and the pager seeks to traverse over a new one. In order to do this, it needs to construct the next page's URL.

type SecurityGroupPage

type SecurityGroupPage struct {
	pagination.LinkedPageBase
}

SecurityGroupPage is the page returned by a pager when traversing over a collection of security groups.

func (SecurityGroupPage) IsEmpty

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

IsEmpty checks whether a SecurityGroupPage struct is empty.

func (SecurityGroupPage) NextPageURL

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

NextPageURL is invoked when a paginated collection of security groups has reached the end of a page and the pager seeks to traverse over a new one. In order to do this, it needs to construct the next page's URL.

type SecurityGroupRule

type SecurityGroupRule struct {
	ID              string                   `json:"id"`
	SecurityGroupID string                   `json:"security_group_id"`
	RemoteGroupID   *string                  `json:"remote_group_id"`
	Direction       types.RuleDirection      `json:"direction"`
	EtherType       *types.EtherType         `json:"ethertype"`
	Protocol        *types.Protocol          `json:"protocol"`
	PortRangeMax    *int                     `json:"port_range_max"`
	PortRangeMin    *int                     `json:"port_range_min"`
	Description     *string                  `json:"description"`
	RemoteIPPrefix  *string                  `json:"remote_ip_prefix"`
	CreatedAt       gcorecloud.JSONRFC3339Z  `json:"created_at"`
	UpdatedAt       *gcorecloud.JSONRFC3339Z `json:"updated_at"`
	RevisionNumber  int                      `json:"revision_number"`
}

SecurityGroupRule represents a security group rule.

type UpdateOpts

type UpdateOpts struct {
	Name string `json:"name" required:"true"`
}

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
}

UpdateResult represents the result of an update operation. Call its Extract method to interpret it as a SecurityGroup.

func Update

func Update(c *gcorecloud.ServiceClient, securityGroupID string, opts UpdateOptsBuilder) (r UpdateResult)

Update accepts a UpdateOpts struct and updates an existing security group using the values provided. For more information, see the Create function.

func (UpdateResult) Extract

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

Extract is a function that accepts a result and extracts a security group resource.

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