Class: ThreeScaleToolbox::Commands::ServiceCommand::CopyCommand::CopyPricingRulesTask
- Inherits:
-
Object
- Object
- ThreeScaleToolbox::Commands::ServiceCommand::CopyCommand::CopyPricingRulesTask
- Includes:
- Task
- Defined in:
- lib/3scale_toolbox/commands/service_command/copy_command/copy_pricingrules_task.rb
Instance Attribute Summary
Attributes included from Task
Instance Method Summary collapse
Methods included from Task
#delete_mapping_rules, #find_source_service, #force_delete_mapping_rules, #initialize, #invalidate_target_methods, #invalidate_target_metrics, #option_target_system_name, #source, #source_hits, #source_methods, #source_metrics, #source_metrics_and_methods, #source_remote, #source_service_ref, #target, #target=, #target_hits, #target_methods, #target_metrics, #target_metrics_and_methods, #target_remote
Instance Method Details
#call ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/3scale_toolbox/commands/service_command/copy_command/copy_pricingrules_task.rb', line 8 def call plan_mapping = Helper.application_plan_mapping(source.plans, target.plans) plan_mapping.each do |plan_id, target_plan| pricing_rules_source = source.remote.list_pricingrules_per_application_plan(plan_id) pricing_rules_target = target.remote.list_pricingrules_per_application_plan(target_plan['id']) missing_pricing_rules = missing_pricing_rules(pricing_rules_source, pricing_rules_target, metrics_map) missing_pricing_rules.each do |pricing_rule| pricing_rule.delete('links') target.remote.create_pricingrule( target_plan['id'], metrics_map.fetch(pricing_rule['metric_id']), pricing_rule ) end puts "Missing #{missing_pricing_rules.size} pricing rules from target application plan " \ "#{target_plan['id']}. Source plan #{plan_id}" end end |