Sha256: 505b9ecf233b761eb9cc608c508c372a7deb76eacadecbb15091530c5b808ffc

Contents?: true

Size: 1.56 KB

Versions: 17

Compression:

Stored size: 1.56 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 * User_key (API key)
              \n * App_id (from app_id/app_key pair) or Client ID (for OAuth and OpenID Connect authentication modes)
              \n * Application internal id
              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

17 entries across 17 versions & 1 rubygems

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