Module: ThreeScaleToolbox::Commands::PlansCommand::Import::Step
- Included in:
- CreateOrUpdateAppPlanStep, ImportMetricLimitsStep, ImportMetricsStep, ImportPlanFeaturesStep, ImportPricingRulesStep
- Defined in:
- lib/3scale_toolbox/commands/plans_command/import/step.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
-
#artifacts_resource ⇒ Object
deserialized artifacts content.
- #file ⇒ Object
- #find_feature_by_system_name(system_name) ⇒ Object
- #find_metric_by_system_name(system_name) ⇒ Object
- #initialize(context) ⇒ Object
- #invalidate_service_methods ⇒ Object
- #invalidate_service_metrics ⇒ Object
- #plan ⇒ Object
-
#plan_system_name ⇒ Object
can be id or system_name.
- #resource_features ⇒ Object
- #resource_limits ⇒ Object
- #resource_methods ⇒ Object
- #resource_metrics ⇒ Object
- #resource_plan ⇒ Object
- #resource_pricing_rules ⇒ Object
- #result ⇒ Object
- #service ⇒ Object
- #service_features ⇒ Object
- #service_hits ⇒ Object
- #service_methods ⇒ Object
- #service_metrics ⇒ Object
- #service_metrics_and_methods ⇒ Object
-
#service_system_name ⇒ Object
can be id or system_name.
- #threescale_client ⇒ Object
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
6 7 8 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 6 def context @context end |
Instance Method Details
#artifacts_resource ⇒ Object
deserialized artifacts content
97 98 99 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 97 def artifacts_resource context[:artifacts_resource] end |
#file ⇒ Object
16 17 18 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 16 def file context[:file] end |
#find_feature_by_system_name(system_name) ⇒ Object
101 102 103 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 101 def find_feature_by_system_name(system_name) service_features.find { |feature| feature['system_name'] == system_name } end |
#find_metric_by_system_name(system_name) ⇒ Object
105 106 107 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 105 def find_metric_by_system_name(system_name) service_metrics_and_methods.find { |metric| metric['system_name'] == system_name } end |
#initialize(context) ⇒ Object
8 9 10 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 8 def initialize(context) @context = context end |
#invalidate_service_methods ⇒ Object
88 89 90 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 88 def invalidate_service_methods context[:service_methods] = nil end |
#invalidate_service_metrics ⇒ Object
72 73 74 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 72 def invalidate_service_metrics context[:service_metrics] = nil end |
#plan ⇒ Object
38 39 40 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 38 def plan context[:plan] ||= find_plan end |
#plan_system_name ⇒ Object
can be id or system_name
30 31 32 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 30 def plan_system_name context[:plan_system_name] || artifacts_resource.dig('plan', 'system_name') end |
#resource_features ⇒ Object
64 65 66 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 64 def resource_features artifacts_resource['plan_features'] || [] end |
#resource_limits ⇒ Object
56 57 58 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 56 def resource_limits artifacts_resource['limits'] || [] end |
#resource_methods ⇒ Object
52 53 54 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 52 def resource_methods artifacts_resource['methods'] || [] end |
#resource_metrics ⇒ Object
48 49 50 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 48 def resource_metrics artifacts_resource['metrics'] || [] end |
#resource_plan ⇒ Object
42 43 44 45 46 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 42 def resource_plan artifacts_resource.fetch('plan') do raise ThreeScaleToolbox::Error, 'Invalid content. Plan not found' end end |
#resource_pricing_rules ⇒ Object
60 61 62 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 60 def resource_pricing_rules artifacts_resource['pricingrules'] || [] end |
#result ⇒ Object
34 35 36 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 34 def result context[:result] ||= {} end |
#service ⇒ Object
12 13 14 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 12 def service context[:service] ||= find_service end |
#service_features ⇒ Object
92 93 94 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 92 def service_features context[:service_features] ||= service.features end |
#service_hits ⇒ Object
76 77 78 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 76 def service_hits context[:service_hits] ||= service.hits end |
#service_methods ⇒ Object
80 81 82 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 80 def service_methods context[:service_methods] ||= service.methods(service_hits['id']) end |
#service_metrics ⇒ Object
68 69 70 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 68 def service_metrics context[:service_metrics] ||= service.metrics end |
#service_metrics_and_methods ⇒ Object
84 85 86 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 84 def service_metrics_and_methods service_metrics + service_methods end |
#service_system_name ⇒ Object
can be id or system_name
25 26 27 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 25 def service_system_name context[:service_system_name] end |
#threescale_client ⇒ Object
20 21 22 |
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 20 def threescale_client context[:threescale_client] end |