Skip to content

Commit

Permalink
[4.3] Add missing fields from resources schema (#6444)
Browse files Browse the repository at this point in the history
* [4.3] Add missing fields from resources schema

Stepswitch makes use of a number of fields that aren't defined on the
resources schema. Add them and use the accessor module when possible.
  • Loading branch information
jamesaimonetti authored Apr 7, 2020
1 parent cdf806c commit 6df0731
Show file tree
Hide file tree
Showing 11 changed files with 545 additions and 95 deletions.
6 changes: 6 additions & 0 deletions applications/callflow/src/cf_exe.erl
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,12 @@ handle_cast({'gen_listener', {'is_consuming', 'true'}}
) ->
lager:debug("ready to recv events, launching the callflow"),
{'noreply', launch_cf_module(State#state{status = 'running'})};
handle_cast({'gen_listener', {'is_consuming', 'true'}}, State) ->
lager:info("consuming AMQP events"),
{'noreply', State};
handle_cast({'gen_listener', {'is_consuming', 'false'}}, State) ->
lager:info("no longer consuming AMQP events"),
{'noreply', State};
handle_cast(_Msg, State) ->
lager:debug("unhandled cast: ~p", [_Msg]),
{'noreply', State}.
Expand Down
12 changes: 12 additions & 0 deletions applications/crossbar/doc/ref/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ Schema for resources

Key | Description | Type | Default | Required | Support Level
--- | ----------- | ---- | ------- | -------- | -------------
`caller_id_options.type` | Caller ID type to choose | `string('internal' | 'external' | 'emergency')` | | `false` |
`caller_id_options` | Caller ID options | `object()` | | `false` |
`cid_rules.[]` | | `string()` | | `false` |
`cid_rules` | Regexps to match against caller ID | `array(string())` | | `false` |
`classifiers.emergency` | Determines if the resource represents emergency services | `boolean()` | `false` | `false` |
`classifiers.enabled` | Determines if the resource is currently enabled | `boolean()` | `true` | `false` |
`classifiers.prefix` | A string to prepend to the dialed number or capture group of the matching rule | `string(0..64)` | | `false` |
`classifiers.regex` | regexp to match against dialed number | `string()` | | `false` |
`classifiers.suffix` | A string to append to the dialed number or capture group of the matching rule | `string(0..64)` | | `false` |
`classifiers.weight_cost` | A value between 0 and 100 that determines the order of resources when multiple can be used | `integer()` | `50` | `false` |
`classifiers` | Resource classifiers to use as rules when matching against dialed numbers | `object()` | | `false` |
`emergency` | Determines if the resource represents emergency services | `boolean()` | `false` | `false` |
`enabled` | Determines if the resource is currently enabled | `boolean()` | `true` | `false` |
`flags.[]` | | `string()` | | `false` |
Expand All @@ -18,6 +29,7 @@ Key | Description | Type | Default | Required | Support Level
`flat_rate_whitelist` | Regex for determining if the number is eligible for flat-rate trunking | `string()` | | `false` |
`format_from_uri` | When set to true requests to this resource will have a reformatted SIP From Header | `boolean()` | | `false` |
`formatters` | Schema for request formatters | `object()` | | `false` |
`from_account_realm` | When formatting SIP From on outbound requests, use the calling account's SIP realm | `boolean()` | `false` | `false` |
`from_uri_realm` | When formatting SIP From on outbound requests this can be used to override the realm | `string()` | | `false` |
`gateway_strategy` | The strategy of choosing gateways from list: sequential or random | `string('sequential' | 'random')` | | `false` |
`gateways.[].bypass_media` | The resource gateway bypass media mode | `boolean()` | | `false` |
Expand Down
12 changes: 12 additions & 0 deletions applications/crossbar/doc/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ Schema for resources

Key | Description | Type | Default | Required | Support Level
--- | ----------- | ---- | ------- | -------- | -------------
`caller_id_options.type` | Caller ID type to choose | `string('internal' | 'external' | 'emergency')` | | `false` |
`caller_id_options` | Caller ID options | `object()` | | `false` |
`cid_rules.[]` | | `string()` | | `false` |
`cid_rules` | Regexps to match against caller ID | `array(string())` | | `false` |
`classifiers.emergency` | Determines if the resource represents emergency services | `boolean()` | `false` | `false` |
`classifiers.enabled` | Determines if the resource is currently enabled | `boolean()` | `true` | `false` |
`classifiers.prefix` | A string to prepend to the dialed number or capture group of the matching rule | `string(0..64)` | | `false` |
`classifiers.regex` | regexp to match against dialed number | `string()` | | `false` |
`classifiers.suffix` | A string to append to the dialed number or capture group of the matching rule | `string(0..64)` | | `false` |
`classifiers.weight_cost` | A value between 0 and 100 that determines the order of resources when multiple can be used | `integer()` | `50` | `false` |
`classifiers` | Resource classifiers to use as rules when matching against dialed numbers | `object()` | | `false` |
`emergency` | Determines if the resource represents emergency services | `boolean()` | `false` | `false` |
`enabled` | Determines if the resource is currently enabled | `boolean()` | `true` | `false` |
`flags.[]` | | `string()` | | `false` |
Expand All @@ -36,6 +47,7 @@ Key | Description | Type | Default | Required | Support Level
`flat_rate_whitelist` | Regex for determining if the number is eligible for flat-rate trunking | `string()` | | `false` |
`format_from_uri` | When set to true requests to this resource will have a reformatted SIP From Header | `boolean()` | | `false` |
`formatters` | Schema for request formatters | `object()` | | `false` |
`from_account_realm` | When formatting SIP From on outbound requests, use the calling account's SIP realm | `boolean()` | `false` | `false` |
`from_uri_realm` | When formatting SIP From on outbound requests this can be used to override the realm | `string()` | | `false` |
`gateway_strategy` | The strategy of choosing gateways from list: sequential or random | `string('sequential' | 'random')` | | `false` |
`gateways.[].bypass_media` | The resource gateway bypass media mode | `boolean()` | | `false` |
Expand Down
65 changes: 65 additions & 0 deletions applications/crossbar/priv/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -27879,6 +27879,66 @@
"resources": {
"description": "Schema for resources",
"properties": {
"caller_id_options": {
"description": "Caller ID options",
"properties": {
"type": {
"description": "Caller ID type to choose",
"enum": [
"internal",
"external",
"emergency"
],
"type": "string"
}
},
"type": "object"
},
"cid_rules": {
"description": "Regexps to match against caller ID",
"items": {
"description": "Regexp to match against caller ID",
"type": "string"
},
"type": "array"
},
"classifiers": {
"description": "Resource classifiers to use as rules when matching against dialed numbers",
"properties": {
"emergency": {
"default": false,
"description": "Determines if the resource represents emergency services",
"type": "boolean"
},
"enabled": {
"default": true,
"description": "Determines if the resource is currently enabled",
"type": "boolean"
},
"prefix": {
"description": "A string to prepend to the dialed number or capture group of the matching rule",
"maxLength": 64,
"type": "string"
},
"regex": {
"description": "regexp to match against dialed number",
"type": "string"
},
"suffix": {
"description": "A string to append to the dialed number or capture group of the matching rule",
"maxLength": 64,
"type": "string"
},
"weight_cost": {
"default": 50,
"description": "A value between 0 and 100 that determines the order of resources when multiple can be used",
"maximum": 100,
"minimum": 0,
"type": "integer"
}
},
"type": "object"
},
"emergency": {
"default": false,
"description": "Determines if the resource represents emergency services",
Expand Down Expand Up @@ -27913,6 +27973,11 @@
"$ref": "#/definitions/formatters",
"type": "object"
},
"from_account_realm": {
"default": false,
"description": "When formatting SIP From on outbound requests, use the calling account's SIP realm",
"type": "boolean"
},
"from_uri_realm": {
"description": "When formatting SIP From on outbound requests this can be used to override the realm",
"type": "string"
Expand Down
65 changes: 65 additions & 0 deletions applications/crossbar/priv/couchdb/schemas/resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,66 @@
"_id": "resources",
"description": "Schema for resources",
"properties": {
"caller_id_options": {
"description": "Caller ID options",
"properties": {
"type": {
"description": "Caller ID type to choose",
"enum": [
"internal",
"external",
"emergency"
],
"type": "string"
}
},
"type": "object"
},
"cid_rules": {
"description": "Regexps to match against caller ID",
"items": {
"description": "Regexp to match against caller ID",
"type": "string"
},
"type": "array"
},
"classifiers": {
"description": "Resource classifiers to use as rules when matching against dialed numbers",
"properties": {
"emergency": {
"default": false,
"description": "Determines if the resource represents emergency services",
"type": "boolean"
},
"enabled": {
"default": true,
"description": "Determines if the resource is currently enabled",
"type": "boolean"
},
"prefix": {
"description": "A string to prepend to the dialed number or capture group of the matching rule",
"maxLength": 64,
"type": "string"
},
"regex": {
"description": "regexp to match against dialed number",
"type": "string"
},
"suffix": {
"description": "A string to append to the dialed number or capture group of the matching rule",
"maxLength": 64,
"type": "string"
},
"weight_cost": {
"default": 50,
"description": "A value between 0 and 100 that determines the order of resources when multiple can be used",
"maximum": 100,
"minimum": 0,
"type": "integer"
}
},
"type": "object"
},
"emergency": {
"default": false,
"description": "Determines if the resource represents emergency services",
Expand Down Expand Up @@ -37,6 +97,11 @@
"$ref": "formatters",
"type": "object"
},
"from_account_realm": {
"default": false,
"description": "When formatting SIP From on outbound requests, use the calling account's SIP realm",
"type": "boolean"
},
"from_uri_realm": {
"description": "When formatting SIP From on outbound requests this can be used to override the realm",
"type": "string"
Expand Down
4 changes: 2 additions & 2 deletions applications/jonny5/src/j5_flat_rate.erl
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ maybe_get_resource_flat_rate(Request, 'true') ->
ResourceId = j5_request:resource_id(Request),
case kz_datamgr:open_cache_doc(?KZ_OFFNET_DB, ResourceId) of
{'ok', JObj} ->
{kzd_resource:flat_rate_whitelist(JObj, ?WHITELIST)
,kzd_resource:flat_rate_blacklist(JObj, ?BLACKLIST)
{kzd_resources:flat_rate_whitelist(JObj, ?WHITELIST)
,kzd_resources:flat_rate_blacklist(JObj, ?BLACKLIST)
};
{'error', _E} ->
{?WHITELIST, ?BLACKLIST}
Expand Down
Loading

0 comments on commit 6df0731

Please sign in to comment.