Class: ThreeScaleToolbox::Commands::PoliciesCommand::ExportSubcommand

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

Defined Under Namespace

Classes: JSONSerializer, SerializerTransformer, YAMLSerializer

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



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/3scale_toolbox/commands/policies_command/export_command.rb', line 32

def self.command
  Cri::Command.define do
    name        'export'
    usage       'export [opts] <remote> <product>'
    summary     'export product policy chain'
    description 'export product policy chain'

    option      :f, :file, 'Write to file instead of stdout', argument: :required
    option      :o, :output, 'Output format. One of: json|yaml', argument: :required, transform: SerializerTransformer.new
    param       :remote
    param       :service_ref

    runner ExportSubcommand
  end
end

Instance Method Details

#runObject



48
49
50
51
52
# File 'lib/3scale_toolbox/commands/policies_command/export_command.rb', line 48

def run
  select_output do |output|
    output.write(serializer.call(product.policies))
  end
end