rule

package
v0.0.0-...-2d83bcd Latest Latest
Warning

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

Go to latest
Published: May 16, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WildcardString           = "ANY"
	NullRule                 = Rule{}
	NullRuleString           = ""
	NullID                   = 0
	NullAction               = ""
	ErrorIdAlreadyExists     = errors.New("ID already exists")
	ErrorIdNotFound          = errors.New("ID not found")
	ErrorNotAbleToGenerateId = errors.New("Not able to generate ID")
	ErrorNotAbleToParseId    = errors.New("Not able to parse ID")
	ErrorUnableToMarshalJSON = errors.New("Unable to marshal JSON")
	ErrorRuleNotValid        = errors.New("Rule not valid")
)

Functions

func FromAction

func FromAction(action Action) string

Types

type Action

type Action int
const (
	ActionUndefined Action = iota
	ActionAllow
	ActionDeny
)

func ToAction

func ToAction(action string) Action

type Client

type Client struct {
	sync.RWMutex
	Index int
	// contains filtered or unexported fields
}

func NewClient

func NewClient() *Client

func (*Client) Add

func (client *Client) Add(opts Options) (ID, error)

func (*Client) Delete

func (client *Client) Delete(id ID) error

func (*Client) Get

func (client *Client) Get(id ID) (Rule, error)

func (*Client) GetAll

func (client *Client) GetAll() ([]Rule, error)

func (*Client) GetAllJSON

func (client *Client) GetAllJSON() (string, error)

func (*Client) GetJSON

func (client *Client) GetJSON(id ID) (string, error)

func (*Client) Set

func (client *Client) Set(id ID, opts Options) error

type ID

type ID = int

func StringToID

func StringToID(id string) (ID, error)

type Options

type Options struct {
	Country    string
	City       string
	Building   string
	Role       string
	DeviceType string
	Action     Action
}

type Rule

type Rule struct {
	ID         ID     `json:"id"`
	Country    string `json:"country"`
	City       string `json:"city"`
	Building   string `json:"building"`
	Role       string `json:"role"`
	DeviceType string `json:"device_type"`
	Action     string `json:"action"`
}

func (*Rule) Valid

func (rule *Rule) Valid() bool

Jump to

Keyboard shortcuts

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