Skip to content

Commit

Permalink
KCRO-21: correct classifiers schema to include classifier name (2600h…
Browse files Browse the repository at this point in the history
…z#6460)

* KCRO-21: correct classifiers schema to include classifier name

* fmt
  • Loading branch information
jamesaimonetti authored Apr 10, 2020
1 parent 06d9546 commit c292fb4
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 250 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 @@ -30,12 +30,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 @@ -31291,39 +31291,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
61 changes: 32 additions & 29 deletions applications/crossbar/priv/oas3/oas3-schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7896,36 +7896,39 @@
'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
'x-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
'emergency':
'default': false
'description': Determines if the resource represents emergency services
Expand Down
22 changes: 12 additions & 10 deletions applications/stepswitch/src/stepswitch_resources.erl
Original file line number Diff line number Diff line change
Expand Up @@ -992,32 +992,34 @@ 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(), kzd_resources:doc(), resources()) -> resources().
create_resource([], _ConfigClassifiers, _ResourceJObj, Resources) -> Resources;
create_resource([{Classifier, ClassifierJObj}|Classifiers], ConfigClassifiers, ResourceJObj, Resources) ->
case props:get_value(Classifier, ConfigClassifiers) of
create_resource([{ResourceClassifier, ResourceClassifierJObj}|ResourceClassifiers]
,ConfigClassifiers, ResourceJObj, Resources
) ->
case props:get_value(ResourceClassifier, ConfigClassifiers) of
'undefined' ->
create_resource(Classifiers, ConfigClassifiers, ResourceJObj, Resources);
create_resource(ResourceClassifiers, ConfigClassifiers, ResourceJObj, Resources);
ConfigClassifier ->
JObj =
create_classifier_resource(ResourceJObj
,ClassifierJObj
,Classifier
,ResourceClassifierJObj
,ResourceClassifier
,ConfigClassifier
),
create_resource(Classifiers
create_resource(ResourceClassifiers
,ConfigClassifiers
,ResourceJObj
,[resource_from_jobj(JObj)
Expand Down
Loading

0 comments on commit c292fb4

Please sign in to comment.