Sha256: 31932a5e893ab347924871567be8f8b9305fc3b6844f93cf89b60eef3157f269

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

module ThreeScaleToolbox
  module Commands
    module ProxyCommand
      class ShowSubcommand < Cri::CommandRunner
        include ThreeScaleToolbox::Command

        def self.command
          Cri::Command.define do
            name        'show'
            usage       'show <remote> <service>'
            summary     'Fetch (undeployed) APIcast configuration'
            description 'Fetch (undeployed) APIcast configuration'

            param :remote
            param :service_ref

            ThreeScaleToolbox::CLI.output_flag(self)

            runner ShowSubcommand
          end
        end

        def run
          printer.print_record service.proxy
        end

        private

        def remote
          @remote ||= threescale_client(arguments[:remote])
        end

        def service_ref
          arguments[:service_ref]
        end

        def find_service
          Entities::Service.find(remote: remote,
                                 ref: service_ref).tap do |svc|
            raise ThreeScaleToolbox::Error, "Service #{service_ref} does not exist" if svc.nil?
          end
        end

        def service
          @service ||= find_service
        end

        def printer
          options.fetch(:output, CLI::JsonPrinter.new)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
3scale_toolbox-1.0.1 lib/3scale_toolbox/commands/proxy_command/show_command.rb
3scale_toolbox-1.0.0 lib/3scale_toolbox/commands/proxy_command/show_command.rb
3scale_toolbox-0.20.0 lib/3scale_toolbox/commands/proxy_command/show_command.rb