[Index]
Lua Scripts for MS Teams hybrid setup
Model ref.: data/MS-Teams-LuaScriptDAT
The full URL would include the host-proxy name: https://[host-proxy].
Variables are enclosed in square brackets.
{ "$schema": "http://json-schema.org/draft-03/schema", "type": "object", "properties": { "name": { "required": true, "type": "string", "title": "Name" }, "script": { "required": true, "type": "string", "title": "Script" } }, "schema_version": "0.0" }
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Get the GUI Add form. | GET | /api/data/MS-Teams-LuaScriptDAT/add/ |
|
The GUI Add form of data/MS-Teams-LuaScriptDAT as JSON |
The API call to the /add/ URL can only be made from a hierarchy that allows the model type to be added. The actions in the response shows the url for the POST API call to create an instance.
Task | Call | URL | Parameters | Payload |
---|---|---|---|---|
Create | POST | /api/data/MS-Teams-LuaScriptDAT/ | hierarchy=[hierarchy] |
|
tool/Transaction/[trans pkid]to inspect the created resource and its instance pkid.
Task | Call | URL | Parameters | Payload |
---|---|---|---|---|
Bulk delete [pkid1],[pkid2]... | DELETE | /api/data/MS-Teams-LuaScriptDAT/ | hierarchy=[hierarchy] | {"hrefs":["/api/data/MS-Teams-LuaScriptDAT/[pkid1]", "/api/data/MS-Teams-LuaScriptDAT/[pkid2]", ...]} |
GET http://[host-proxy]/api/data/MS-Teams-LuaScriptDAT/?hierarchy=[hierarchy]&format=json
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Bulk Modify | GET | /api/data/MS-Teams-LuaScriptDAT/bulk_update/?schema=&schema_rules=true |
|
|
Task | Call | URL | Parameters | Payload |
---|---|---|---|---|
Bulk Modify | POST | /api/data/MS-Teams-LuaScriptDAT/bulk_update/ |
|
For example: {"data":{"name":"value"}, "meta":{}, "request_meta":{ "hrefs":["/api/v0/data/MS-Teams-LuaScriptDAT/[pkid1]", "/api/v0/data/MS-Teams-LuaScriptDAT/[pkid2]",...]}} |
GET http://[host-proxy]/api/data/MS-Teams-LuaScriptDAT/?hierarchy=[hierarchy]&format=json
Task | Call | URL | Parameters | Payload |
---|---|---|---|---|
Get a selected [export_format] of the schema and instances [pkid1], [pkid2],... of data/MS-Teams-LuaScriptDAT; optionally with tag_version at [version] and Configuration Template as [configtemplate]. | POST | /api/data/MS-Teams-LuaScriptDAT/export/ |
|
{ "hrefs":["/api/data/MS-Teams-LuaScriptDAT/[pkid1]", "/api/data/MS-Teams-LuaScriptDAT/[pkid2]",...]}} |
For export_format=json, the response is a time stamped zip file of data in JSON as in the system database. Item properties such as strings that are empty or Boolean values that are not set, are not included. The filename in the response is of the format as the example:
Content-Disposition: attachment; filename=export_2013-05-17_14:20:19.186444.json.zip Content-Language:en Content-Type:application/x-zip
For export_format=raw_xlsx, the response is a MS Excel spreadsheet with columns corresponding to the JSON format export and a response filename format:
Content-Disposition: attachment; filename=<resource_type>_<resource_name>_exportedsheet_CCYY-MM-DD_HH-MM-SS.xlsx Content-Language:en Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
For export_format=xlsx, the response is a MS Excel spreadsheet, arranged by any Field Display Policies that apply. The columns correspond with those of a Bulk Load Template export sheet. The response filename format is:
Content-Disposition: attachment; filename=<resource_type>_<resource_name>_exportedsheet_formatted_CCYY-MM-DD_HH-MM-SS.xlsx Content-Language:en Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
The XLSX format can be used to bulk load instances of data/MS-Teams-LuaScriptDAT and the JSON format can be used to import instances of data/MS-Teams-LuaScriptDAT.
GET http://[host-proxy]/api/data/MS-Teams-LuaScriptDAT/?hierarchy=[hierarchy]
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Get a compressed format of the Bulk Load spreadsheet template for data/MS-Teams-LuaScriptDAT | POST | /api/data/MS-Teams-LuaScriptDAT/export_bulkload_template/ |
|
The response is an attachment of the format: filetype_bulkloadsheet.xlsx.gz |
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Configuration Template | GET | /api/data/MS-Teams-LuaScriptDAT/configuration_template/ | hierarchy=[hierarchy] |
|
POST http://[host-proxy]/api/data/ConfigurationTemplate/?hierarchy=[hierarchy]
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Field Display Policy | GET | /api/data/MS-Teams-LuaScriptDAT/field_display_policy/ | hierarchy=[hierarchy] |
|
POST http://[host-proxy]/api/data/FieldDisplayPolicy/?hierarchy=[hierarchy]
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Migration Template | GET | /api/data/MS-Teams-LuaScriptDAT/migration/ |
|
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
List | GET | /api/data/MS-Teams-LuaScriptDAT/ |
|
The data/MS-Teams-LuaScriptDAT schema and all instances as JSON. |
(The list will return 0 to 3 data/MS-Teams-LuaScriptDAT instances)
{ "operations": [ "field_display_policy", "configuration_template", "help", "get", "export_bulkload_template", "list", "update", "remove", "move", "transform", "add", "export", "migration", "bulk_update_form" ], "pagination": { "direction": "asc", "order_by": "name", "maximum_limit": 2000, "skip": 0, "current": "/api/data/MS-Teams-LuaScriptDAT/?skip=0&limit=3&order_by=name&direction=asc&traversal=default", "limit": 3, "total_limit": null, "total": 1 }, "meta": { "tags": [], "cached": true, "title": "", "business_key": { "hierarchy": true, "consider_null": false, "unique": [ "name" ] }, "schema_version": "0.0", "references": { "device": [ { "pkid": "", "href": "" } ], "children": [], "parent": [ { "pkid": "6t0ggef2c0deab00hb595101", "href": "/api/data/HierarchyNode/6t0ggef2c0deab00hb595101" } ], "foreign_key": [] }, "actions": [ { "add": { "support_async": false, "class": "add", "href": "/api/data/MS-Teams-LuaScriptDAT/add/?hierarchy=[hierarchy]", "method": "GET", "title": "Add" } }, { "remove": { "support_async": true, "class": "delete", "href": "/api/data/MS-Teams-LuaScriptDAT/?hierarchy=[hierarchy]", "method": "DELETE", "title": "Delete" } }, { "bulk_update_form": { "support_async": false, "class": "update", "href": "/api/data/MS-Teams-LuaScriptDAT/bulk_update/?hierarchy=[hierarchy]&schema=&schema_rules=true", "method": "GET", "title": "Bulk Modify" } }, { "export": { "title": "Export", "support_async": false, "submit": "payload", "class": "export", "href": "/api/data/MS-Teams-LuaScriptDAT/export/?hierarchy=[hierarchy]", "method": "POST", "view": "/api/view/ExportData/add/?auth_token=[authtoken] } }, { "export_bulkload_template": { "support_async": false, "class": "bulkload_template", "href": "/api/data/MS-Teams-LuaScriptDAT/export_bulkload_template/?hierarchy=[hierarchy]", "method": "POST", "title": "Export Bulk Load Template" } }, { "tag": { "title": "Tag", "support_async": true, "method": "PATCH", "href": "/api/data/MS-Teams-LuaScriptDAT/+tag/?hierarchy=[hierarchy]", "class": "tag", "view": "/api/view/TagNameForm/add/?auth_token=[authtoken] } }, { "tag_version": { "title": "Tag Version", "support_async": true, "method": "PATCH", "href": "/api/data/MS-Teams-LuaScriptDAT/+tag_version/?hierarchy=[hierarchy]", "class": "tag_version", "view": "/api/view/TagVersionForm/add/?auth_token=[authtoken] } }, { "configuration_template": { "support_async": false, "class": "config", "href": "/api/data/MS-Teams-LuaScriptDAT/configuration_template/?hierarchy=[hierarchy]", "method": "GET", "title": "Configuration Template" } }, { "field_display_policy": { "support_async": false, "class": "display_policy", "href": "/api/data/MS-Teams-LuaScriptDAT/field_display_policy/?hierarchy=[hierarchy]", "method": "GET", "title": "Field Display Policy" } }, { "migration": { "support_async": false, "class": "migration", "href": "/api/data/MS-Teams-LuaScriptDAT/migration/?hierarchy=[hierarchy]", "method": "GET", "title": "Migration Template" } }, { "list": { "support_async": false, "class": "list", "href": "/api/data/MS-Teams-LuaScriptDAT/?hierarchy=[hierarchy]", "method": "GET", "title": "List" } }, { "help": { "support_async": false, "class": "help", "href": "/api/data/MS-Teams-LuaScriptDAT/help?hierarchy=[hierarchy]", "method": "GET", "title": "Help" } }, { "transform": { "support_async": false, "class": "transform", "href": "/api/data/MS-Teams-LuaScriptDAT/transform/?hierarchy=[hierarchy]", "method": "GET", "title": "Transform Template" } } ], "model_type": "data/MS-Teams-LuaScriptDAT", "model_specific_actions": [ "add", "bulk_update_form", "clone", "configuration_template", "export", "export_bulkload_template", "field_display_policy", "get", "help", "list", "migration", "transform", "remove", "tag", "tag_version", "update" ], "summary_attrs": [ { "name": "name", "title": "Name" }, { "allow_filtering": true, "name": "hierarchy_friendly_name", "title": "Located At" } ], "api_version": "21.2", "tagged_versions": [] }, "resources": [ { "pkid": "6305141243fcc416f18f7e1e", "meta": { "tags": [ "V4UC", "ba_CommonOverlay" ], "cached": true, "title": "MS-AntiLoop_V0.11", "business_key": { "hierarchy": true, "consider_null": false, "unique": [ "name" ] }, "schema_version": "0.0", "summary": "false", "references": { "device": [ { "pkid": "", "href": "" } ], "owner": [ { "pkid": "" } ], "self": [ { "pkid": "6305141243fcc416f18f7e1e", "href": "/api/data/MS-Teams-LuaScriptDAT/6305141243fcc416f18f7e1e/" } ], "parent": [ { "pkid": "6305086243fcc416f18ea4ac", "href": "/api/data/HierarchyNode/6305086243fcc416f18ea4ac" } ], "foreign_key": [] }, "actions": [ { "update": { "support_async": true, "class": "update", "href": "/api/data/MS-Teams-LuaScriptDAT/6305141243fcc416f18f7e1e/", "method": "PUT", "title": "Modify" } }, { "remove": { "support_async": true, "class": "delete", "href": "/api/data/MS-Teams-LuaScriptDAT/6305141243fcc416f18f7e1e/", "method": "DELETE", "title": "Delete" } }, { "clone": { "support_async": false, "class": "clone", "href": "/api/data/MS-Teams-LuaScriptDAT/6305141243fcc416f18f7e1e/clone/?schema=&schema_rules=true", "method": "GET", "title": "Clone" } }, { "export": { "title": "Export", "support_async": false, "submit": "payload", "class": "export", "href": "/api/data/MS-Teams-LuaScriptDAT/6305141243fcc416f18f7e1e/export/", "method": "GET", "view": "/api/view/ExportData/add/" } }, { "tag": { "title": "Tag", "support_async": true, "method": "PATCH", "href": "/api/data/MS-Teams-LuaScriptDAT/6305141243fcc416f18f7e1e/+tag/", "class": "tag", "view": "/api/view/TagNameForm/add/" } }, { "tag_version": { "title": "Tag Version", "support_async": true, "method": "PATCH", "href": "/api/data/MS-Teams-LuaScriptDAT/6305141243fcc416f18f7e1e/+tag_version/", "class": "tag_version", "view": "/api/view/TagVersionForm/add/" } }, { "get": { "support_async": false, "class": "get", "href": "/api/data/MS-Teams-LuaScriptDAT/6305141243fcc416f18f7e1e/", "method": "GET", "title": "Get" } }, { "help": { "support_async": false, "class": "help", "href": "/api/data/MS-Teams-LuaScriptDAT/6305141243fcc416f18f7e1e/help", "method": "GET", "title": "Help" } } ], "model_type": "data/MS-Teams-LuaScriptDAT", "path": [ "6t0ggef2c0deab00hb595101", "6305086243fcc416f18ea4ac", "6305141243fcc416f18f7e1e" ], "summary_attrs": [ { "name": "name", "title": "Name" }, { "allow_filtering": true, "name": "hierarchy_friendly_name", "title": "Located At" } ], "api_version": "21.2", "tagged_versions": [] }, "data": { "pkid": "6305141243fcc416f18f7e1f", "hierarchy_friendly_name": "hcs (Hcs)", "script": "--[[ Name: MS-AntiLoop_v0.11.lua Description: Allow interoperability between CUCM and MS-Teams. Mechanism to stop calls forked from MS-Teams to SNR back from Cisco, utilising the TOD access feature on the Remote Destination V0.6 \ton the inbound invite copy the \"History-Info\" header to the \"From\" Header \t\tCopy the \"From\" header to the \"P-Asserted-Identity\" V0.7\tUse original inbound \"From\" header in 200 and 18X replies. Include \"History-Info\" in replies. V0.8\tRestrict inbound invite manipulation to initial invites only. \t\tTidy up code \t\tAdd comments and changelog V0.9 \tConvert Diversion header to History-Info for outbound initial invites V0.10\tCopy \"REFERRED-BY\" header to \"From\" to handle Blind Transfer \t\tRemoved redundant line \"local orig_From_header = msg:getHeader(\"From\")\" V0.11\tRetain original MS-Teams \"From\" in custom \"MS-From\" header and pass through --]] M = {} -- Allow this header to be passed through M.allowHeaders = {\"History-Info\", \"REFERRED-BY\",\"MS-From\"} -- Enable Tracing if enabled on the trunk trace.enable() local function splitURI(i_uri) \t\t\tlocal position_of_semi = string.find(i_uri, \";\") \t\t\tlocal position_of_sip = string.find(i_uri, \"sip\") \t\t\tif position_of_semi then \t\t\t\ti_uri_id = string.sub(i_uri, position_of_sip, (position_of_semi -1 )) \t\t\t\tr_uri_user = string.sub(i_uri, (position_of_semi + 1 )) \t\t\telse \t\t\t\t-- no user \t\t\t\ti_uri_id = string.sub(i_uri, position_of_sip) \t\t\t\tr_uri_user=nil \t\t\tend \t\t\ti_uri_id = string.gsub(i_uri_id,\"sip:\",\"\") \t\t\tlocal position_of_ampersand = string.find(i_uri_id, \"@\") \t\t\tlocal r_uri_host=string.sub(i_uri_id,1,(position_of_ampersand-1)) \t\t\tlocal r_uri_domain=string.sub(i_uri_id,(position_of_ampersand+1)) \t\t\tlocal port_position = string.find(r_uri_domain, \":\", 2) \t\t\tif port_position then \t\t\t\tr_uri_domain_port = string.sub(r_uri_domain,(port_position+1)) \t\t\t\tr_uri_domain = string.sub(r_uri_domain,1,(port_position-1)) \t\t\telse \t\t\t\t-- no port \t\t\t\tr_uri_domain_port = nil \t\t\tend \treturn r_uri_host, r_uri_domain, r_uri_domain_port, r_uri_user end local function handle_inbound_invite(msg) local isInitialInvite = msg:isInitialInviteRequest() if isInitialInvite \tthen \t-- save the History-Info header and From Header in the context data for use in outbound replies \t\tlocal history = msg:getHeader(\"History-Info\") \t\tlocal save_from = msg:getHeader(\"From\") \t\tlocal pt = msg:getPassThrough() \t\tif history \t\tthen \t\t\ttrace.format(\"History variable is %s\", history) \t\t\ttrace.format(\"Save From variable is %s\", save_from) \t\t\tmsg:convertHIToDiversion() \t\t\tlocal context = msg:getContext() \t\t\tif context \t\t\tthen \t\t\tcontext[\"History-Info\"] = history \t\t\tcontext[\"From\"] = save_from \t\t\tend \t-- Custom Header to retain original MS-Teams From \t\t\tmsg:addHeader(\"MS-From\", save_from) \t\t\tpt:addHeader(\"MS-From\", save_from)\t \t\tend \t-- write History-Info URI to variable HistoryInfo_uri \t\tlocal HistoryInfo_uri = msg:getUri(\"History-Info\") \t\tif HistoryInfo_uri \t\tthen \t\t\ttrace.format(\"History-Info header is %s\", HistoryInfo_uri) \t\t\tlocal HI_Uri = sipUtils.parseUri(HistoryInfo_uri) \t\t\tif HI_Uri \t\t\tthen \t\t\t\tHI_Host = HI_Uri:getHost() \t\t\t\tHI_User = HI_Uri:getUser() \t\t\tend \t\t\tlocal From_uri = msg:getUri(\"From\") \t\t\ttrace.format( \"the From URI %s\", From_uri) \t\t\tif From_uri \t\t\tthen \t-- Copy \"From\" Header to PAId. Create Header if it doesnt exist \t\t\t\tlocal Pai_header = msg:getHeader(\"P-Asserted-Identity\") \t\t\t\tFrom_uri_host, From_uri_domain, From_uri_domain_port, From_uri_user=splitURI(From_uri) \t--\t\t\ttrace.format(\"From Host is %s\", From_uri_host) \t--\t\t\ttrace.format(\"From Domain is %s\",From_uri_domain) \t--\t\t\ttrace.format(\"From Port is %s\", From_uri_domain_port) \t--\t\t\ttrace.format(\"From User is %s\", From_uri_user) \t\t\t\tFrom_Tag = msg:getHeaderValueParameter(\"From\", \"tag\") \t\t\t\tif Pai_header \t\t\t\tthen \t\t\t\t\tlocal new_pai_header = '<sip:' .. From_uri_host .. '@' .. From_uri_domain .. '>' \t\t\t\t\tmsg:modifyHeader(\"P-Asserted-Identity\", new_pai_header) \t\t\t\telse \t\t\t\t\tmsg:addHeader(\"P-Asserted-Identity\", new_pai_header) \t\t\t\tend \t-- Recreate \"From\" Header with the \"User\" from History-Info and the \"Host\" of the original \"From\" header \t\t\t\tlocal new_From_header = '\"' .. HI_User .. '\" <sip:' .. HI_User .. '@' .. From_uri_domain .. '>;tag=' .. From_Tag \t\t\t\tmsg:modifyHeader(\"From\", new_From_header) \t\t\tend \t\tend \t-- If Invite Contains a REFERRED-BY copy the contents in to the From Header (Blind Transfer) \t\tlocal local_refferedby = msg:getHeader(\"REFERRED-BY\") \t\tif local_refferedby \t\tthen \t\t\trefferedby_uri_host, refferedby_uri_domain, refferedby_uri_domain_port, refferedby_uri_user=splitURI(local_refferedby) \t--\t\ttrace.format(\"ReferredBy Host is %s\", refferedby_uri_host) \t--\t\ttrace.format(\"ReferredBy Domain is %s\",refferedby_uri_domain) \t--\t\ttrace.format(\"ReferredBy Port is %s\", refferedby_uri_domain_port) \t--\t\ttrace.format(\"ReferredBy User is %s\", refferedby_uri_user) \t\t\tFrom_Tag = msg:getHeaderValueParameter(\"From\", \"tag\") \t\t\tlocal new_From_header = '<sip:' .. refferedby_uri_host .. '@' .. refferedby_uri_domain .. ':' .. refferedby_uri_domain_port .. ';' .. refferedby_uri_user .. ';tag=' .. From_Tag \t\t\tmsg:modifyHeader(\"From\", new_From_header) \t\tend \tend end local function handle_outbound_replies(msg, clear) -- Call saved \"History-Info\" and \"From\" headers from the context data. \tlocal context = msg:getContext() \tif context \tthen \t\tlocal history = context[\"History-Info\"] \t\tlocal save_from = context[\"From\"] \t\tif history \t\tthen -- Add original History-Info header -- Replace From header with the values from the original inbound Invite \t\t\ttrace.format(\"From is %s\", save_from) \t\t\tmsg:addHeader(\"History-Info\", history) \t\t\tmsg:modifyHeader(\"From\", save_from) \t\t\tif clear \t\t\tthen \t\t\t\tcontext[\"History-Info\"] = nil \t\t\tend \t\tend \tend end -- Convert Diversion Header to History-Info on outbound Invites local function handle_outbound_invite(msg) local isInitialInvite = msg:isInitialInviteRequest() if isInitialInvite \tthen \t\tif msg:getHeader(\"Diversion\") \t\tthen \t\t\tmsg:convertDiversionToHI() \t\t\t-- msg:removeHeader(\"Diversion\") \t\tend \tend end -- Manipulate Inbound Invite based on the function handle_inbound_invite M.inbound_INVITE = handle_inbound_invite M.outbound_200_INVITE = handle_outbound_replies M.outbound_18X_INVITE = handle_outbound_replies M.outbound_INVITE\t=\thandle_outbound_invite return M", "name": "MS-AntiLoop_V0.11", "hierarchy_path": "sys.hcs" } } ] }
(Show the first instance)
{ "pkid": "6305141243fcc416f18f7e1e", "meta": { "tags": [ "V4UC", "ba_CommonOverlay" ], "cached": false, "title": "MS-AntiLoop_V0.11", "business_key": { "hierarchy": true, "consider_null": false, "unique": [ "name" ] }, "schema_version": "0.0", "references": { "parent": [ { "pkid": "6305086243fcc416f18ea4ac", "href": "/api/data/HierarchyNode/6305086243fcc416f18ea4ac" } ], "self": [ { "pkid": "6305141243fcc416f18f7e1e", "href": "/api/data/MS-Teams-LuaScriptDAT/6305141243fcc416f18f7e1e/" } ], "foreign_key": [], "device": [ { "pkid": "", "href": "" } ], "owner": [ { "pkid": "" } ], "children": [] }, "actions": [ { "update": { "support_async": true, "class": "update", "href": "/api/data/MS-Teams-LuaScriptDAT/6305141243fcc416f18f7e1e/?hierarchy=[hierarchy]", "method": "PUT", "title": "Modify" } }, { "remove": { "support_async": true, "class": "delete", "href": "/api/data/MS-Teams-LuaScriptDAT/6305141243fcc416f18f7e1e/?hierarchy=[hierarchy]", "method": "DELETE", "title": "Delete" } }, { "clone": { "support_async": false, "class": "clone", "href": "/api/data/MS-Teams-LuaScriptDAT/6305141243fcc416f18f7e1e/clone/?hierarchy=[hierarchy]&schema=&schema_rules=true", "method": "GET", "title": "Clone" } }, { "export": { "title": "Export", "support_async": false, "submit": "payload", "class": "export", "href": "/api/data/MS-Teams-LuaScriptDAT/6305141243fcc416f18f7e1e/export/?hierarchy=[hierarchy]", "method": "GET", "view": "/api/view/ExportData/add/?auth_token=[authtoken] } }, { "tag": { "title": "Tag", "support_async": true, "method": "PATCH", "href": "/api/data/MS-Teams-LuaScriptDAT/6305141243fcc416f18f7e1e/+tag/?hierarchy=[hierarchy]", "class": "tag", "view": "/api/view/TagNameForm/add/?auth_token=[authtoken] } }, { "tag_version": { "title": "Tag Version", "support_async": true, "method": "PATCH", "href": "/api/data/MS-Teams-LuaScriptDAT/6305141243fcc416f18f7e1e/+tag_version/?hierarchy=[hierarchy]", "class": "tag_version", "view": "/api/view/TagVersionForm/add/?auth_token=[authtoken] } }, { "get": { "support_async": false, "class": "get", "href": "/api/data/MS-Teams-LuaScriptDAT/6305141243fcc416f18f7e1e/?hierarchy=[hierarchy]", "method": "GET", "title": "Get" } }, { "help": { "support_async": false, "class": "help", "href": "/api/data/MS-Teams-LuaScriptDAT/6305141243fcc416f18f7e1e/help?hierarchy=[hierarchy]", "method": "GET", "title": "Help" } } ], "model_type": "data/MS-Teams-LuaScriptDAT", "path": [ "6t0ggef2c0deab00hb595101", "6305086243fcc416f18ea4ac", "6305141243fcc416f18f7e1e" ], "summary_attrs": [ { "name": "name", "title": "Name" }, { "allow_filtering": true, "name": "hierarchy_friendly_name", "title": "Located At" } ], "api_version": "21.2", "tagged_versions": [] }, "data": { "pkid": "6305141243fcc416f18f7e1f", "name": "MS-AntiLoop_V0.11", "script": "--[[ Name: MS-AntiLoop_v0.11.lua Description: Allow interoperability between CUCM and MS-Teams. Mechanism to stop calls forked from MS-Teams to SNR back from Cisco, utilising the TOD access feature on the Remote Destination V0.6 \ton the inbound invite copy the \"History-Info\" header to the \"From\" Header \t\tCopy the \"From\" header to the \"P-Asserted-Identity\" V0.7\tUse original inbound \"From\" header in 200 and 18X replies. Include \"History-Info\" in replies. V0.8\tRestrict inbound invite manipulation to initial invites only. \t\tTidy up code \t\tAdd comments and changelog V0.9 \tConvert Diversion header to History-Info for outbound initial invites V0.10\tCopy \"REFERRED-BY\" header to \"From\" to handle Blind Transfer \t\tRemoved redundant line \"local orig_From_header = msg:getHeader(\"From\")\" V0.11\tRetain original MS-Teams \"From\" in custom \"MS-From\" header and pass through --]] M = {} -- Allow this header to be passed through M.allowHeaders = {\"History-Info\", \"REFERRED-BY\",\"MS-From\"} -- Enable Tracing if enabled on the trunk trace.enable() local function splitURI(i_uri) \t\t\tlocal position_of_semi = string.find(i_uri, \";\") \t\t\tlocal position_of_sip = string.find(i_uri, \"sip\") \t\t\tif position_of_semi then \t\t\t\ti_uri_id = string.sub(i_uri, position_of_sip, (position_of_semi -1 )) \t\t\t\tr_uri_user = string.sub(i_uri, (position_of_semi + 1 )) \t\t\telse \t\t\t\t-- no user \t\t\t\ti_uri_id = string.sub(i_uri, position_of_sip) \t\t\t\tr_uri_user=nil \t\t\tend \t\t\ti_uri_id = string.gsub(i_uri_id,\"sip:\",\"\") \t\t\tlocal position_of_ampersand = string.find(i_uri_id, \"@\") \t\t\tlocal r_uri_host=string.sub(i_uri_id,1,(position_of_ampersand-1)) \t\t\tlocal r_uri_domain=string.sub(i_uri_id,(position_of_ampersand+1)) \t\t\tlocal port_position = string.find(r_uri_domain, \":\", 2) \t\t\tif port_position then \t\t\t\tr_uri_domain_port = string.sub(r_uri_domain,(port_position+1)) \t\t\t\tr_uri_domain = string.sub(r_uri_domain,1,(port_position-1)) \t\t\telse \t\t\t\t-- no port \t\t\t\tr_uri_domain_port = nil \t\t\tend \treturn r_uri_host, r_uri_domain, r_uri_domain_port, r_uri_user end local function handle_inbound_invite(msg) local isInitialInvite = msg:isInitialInviteRequest() if isInitialInvite \tthen \t-- save the History-Info header and From Header in the context data for use in outbound replies \t\tlocal history = msg:getHeader(\"History-Info\") \t\tlocal save_from = msg:getHeader(\"From\") \t\tlocal pt = msg:getPassThrough() \t\tif history \t\tthen \t\t\ttrace.format(\"History variable is %s\", history) \t\t\ttrace.format(\"Save From variable is %s\", save_from) \t\t\tmsg:convertHIToDiversion() \t\t\tlocal context = msg:getContext() \t\t\tif context \t\t\tthen \t\t\tcontext[\"History-Info\"] = history \t\t\tcontext[\"From\"] = save_from \t\t\tend \t-- Custom Header to retain original MS-Teams From \t\t\tmsg:addHeader(\"MS-From\", save_from) \t\t\tpt:addHeader(\"MS-From\", save_from)\t \t\tend \t-- write History-Info URI to variable HistoryInfo_uri \t\tlocal HistoryInfo_uri = msg:getUri(\"History-Info\") \t\tif HistoryInfo_uri \t\tthen \t\t\ttrace.format(\"History-Info header is %s\", HistoryInfo_uri) \t\t\tlocal HI_Uri = sipUtils.parseUri(HistoryInfo_uri) \t\t\tif HI_Uri \t\t\tthen \t\t\t\tHI_Host = HI_Uri:getHost() \t\t\t\tHI_User = HI_Uri:getUser() \t\t\tend \t\t\tlocal From_uri = msg:getUri(\"From\") \t\t\ttrace.format( \"the From URI %s\", From_uri) \t\t\tif From_uri \t\t\tthen \t-- Copy \"From\" Header to PAId. Create Header if it doesnt exist \t\t\t\tlocal Pai_header = msg:getHeader(\"P-Asserted-Identity\") \t\t\t\tFrom_uri_host, From_uri_domain, From_uri_domain_port, From_uri_user=splitURI(From_uri) \t--\t\t\ttrace.format(\"From Host is %s\", From_uri_host) \t--\t\t\ttrace.format(\"From Domain is %s\",From_uri_domain) \t--\t\t\ttrace.format(\"From Port is %s\", From_uri_domain_port) \t--\t\t\ttrace.format(\"From User is %s\", From_uri_user) \t\t\t\tFrom_Tag = msg:getHeaderValueParameter(\"From\", \"tag\") \t\t\t\tif Pai_header \t\t\t\tthen \t\t\t\t\tlocal new_pai_header = '<sip:' .. From_uri_host .. '@' .. From_uri_domain .. '>' \t\t\t\t\tmsg:modifyHeader(\"P-Asserted-Identity\", new_pai_header) \t\t\t\telse \t\t\t\t\tmsg:addHeader(\"P-Asserted-Identity\", new_pai_header) \t\t\t\tend \t-- Recreate \"From\" Header with the \"User\" from History-Info and the \"Host\" of the original \"From\" header \t\t\t\tlocal new_From_header = '\"' .. HI_User .. '\" <sip:' .. HI_User .. '@' .. From_uri_domain .. '>;tag=' .. From_Tag \t\t\t\tmsg:modifyHeader(\"From\", new_From_header) \t\t\tend \t\tend \t-- If Invite Contains a REFERRED-BY copy the contents in to the From Header (Blind Transfer) \t\tlocal local_refferedby = msg:getHeader(\"REFERRED-BY\") \t\tif local_refferedby \t\tthen \t\t\trefferedby_uri_host, refferedby_uri_domain, refferedby_uri_domain_port, refferedby_uri_user=splitURI(local_refferedby) \t--\t\ttrace.format(\"ReferredBy Host is %s\", refferedby_uri_host) \t--\t\ttrace.format(\"ReferredBy Domain is %s\",refferedby_uri_domain) \t--\t\ttrace.format(\"ReferredBy Port is %s\", refferedby_uri_domain_port) \t--\t\ttrace.format(\"ReferredBy User is %s\", refferedby_uri_user) \t\t\tFrom_Tag = msg:getHeaderValueParameter(\"From\", \"tag\") \t\t\tlocal new_From_header = '<sip:' .. refferedby_uri_host .. '@' .. refferedby_uri_domain .. ':' .. refferedby_uri_domain_port .. ';' .. refferedby_uri_user .. ';tag=' .. From_Tag \t\t\tmsg:modifyHeader(\"From\", new_From_header) \t\tend \tend end local function handle_outbound_replies(msg, clear) -- Call saved \"History-Info\" and \"From\" headers from the context data. \tlocal context = msg:getContext() \tif context \tthen \t\tlocal history = context[\"History-Info\"] \t\tlocal save_from = context[\"From\"] \t\tif history \t\tthen -- Add original History-Info header -- Replace From header with the values from the original inbound Invite \t\t\ttrace.format(\"From is %s\", save_from) \t\t\tmsg:addHeader(\"History-Info\", history) \t\t\tmsg:modifyHeader(\"From\", save_from) \t\t\tif clear \t\t\tthen \t\t\t\tcontext[\"History-Info\"] = nil \t\t\tend \t\tend \tend end -- Convert Diversion Header to History-Info on outbound Invites local function handle_outbound_invite(msg) local isInitialInvite = msg:isInitialInviteRequest() if isInitialInvite \tthen \t\tif msg:getHeader(\"Diversion\") \t\tthen \t\t\tmsg:convertDiversionToHI() \t\t\t-- msg:removeHeader(\"Diversion\") \t\tend \tend end -- Manipulate Inbound Invite based on the function handle_inbound_invite M.inbound_INVITE = handle_inbound_invite M.outbound_200_INVITE = handle_outbound_replies M.outbound_18X_INVITE = handle_outbound_replies M.outbound_INVITE\t=\thandle_outbound_invite return M" } }
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Get the on-line Help for data/MS-Teams-LuaScriptDAT. | GET | /api/data/MS-Teams-LuaScriptDAT/help | hierarchy=[hierarchy] | On-line help of Model ref.: data/MS-Teams-LuaScriptDAT as HTML |
Task | Call | URL | Parameters | Payload |
---|---|---|---|---|
Modify | PUT | /api/data/MS-Teams-LuaScriptDAT/[pkid]/ | hierarchy=[hierarchy] | (For payload specification) |
For Bulk modification, refer to the Bulk Modify section.
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Delete | DELETE | /api/data/MS-Teams-LuaScriptDAT/[pkid]/ | hierarchy=[hierarchy] |
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Clone instance with [pkid]. The schema rules are applied. | GET | /api/data/MS-Teams-LuaScriptDAT/[pkid]/clone/?schema=&schema_rules=true |
|
A JSON payload with:
|
GET http://[host-proxy]/api/data/MS-Teams-LuaScriptDAT/?hierarchy=[hierarchy]&format=json
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Get a selected [export_format] of the schema and a single instance with [pkid] of data/MS-Teams-LuaScriptDAT; optionally with tag_version at [version] and Configuration Template as [configtemplate]. | GET | /api/data/MS-Teams-LuaScriptDAT/[pkid]/export/ |
|
The response is an attachment. Refer to the list below. |
For export_format=raw_xlsx, the response is a "raw" MS Excel spreadsheet with columns corresponding to the JSON format export and a response format:
Content-Disposition: attachment; filename=<resource_type>_<resource_name>_exportedsheet_CCYY-MM-DD_HH-MM-SS.xlsx Content-Language:en Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
For export_format=xlsx, the response is a MS Excel spreadsheet, formatted to show all columns and a response format:
Content-Disposition: attachment; filename=<resource_type>_<resource_name>_exportedsheet_formatted_CCYY-MM-DD_HH-MM-SS.xlsx Content-Language:en Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
For export_format=json, the response is a time stamped zip file of data in JSON and a response format:
Content-Disposition: attachment; filename=export_2013-05-17_14:20:19.186444.json.zip Content-Language:en Content-Type:application/x-zip
The XLSX format can be used to bulk load instances of data/MS-Teams-LuaScriptDAT and the JSON format can be used to import instances of data/MS-Teams-LuaScriptDAT.
For Bulk Export, refer to the Bulk Export section.
Task | Call | URL | Parameters | Payload |
---|---|---|---|---|
Tag | PATCH | /api/data/MS-Teams-LuaScriptDAT/[pkid]/+tag/ | hierarchy=[hierarchy] | If payload required: |
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Get | GET | /api/data/MS-Teams-LuaScriptDAT/[pkid]/ | hierarchy=[hierarchy] | The data/MS-Teams-LuaScriptDAT instance with [pkid]. |
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Help | GET | /api/data/MS-Teams-LuaScriptDAT/[pkid]/help | hierarchy=[hierarchy] | The on-line Help for data/MS-Teams-LuaScriptDAT. |