Class: ThreeScaleToolbox::Commands::MetricsCommand::Create::CreateSubcommand

Inherits:
Cri::CommandRunner
  • Object
show all
Includes:
ThreeScaleToolbox::Command
Defined in:
lib/3scale_toolbox/commands/metrics_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, #keep_alive, #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
41
# File 'lib/3scale_toolbox/commands/metrics_command/create_command.rb', line 22

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

    option      :t, 'system-name', 'Metric system name', argument: :required
    flag        nil, :disabled, 'Disables this metric in all application plans'
    option      nil, :unit, 'Metric unit. Default hit', argument: :required
    option      nil, :description, 'Metric description', argument: :required
    ThreeScaleToolbox::CLI.output_flag(self)

    param       :remote
    param       :service_ref
    param       :metric_name

    runner CreateSubcommand
  end
end

Instance Method Details

#runObject



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

def run
  metric = ThreeScaleToolbox::Entities::Metric.create(
    service: service,
    attrs: metric_attrs
  )
  metric.disable if option_disabled

  printer.print_record metric.attrs
end