Class: ThreeScaleToolbox::Commands::PoliciesCommand::ImportSubcommand
- Inherits:
-
Cri::CommandRunner
- Object
- Cri::CommandRunner
- ThreeScaleToolbox::Commands::PoliciesCommand::ImportSubcommand
- Includes:
- ThreeScaleToolbox::Command, ResourceReader
- Defined in:
- lib/3scale_toolbox/commands/policies_command/import_command.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods included from ResourceReader
#load_resource, #read_content, #read_file, #read_stdin, #read_stringio, #read_url
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
.command ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/3scale_toolbox/commands/policies_command/import_command.rb', line 8 def self.command Cri::Command.define do name 'import' usage 'import [opts] <remote> <product>' summary 'import product policy chain' description 'import product policy chain' option :f, :file, 'Read from file', argument: :required option :u, :url, 'Read from url', argument: :required param :remote param :service_ref runner ImportSubcommand end end |
Instance Method Details
#run ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/3scale_toolbox/commands/policies_command/import_command.rb', line 24 def run res = product.update_policies('policies_config' => policies) if res.is_a?(Hash) && (errors = res['errors']) raise ThreeScaleToolbox::Error, "Product policies have not been imported. #{errors}" end if res.is_a?(Array) && (error_item = res.find { |i| i.key?('errors') }) raise ThreeScaleToolbox::Error, "Product policies have not been imported. #{error_item['errors']}" end end |