securitygroups

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Package securitygroups represents our SiteHost `/server/firewall/security_groups` API endpoint.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddRequest

type AddRequest struct {
	ClientID string `json:"client_id"`
	Label    string `json:"label"`
}

AddRequest represents a request to create a security group.

type AddResponse

type AddResponse struct {
	Return struct {
		Name string `json:"name"`
	} `json:"return"`
	models.APIResponse
}

AddResponse represents a result of creating a security group.

type Client

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

Client is a Service to work with API Jobs.

func New

func New(c *api.Client) *Client

New is used to instantiate the Client struct.

func (*Client) Add

func (s *Client) Add(ctx context.Context, request AddRequest) (response AddResponse, err error)

Add creates a new security group.

func (*Client) Delete

func (s *Client) Delete(ctx context.Context, request DeleteRequest) (response models.APIResponse, err error)

Delete removes a security group.

func (*Client) Get

func (s *Client) Get(ctx context.Context, request GetRequest) (response GetResponse, err error)

Get retrieves details of a security group including its rules and attached servers.

func (*Client) List

func (s *Client) List(ctx context.Context, request ListAllRequest) (response ListResponse, err error)

List retrieves all security groups with optional filtering.

func (*Client) Update

func (s *Client) Update(ctx context.Context, request UpdateRequest) (response UpdateResponse, err error)

Update updates a security group.

type DeleteRequest

type DeleteRequest struct {
	ClientID string `json:"client_id"`
	Name     string `json:"name"`
}

DeleteRequest represents a request to remove a security group.

type GetRequest

type GetRequest struct {
	ClientID string `json:"client_id"`
	Name     string `json:"name"`
}

GetRequest represents a request to get details of a security group.

type GetResponse

type GetResponse struct {
	Return struct {
		Label       string `json:"label"`
		Name        string `json:"name"`
		Pending     string `json:"pending"`
		IsMissing   bool   `json:"is_missing"`
		DateAdded   string `json:"date_added"`
		DateUpdated string `json:"date_updated"`
		Servers     []struct {
			Name  string `json:"name"`
			Label string `json:"label"`
		} `json:"servers"`
		Rules struct {
			In  []Rule `json:"in"`
			Out []Rule `json:"out"`
		} `json:"rules"`
	} `json:"return"`
	models.APIResponse
}

GetResponse represents a result of a get security group call.

type ListAllRequest

type ListAllRequest struct {
	Label string `url:"filters[label],omitempty"`
	models.Filtering
}

ListAllRequest represents options for filtering security groups.

type ListResponse

type ListResponse struct {
	Return struct {
		models.Pagination
		Data []struct {
			Name        string   `json:"name"`
			Label       string   `json:"label"`
			Version     int      `json:"version"`
			Servers     []string `json:"servers"`
			DateUpdated string   `json:"date_updated"`
			Pending     string   `json:"pending"`
			IsMissing   bool     `json:"is_missing"`
		} `json:"data"`
	} `json:"return"`
	models.APIResponse
}

ListResponse represents a result of listing all security groups.

type ParamsOptions

type ParamsOptions struct {
	Label    string              `json:"label"`
	RulesIn  []UpdateRequestRule `json:"rules_in"`
	RulesOut []UpdateRequestRule `json:"rules_out"`
}

ParamsOptions represents options for updating a security group.

type Rule

type Rule struct {
	Pos        int    `json:"pos"`
	Dir        string `json:"dir"`
	Enabled    bool   `json:"enabled"`
	Action     string `json:"action"`
	Protocol   string `json:"protocol"`
	SrcIP      string `json:"src_ip"`
	SrcIPType  string `json:"src_ip_type"`
	SrcPort    string `json:"src_port"`
	DestIP     string `json:"dest_ip"`
	DestIPType string `json:"dest_ip_type"`
	DestPort   int    `json:"dest_port"`
}

Rule represents a security group firewall rule.

type RuleOut

type RuleOut struct {
	Enabled         bool   `json:"enabled"`
	Action          string `json:"action"`
	Protocol        string `json:"protocol"`
	DestinationIP   string `json:"dest_ip"`
	DestinationPort string `json:"dest_port"`
}

RuleOut represents a request to update an outbound rule for a security group.

type UpdateRequest

type UpdateRequest struct {
	ClientID string        `json:"client_id"`
	Name     string        `json:"name"`
	Params   ParamsOptions `json:"params"`
}

UpdateRequest represents a request to update a security group.

type UpdateRequestRule

type UpdateRequestRule struct {
	Enabled         bool   `json:"enabled"`
	Action          string `json:"action"`
	Protocol        string `json:"protocol"`
	DestinationPort string `json:"dest_port"`
	IP              string
}

UpdateRequestRule represents a request to update a rule for a security group.

type UpdateResponse

type UpdateResponse struct {
	Return struct {
		models.Job `json:"job"`
	} `json:"return"`
	models.APIResponse
}

UpdateResponse represents a result of an update security group call.

Jump to

Keyboard shortcuts

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