Class: ThreeScaleToolbox::Commands::PlansCommand::Create::CreateSubcommand

Inherits:
Cri::CommandRunner
  • Object
show all
Includes:
ThreeScaleToolbox::Command
Defined in:
lib/3scale_toolbox/commands/plans_command/create_command.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ThreeScaleToolbox::Command

#config, #config_file, #exit_with_message, #fetch_required_option, included, #remotes, #threescale_client, #verbose, #verify_ssl

Class Method Details

.commandObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/3scale_toolbox/commands/plans_command/create_command.rb', line 23

def self.command
  Cri::Command.define do
    name        'create'
    usage       'create [opts] <remote> <service> <plan-name>'
    summary     'create application plan'
    description 'Create application plan'

    option      :t, 'system-name', 'Application plan system name', argument: :required
    flag        nil, :default, 'Make default application plan'
    flag        nil, :disabled, 'Disables all methods and metrics in this application plan'
    flag        :p, :publish, 'Publish application plan'
    option      nil, 'approval-required', 'Applications require approval. true or false', argument: :required, transform: ThreeScaleToolbox::Helper::BooleanTransformer.new
    option      nil, 'cost-per-month', 'Cost per month', argument: :required, transform: method(:Float)
    option      nil, 'setup-fee', 'Setup fee', argument: :required, transform: method(:Float)
    option      nil, 'trial-period-days', 'Trial period days', argument: :required, transform: method(:Integer)
    ThreeScaleToolbox::CLI.output_flag(self)

    param       :remote
    param       :service_ref
    param       :plan_name

    runner CreateSubcommand
  end
end

Instance Method Details

#runObject



48
49
50
51
52
53
# File 'lib/3scale_toolbox/commands/plans_command/create_command.rb', line 48

def run
  plan = create_application_plan
  plan.make_default if option_default
  plan.disable if option_disabled
  printer.print_record plan.attrs
end