module Giraffi::Client::Triggers

Defines methods related to the triggers

Public Instance Methods

destroy_trigger(id) click to toggle source

Deletes the trigger

@requires_apikey Yes @param id [String] The numerical ID of the desired trigger @return [HTTParty::Response]

# File lib/giraffi/client/triggers.rb, line 77
def destroy_trigger(id)
  self.class.delete("/triggers/#{id}.json?apikey=#{apikey}")
end
execute_axions_by_trigger(id) click to toggle source

Executes all axions related to the desired trigger

@requires_apikey Yes @param id [String] The numerical ID of the desired trigger @return [HTTParty::Response]

# File lib/giraffi/client/triggers.rb, line 45
def execute_axions_by_trigger(id)
  self.class.post("/triggers/#{id}/axions/execute.json?apikey=#{apikey}")
end
find_axions_by_trigger(*args) click to toggle source

Returns all axions related to the desired trigger

@requires_apikey Yes @param args [Array] A set of params to retrieve axions related to the trigger @option args [String] The numerical ID of the related trigger @option args [String] The kind of axion [problem, recovery] to retrieve @return [HTTParty::Response]

# File lib/giraffi/client/triggers.rb, line 31
def find_axions_by_trigger(*args)
  raise ArgumentError.new('The method `find_axions_by_trigger` requires at least a trigger id.') if args.size.zero?
  if args.size == 1
    self.class.get("/triggers/#{args[0]}/axions.json?apikey=#{apikey}")
  else
    self.class.get("/triggers/#{args[0]}/axions.json?apikey=#{apikey}", :query => {:axionkind => args[-1]})
  end
end
find_trigger(id) click to toggle source

Returns the desired trigger

@requires_apikey Yes @param id [String] The numerical ID of the desired trigger @return [HTTParty::Response]

# File lib/giraffi/client/triggers.rb, line 20
def find_trigger(id)
  self.class.get("/triggers/#{id}.json?apikey=#{apikey}")
end
find_triggers(options={}) click to toggle source

Returns the desired trigger

@requires_apikey Yes @param options [Hash] The request params to retrieve the desired triggers @return [HTTParty::Response]

# File lib/giraffi/client/triggers.rb, line 11
def find_triggers(options={})
  self.class.get("/triggers.json?apikey=#{apikey}", :query => options)
end
remove_axion_from_trigger(*args) click to toggle source

Removes an axion from the trigger

@requires_apikey Yes @param args [Array] A set of parmas to remove an axion from the trigger @option args [String] The numerical ID of the related trigger @option args [String] The numerical ID of the axion to remove @return [HTTParty::Response]

# File lib/giraffi/client/triggers.rb, line 88
def remove_axion_from_trigger(*args)
  raise ArgumentError.new('The method `remove_axion_from_trigger` requires 2 arguments (trigger-id and axion-id)') if args.size != 2
  self.class.delete("/triggers/#{args[0]}/axions/#{args[-1]}.json?apikey=#{apikey}")
end
update_axion_of_trigger(*args) click to toggle source

Updates the axion related to the desired trigger

@requires_apikey Yes @param args [Array] A set of parmas to update the axion related to the trigger @option args [String] The numerical ID of the related trigger @option args [String] The numerical ID of the desired axion @option args [String] The kind of axion [problem, recovery] to update @return [HTTParty::Response]

# File lib/giraffi/client/triggers.rb, line 67
def update_axion_of_trigger(*args)
  raise ArgumentError.new('The method `update_axion_by_trigger` requires 3 argments (trigger-id, axion-id and axion-kind)') if args.size != 3
  self.class.put("/triggers/#{args[0]}/axions/#{args[1]}.json?apikey=#{apikey}", :query => { :axionkind => args[-1] }, :body => {})
end
update_trigger(id, options={}) click to toggle source

Updates the desired trigger

@requires_apikey Yes @param id [String] The numerical ID of the desired trigger @param options [Hash] A set of attributes to update the trigger @return [HTTParty::Response]

# File lib/giraffi/client/triggers.rb, line 55
def update_trigger(id, options={})
  self.class.put("/triggers/#{id}.json?apikey=#{apikey}", :query => {:trigger => options}, :body => {})
end