class ThreeScaleToolbox::Commands::PlansCommand::Show::ShowSubcommand

Constants

FIELDS_TO_SHOW

Public Class Methods

command() click to toggle source
# File lib/3scale_toolbox/commands/plans_command/show_command.rb, line 11
def self.command
  Cri::Command.define do
    name        'show'
    usage       'show [opts] <remote> <service> <plan>'
    summary     'show application plan'
    description 'show application plan'

    ThreeScaleToolbox::CLI.output_flag(self)
    param       :remote
    param       :service_ref
    param       :plan_ref

    runner ShowSubcommand
  end
end

Public Instance Methods

run() click to toggle source
# File lib/3scale_toolbox/commands/plans_command/show_command.rb, line 27
def run
  printer.print_record plan.attrs
end

Private Instance Methods

find_plan() click to toggle source
# File lib/3scale_toolbox/commands/plans_command/show_command.rb, line 48
def find_plan
  Entities::ApplicationPlan.find(service: service, ref: plan_ref).tap do |p|
    raise ThreeScaleToolbox::Error, "Application plan #{plan_ref} does not exist" if p.nil?
  end
end
find_service() click to toggle source
# File lib/3scale_toolbox/commands/plans_command/show_command.rb, line 41
def find_service
  Entities::Service.find(remote: remote,
                         ref: service_ref).tap do |svc|
    raise ThreeScaleToolbox::Error, "Service #{service_ref} does not exist" if svc.nil?
  end
end
plan() click to toggle source
# File lib/3scale_toolbox/commands/plans_command/show_command.rb, line 37
def plan
  @plan ||= find_plan
end
plan_ref() click to toggle source
# File lib/3scale_toolbox/commands/plans_command/show_command.rb, line 62
def plan_ref
  arguments[:plan_ref]
end
printer() click to toggle source
# File lib/3scale_toolbox/commands/plans_command/show_command.rb, line 66
def printer
  options.fetch(:output, CLI::CustomTablePrinter.new(FIELDS_TO_SHOW))
end
remote() click to toggle source
# File lib/3scale_toolbox/commands/plans_command/show_command.rb, line 54
def remote
  @remote ||= threescale_client(arguments[:remote])
end
service() click to toggle source
# File lib/3scale_toolbox/commands/plans_command/show_command.rb, line 33
def service
  @service ||= find_service
end
service_ref() click to toggle source
# File lib/3scale_toolbox/commands/plans_command/show_command.rb, line 58
def service_ref
  arguments[:service_ref]
end