class ThreeScaleToolbox::Commands::PlansCommand::Import::ImportSubcommand

Public Class Methods

command() click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import_command.rb, line 16
def self.command
  Cri::Command.define do
    name        'import'
    usage       'import [opts] <remote> <service_system_name>'
    summary     'import application plan'
    description 'Import application plan, limits, pricing rules and features'

    option      :f, :file, 'Read from file or url instead of stdin', argument: :required
    option      :p, :plan, 'Override application plan reference', argument: :required
    param       :remote
    param       :service_system_name

    runner ImportSubcommand
  end
end

Public Instance Methods

run() click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import_command.rb, line 32
def run
  tasks = []
  tasks << CreateOrUpdateAppPlanStep.new(context)
  tasks << ImportMetricsStep.new(context)
  tasks << ImportMetricLimitsStep.new(context)
  tasks << ImportPricingRulesStep.new(context)
  tasks << ImportPlanFeaturesStep.new(context)

  # run tasks
  tasks.each(&:call)
end

Private Instance Methods

context() click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import_command.rb, line 46
def context
  @context ||= create_context
end
create_context() click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import_command.rb, line 50
def create_context
  {
    artifacts_resource: load_resource(options[:file] || '-'),
    threescale_client: threescale_client(arguments[:remote]),
    service_system_name: arguments[:service_system_name],
    plan_system_name: options[:plan],
  }
end