client

package module
v0.0.0-...-5dc204e Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: MIT Imports: 15 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfigFromEnv

func GetConfigFromEnv() (host, username, password string, tls bool, caCertificate string, insecure bool)

func IsNotFoundError

func IsNotFoundError(err error) bool

func Marshal

func Marshal(c string, s interface{}) []string

func NewNotFound

func NewNotFound(text string) error

func RandomString

func RandomString() string

RandomString returns a random string

func SetupAndTestMainExec

func SetupAndTestMainExec(m *testing.M, sysResources *SystemResources)

func SkipIfRouterOSV6OrEarlier

func SkipIfRouterOSV6OrEarlier(t *testing.T, systemResources SystemResources)

func SkipIfRouterOSV7OrLater

func SkipIfRouterOSV7OrLater(t *testing.T, systemResources SystemResources)

func Unmarshal

func Unmarshal(reply routeros.Reply, v interface{}) error

Unmarshal decodes MikroTik's API reply into Go object

Types

type Action

type Action string

Action represents possible action on resource.

const (
	Add    Action = "add"
	Update Action = "update"
	Find   Action = "find"
	List   Action = "list"
	Delete Action = "delete"
)

type Adder

type Adder interface {
	// AfterAddHook is called right after the resource successfully added.
	// This hook is mainly used to set resource's ID field based on reply from RouterOS.
	AfterAddHook(r *routeros.Reply)
}

Adder defines contract for resources which require custom behaviour during resource creation.

type BgpInstance

type BgpInstance struct {
	Id                       string `mikrotik:".id" codegen:"id,mikrotikID"`
	Name                     string `mikrotik:"name" codegen:"name,required,terraformID"`
	As                       int    `mikrotik:"as" codegen:"as,required"`
	ClientToClientReflection bool   `mikrotik:"client-to-client-reflection" codegen:"client_to_client_reflection"`
	Comment                  string `mikrotik:"comment" codegen:"comment"`
	ConfederationPeers       string `mikrotik:"confederation-peers" codegen:"confederation_peers"`
	Disabled                 bool   `mikrotik:"disabled" codegen:"disabled"`
	IgnoreAsPathLen          bool   `mikrotik:"ignore-as-path-len" codegen:"ignore_as_path_len"`
	OutFilter                string `mikrotik:"out-filter" codegen:"out_filter"`
	RedistributeConnected    bool   `mikrotik:"redistribute-connected" codegen:"redistribute_connected"`
	RedistributeOspf         bool   `mikrotik:"redistribute-ospf" codegen:"redistribute_ospf"`
	RedistributeOtherBgp     bool   `mikrotik:"redistribute-other-bgp" codegen:"redistribute_other_bgp"`
	RedistributeRip          bool   `mikrotik:"redistribute-rip" codegen:"redistribute_rip"`
	RedistributeStatic       bool   `mikrotik:"redistribute-static" codegen:"redistribute_static"`
	RouterID                 string `mikrotik:"router-id" codegen:"router_id,required"`
	RoutingTable             string `mikrotik:"routing-table" codegen:"routing_table"`
	ClusterID                string `mikrotik:"cluster-id" codegen:"cluster_id"`
	Confederation            int    `mikrotik:"confederation" codegen:"confederation"`
}

BgpInstance Mikrotik resource

func (*BgpInstance) ActionToCommand

func (b *BgpInstance) ActionToCommand(a Action) string

func (*BgpInstance) AfterAddHook

func (b *BgpInstance) AfterAddHook(r *routeros.Reply)

func (*BgpInstance) DeleteField

func (b *BgpInstance) DeleteField() string

func (*BgpInstance) DeleteFieldValue

func (b *BgpInstance) DeleteFieldValue() string

func (*BgpInstance) FindField

func (b *BgpInstance) FindField() string

func (*BgpInstance) FindFieldValue

func (b *BgpInstance) FindFieldValue() string

func (*BgpInstance) HandleError

func (b *BgpInstance) HandleError(err error) error

HandleError intercepts errors during CRUD operations. It is used to catch "no such command prefix" on RouterOS >= v7.0

func (*BgpInstance) ID

func (b *BgpInstance) ID() string

func (*BgpInstance) IDField

func (b *BgpInstance) IDField() string

func (*BgpInstance) SetID

func (b *BgpInstance) SetID(id string)

type BgpPeer

type BgpPeer struct {
	Id                   string `mikrotik:".id" codegen:"id,mikrotikID"`
	Name                 string `mikrotik:"name" codegen:"name,required,terraformID"`
	AddressFamilies      string `mikrotik:"address-families" codegen:"address_families,optional,computed"`
	AllowAsIn            int    `mikrotik:"allow-as-in" codegen:"allow_as_in"`
	AsOverride           bool   `mikrotik:"as-override" codegen:"as_override"`
	CiscoVplsNlriLenFmt  string `mikrotik:"cisco-vpls-nlri-len-fmt" codegen:"cisco_vpls_nlri_len_fmt"`
	Comment              string `mikrotik:"comment" codegen:"comment"`
	DefaultOriginate     string `mikrotik:"default-originate" codegen:"default_originate,optional,computed"`
	Disabled             bool   `mikrotik:"disabled" codegen:"disabled"`
	HoldTime             string `mikrotik:"hold-time" codegen:"hold_time,optional,computed"`
	InFilter             string `mikrotik:"in-filter" codegen:"in_filter"`
	Instance             string `mikrotik:"instance" codegen:"instance"`
	KeepAliveTime        string `mikrotik:"keepalive-time" codegen:"keepalive_time"`
	MaxPrefixLimit       int    `mikrotik:"max-prefix-limit" codegen:"max_prefix_limit"`
	MaxPrefixRestartTime string `mikrotik:"max-prefix-restart-time" codegen:"max_prefix_restart_time"`
	Multihop             bool   `mikrotik:"multihop" codegen:"multihop"`
	NexthopChoice        string `mikrotik:"nexthop-choice" codegen:"nexthop_choice,optional,computed"`
	OutFilter            string `mikrotik:"out-filter" codegen:"out_filter"`
	Passive              bool   `mikrotik:"passive" codegen:"passive"`
	RemoteAddress        string `mikrotik:"remote-address" codegen:"remote_address,required"`
	RemoteAs             int    `mikrotik:"remote-as" codegen:"remote_as,required"`
	RemotePort           int    `mikrotik:"remote-port" codegen:"remote_port"`
	RemovePrivateAs      bool   `mikrotik:"remove-private-as" codegen:"remove_private_as"`
	RouteReflect         bool   `mikrotik:"route-reflect" codegen:"route_reflect"`
	TCPMd5Key            string `mikrotik:"tcp-md5-key" codegen:"tcp_md5_key"`
	TTL                  string `mikrotik:"ttl" codegen:"ttl,optional,computed"`
	UpdateSource         string `mikrotik:"update-source" codegen:"update_source"`
	UseBfd               bool   `mikrotik:"use-bfd" codegen:"use_bfd"`
}

BgpPeer Mikrotik resource

func (*BgpPeer) ActionToCommand

func (b *BgpPeer) ActionToCommand(a Action) string

func (*BgpPeer) AfterAddHook

func (b *BgpPeer) AfterAddHook(r *routeros.Reply)

func (*BgpPeer) DeleteField

func (b *BgpPeer) DeleteField() string

func (*BgpPeer) DeleteFieldValue

func (b *BgpPeer) DeleteFieldValue() string

func (*BgpPeer) FindField

func (b *BgpPeer) FindField() string

func (*BgpPeer) FindFieldValue

func (b *BgpPeer) FindFieldValue() string

func (*BgpPeer) ID

func (b *BgpPeer) ID() string

func (*BgpPeer) IDField

func (b *BgpPeer) IDField() string

func (*BgpPeer) SetID

func (b *BgpPeer) SetID(id string)

type Bridge

type Bridge struct {
	Id            string `mikrotik:".id" codegen:"id,mikrotikID"`
	Name          string `mikrotik:"name" codegen:"name,required,terraformID"`
	FastForward   bool   `mikrotik:"fast-forward" codegen:"fast_forward"`
	VlanFiltering bool   `mikrotik:"vlan-filtering" codegen:"vlan_filtering"`
	Comment       string `mikrotik:"comment" codegen:"comment"`
}

Bridge defines /bridge resource

func (*Bridge) ActionToCommand

func (b *Bridge) ActionToCommand(a Action) string

func (*Bridge) AfterAddHook

func (b *Bridge) AfterAddHook(r *routeros.Reply)

func (*Bridge) DeleteField

func (b *Bridge) DeleteField() string

func (*Bridge) DeleteFieldValue

func (b *Bridge) DeleteFieldValue() string

func (*Bridge) FindField

func (b *Bridge) FindField() string

func (*Bridge) FindFieldValue

func (b *Bridge) FindFieldValue() string

func (*Bridge) ID

func (b *Bridge) ID() string

func (*Bridge) IDField

func (b *Bridge) IDField() string

func (*Bridge) SetID

func (b *Bridge) SetID(id string)

type BridgePort

type BridgePort struct {
	Id        string `mikrotik:".id" codegen:"id,mikrotikID"`
	Bridge    string `mikrotik:"bridge" codegen:"bridge"`
	Interface string `mikrotik:"interface" codegen:"interface"`
	PVId      int    `mikrotik:"pvid" codegen:"pvid"`
	Comment   string `mikrotik:"comment" codegen:"comment"`
}

BridgePort defines port-in-bridge association

func (*BridgePort) ActionToCommand

func (b *BridgePort) ActionToCommand(a Action) string

func (*BridgePort) AfterAddHook

func (b *BridgePort) AfterAddHook(r *routeros.Reply)

func (*BridgePort) DeleteField

func (b *BridgePort) DeleteField() string

func (*BridgePort) DeleteFieldValue

func (b *BridgePort) DeleteFieldValue() string

func (*BridgePort) ID

func (b *BridgePort) ID() string

func (*BridgePort) IDField

func (b *BridgePort) IDField() string

func (*BridgePort) SetID

func (b *BridgePort) SetID(id string)

type BridgeVlan

type BridgeVlan struct {
	Id       string                `mikrotik:".id" codegen:"id,mikrotikID"`
	Bridge   string                `mikrotik:"bridge" codegen:"bridge,required"`
	Tagged   types.MikrotikList    `mikrotik:"tagged" codegen:"tagged,elemType=String"`
	Untagged types.MikrotikList    `mikrotik:"untagged" codegen:"untagged,elemType=String"`
	VlanIds  types.MikrotikIntList `mikrotik:"vlan-ids" codegen:"vlan_ids,elemType=Int64"`
}

BridgeVlan defines vlan filtering in bridge resource

func (*BridgeVlan) ActionToCommand

func (b *BridgeVlan) ActionToCommand(a Action) string

func (*BridgeVlan) AfterAddHook

func (b *BridgeVlan) AfterAddHook(r *routeros.Reply)

func (*BridgeVlan) ID

func (b *BridgeVlan) ID() string

func (*BridgeVlan) IDField

func (b *BridgeVlan) IDField() string

func (*BridgeVlan) SetID

func (b *BridgeVlan) SetID(id string)

type Deleter

type Deleter interface {
	// DeleteField retrieves a name of a field which is used for resource deletion.
	DeleteField() string

	// DeleteFieldValue retrieves a value for DeleteField field.
	DeleteFieldValue() string
}

Deleter defines contract for resources which require custom behaviour during resource deletion.

type DhcpLease

type DhcpLease struct {
	Id          string `mikrotik:".id" codegen:"id,mikrotikID,terraformID"`
	Address     string `mikrotik:"address" codegen:"address,required"`
	MacAddress  string `mikrotik:"mac-address" codegen:"macaddress,required"`
	Comment     string `mikrotik:"comment" codegen:"comment"`
	BlockAccess bool   `mikrotik:"block-access" codegen:"blocked"`
	Dynamic     bool   `mikrotik:"dynamic,readonly" codegen:"dynamic,computed"` // TODO:  don't see this listed as a param https://wiki.mikrotik.com/wiki/Manual:IP/DHCP_Server, but our docs list it as one
	Hostname    string `mikrotik:"host-name,readonly" codegen:"hostname,computed"`
}

func (*DhcpLease) ActionToCommand

func (b *DhcpLease) ActionToCommand(a Action) string

func (*DhcpLease) AfterAddHook

func (b *DhcpLease) AfterAddHook(r *routeros.Reply)

func (*DhcpLease) ID

func (b *DhcpLease) ID() string

func (*DhcpLease) IDField

func (b *DhcpLease) IDField() string

func (*DhcpLease) SetID

func (b *DhcpLease) SetID(id string)

type DhcpServer

type DhcpServer struct {
	Id            string `mikrotik:".id" codegen:"id,mikrotikID"`
	Name          string `mikrotik:"name" codegen:"name,terraformID,required"`
	Disabled      bool   `mikrotik:"disabled" codegen:"disabled"`
	AddArp        bool   `mikrotik:"add-arp" codegen:"add_arp"`
	AddressPool   string `mikrotik:"address-pool" codegen:"address_pool"`
	Authoritative string `mikrotik:"authoritative" codegen:"authoritative"`
	Interface     string `mikrotik:"interface" codegen:"interface"`
	LeaseScript   string `mikrotik:"lease-script" codegen:"lease_script"`
}

DhcpServer represents DHCP server resource

func (*DhcpServer) ActionToCommand

func (b *DhcpServer) ActionToCommand(a Action) string

func (*DhcpServer) AfterAddHook

func (b *DhcpServer) AfterAddHook(r *routeros.Reply)

func (*DhcpServer) DeleteField

func (b *DhcpServer) DeleteField() string

func (*DhcpServer) DeleteFieldValue

func (b *DhcpServer) DeleteFieldValue() string

func (*DhcpServer) FindField

func (b *DhcpServer) FindField() string

func (*DhcpServer) FindFieldValue

func (b *DhcpServer) FindFieldValue() string

func (*DhcpServer) ID

func (b *DhcpServer) ID() string

func (*DhcpServer) IDField

func (b *DhcpServer) IDField() string

func (*DhcpServer) SetID

func (b *DhcpServer) SetID(id string)

type DhcpServerNetwork

type DhcpServerNetwork struct {
	Id        string `mikrotik:".id" codegen:"id,mikrotikID"`
	Comment   string `mikrotik:"comment" codegen:"comment"`
	Address   string `mikrotik:"address" codegen:"address"`
	Netmask   string `mikrotik:"netmask" codegen:"netmask"`
	Gateway   string `mikrotik:"gateway" codegen:"gateway"`
	DnsServer string `mikrotik:"dns-server" codegen:"dns_server"`
}

DhcpServerNetwork describes network configuration for DHCP server

func (*DhcpServerNetwork) ActionToCommand

func (b *DhcpServerNetwork) ActionToCommand(a Action) string

func (*DhcpServerNetwork) AfterAddHook

func (b *DhcpServerNetwork) AfterAddHook(r *routeros.Reply)

func (*DhcpServerNetwork) ID

func (b *DhcpServerNetwork) ID() string

func (*DhcpServerNetwork) IDField

func (b *DhcpServerNetwork) IDField() string

func (*DhcpServerNetwork) SetID

func (b *DhcpServerNetwork) SetID(id string)

type DnsRecord

type DnsRecord struct {
	Id      string                 `mikrotik:".id" codegen:"id,mikrotikID"`
	Name    string                 `mikrotik:"name" codegen:"name,terraformID,required"`
	Ttl     types.MikrotikDuration `mikrotik:"ttl" codegen:"ttl"`
	Address string                 `mikrotik:"address" codegen:"address,required"`
	Comment string                 `mikrotik:"comment" codegen:"comment"`
}

func (*DnsRecord) ActionToCommand

func (d *DnsRecord) ActionToCommand(action Action) string

func (*DnsRecord) AfterAddHook

func (d *DnsRecord) AfterAddHook(r *routeros.Reply)

func (*DnsRecord) DeleteField

func (d *DnsRecord) DeleteField() string

func (*DnsRecord) DeleteFieldValue

func (d *DnsRecord) DeleteFieldValue() string

func (*DnsRecord) FindField

func (d *DnsRecord) FindField() string

func (*DnsRecord) FindFieldValue

func (d *DnsRecord) FindFieldValue() string

func (*DnsRecord) ID

func (d *DnsRecord) ID() string

func (*DnsRecord) IDField

func (d *DnsRecord) IDField() string

func (*DnsRecord) SetID

func (d *DnsRecord) SetID(id string)

type ErrorHandler

type ErrorHandler interface {
	HandleError(error) error
}

ErrorHandler Defines contract to handle errors returned by RouterOS. It can either return another error, or supress original error by returning nil.

type Finder

type Finder interface {
	// FindField retrieves a name of a field to use as key for resource retrieval.
	FindField() string

	// FindFieldValue retrieves a value to use for resource retrieval.
	FindFieldValue() string
}

Finder defines contract for resources which provide custom behaviour during resource retrieval.

type FirewallFilterRule

type FirewallFilterRule struct {
	Id               string             `mikrotik:".id" codegen:"id,mikrotikID,terraformID"`
	Action           string             `mikrotik:"action" codegen:"action"`
	Chain            string             `mikrotik:"chain" codegen:"chain,required"`
	Comment          string             `mikrotik:"comment" codegen:"comment"`
	ConnectionState  types.MikrotikList `mikrotik:"connection-state" codegen:"connection_state"`
	DestPort         string             `mikrotik:"dst-port" codegen:"dst_port"`
	InInterface      string             `mikrotik:"in-interface" codegen:"in_interface"`
	InInterfaceList  string             `mikrotik:"in-interface-list" codegen:"in_interface_list"`
	OutInterfaceList string             `mikrotik:"out-interface-list" codegen:"out_interface_list"`
	Protocol         string             `mikrotik:"protocol" codegen:"protocol"`
}

FirewallFilterRule defines /ip/firewall/filter rule

func (*FirewallFilterRule) ActionToCommand

func (b *FirewallFilterRule) ActionToCommand(a Action) string

func (*FirewallFilterRule) AfterAddHook

func (b *FirewallFilterRule) AfterAddHook(r *routeros.Reply)

func (*FirewallFilterRule) ID

func (b *FirewallFilterRule) ID() string

func (*FirewallFilterRule) IDField

func (b *FirewallFilterRule) IDField() string

func (*FirewallFilterRule) SetID

func (b *FirewallFilterRule) SetID(id string)

type InterfaceList

type InterfaceList struct {
	Id      string `mikrotik:".id" codegen:"id,mikrotikID"`
	Comment string `mikrotik:"comment" codegen:"comment"`
	Name    string `mikrotik:"name" codegen:"name,terraformID,required"`
}

InterfaceList manages a list of interfaces

func (*InterfaceList) ActionToCommand

func (b *InterfaceList) ActionToCommand(a Action) string

func (*InterfaceList) AfterAddHook

func (b *InterfaceList) AfterAddHook(r *routeros.Reply)

func (*InterfaceList) DeleteField

func (b *InterfaceList) DeleteField() string

func (*InterfaceList) DeleteFieldValue

func (b *InterfaceList) DeleteFieldValue() string

func (*InterfaceList) FindField

func (b *InterfaceList) FindField() string

func (*InterfaceList) FindFieldValue

func (b *InterfaceList) FindFieldValue() string

func (*InterfaceList) ID

func (b *InterfaceList) ID() string

func (*InterfaceList) IDField

func (b *InterfaceList) IDField() string

func (*InterfaceList) SetID

func (b *InterfaceList) SetID(id string)

type InterfaceListMember

type InterfaceListMember struct {
	Id        string `mikrotik:".id" codegen:"id,mikrotikID"`
	Interface string `mikrotik:"interface" codegen:"interface,required"`
	List      string `mikrotik:"list" codegen:"list,required"`
}

InterfaceListMember manages an interface list's members

func (*InterfaceListMember) ActionToCommand

func (b *InterfaceListMember) ActionToCommand(a Action) string

func (*InterfaceListMember) AfterAddHook

func (b *InterfaceListMember) AfterAddHook(r *routeros.Reply)

func (*InterfaceListMember) DeleteField

func (b *InterfaceListMember) DeleteField() string

func (*InterfaceListMember) DeleteFieldValue

func (b *InterfaceListMember) DeleteFieldValue() string

func (*InterfaceListMember) ID

func (b *InterfaceListMember) ID() string

func (*InterfaceListMember) IDField

func (b *InterfaceListMember) IDField() string

func (*InterfaceListMember) SetID

func (b *InterfaceListMember) SetID(id string)

type InterfaceWireguard

type InterfaceWireguard struct {
	Id         string `mikrotik:".id"`
	Name       string `mikrotik:"name"`
	Comment    string `mikrotik:"comment"`
	Disabled   bool   `mikrotik:"disabled"`
	ListenPort int    `mikrotik:"listen-port"`
	Mtu        int    `mikrotik:"mtu"`
	PrivateKey string `mikrotik:"private-key"`
	PublicKey  string `mikrotik:"public-key,readonly"` //read only property
	Running    bool   `mikrotik:"running,readonly"`    //read only property
}

func (*InterfaceWireguard) ActionToCommand

func (i *InterfaceWireguard) ActionToCommand(action Action) string

func (*InterfaceWireguard) AfterAddHook

func (i *InterfaceWireguard) AfterAddHook(r *routeros.Reply)

func (*InterfaceWireguard) DeleteField

func (i *InterfaceWireguard) DeleteField() string

func (*InterfaceWireguard) DeleteFieldValue

func (i *InterfaceWireguard) DeleteFieldValue() string

func (*InterfaceWireguard) FindField

func (i *InterfaceWireguard) FindField() string

func (*InterfaceWireguard) FindFieldValue

func (i *InterfaceWireguard) FindFieldValue() string

func (*InterfaceWireguard) ID

func (i *InterfaceWireguard) ID() string

func (*InterfaceWireguard) IDField

func (i *InterfaceWireguard) IDField() string

func (*InterfaceWireguard) SetID

func (i *InterfaceWireguard) SetID(id string)

type InterfaceWireguardPeer

type InterfaceWireguardPeer struct {
	Id                  string `mikrotik:".id"`
	AllowedAddress      string `mikrotik:"allowed-address"`
	Comment             string `mikrotik:"comment"`
	Disabled            bool   `mikrotik:"disabled"`
	EndpointAddress     string `mikrotik:"endpoint-address"`
	EndpointPort        int64  `mikrotik:"endpoint-port"`
	Interface           string `mikrotik:"interface"`
	PersistentKeepalive int64  `mikrotik:"persistent-keepalive"`
	PresharedKey        string `mikrotik:"preshared-key"`
	PublicKey           string `mikrotik:"public-key"`
}

func (*InterfaceWireguardPeer) ActionToCommand

func (i *InterfaceWireguardPeer) ActionToCommand(action Action) string

func (*InterfaceWireguardPeer) AfterAddHook

func (i *InterfaceWireguardPeer) AfterAddHook(r *routeros.Reply)

func (*InterfaceWireguardPeer) DeleteField

func (i *InterfaceWireguardPeer) DeleteField() string

func (*InterfaceWireguardPeer) DeleteFieldValue

func (i *InterfaceWireguardPeer) DeleteFieldValue() string

func (*InterfaceWireguardPeer) ID

func (*InterfaceWireguardPeer) IDField

func (i *InterfaceWireguardPeer) IDField() string

func (*InterfaceWireguardPeer) SetID

func (i *InterfaceWireguardPeer) SetID(id string)

type IpAddress

type IpAddress struct {
	Id        string `mikrotik:".id" codegen:"id,mikrotikID"`
	Address   string `mikrotik:"address" codegen:"address,required"`
	Comment   string `mikrotik:"comment" codegen:"comment"`
	Disabled  bool   `mikrotik:"disabled" codegen:"disabled"`
	Interface string `mikrotik:"interface" codegen:"interface,required"`
	Network   string `mikrotik:"network" codegen:"network,computed"`
}

func (*IpAddress) ActionToCommand

func (b *IpAddress) ActionToCommand(a Action) string

func (*IpAddress) AfterAddHook

func (b *IpAddress) AfterAddHook(r *routeros.Reply)

func (*IpAddress) ID

func (b *IpAddress) ID() string

func (*IpAddress) IDField

func (b *IpAddress) IDField() string

func (*IpAddress) SetID

func (b *IpAddress) SetID(id string)

type Ipv6Address

type Ipv6Address struct {
	Id        string `mikrotik:".id" codegen:"id,mikrotikID,terraformID"`
	Address   string `mikrotik:"address" codegen:"address,required"`
	Advertise bool   `mikrotik:"advertise" codegen:"advertise"`
	Comment   string `mikrotik:"comment" codegen:"comment"`
	Disabled  bool   `mikrotik:"disabled" codegen:"disabled"`
	Eui64     bool   `mikrotik:"eui-64" codegen:"eui_64"`
	FromPool  string `mikrotik:"from-pool" codegen:"from_pool"`
	Interface string `mikrotik:"interface" codegen:"interface,required"`
	NoDad     bool   `mikrotik:"no-dad" codegen:"no_dad"`
}

Ipv6Address defines resource

func (*Ipv6Address) ActionToCommand

func (b *Ipv6Address) ActionToCommand(a Action) string

func (*Ipv6Address) AfterAddHook

func (b *Ipv6Address) AfterAddHook(r *routeros.Reply)

func (*Ipv6Address) ID

func (b *Ipv6Address) ID() string

func (*Ipv6Address) IDField

func (b *Ipv6Address) IDField() string

func (*Ipv6Address) SetID

func (b *Ipv6Address) SetID(id string)

type LegacyBgpUnsupported

type LegacyBgpUnsupported struct{}

func (LegacyBgpUnsupported) Error

func (LegacyBgpUnsupported) Error() string

type Marshaler

type Marshaler interface {
	// MarshalMikrotik serializes Go type value as RouterOS field value
	MarshalMikrotik() string
}

Marshaler interface will be used to serialize struct to RouterOS sentence

type Mikrotik

type Mikrotik struct {
	Host     string
	Username string
	Password string
	TLS      bool
	CA       string
	Insecure bool
	// contains filtered or unexported fields
}

Mikrotik struct defines connection parameters for RouterOS client

func NewClient

func NewClient(host, username, password string, tls bool, caCertificate string, insecure bool) *Mikrotik

NewClient initializes new Mikrotik client object

func (Mikrotik) Add

func (client Mikrotik) Add(d Resource) (Resource, error)

Add creates new resource on remote system

func (Mikrotik) AddBgpInstance

func (c Mikrotik) AddBgpInstance(r *BgpInstance) (*BgpInstance, error)

Typed wrappers

func (Mikrotik) AddBgpPeer

func (c Mikrotik) AddBgpPeer(r *BgpPeer) (*BgpPeer, error)

Typed wrappers

func (Mikrotik) AddBridge

func (c Mikrotik) AddBridge(r *Bridge) (*Bridge, error)

Typed wrappers

func (Mikrotik) AddBridgePort

func (c Mikrotik) AddBridgePort(r *BridgePort) (*BridgePort, error)

Typed wrappers

func (Mikrotik) AddBridgeVlan

func (c Mikrotik) AddBridgeVlan(r *BridgeVlan) (*BridgeVlan, error)

func (Mikrotik) AddDhcpLease

func (c Mikrotik) AddDhcpLease(r *DhcpLease) (*DhcpLease, error)

Typed wrappers

func (Mikrotik) AddDhcpServer

func (c Mikrotik) AddDhcpServer(r *DhcpServer) (*DhcpServer, error)

Typed wrappers

func (Mikrotik) AddDhcpServerNetwork

func (c Mikrotik) AddDhcpServerNetwork(r *DhcpServerNetwork) (*DhcpServerNetwork, error)

Typed wrappers

func (Mikrotik) AddDnsRecord

func (client Mikrotik) AddDnsRecord(d *DnsRecord) (*DnsRecord, error)

func (Mikrotik) AddFirewallFilterRule

func (c Mikrotik) AddFirewallFilterRule(r *FirewallFilterRule) (*FirewallFilterRule, error)

func (Mikrotik) AddInterfaceList

func (c Mikrotik) AddInterfaceList(r *InterfaceList) (*InterfaceList, error)

Typed wrappers

func (Mikrotik) AddInterfaceListMember

func (c Mikrotik) AddInterfaceListMember(r *InterfaceListMember) (*InterfaceListMember, error)

Typed wrappers

func (Mikrotik) AddInterfaceWireguard

func (client Mikrotik) AddInterfaceWireguard(i *InterfaceWireguard) (*InterfaceWireguard, error)

func (Mikrotik) AddInterfaceWireguardPeer

func (client Mikrotik) AddInterfaceWireguardPeer(i *InterfaceWireguardPeer) (*InterfaceWireguardPeer, error)

func (Mikrotik) AddIpAddress

func (c Mikrotik) AddIpAddress(r *IpAddress) (*IpAddress, error)

Typed wrappers

func (Mikrotik) AddIpv6Address

func (c Mikrotik) AddIpv6Address(r *Ipv6Address) (*Ipv6Address, error)

Typed wrappers

func (Mikrotik) AddPool

func (c Mikrotik) AddPool(r *Pool) (*Pool, error)

Typed wrappers

func (Mikrotik) AddScheduler

func (client Mikrotik) AddScheduler(s *Scheduler) (*Scheduler, error)

typed wrappers

func (Mikrotik) AddScript

func (c Mikrotik) AddScript(r *Script) (*Script, error)

Typed wrappers

func (Mikrotik) AddVlanInterface

func (c Mikrotik) AddVlanInterface(r *VlanInterface) (*VlanInterface, error)

Typed wrappers

func (Mikrotik) CreateScheduler

func (client Mikrotik) CreateScheduler(s *Scheduler) (*Scheduler, error)

func (Mikrotik) Delete

func (client Mikrotik) Delete(d Resource) error

Delete removes existing resource from remote system

func (Mikrotik) DeleteBgpInstance

func (c Mikrotik) DeleteBgpInstance(name string) error

func (Mikrotik) DeleteBgpPeer

func (c Mikrotik) DeleteBgpPeer(name string) error

func (Mikrotik) DeleteBridge

func (c Mikrotik) DeleteBridge(name string) error

func (Mikrotik) DeleteBridgePort

func (c Mikrotik) DeleteBridgePort(id string) error

func (Mikrotik) DeleteBridgeVlan

func (c Mikrotik) DeleteBridgeVlan(id string) error

func (Mikrotik) DeleteDhcpLease

func (c Mikrotik) DeleteDhcpLease(id string) error

func (Mikrotik) DeleteDhcpServer

func (c Mikrotik) DeleteDhcpServer(name string) error

func (Mikrotik) DeleteDhcpServerNetwork

func (c Mikrotik) DeleteDhcpServerNetwork(id string) error

func (Mikrotik) DeleteDnsRecord

func (client Mikrotik) DeleteDnsRecord(id string) error

func (Mikrotik) DeleteFirewallFilterRule

func (c Mikrotik) DeleteFirewallFilterRule(id string) error

func (Mikrotik) DeleteInterfaceList

func (c Mikrotik) DeleteInterfaceList(name string) error

func (Mikrotik) DeleteInterfaceListMember

func (c Mikrotik) DeleteInterfaceListMember(id string) error

func (Mikrotik) DeleteInterfaceWireguard

func (client Mikrotik) DeleteInterfaceWireguard(name string) error

func (Mikrotik) DeleteInterfaceWireguardPeer

func (client Mikrotik) DeleteInterfaceWireguardPeer(id string) error

func (Mikrotik) DeleteIpAddress

func (c Mikrotik) DeleteIpAddress(id string) error

func (Mikrotik) DeleteIpv6Address

func (c Mikrotik) DeleteIpv6Address(id string) error

func (Mikrotik) DeletePool

func (c Mikrotik) DeletePool(id string) error

func (Mikrotik) DeleteScheduler

func (client Mikrotik) DeleteScheduler(name string) error

func (Mikrotik) DeleteScript

func (c Mikrotik) DeleteScript(id string) error

func (Mikrotik) DeleteVlanInterface

func (c Mikrotik) DeleteVlanInterface(name string) error

func (Mikrotik) Find

func (client Mikrotik) Find(d Resource) (Resource, error)

Find retrieves resource from remote system

func (Mikrotik) FindBgpInstance

func (c Mikrotik) FindBgpInstance(name string) (*BgpInstance, error)

func (Mikrotik) FindBgpPeer

func (c Mikrotik) FindBgpPeer(name string) (*BgpPeer, error)

func (Mikrotik) FindBridge

func (c Mikrotik) FindBridge(name string) (*Bridge, error)

func (Mikrotik) FindBridgePort

func (c Mikrotik) FindBridgePort(id string) (*BridgePort, error)

func (Mikrotik) FindBridgeVlan

func (c Mikrotik) FindBridgeVlan(id string) (*BridgeVlan, error)

func (Mikrotik) FindDhcpLease

func (c Mikrotik) FindDhcpLease(id string) (*DhcpLease, error)

func (Mikrotik) FindDhcpServer

func (c Mikrotik) FindDhcpServer(name string) (*DhcpServer, error)

func (Mikrotik) FindDhcpServerNetwork

func (c Mikrotik) FindDhcpServerNetwork(id string) (*DhcpServerNetwork, error)

func (Mikrotik) FindDnsRecord

func (client Mikrotik) FindDnsRecord(name string) (*DnsRecord, error)

func (Mikrotik) FindFirewallFilterRule

func (c Mikrotik) FindFirewallFilterRule(id string) (*FirewallFilterRule, error)

func (Mikrotik) FindInterfaceList

func (c Mikrotik) FindInterfaceList(name string) (*InterfaceList, error)

func (Mikrotik) FindInterfaceListMember

func (c Mikrotik) FindInterfaceListMember(id string) (*InterfaceListMember, error)

func (Mikrotik) FindInterfaceWireguard

func (client Mikrotik) FindInterfaceWireguard(name string) (*InterfaceWireguard, error)

func (Mikrotik) FindInterfaceWireguardPeer

func (client Mikrotik) FindInterfaceWireguardPeer(id string) (*InterfaceWireguardPeer, error)

func (Mikrotik) FindIpAddress

func (c Mikrotik) FindIpAddress(id string) (*IpAddress, error)

func (Mikrotik) FindIpv6Address

func (c Mikrotik) FindIpv6Address(id string) (*Ipv6Address, error)

func (Mikrotik) FindPool

func (c Mikrotik) FindPool(id string) (*Pool, error)

func (Mikrotik) FindPoolByName

func (c Mikrotik) FindPoolByName(name string) (*Pool, error)

func (Mikrotik) FindScheduler

func (client Mikrotik) FindScheduler(name string) (*Scheduler, error)

func (Mikrotik) FindScript

func (c Mikrotik) FindScript(name string) (*Script, error)

func (Mikrotik) FindVlanInterface

func (c Mikrotik) FindVlanInterface(name string) (*VlanInterface, error)

func (Mikrotik) GetSystemResources

func (client Mikrotik) GetSystemResources() (*SystemResources, error)

func (Mikrotik) InspectConsoleCommand

func (c Mikrotik) InspectConsoleCommand(command string) (consoleinspected.ConsoleItem, error)

func (Mikrotik) List

func (client Mikrotik) List(d Resource) ([]Resource, error)

Find retrieves resource from remote system

func (Mikrotik) ListDhcpLease

func (client Mikrotik) ListDhcpLease() ([]DhcpLease, error)

func (Mikrotik) ListDhcpLeases

func (client Mikrotik) ListDhcpLeases() ([]DhcpLease, error)

func (Mikrotik) ListIpAddress

func (client Mikrotik) ListIpAddress() ([]IpAddress, error)

func (Mikrotik) ListIpv6Address

func (c Mikrotik) ListIpv6Address() ([]Ipv6Address, error)

func (Mikrotik) ListPools

func (c Mikrotik) ListPools() ([]Pool, error)

func (Mikrotik) ListVlanInterface

func (c Mikrotik) ListVlanInterface() ([]VlanInterface, error)

func (Mikrotik) Update

func (client Mikrotik) Update(resource Resource) (Resource, error)

Update updates existing resource on remote system

func (Mikrotik) UpdateBgpInstance

func (c Mikrotik) UpdateBgpInstance(r *BgpInstance) (*BgpInstance, error)

func (Mikrotik) UpdateBgpPeer

func (c Mikrotik) UpdateBgpPeer(r *BgpPeer) (*BgpPeer, error)

func (Mikrotik) UpdateBridge

func (c Mikrotik) UpdateBridge(r *Bridge) (*Bridge, error)

func (Mikrotik) UpdateBridgePort

func (c Mikrotik) UpdateBridgePort(r *BridgePort) (*BridgePort, error)

func (Mikrotik) UpdateBridgeVlan

func (c Mikrotik) UpdateBridgeVlan(r *BridgeVlan) (*BridgeVlan, error)

func (Mikrotik) UpdateDhcpLease

func (c Mikrotik) UpdateDhcpLease(r *DhcpLease) (*DhcpLease, error)

func (Mikrotik) UpdateDhcpServer

func (c Mikrotik) UpdateDhcpServer(r *DhcpServer) (*DhcpServer, error)

func (Mikrotik) UpdateDhcpServerNetwork

func (c Mikrotik) UpdateDhcpServerNetwork(r *DhcpServerNetwork) (*DhcpServerNetwork, error)

func (Mikrotik) UpdateDnsRecord

func (client Mikrotik) UpdateDnsRecord(d *DnsRecord) (*DnsRecord, error)

func (Mikrotik) UpdateFirewallFilterRule

func (c Mikrotik) UpdateFirewallFilterRule(r *FirewallFilterRule) (*FirewallFilterRule, error)

func (Mikrotik) UpdateInterfaceList

func (c Mikrotik) UpdateInterfaceList(r *InterfaceList) (*InterfaceList, error)

func (Mikrotik) UpdateInterfaceListMember

func (c Mikrotik) UpdateInterfaceListMember(r *InterfaceListMember) (*InterfaceListMember, error)

func (Mikrotik) UpdateInterfaceWireguard

func (client Mikrotik) UpdateInterfaceWireguard(i *InterfaceWireguard) (*InterfaceWireguard, error)

func (Mikrotik) UpdateInterfaceWireguardPeer

func (client Mikrotik) UpdateInterfaceWireguardPeer(i *InterfaceWireguardPeer) (*InterfaceWireguardPeer, error)

func (Mikrotik) UpdateIpAddress

func (c Mikrotik) UpdateIpAddress(r *IpAddress) (*IpAddress, error)

func (Mikrotik) UpdateIpv6Address

func (c Mikrotik) UpdateIpv6Address(r *Ipv6Address) (*Ipv6Address, error)

func (Mikrotik) UpdatePool

func (c Mikrotik) UpdatePool(r *Pool) (*Pool, error)

func (Mikrotik) UpdateScheduler

func (client Mikrotik) UpdateScheduler(s *Scheduler) (*Scheduler, error)

func (Mikrotik) UpdateScript

func (c Mikrotik) UpdateScript(r *Script) (*Script, error)

func (Mikrotik) UpdateVlanInterface

func (c Mikrotik) UpdateVlanInterface(r *VlanInterface) (*VlanInterface, error)

type NotFound

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

func (NotFound) Error

func (e NotFound) Error() string

type Pool

type Pool struct {
	Id       string `mikrotik:".id" codegen:"id,mikrotikID,terraformID"`
	Name     string `mikrotik:"name" codegen:"name,required"`
	Ranges   string `mikrotik:"ranges" codegen:"ranges,required"`
	NextPool string `mikrotik:"next-pool" codegen:"next_pool,optiona,computed"`
	Comment  string `mikrotik:"comment" codegen:"comment,optional,computed"`
}

func (*Pool) ActionToCommand

func (b *Pool) ActionToCommand(a Action) string

func (*Pool) AfterAddHook

func (b *Pool) AfterAddHook(r *routeros.Reply)

func (*Pool) ID

func (b *Pool) ID() string

func (*Pool) IDField

func (b *Pool) IDField() string

func (*Pool) SetID

func (b *Pool) SetID(id string)

type Resource

type Resource interface {
	// ActionToCommand translates CRUD action to RouterOS command path.
	ActionToCommand(Action) string

	// IDField reveals name of ID field to use in requests to MikroTik router.
	// It is used in operations like Find.
	IDField() string

	// ID returns value of the ID field.
	ID() string

	// SetID updates a value of the ID field.
	SetID(string)
}

Resource interface defines a contract for abstract RouterOS resource.

type Scheduler

type Scheduler struct {
	Id        string                 `mikrotik:".id"`
	Name      string                 `mikrotik:"name"`
	OnEvent   string                 `mikrotik:"on-event"`
	StartDate string                 `mikrotik:"start-date"`
	StartTime string                 `mikrotik:"start-time"`
	Interval  types.MikrotikDuration `mikrotik:"interval"`
}

func (*Scheduler) ActionToCommand

func (b *Scheduler) ActionToCommand(a Action) string

func (*Scheduler) AfterAddHook

func (b *Scheduler) AfterAddHook(r *routeros.Reply)

func (*Scheduler) DeleteField

func (b *Scheduler) DeleteField() string

func (*Scheduler) DeleteFieldValue

func (b *Scheduler) DeleteFieldValue() string

func (*Scheduler) FindField

func (b *Scheduler) FindField() string

func (*Scheduler) FindFieldValue

func (b *Scheduler) FindFieldValue() string

func (*Scheduler) ID

func (b *Scheduler) ID() string

func (*Scheduler) IDField

func (b *Scheduler) IDField() string

func (*Scheduler) SetID

func (b *Scheduler) SetID(id string)

type Script

type Script struct {
	Id                     string             `mikrotik:".id" codegen:"id,deleteID"`
	Name                   string             `mikrotik:"name" codegen:"name,required,mikrotikID"`
	Owner                  string             `mikrotik:"owner" codegen:"owner,required"`
	Policy                 types.MikrotikList `mikrotik:"policy" codegen:"policy,required"`
	DontRequirePermissions bool               `mikrotik:"dont-require-permissions" codegen:"dont_require_permissions"`
	Source                 string             `mikrotik:"source" codegen:"source,required"`
}

func (*Script) ActionToCommand

func (b *Script) ActionToCommand(a Action) string

func (*Script) AfterAddHook

func (b *Script) AfterAddHook(r *routeros.Reply)

func (*Script) DeleteField

func (b *Script) DeleteField() string

func (*Script) DeleteFieldValue

func (b *Script) DeleteFieldValue() string

func (*Script) FindField

func (b *Script) FindField() string

func (*Script) FindFieldValue

func (b *Script) FindFieldValue() string

func (*Script) ID

func (b *Script) ID() string

func (*Script) IDField

func (b *Script) IDField() string

func (*Script) SetID

func (b *Script) SetID(id string)

type SystemResources

type SystemResources struct {
	Uptime  types.MikrotikDuration `mikrotik:"uptime"`
	Version string                 `mikrotik:"version"`
}

func (*SystemResources) ActionToCommand

func (d *SystemResources) ActionToCommand(action Action) string

type Unmarshaler

type Unmarshaler interface {
	// UnmarshalMikrotik de-serializes RouterOS field into Go type value
	UnmarshalMikrotik(string) error
}

Unmarshaler interface will be used to de-serialize reply from RouterOS into Go struct

type VlanInterface

type VlanInterface struct {
	Id            string `mikrotik:".id" codegen:"id,mikrotikID"`
	Interface     string `mikrotik:"interface" codegen:"interface"`
	Mtu           int    `mikrotik:"mtu" codegen:"mtu"`
	Name          string `mikrotik:"name" codegen:"name,required,terraformID"`
	Disabled      bool   `mikrotik:"disabled" codegen:"disabled"`
	UseServiceTag bool   `mikrotik:"use-service-tag" codegen:"use_service_tag"`
	VlanId        int    `mikrotik:"vlan-id" codegen:"vlan_id"`
}

VlanInterface represents vlan interface resource

func (*VlanInterface) ActionToCommand

func (b *VlanInterface) ActionToCommand(a Action) string

func (*VlanInterface) AfterAddHook

func (b *VlanInterface) AfterAddHook(r *routeros.Reply)

func (*VlanInterface) DeleteField

func (b *VlanInterface) DeleteField() string

func (*VlanInterface) DeleteFieldValue

func (b *VlanInterface) DeleteFieldValue() string

func (*VlanInterface) FindField

func (b *VlanInterface) FindField() string

func (*VlanInterface) FindFieldValue

func (b *VlanInterface) FindFieldValue() string

func (*VlanInterface) ID

func (b *VlanInterface) ID() string

func (*VlanInterface) IDField

func (b *VlanInterface) IDField() string

func (*VlanInterface) SetID

func (b *VlanInterface) SetID(id string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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