Skip to content

Commit

Permalink
[4.3] KCRO-21: correct classifiers schema to include classifier name (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesaimonetti authored Apr 9, 2020
1 parent 8c604f2 commit 2ae90ae
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 224 deletions.
13 changes: 7 additions & 6 deletions applications/crossbar/doc/ref/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ Key | Description | Type | Default | Required | Support Level
`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./.+/.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./.+/` | | `object()` | | `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` |
Expand Down
13 changes: 7 additions & 6 deletions applications/crossbar/doc/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ Key | Description | Type | Default | Required | Support Level
`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./.+/.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./.+/` | | `object()` | | `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` |
Expand Down
33 changes: 0 additions & 33 deletions applications/crossbar/priv/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -27904,39 +27904,6 @@
},
"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": {
Expand Down
67 changes: 36 additions & 31 deletions applications/crossbar/priv/couchdb/schemas/resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,42 @@
},
"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"
"patternProperties": {
".+": {
"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"
}
},
"type": "object"
Expand Down
28 changes: 15 additions & 13 deletions applications/stepswitch/src/stepswitch_resources.erl
Original file line number Diff line number Diff line change
Expand Up @@ -985,34 +985,36 @@ resources_from_jobjs([JObj|JObjs], Resources) ->
end.

-spec create_resource(kzd_resources:doc(), resources()) -> resources().
create_resource(JObj, Resources) ->
case kzd_resources:classifiers(JObj) of
'undefined' -> [resource_from_jobj(JObj) | Resources];
create_resource(ResourceJObj, Resources) ->
case kzd_resources:classifiers(ResourceJObj) of
'undefined' -> [resource_from_jobj(ResourceJObj) | Resources];
ResourceClassifiers ->
AvailableClassifiers = kz_json:to_proplist(knm_converters:available_classifiers()),
create_resource(kz_json:to_proplist(ResourceClassifiers)
,AvailableClassifiers
,JObj
,ResourceJObj
,Resources
)
end.

-spec create_resource(kz_term:proplist(), kz_term:proplist(), kz_json:object(), resources()) -> resources().
create_resource([], _ConfigClassifiers, _Resource, Resources) -> Resources;
create_resource([{Classifier, ClassifierJObj}|Classifiers], ConfigClassifiers, Resource, Resources) ->
case props:get_value(Classifier, ConfigClassifiers) of
create_resource([], _ConfigClassifiers, _ResourceJObj, Resources) -> Resources;
create_resource([{ResourceClassifier, ResourceClassifierJObj}|ResourceClassifiers]
,ConfigClassifiers, ResourceJObj, Resources
) ->
case props:get_value(ResourceClassifier, ConfigClassifiers) of
'undefined' ->
create_resource(Classifiers, ConfigClassifiers, Resource, Resources);
create_resource(ResourceClassifiers, ConfigClassifiers, ResourceJObj, Resources);
ConfigClassifier ->
JObj =
create_classifier_resource(Resource
,ClassifierJObj
,Classifier
create_classifier_resource(ResourceJObj
,ResourceClassifierJObj
,ResourceClassifier
,ConfigClassifier
),
create_resource(Classifiers
create_resource(ResourceClassifiers
,ConfigClassifiers
,Resource
,ResourceJObj
,[resource_from_jobj(JObj)
| Resources
]
Expand Down
Loading

0 comments on commit 2ae90ae

Please sign in to comment.