Class: ThreeScaleToolbox::Commands::PlansCommand::Import::ImportPricingRulesStep
- Inherits:
-
Object
- Object
- ThreeScaleToolbox::Commands::PlansCommand::Import::ImportPricingRulesStep
- Includes:
- Step
- Defined in:
- lib/3scale_toolbox/commands/plans_command/import/import_plan_pricing_rules_step.rb
Instance Attribute Summary
Attributes included from Step
Instance Method Summary collapse
-
#call ⇒ Object
Writes Plan pricing rules.
Methods included from Step
#artifacts_resource, #file, #find_feature_by_system_name, #find_metric_by_system_name, #initialize, #invalidate_service_methods, #invalidate_service_metrics, #plan, #plan_system_name, #resource_features, #resource_limits, #resource_methods, #resource_metrics, #resource_plan, #resource_pricing_rules, #result, #service, #service_features, #service_hits, #service_methods, #service_metrics, #service_metrics_and_methods, #service_system_name, #threescale_client
Instance Method Details
#call ⇒ Object
Writes Plan pricing rules
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/3scale_toolbox/commands/plans_command/import/import_plan_pricing_rules_step.rb', line 9 def call # SET semantics # First, delete existing pricing rules # Second, add new pricing rules remote_pr_processed.each do |pr| metric_id = pr.fetch('metric_id') plan.delete_pricing_rule metric_id, pr.fetch('id') puts "Deleted existing plan pricing rule: [metric: #{metric_id}, #{pr}]" end resource_pr_processed.each do |pr| metric_id = pr.delete('metric_id') plan.create_pricing_rule(metric_id, pr) puts "Created plan pricing rule: [metric: #{metric_id}, #{pr}]" end end |