diff --git a/dhall/asterisk.dhall b/dhall/asterisk.dhall new file mode 100644 index 0000000..8571bbe --- /dev/null +++ b/dhall/asterisk.dhall @@ -0,0 +1,106 @@ +let Text/concatMapSep = https://prelude.dhall-lang.org/Text/concatMapSep + +let Mailbox = + { Type = { id : Text, context : Text, name : Text, email : Text } + , default = { name = "", email = "" } + } + +let Endpoint = + { Type = + { id : Text + , context : Text + , password : Text + , callerid : Text + , mailboxes : List Mailbox.Type + } + , default = { callerid = "", mailboxes = [] : List Mailbox.Type } + } + +let mailboxes = + { correl = Mailbox::{ + , id = "100" + , context = "sailmaker" + , name = "Correl Roush" + } + } + +let endpoints = + { correl = Endpoint::{ + , id = "100" + , context = "from-internal" + , password = "mJzTGkXdh02OVXGOaxcH8V3To" + , mailboxes = [ mailboxes.correl ] + } + , correl_softphone = Endpoint::{ + , id = "101" + , context = "from-internal" + , password = "5KVzU5Ez77lIIv4SAyzDOnMWo" + , mailboxes = [ mailboxes.correl ] + } + , correl_conference = Endpoint::{ + , id = "102" + , context = "from-internal" + , password = "mpHoQ29k2AiH4EN7IXL9vnE9j" + , mailboxes = [ mailboxes.correl ] + } + } + +let mailbox/conf = + \(mailbox : Mailbox.Type) -> + "${mailbox.id} => ${mailbox.id},${mailbox.name},${mailbox.email}" + +let mailbox/address = + \(mailbox : Mailbox.Type) -> "${mailbox.id}@${mailbox.context}" + +let pjsip/endpoint = + \(endpoint : Endpoint.Type) -> + '' + [${endpoint.id}] + type=endpoint + context=${endpoint.context} + callerid='${endpoint.callerid}' + disallow=all + allow=ulaw + auth=${endpoint.id} + aors=${endpoint.id} + mailboxes=${Text/concatMapSep + "," + Mailbox.Type + mailbox/address + endpoint.mailboxes}'' + +let pjsip/auth = + \(endpoint : Endpoint.Type) -> + '' + [${endpoint.id}] + type=auth + auth_type=userpass + password=${endpoint.password} + username=${endpoint.id}'' + +let pjsip/aor = + \(endpoint : Endpoint.Type) -> + '' + [${endpoint.id}] + type=aor + max_contacts=1 + remove_existing=yes'' + +let pjsip/all = + \(endpoint : Endpoint.Type) -> + '' + ${pjsip/endpoint endpoint} + + ${pjsip/auth endpoint} + + ${pjsip/aor endpoint} + '' + +in Text/concatMapSep + "\n" + Endpoint.Type + pjsip/all + [ endpoints.correl + , endpoints.correl_softphone + , endpoints.correl_conference + ]