astorg

package
v0.0.0-...-eec0033 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package astorg provides a set of simplified domain entities for an organization that needs to provide configuration to one or more asterisk phone servers.

An organization described by the types in this package can define locations, people, phones and phone roles.

The astgen package can be used to transform the data types in this package into asterisk configuration files.

This package is experimental and is subject to breaking changes.

Index

Constants

View Source
const (
	Unassigned     = 0
	RoleAssigned   = 1
	PersonAssigned = 2
)

Phone assignment types.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Name     string
	Type     string
	Ringtone string
}

Alert is an alert definition.

type AlertList

type AlertList []Alert

AlertList is a slice of alerts.

func (AlertList) ByName

func (alerts AlertList) ByName() map[string]Alert

ByName returns a map of alerts indexed by name.

type Assignment

type Assignment struct {
	Type     AssignmentType
	Username string
}

Assignment declares an assignment of a phone.

type AssignmentMap

type AssignmentMap map[string]Assignment

AssignmentMap is a map of phone assignments indexed a key, which is typically the phone's mac address. The map is used to progressively tracks phone assignments; it incorporates new values according to a prioritized order of assignment types:

  1. People
  2. Roles
  3. Unassigned

When more than one entity of the same assignment type claims a phone, the first entity added to the map will hold the claim.

func MergeAssignments

func MergeAssignments(maps ...AssignmentMap) AssignmentMap

MergeAssignments merges any number of assignment maps according to the assignment priority rules.

func (AssignmentMap) Add

func (m AssignmentMap) Add(key string, assignment Assignment) bool

Add attempts to add a phone assignment to the map for the given key. The assignment will succeed if an existing assignment of equal or greater priority does not already exist in the map with that key.

Add returns true if the assignment was added successfully.

func (AssignmentMap) ByUsername

func (m AssignmentMap) ByUsername() map[string][]string

ByUsername returns the set of keys assigned to each username.

type AssignmentType

type AssignmentType int

AssignmentType declares the type of a phone's assignment.

type DataSet

type DataSet struct {
	Locations    LocationList
	People       PersonList
	PhoneRoles   PhoneRoleList
	Phones       PhoneList
	Softphones   SoftphoneList
	PagingGroups PagingGroupList
	Alerts       AlertList
	Ringtones    RingtoneList
	Mailboxes    MailboxList
	Tags         TagList
}

DataSet represents a complete dataset for an organization.

func (*DataSet) Equal

func (d *DataSet) Equal(e *DataSet) bool

Equal reports whether d and e are equal.

func (*DataSet) Lookup

func (d *DataSet) Lookup() Lookup

Lookup returns a lookup constructed from the data set.

func (*DataSet) Size

func (d *DataSet) Size() int

Size returns the total number of records in the data set.

type Email

type Email struct {
	Address string
	Label   string
	Primary bool
}

Email is an email address for a person.

type Location

type Location struct {
	Name         string
	Abbreviation string
	Server       string
	Network      string
	Timezone     string
	CallerID     string
	AreaCode     string
	PagingGroups []string
}

Location represents the location of a person or phone.

func OverlayLocations

func OverlayLocations(locations ...Location) (overlayed Location)

OverlayLocations returns the overlayed configuration of all the given locations, in order of priority from least to greatest.

func (*Location) Equal

func (a *Location) Equal(b *Location) bool

Equal reports whether p and q are equal.

type LocationList

type LocationList []Location

LocationList is a slice of locations.

func (LocationList) ByName

func (locations LocationList) ByName() map[string]Location

ByName returns a map of locations indexed by name.

type Lookup

type Lookup struct {
	LocationByName    map[string]Location    // Maps names to locations
	PersonByEmail     map[string]Person      // Maps email addresses to people
	PersonByNumber    map[string]Person      // Maps phone numbers to people
	RoleByUsername    map[string]PhoneRole   // Maps usernames to phone roles
	RoleByNumber      map[string]PhoneRole   // Maps phone numbers to phone roles
	PhoneAssignments  AssignmentMap          // Maps phone mac addresses to their highest priority assignments
	PagingGroupsByExt map[string]PagingGroup // Maps extensions to paging groups
	AlertsByName      map[string]Alert       // Maps alert names to alerts
	RingtonesByName   map[string]Ringtone    // Maps ringtone names to ringtones
	MailboxesByName   map[string]Mailbox     // Maps mailbox names to mailboxes
	TagsByName        map[string]Tag         // Maps tag names to tags
}

Lookup holds various lookup maps for a data set.

type Mailbox

type Mailbox struct {
	Name       string
	Number     string
	AccessCode string
	Email      string
	AccessMode astorgvm.Access
}

Mailbox is a voicemail mailbox.

type MailboxList

type MailboxList []Mailbox

MailboxList is a slice of mailboxes.

func (MailboxList) ByName

func (mailboxes MailboxList) ByName() map[string]Mailbox

ByName returns a map of mailboxes indexed by mailbox name.

type Number

type Number struct {
	Label      string
	Dial       string
	DialPrefix string
}

Number is a phone number for a person.

type PagingGroup

type PagingGroup struct {
	Name      string
	Extension string
	Alert     string
}

PagingGroup represents a paging group within an organization.

type PagingGroupList

type PagingGroupList []PagingGroup

PagingGroupList is a slice of paging groups.

func (PagingGroupList) ByExtension

func (groups PagingGroupList) ByExtension() map[string]PagingGroup

ByExtension returns a map of paging groups indexed by extension.

type Person

type Person struct {
	//Server             string // Identifies which server manages presence
	Extension          string // Primary Extension
	Username           string
	FirstName          string
	LastName           string
	FullName           string
	Organization       string
	Title              string
	Location           string
	Hidden             bool // Hidden from organization contact groups
	CallerID           string
	AreaCode           string
	Firmware           string
	CalendarURL        string
	VoicemailExtension string
	VoicemailCode      string
	VoicemailAccess    astorgvm.Access
	DefaultRingtone    string
	Tags               []string
	PagingGroups       []string
	Alerts             []string
	Ringtones          []string
	Apps               []string
	ContactNumbers     []Number // Additional phone numbers
	Phones             []string // MACs of phones to be assigned this role
	Softphones         []string // Usernames of software phones to be assigned this role
	EmailAddresses     []Email
}

Person represents a person in an organization.

func (*Person) Equal

func (p *Person) Equal(q *Person) bool

Equal reports whether p and q are equal.

type PersonList

type PersonList []Person

PersonList is a slice of people.

func (PersonList) Assignments

func (people PersonList) Assignments() AssignmentMap

Assignments returns a phone assignment map for people, indexed by mac address.

func (PersonList) ByEmail

func (people PersonList) ByEmail() map[string]Person

ByEmail returns a map of people indexed by email address.

func (PersonList) ByExtension

func (people PersonList) ByExtension() map[string]Person

ByExtension returns a map of people indexed by extension.

type Phone

type Phone struct {
	MAC       string
	Location  string
	Secret    string
	Templates []string
}

Phone represents a phone within an organization.

func (*Phone) Equal

func (p *Phone) Equal(q *Phone) bool

Equal reports whether p and q are equal.

type PhoneList

type PhoneList []Phone

PhoneList is a slice of phones.

func (PhoneList) Assignments

func (phones PhoneList) Assignments() AssignmentMap

Assignments returns a phone assignment map for phones, indexed by mac address.

type PhoneRole

type PhoneRole struct {
	Extension      string
	Username       string
	DisplayName    string
	Location       string
	AreaCode       string
	Firmware       string
	Hidden         bool // Hidden from organization contact groups
	ContactsSource string
	CallerID       string
	MailboxNumber  string
	Tags           []string
	PagingGroups   []string
	Apps           []string
	Phones         []string // MACs of phones to be assigned this role
	Softphones     []string // Usernames of software phones to be assigned this role
}

PhoneRole is a role that is assigned to a particular phone.

func (*PhoneRole) Equal

func (p *PhoneRole) Equal(q *PhoneRole) bool

Equal reports whether p and q are equal.

type PhoneRoleList

type PhoneRoleList []PhoneRole

PhoneRoleList is a slice of phone roles.

func (PhoneRoleList) Assignments

func (roles PhoneRoleList) Assignments() AssignmentMap

Assignments returns a phone assignment map for roles, indexed by mac address.

func (PhoneRoleList) ByExtension

func (roles PhoneRoleList) ByExtension() map[string]PhoneRole

ByExtension returns a map of phone roles indexed by extension.

func (PhoneRoleList) ByUsername

func (roles PhoneRoleList) ByUsername() map[string]PhoneRole

ByUsername returns a map of phone roles indexed by username.

type Ringtone

type Ringtone struct {
	Name        string
	DisplayName string
	Filename    string
}

Ringtone is a ringtone definition.

type RingtoneList

type RingtoneList []Ringtone

RingtoneList is a slice of ringtones.

func (RingtoneList) ByName

func (ringtones RingtoneList) ByName() map[string]Ringtone

ByName returns a map of ringtones indexed by name.

type Softphone

type Softphone struct {
	Username  string
	Location  string
	Secret    string
	Templates []string
}

Softphone represents a software phone within an organization.

func (*Softphone) Equal

func (p *Softphone) Equal(q *Softphone) bool

Equal reports whether p and q are equal.

type SoftphoneList

type SoftphoneList []Softphone

SoftphoneList is a slice of software phones.

func (SoftphoneList) Assignments

func (phones SoftphoneList) Assignments() AssignmentMap

Assignments returns a phone assignment map for software phones, indexed by softphone username.

type Tag

type Tag struct {
	Name         string
	Firmware     string
	PagingGroups []string
	Alerts       []string
	Ringtones    []string
	Apps         []string
}

A Tag holds a set of phone settings shared by people and phone roles that have been assigned the tag.

func (*Tag) Equal

func (p *Tag) Equal(q *Tag) bool

Equal reports whether p and q are equal.

type TagList

type TagList []Tag

TagList is a slice of tags.

func (TagList) ByName

func (tags TagList) ByName() map[string]Tag

ByName returns a map of tags indexed by name.

Directories

Path Synopsis
Package astorgvm defines voicemail configuration settings for an astorg.
Package astorgvm defines voicemail configuration settings for an astorg.

Jump to

Keyboard shortcuts

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