Sha256: 3cc708310dc2f4fd43d6b422a0d36b231db8984d46f0cb943c926e3898392e8f

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

module ThreeScaleToolbox
  module Commands
    module ServiceCommand
      module Delete
        class DeleteSubcommand < Cri::CommandRunner
          include ThreeScaleToolbox::Command

          def self.command
            Cri::Command.define do
              name        'delete'
              usage       'delete <remote> <service-id_or_system-name>'
              summary     'Delete a service'
              description 'Delete a service'
              runner DeleteSubcommand

              param   :remote
              param   :service_id_or_system_name
            end
          end

          def run
            service.delete
            puts "Service with id: #{service.id} deleted"
          end

          private

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

          def ref
            @ref ||= arguments[:service_id_or_system_name]
          end

          def service
            @service ||= find_service
          end

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
3scale_toolbox-0.15.0 lib/3scale_toolbox/commands/service_command/delete_command.rb
3scale_toolbox-0.14.0 lib/3scale_toolbox/commands/service_command/delete_command.rb
3scale_toolbox-0.13.0 lib/3scale_toolbox/commands/service_command/delete_command.rb
3scale_toolbox-0.12.4 lib/3scale_toolbox/commands/service_command/delete_command.rb
3scale_toolbox-0.12.3 lib/3scale_toolbox/commands/service_command/delete_command.rb
3scale_toolbox-0.12.2 lib/3scale_toolbox/commands/service_command/delete_command.rb
3scale_toolbox-0.11.0 lib/3scale_toolbox/commands/service_command/delete_command.rb