Class: ThreeScaleToolbox::Commands::MethodsCommand::Create::CreateSubcommand

Inherits:
Cri::CommandRunner
  • Object
show all
Includes:
ThreeScaleToolbox::Command
Defined in:
lib/3scale_toolbox/commands/methods_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



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/3scale_toolbox/commands/methods_command/create_command.rb', line 22

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

    option      :t, 'system-name', 'Method system name', argument: :required
    flag        nil, :disabled, 'Disables this method in all application plans'
    option      nil, :description, 'Method description', argument: :required
    ThreeScaleToolbox::CLI.output_flag(self)

    param       :remote
    param       :service_ref
    param       :method_name

    runner CreateSubcommand
  end
end

Instance Method Details

#runObject



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/3scale_toolbox/commands/methods_command/create_command.rb', line 42

def run
  hits = service.hits
  method = ThreeScaleToolbox::Entities::Method.create(
    service: service,
    parent_id: hits.fetch('id'),
    attrs: method_attrs
  )
  method.disable if option_disabled

  printer.print_record method.attrs
end