Class: ScoutAgent::API::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_agent/api.rb

Overview

You should not need to consruct instances of this class directly as the API will handle those details for you. However, you can use the methods of these instances, returned by many API methods, to examine the success or failure of your requests.

Direct Known Subclasses

QueueCommand

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, args, input, options) ⇒ Command

:nodoc:



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/scout_agent/api.rb', line 32

def initialize(name, args, input, options)  # :nodoc:
  @name          = name
  @args          = args
  @input         = input
  @background    = options[:background]
  @exit_status   = nil
  @error_message = nil
  @finished      = false
  
  @background ? run_in_background : run
end

Instance Attribute Details

#error_messageObject (readonly)

Returns the error message from the agent as a Sting. This is only set if the request was not a success?().



52
53
54
# File 'lib/scout_agent/api.rb', line 52

def error_message
  @error_message
end

#exit_statusObject (readonly) Also known as: error_code

Returns the exit status of the agent command as an Integer.



45
46
47
# File 'lib/scout_agent/api.rb', line 45

def exit_status
  @exit_status
end

Instance Method Details

#finished?Boolean

Returns true if you chose to run the request in the background and it is now complete. You can periodically poll this method to see if a background request has completed yet.

Warning: none of the other methods should be trusted until this method returns true.

Returns:

  • (Boolean)


67
68
69
# File 'lib/scout_agent/api.rb', line 67

def finished?
  @finished
end

#success?Boolean

Returns true if your request to the agent completed successfully.

Returns:

  • (Boolean)


55
56
57
# File 'lib/scout_agent/api.rb', line 55

def success?
  exit_status and exit_status.zero?
end