unifi

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: MIT Imports: 15 Imported by: 0

README

unifi

Unifi api client in Go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

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

func NewAPIClient

func NewAPIClient(ctx context.Context, conf APIClientConfig) (*APIClient, error)

NewAPIClient returns an instance of APIClient

func (*APIClient) Block added in v0.0.3

func (c *APIClient) Block(ctx context.Context, req BlockRequest) ([]byte, error)

func (*APIClient) BlockIP

func (c *APIClient) BlockIP(ctx context.Context, ipaddress string, dir string) error

func (*APIClient) Delete

func (c *APIClient) Delete(ctx context.Context, endpoint string) ([]byte, error)

func (*APIClient) DeleteFirewallRule added in v0.0.3

func (c *APIClient) DeleteFirewallRule(ctx context.Context, id string) ([]byte, error)

func (*APIClient) FirewallList

func (c *APIClient) FirewallList(ctx context.Context) (ResponseFirewallRules, error)

func (*APIClient) Get

func (c *APIClient) Get(ctx context.Context, endpoint string) ([]byte, error)

func (*APIClient) Login

func (c *APIClient) Login(ctx context.Context) error

func (*APIClient) Post

func (c *APIClient) Post(ctx context.Context, endpoint string, data interface{}) ([]byte, error)

func (*APIClient) UnBlockIP

func (c *APIClient) UnBlockIP(ctx context.Context, ipaddress string, dir string) error

type APIClientConfig

type APIClientConfig struct {
	Host     string `yaml:"host"`
	Timeout  int    `yaml:"timeout"` // seconds
	User     string `yaml:"user"`
	Password string `yaml:"password"`
}

type BlockRequest added in v0.0.3

type BlockRequest struct {
	Name         string `json:"name"`
	Interface    string `json:"interface"`
	RuleLocation string `json:"location"`
	SrcAddress   string `json:"src"`
	DstAddress   string `json:"dst"`
	Protocol     string `json:"protocol"`
	Action       string `json:"action"`
	// contains filtered or unexported fields
}

func (BlockRequest) AsFirewallRule added in v0.0.3

func (b BlockRequest) AsFirewallRule() FirewallRule

func (*BlockRequest) Description added in v0.0.3

func (b *BlockRequest) Description() (string, error)

func (*BlockRequest) Index added in v0.0.3

func (b *BlockRequest) Index() int

func (*BlockRequest) Validate added in v0.0.3

func (b *BlockRequest) Validate() error

type FirewallRule added in v0.0.3

type FirewallRule struct {
	ID                    string   `json:"_id,omitempty"`
	Ruleset               string   `json:"ruleset"`
	RuleIndex             int      `json:"rule_index"`
	Name                  string   `json:"name"`
	Enabled               bool     `json:"enabled"`
	Action                string   `json:"action"`
	ProtocolMatchExcepted bool     `json:"protocol_match_excepted"`
	Logging               bool     `json:"logging"`
	StateNew              bool     `json:"state_new"`
	StateEstablished      bool     `json:"state_established"`
	StateInvalid          bool     `json:"state_invalid"`
	StateRelated          bool     `json:"state_related"`
	Ipsec                 string   `json:"ipsec"`
	SrcFirewallgroupIds   []string `json:"src_firewallgroup_ids"`
	SrcMacAddress         string   `json:"src_mac_address"`
	DstFirewallgroupIds   []string `json:"dst_firewallgroup_ids"`
	DstAddress            string   `json:"dst_address"`
	SrcAddress            string   `json:"src_address"`
	Protocol              string   `json:"protocol"`
	IcmpTypename          string   `json:"icmp_typename"`
	SrcNetworkconfID      string   `json:"src_networkconf_id"`
	SrcNetworkconfType    string   `json:"src_networkconf_type"`
	DstNetworkconfID      string   `json:"dst_networkconf_id"`
	DstNetworkconfType    string   `json:"dst_networkconf_type"`
	SiteID                string   `json:"site_id"`
}

type Meta

type Meta struct {
	ResponseCode string `json:"rc"`
}

type ResponseEnvelope

type ResponseEnvelope struct {
	Meta ResponseMetaData `json:"meta"`
	Data *json.RawMessage `json:"data"`
}

type ResponseFirewallRules

type ResponseFirewallRules struct {
	Meta ResponseMetaData `json:"meta"`
	Data []FirewallRule   `json:"data"`
}

type ResponseMetaData

type ResponseMetaData struct {
	Rc string `json:"rc"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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