class Stashboardmanager::Manager
Main class for interacting with StashboardManager.
Public Class Methods
Create a new StashboardManager instance.
# File lib/stashboardmanager.rb, line 10 def initialize(address, token, secret) @stashboard = Stashboard::Stashboard.new(address, token, secret) end
Public Instance Methods
Get an array of service ids. This is just for convenience/
@return [Array] Services Array containing just the service ids
# File lib/stashboardmanager.rb, line 35 def service_ids @stashboard.service_ids end
Get the current status of a service.
@param [String] service The service you are attempting to set @return [Hash] details A hash containing the details for this service
# File lib/stashboardmanager.rb, line 43 def service_status(service) #Do we have a service for this set up services = self.service_ids exists = services.include? service status = false #Make sure we have some services and that this one exists if exists #Get the service's details s = @stashboard.service(service) #Grab the current event current_event = s["current-event"] #Make sure we have a current event if(!current_event.nil?) status = current_event["status"]["id"] end end status end
Is this service updatable?
@param [String] service The name of the service you want to check @param [String] status The status you are trying to update the service to @return [Boolean] response Response containing a true if this service should be updated, a false if it shouldn't OR a nil if the service doesn't exist
# File lib/stashboardmanager.rb, line 72 def service_updatable(service, status) #What is the current service status? serv_stat = self.service_status(service) if serv_stat == status #If match don't update return false else #No match - update return true end end
Check to see if a service is already set as 'status'. If not, update it. @param [String] service The service you are attempting to set
@param [String] status The status you are attempting to set
@param [String] message The message you wish to attach to this update
# File lib/stashboardmanager.rb, line 19 def service_update(service, status, message) if service_updatable(service, status) @stashboard.create_event(service, status, message) end end
Get all services attached to this stashboard.
@return [Hash] services A hash containing an array of service detail hashes, or an error message
# File lib/stashboardmanager.rb, line 28 def services @stashboard.services end