Class: EPC::Command::UndefineServiceCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- EPC::Command::UndefineServiceCommand
- Defined in:
- lib/epc/command/undefine_service_command.rb
Constant Summary
Constants inherited from BaseCommand
BaseCommand::GIVEUP_TICKS, BaseCommand::SLEEP_TIME, BaseCommand::TICKER_TICKS
Instance Attribute Summary
Attributes inherited from BaseCommand
Instance Method Summary collapse
Methods inherited from BaseCommand
#go, inherited, #initialize, required_options
Methods included from PersistentAttributes
#auth_token, #caller_id, #target_url
Constructor Details
This class inherits a constructor from EPC::Command::BaseCommand
Instance Method Details
#execute(service_name = nil) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/epc/command/undefine_service_command.rb', line 4 def execute(service_name = nil) if service_name.nil? say("You must specify a name for the service") say(EPC::Help::COMMAND_USAGES[:undefine_service]) return 1 end if numeric?(service_name) service_id = service_name.to_i else service_id = get_resource_id(EPC::Config::SERVICE_DEFINITIONS_PATH, :name, service_name) end if service_id.nil? || service_id == 0 say("#{service_name} service could not be found.") return 1 end status, response, headers = client.delete(EPC::Config::SERVICE_DEFINITIONS_PATH + "/#{service_id}") if status.failure? say("Service removal failed with: [#{response['message']}]") else say("#{service_name} has been undefined.") end return status end |