Sha256: 6bef6c81cdb6b0d2521b39ef8eb8561febe49e883cd3df4a986521a69c657f3b

Contents?: true

Size: 1.28 KB

Versions: 20

Compression:

Stored size: 1.28 KB

Contents

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

          def self.command
            Cri::Command.define do
              name        'delete'
              usage       'delete <remote> <activedocs-id_or-system-name>'
              summary     'Delete an ActiveDocs'
              description 'Remove an ActiveDocs'
              runner DeleteSubcommand

              param   :remote
              param   :activedocs_id_or_system_name
            end
          end

          def run
            activedocs.delete
            puts "ActiveDocs with id: #{activedocs.id} deleted"
          end

          private

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

          def ref
            arguments[:activedocs_id_or_system_name]
          end

          def activedocs
            @activedocs ||= find_activedocs
          end

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
3scale_toolbox-1.0.1 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb
3scale_toolbox-1.0.0 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb
3scale_toolbox-0.20.0 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb
3scale_toolbox-0.19.3 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb
3scale_toolbox-0.19.2 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb
3scale_toolbox-0.19.1 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb
3scale_toolbox-0.19.0 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb
3scale_toolbox-0.18.3 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb
3scale_toolbox-0.18.2 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb
3scale_toolbox-0.18.0 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb
3scale_toolbox-0.17.1 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb
3scale_toolbox-0.17.0 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb
3scale_toolbox-0.16.0 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb
3scale_toolbox-0.15.0 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb
3scale_toolbox-0.14.0 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb
3scale_toolbox-0.13.0 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb
3scale_toolbox-0.12.4 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb
3scale_toolbox-0.12.3 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb
3scale_toolbox-0.12.2 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb
3scale_toolbox-0.11.0 lib/3scale_toolbox/commands/activedocs_command/delete_command.rb