Class: ThreeScaleToolbox::CRD::BackendParser
- Inherits:
-
Object
- Object
- ThreeScaleToolbox::CRD::BackendParser
show all
- Defined in:
- lib/3scale_toolbox/crds/backend_parser.rb
Defined Under Namespace
Classes: MappingRule, Method, Metric
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of BackendParser.
10
11
12
|
# File 'lib/3scale_toolbox/crds/backend_parser.rb', line 10
def initialize(cr)
@cr = cr
end
|
Instance Attribute Details
#cr ⇒ Object
Returns the value of attribute cr.
8
9
10
|
# File 'lib/3scale_toolbox/crds/backend_parser.rb', line 8
def cr
@cr
end
|
Instance Method Details
#description ⇒ Object
22
23
24
|
# File 'lib/3scale_toolbox/crds/backend_parser.rb', line 22
def description
cr.dig('spec', 'description')
end
|
#mapping_rules ⇒ Object
42
43
44
45
46
47
|
# File 'lib/3scale_toolbox/crds/backend_parser.rb', line 42
def mapping_rules
@mapping_rules ||= (cr.dig('spec', 'mappingRules') || []).map do |mapping_rule|
MappingRule.new(mapping_rule['metricMethodRef'], mapping_rule['httpMethod'],
mapping_rule['pattern'], mapping_rule['increment'], mapping_rule['last'])
end
end
|
#methods ⇒ Object
36
37
38
39
40
|
# File 'lib/3scale_toolbox/crds/backend_parser.rb', line 36
def methods
@methods ||= (cr.dig('spec', 'methods') || {}).map do |system_name, method|
Method.new(system_name, method['friendlyName'], method['description'])
end
end
|
#metrics ⇒ Object
30
31
32
33
34
|
# File 'lib/3scale_toolbox/crds/backend_parser.rb', line 30
def metrics
@metrics ||= (cr.dig('spec', 'metrics') || {}).map do |system_name, metric|
Metric.new(system_name, metric['friendlyName'], metric['description'], metric['unit'])
end
end
|
#metrics_index ⇒ Object
Metrics and methods index by system_name
50
51
52
|
# File 'lib/3scale_toolbox/crds/backend_parser.rb', line 50
def metrics_index
@metrics_index ||= (methods + metrics).each_with_object({}) { |metric, h| h[metric.system_name] = metric }
end
|
#name ⇒ Object
18
19
20
|
# File 'lib/3scale_toolbox/crds/backend_parser.rb', line 18
def name
cr.dig('spec', 'name')
end
|
#private_endpoint ⇒ Object
26
27
28
|
# File 'lib/3scale_toolbox/crds/backend_parser.rb', line 26
def private_endpoint
cr.dig('spec', 'privateBaseURL')
end
|
#system_name ⇒ Object
14
15
16
|
# File 'lib/3scale_toolbox/crds/backend_parser.rb', line 14
def system_name
cr.dig('spec', 'systemName')
end
|