Sha256: b387ae02410cf8a63a27aa75d0d4d53d201013ad28c0ce1e489731501b063a07

Contents?: true

Size: 1.14 KB

Versions: 13

Compression:

Stored size: 1.14 KB

Contents

module ThreeScaleToolbox
  module Commands
    module ServiceCommand
      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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
3scale_toolbox-1.0.1 lib/3scale_toolbox/commands/service_command/delete_command.rb
3scale_toolbox-1.0.0 lib/3scale_toolbox/commands/service_command/delete_command.rb
3scale_toolbox-0.20.0 lib/3scale_toolbox/commands/service_command/delete_command.rb
3scale_toolbox-0.19.3 lib/3scale_toolbox/commands/service_command/delete_command.rb
3scale_toolbox-0.19.2 lib/3scale_toolbox/commands/service_command/delete_command.rb
3scale_toolbox-0.19.1 lib/3scale_toolbox/commands/service_command/delete_command.rb
3scale_toolbox-0.19.0 lib/3scale_toolbox/commands/service_command/delete_command.rb
3scale_toolbox-0.18.3 lib/3scale_toolbox/commands/service_command/delete_command.rb
3scale_toolbox-0.18.2 lib/3scale_toolbox/commands/service_command/delete_command.rb
3scale_toolbox-0.18.0 lib/3scale_toolbox/commands/service_command/delete_command.rb
3scale_toolbox-0.17.1 lib/3scale_toolbox/commands/service_command/delete_command.rb
3scale_toolbox-0.17.0 lib/3scale_toolbox/commands/service_command/delete_command.rb
3scale_toolbox-0.16.0 lib/3scale_toolbox/commands/service_command/delete_command.rb