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
- type Alert
- type AlertList
- type Assignment
- type AssignmentMap
- type AssignmentType
- type DataSet
- type Email
- type Location
- type LocationList
- type Lookup
- type Mailbox
- type MailboxList
- type Number
- type PagingGroup
- type PagingGroupList
- type Person
- type PersonList
- type Phone
- type PhoneList
- type PhoneRole
- type PhoneRoleList
- type Ringtone
- type RingtoneList
- type Softphone
- type SoftphoneList
- type Tag
- type TagList
Constants ¶
const ( Unassigned = 0 RoleAssigned = 1 PersonAssigned = 2 )
Phone assignment types.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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:
- People
- Roles
- 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.
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 ¶
OverlayLocations returns the overlayed configuration of all the given locations, in order of priority from least to greatest.
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 PagingGroup ¶
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.
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 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.
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 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 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.
Source Files ¶
- alert.go
- alertlist.go
- assignment.go
- assignmentmap.go
- assignmenttype.go
- compare.go
- dataset.go
- doc.go
- email.go
- location.go
- locationlist.go
- lookup.go
- mailbox.go
- mailboxlist.go
- number.go
- paginggroup.go
- paginggrouplist.go
- person.go
- personlist.go
- phone.go
- phonelist.go
- phonerole.go
- phonerolelist.go
- ringtone.go
- ringtonelist.go
- softphone.go
- softphonelist.go
- tag.go
- taglist.go