Sha256: 698d879f29353fe194f6959eae1b139e518c335a701c3cd28326554640d5553b

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

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

          def self.command
            Cri::Command.define do
              name        'delete'
              usage       'delete [opts] <remote> <application>'
              summary     'delete application'
              description <<-HEREDOC
              Delete application'
              \n Application param allows:
              \n * Application internal id
              \n * User_key (API key)
              \n * App_id (from app_id/app_key pair)
              \n * Client ID (for OAuth and OpenID Connect authentication modes)
              HEREDOC

              param       :remote
              param       :application_ref

              runner DeleteSubcommand
            end
          end

          def run
            application.delete
            puts "Application id: #{application.id} deleted"
          end

          private

          def application
            @application ||= find_application
          end

          def find_application
            Entities::Application.find(remote: remote, ref: application_ref).tap do |app|
              raise ThreeScaleToolbox::Error, "Application #{application_ref} does not exist" if app.nil?
            end
          end

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

          def application_ref
            arguments[:application_ref]
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
3scale_toolbox-0.12.3 lib/3scale_toolbox/commands/application_command/delete_command.rb
3scale_toolbox-0.12.2 lib/3scale_toolbox/commands/application_command/delete_command.rb
3scale_toolbox-0.11.0 lib/3scale_toolbox/commands/application_command/delete_command.rb