Sha256: 1089a2e94bd17fc0e00ecdc95b00b2b6d31008a8326be5f905463e36f07d3eec
Contents?: true
Size: 1.34 KB
Versions: 3
Compression:
Stored size: 1.34 KB
Contents
module ThreeScaleToolbox module Tasks class CopyLimitsTask include CopyTask include Helper def call metrics_map = metrics_mapping(source.metrics, target.metrics) plan_mapping = application_plan_mapping(source.plans, target.plans) plan_mapping.each do |plan_id, target_plan| source_plan = ThreeScaleToolbox::Entities::ApplicationPlan.new(id: plan_id, service: source) target_plan = ThreeScaleToolbox::Entities::ApplicationPlan.new(id: target_plan['id'], service: target) missing_limits = missing_limits(source_plan.limits, target_plan.limits, metrics_map) missing_limits.each do |limit| limit.delete('links') target_plan.create_limit(metrics_map.fetch(limit.fetch('metric_id')), limit) end puts "Missing #{missing_limits.size} plan limits from target application plan " \ "#{target_plan.id}. Source plan #{plan_id}" end end private def missing_limits(source_limits, target_limits, metrics_map) ThreeScaleToolbox::Helper.array_difference(source_limits, target_limits) do |limit, target| ThreeScaleToolbox::Helper.compare_hashes(limit, target, ['period']) && metrics_map.fetch(limit.fetch('metric_id')) == target.fetch('metric_id') end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems