Module: ThreeScaleToolbox::Commands::PlansCommand::Import::Step

Included in:
CreateOrUpdateAppPlanStep, ImportBackendMetricsStep, ImportLimitsStep, ImportMetricsStep, ImportPlanFeaturesStep, ImportPricingRulesStep, ValidatePlanStep
Defined in:
lib/3scale_toolbox/commands/plans_command/import/step.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contextObject (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_resourceObject

deserialized artifacts content



89
90
91
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 89

def artifacts_resource
  context[:artifacts_resource]
end

#fileObject



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



93
94
95
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 93

def find_feature_by_system_name(system_name)
  service_features.find { |feature| feature['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

#planObject



38
39
40
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 38

def plan
  context[:plan] ||= find_plan
end

#plan_system_nameObject

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_backend_methodsObject



68
69
70
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 68

def resource_backend_methods
  resource_methods.select{ |mth| mth.has_key? 'backend_system_name' }
end

#resource_backend_metricsObject



64
65
66
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 64

def resource_backend_metrics
  resource_metrics.select{ |m| m.has_key? 'backend_system_name' }
end

#resource_featuresObject



80
81
82
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 80

def resource_features
  artifacts_resource['plan_features'] || []
end

#resource_limitsObject



72
73
74
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 72

def resource_limits
  artifacts_resource['limits'] || []
end

#resource_methodsObject



52
53
54
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 52

def resource_methods
  artifacts_resource['methods'] || []
end

#resource_metricsObject



48
49
50
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 48

def resource_metrics
  artifacts_resource['metrics'] || []
end

#resource_planObject



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_rulesObject



76
77
78
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 76

def resource_pricing_rules
  artifacts_resource['pricingrules'] || []
end

#resource_product_methodsObject



60
61
62
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 60

def resource_product_methods
  resource_methods.reject{ |mth| mth.has_key? 'backend_system_name' }
end

#resource_product_metricsObject



56
57
58
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 56

def resource_product_metrics
  resource_metrics.reject{ |m| m.has_key? 'backend_system_name' }
end

#resultObject



34
35
36
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 34

def result
  context[:result] ||= {}
end

#serviceObject



12
13
14
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 12

def service
  context[:service] ||= find_service
end

#service_featuresObject



84
85
86
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 84

def service_features
  context[:service_features] ||= service.features
end

#service_system_nameObject

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_clientObject



20
21
22
# File 'lib/3scale_toolbox/commands/plans_command/import/step.rb', line 20

def threescale_client
  context[:threescale_client]
end