Class: ThreeScaleToolbox::Commands::UpdateCommand::ServiceSubcommand
- Inherits:
-
Cri::CommandRunner
- Object
- Cri::CommandRunner
- ThreeScaleToolbox::Commands::UpdateCommand::ServiceSubcommand
- Includes:
- ThreeScaleToolbox::Command
- Defined in:
- lib/3scale_toolbox/commands/update_command/service_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
.command ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/3scale_toolbox/commands/update_command/service_command.rb', line 10 def self.command Cri::Command.define do name 'service' usage 'service [opts] -s <src> -d <dst> <src_service_id> <dst_service_id>' summary '[DEPRECATED] update service' description <<-HEREDOC This command has been deprecated. Use '3scale service copy' instead. \n Update existing service, update proxy settings, metrics, methods, application plans and mapping rules.' HEREDOC option :s, :source, '3scale source instance. Url or remote name', argument: :required option :d, :destination, '3scale target instance. Url or remote name', argument: :required option :t, 'target_system_name', 'Target system name', argument: :required flag :f, :force, 'Overwrites the mapping rules by deleting all rules from target service first' flag :r, 'rules-only', 'Updates only the mapping rules' param :src_service_id param :dst_service_id runner ServiceSubcommand end end |
Instance Method Details
#run ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/3scale_toolbox/commands/update_command/service_command.rb', line 32 def run warn "\e[1m\e[31mThis command has been deprecated. Use '3scale service copy' instead\e[0m" source_service = Entities::Service.new( id: arguments[:src_service_id], remote: threescale_client(fetch_required_option(:source)) ) update_service = Entities::Service.new( id: arguments[:dst_service_id], remote: threescale_client(fetch_required_option(:destination)) ) context = create_context(source_service, update_service) tasks = [] unless [:'rules-only'] tasks << ServiceCommand::CopyServiceSettingsTask.new(context) tasks << ThreeScaleToolbox::Commands::ServiceCommand::CopyCommand::CopyMethodsTask.new(context) tasks << ThreeScaleToolbox::Commands::ServiceCommand::CopyCommand::CopyMetricsTask.new(context) tasks << ThreeScaleToolbox::Commands::ServiceCommand::CopyCommand::CopyApplicationPlansTask.new(context) tasks << ThreeScaleToolbox::Commands::ServiceCommand::CopyCommand::CopyLimitsTask.new(context) tasks << ThreeScaleToolbox::Commands::ServiceCommand::CopyCommand::CopyPoliciesTask.new(context) tasks << ThreeScaleToolbox::Commands::ServiceCommand::CopyCommand::CopyPricingRulesTask.new(context) tasks << ServiceCommand::DeleteActiveDocsTask.new(context) tasks << ThreeScaleToolbox::Commands::ServiceCommand::CopyCommand::CopyActiveDocsTask.new(context) # Copy proxy must be the last task # Proxy update is the mechanism to increase version of the proxy, # Hence propagating (mapping rules, poicies, oidc, auth) update to # latest proxy config, making available to gateway. tasks << ThreeScaleToolbox::Commands::ServiceCommand::CopyCommand::CopyServiceProxyTask.new(context) end tasks << ThreeScaleToolbox::Commands::ServiceCommand::CopyCommand::DestroyMappingRulesTask.new(context) tasks << ThreeScaleToolbox::Commands::ServiceCommand::CopyCommand::CopyMappingRulesTask.new(context) # run tasks tasks.each(&:call) end |