Sha256: aaed25cd41b65bb9e100a2f4baf0abaf42277234911f1d1eff0a34a0ca171df6
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 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| limits = source.plan_limits(plan_id) limits_target = target.plan_limits(target_plan['id']) missing_limits = missing_limits(limits, limits_target) missing_limits.each do |limit| limit.delete('links') target.create_application_plan_limit( target_plan['id'], metrics_map.fetch(limit.fetch('metric_id')), limit ) end puts "target application plan #{target_plan['id']} is missing" \ " #{missing_limits.size} from the original plan #{plan_id}" end end private def missing_limits(source_limits, target_limits) ThreeScaleToolbox::Helper.array_difference(source_limits, target_limits) do |limit, target| ThreeScaleToolbox::Helper.compare_hashes(limit, target, ['period']) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
3scale_toolbox-0.6.0 | lib/3scale_toolbox/tasks/copy_limits_task.rb |