module ThreeScaleToolbox::Commands::PlansCommand::Import::Step
Attributes
context[R]
Public Class Methods
new(context)
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/step.rb, line 8 def initialize(context) @context = context end
Public Instance Methods
artifacts_resource()
click to toggle source
deserialized artifacts content
# File lib/3scale_toolbox/commands/plans_command/import/step.rb, line 77 def artifacts_resource context[:artifacts_resource] end
file()
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/step.rb, line 16 def file context[:file] end
find_feature_by_system_name(system_name)
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/step.rb, line 81 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)
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/step.rb, line 85 def find_metric_by_system_name(system_name) service_metrics_and_methods.find { |metric| metric.system_name == system_name } end
plan()
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/step.rb, line 38 def plan context[:plan] ||= find_plan end
plan_system_name()
click to toggle source
can be id or system_name
# 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()
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/step.rb, line 64 def resource_features artifacts_resource['plan_features'] || [] end
resource_limits()
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/step.rb, line 56 def resource_limits artifacts_resource['limits'] || [] end
resource_methods()
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/step.rb, line 52 def resource_methods artifacts_resource['methods'] || [] end
resource_metrics()
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/step.rb, line 48 def resource_metrics artifacts_resource['metrics'] || [] end
resource_plan()
click to toggle source
# 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()
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/step.rb, line 60 def resource_pricing_rules artifacts_resource['pricingrules'] || [] end
result()
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/step.rb, line 34 def result context[:result] ||= {} end
service()
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/step.rb, line 12 def service context[:service] ||= find_service end
service_features()
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/step.rb, line 72 def service_features context[:service_features] ||= service.features end
service_metrics_and_methods()
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/step.rb, line 68 def service_metrics_and_methods service.metrics + service.methods end
service_system_name()
click to toggle source
can be id or system_name
# File lib/3scale_toolbox/commands/plans_command/import/step.rb, line 25 def service_system_name context[:service_system_name] end
threescale_client()
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/step.rb, line 20 def threescale_client context[:threescale_client] end
Private Instance Methods
find_plan()
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/step.rb, line 98 def find_plan Entities::ApplicationPlan.find(service: service, ref: plan_system_name).tap do |p| raise ThreeScaleToolbox::Error, "Application plan #{plan_system_name} does not exist" if p.nil? end end
find_service()
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/step.rb, line 91 def find_service Entities::Service.find(remote: threescale_client, ref: service_system_name).tap do |svc| raise ThreeScaleToolbox::Error, "Service #{service_system_name} does not exist" if svc.nil? end end