Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ASN ¶
type ASN struct {
gorm.Model
// ASN is the number identifying the autonomous system
ASN uint32
// Org is the oranisation holding the AS
Org *Org `gorm:"foreignkey:OrgID"`
// OrgID is the foreign key for the organisation
OrgID uint
// Checked is the status of the ASN add request
Checked bool
// CheckedBy is the authoritative User checked the add request
CheckedBy *User `gorm:"foreignkey:CheckedByUserID"`
// CheckedByUserID is the foreign key to the user checked the record
CheckedByUserID uint `gorm:"nullable"`
}
ASN is an autonomous system number
type ASNDataAccess ¶
type ASNDataAccess struct {
// contains filtered or unexported fields
}
ASNDataAccess provides methods to retrieve and store ASNs
func (*ASNDataAccess) CheckedASNExists ¶
func (d *ASNDataAccess) CheckedASNExists(a uint32) (bool, error)
CheckedASNExists checks if an checked ASN record exists for a given AS number
func (*ASNDataAccess) GetByNumber ¶
func (d *ASNDataAccess) GetByNumber(asn uint32) (*ASN, error)
GetByNumber retrieves the ASN for a number
func (*ASNDataAccess) GetCheckedASN ¶
func (d *ASNDataAccess) GetCheckedASN(asn uint32) (res *ASN, err error)
GetCheckedASN gets a checked ASN object
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection is the connection to the database
func Connect ¶
func Connect(driver, dsn string, options ...Option) (*Connection, error)
Connect connects to the database
func (*Connection) ASNs ¶
func (c *Connection) ASNs() *ASNDataAccess
ASNs returns access to the ASN entity
func (*Connection) Logs ¶
func (c *Connection) Logs() *LogDataAccess
Logs returns access to the Logs entity
func (*Connection) Orgs ¶
func (c *Connection) Orgs() *OrgDataAccess
Orgs returns access to the Org entity
func (*Connection) Tunnels ¶
func (c *Connection) Tunnels() *TunnelDataAccess
Tunnels returns access to the Tunnel entity
func (*Connection) Users ¶
func (c *Connection) Users() *UserDataAccess
Users returns access to the User entity
type Log ¶
type Log struct {
gorm.Model
// User is the user requested the operation
User *User `gorm:"foreignkey:UserID"`
// UserID is the foreign key to an user
UserID uint `gorm:"nullable"`
// Request is the serialized string representation of the request
RequestMessage string
// Response is the serialized string representation of the response
ResponseMessage string
// Error is the error message
Error string
}
Log is the log of all messages processed
type LogDataAccess ¶
type LogDataAccess struct {
// contains filtered or unexported fields
}
LogDataAccess provides methods to retrieve and store logs
func (*LogDataAccess) GetLog ¶
func (d *LogDataAccess) GetLog() (ret []*Log, err error)
GetLog retrieves the full log
func (*LogDataAccess) Insert ¶
func (d *LogDataAccess) Insert(log *Log) error
Insert inserts a log entry
type Option ¶
type Option func(*Connection) error
Option is an option which is applied to the connection
type Org ¶
type Org struct {
gorm.Model
// Name is the long name of the organisation
Name string
// Address is the address of the organisation
Address string
// Short name is the name used to identify the organisation in backend systems
ShortName string `gorm:"size:5"`
// Active is the current status of the organisation
Active bool
// Checked is the status of the organisation add request
Checked bool
// CheckedBy is the authoritative user checked the add request
CheckedBy *User `gorm:"foreignkey:CheckedByUserID"`
// CheckedByUserID is the foreign key to the organisation checked the record
CheckedByUserID uint `gorm:"nullable"`
// IPv4Quota is the max number of NAT-IPs an organisation can hold
IPv4Quota uint8 `gorm:"column:ipv4_quota"`
// IPv6Quota is the max number of /48 prefixes an organisation can hold
IPv6Quota uint8 `gorm:"column:ipv6_quota"`
}
Org is an organisation
type OrgDataAccess ¶
type OrgDataAccess struct {
// contains filtered or unexported fields
}
func (*OrgDataAccess) GetByShortName ¶
func (d *OrgDataAccess) GetByShortName(name string) (*Org, error)
GetByShortName retrieves an organisation by its short name
func (*OrgDataAccess) Save ¶
func (d *OrgDataAccess) Save(o *Org) error
Save persists an organisation
func (*OrgDataAccess) ShortNameExists ¶
func (d *OrgDataAccess) ShortNameExists(name string) (bool, error)
ShortNameExists checks if an short name is already taken
type Tunnel ¶
type Tunnel struct {
gorm.Model
// ASN identifies the ASN requesting the tunnel
ASN *ASN `gorm:"foreignkey:ASNID"`
// ASNID is the foreign key to an ASN
ASNID uint
// Router is the identification string for a router
Router string
// Address is the IP of the GRE endpoint (organisation site)
Address string
// Synced describes if a tunnel is synced to Netbox for provisioning
Synced bool
}
Tunnel is a GRE tunnel connecting an organisation to backbone routers
type TunnelDataAccess ¶
type TunnelDataAccess struct {
// contains filtered or unexported fields
}
TunnelDataAccess provides methods to retrieve and store tunnels
func (*TunnelDataAccess) AddTunnel ¶
func (t *TunnelDataAccess) AddTunnel(asn uint32, address string) error
func (*TunnelDataAccess) GetTunnelsByAddress ¶
func (t *TunnelDataAccess) GetTunnelsByAddress(address string) (ret []*Tunnel, err error)
type User ¶
type User struct {
gorm.Model
// Email identifies the user in API communications
Email string
// Password is password of the user
Password string
// SuperUser is the role of an user permited to perform admin actions
SuperUser bool
// RIPEHandle is the reference in RIPE database
RIPEHandle string `gorm:"column:ripe_handle"`
// Orgs is the list of organisations an user is assinged to
Orgs []*Org `gorm:"many2many:user_org"`
}
User is an user account permited to use the API
type UserDataAccess ¶
type UserDataAccess struct {
// contains filtered or unexported fields
}
UserDataAccess provides methods to retrieve and store users
func (*UserDataAccess) EmailExists ¶
func (d *UserDataAccess) EmailExists(email string) (bool, error)
EmailExists checks if an email address already exists
func (*UserDataAccess) GetByCredentials ¶
func (d *UserDataAccess) GetByCredentials(username, password string) (user *User, err error)
GetByCredentials gets a user object by a users credentials
func (*UserDataAccess) GetByEmail ¶
func (d *UserDataAccess) GetByEmail(email string) (*User, error)
GetByEmail retrieves an user by its email address