Class: EPC::Command::DefineServiceCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- EPC::Command::DefineServiceCommand
- Defined in:
- lib/epc/command/define_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, #method_missing, required_arguments_count, required_options, #respond_to?
Methods included from PersistentAttributes
#auth_token, #caller_id, #target_url
Constructor Details
This class inherits a constructor from EPC::Command::BaseCommand
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class 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 31 32 33 34 |
# File 'lib/epc/command/define_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[:define_service]) return 1 end if @options[:service_type].nil? say("You must specify a service type with -t option.") return 1 end if numeric?(@options[:service_type]) service_type_id = @options[:service_type].to_i else service_type_id = get_resource_id(EPC::Config::SERVICE_TYPES_PATH, :name, @options[:service_type]) end if service_type_id.nil? || service_type_id == 0 say("#{@options[:service_type]} service type could not be found.") return 1 end status, response, headers = client.post(EPC::Config::SERVICE_DEFINITIONS_PATH, {:name => service_name, :type_id => service_type_id}) if status.failure? say("Service definition failed with: [#{response['message']}]") else say("#{service_name} has been defined.") end return status end |