class ThreeScaleToolbox::CRD::BackendParser

Constants

MappingRule
Method
Metric

Attributes

cr[R]

Public Class Methods

new(cr) click to toggle source
# File lib/3scale_toolbox/crds/backend_parser.rb, line 10
def initialize(cr)
  @cr = cr
end

Public Instance Methods

description() click to toggle source
# File lib/3scale_toolbox/crds/backend_parser.rb, line 22
def description
  cr.dig('spec', 'description')
end
mapping_rules() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source

Metrics and methods index by system_name

# 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() click to toggle source
# File lib/3scale_toolbox/crds/backend_parser.rb, line 18
def name
  cr.dig('spec', 'name')
end
private_endpoint() click to toggle source
# File lib/3scale_toolbox/crds/backend_parser.rb, line 26
def private_endpoint
  cr.dig('spec', 'privateBaseURL')
end
system_name() click to toggle source
# File lib/3scale_toolbox/crds/backend_parser.rb, line 14
def system_name
  cr.dig('spec', 'systemName')
end