Module: Giraffi::Client::Triggers

Included in:
Giraffi::Client
Defined in:
lib/giraffi/client/triggers.rb

Overview

Defines methods related to the triggers

Instance Method Summary collapse

Instance Method Details

#destroy_trigger(id) ⇒ HTTParty::Response

Deletes the trigger

Parameters:

  • id (String)

    The numerical ID of the desired trigger

Returns:

  • (HTTParty::Response)

Requires APIKEY?:

  • Yes



77
78
79
# 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) ⇒ HTTParty::Response

Executes all axions related to the desired trigger

Parameters:

  • id (String)

    The numerical ID of the desired trigger

Returns:

  • (HTTParty::Response)

Requires APIKEY?:

  • Yes



45
46
47
# 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) ⇒ HTTParty::Response

Returns all axions related to the desired trigger

Parameters:

  • args (Array)

    A set of params to retrieve axions related to the trigger

Options Hash (*args):

  • The (String)

    numerical ID of the related trigger

  • The (String)

    kind of axion [problem, recovery] to retrieve

Returns:

  • (HTTParty::Response)

Raises:

  • (ArgumentError)

Requires APIKEY?:

  • Yes



31
32
33
34
35
36
37
38
# 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) ⇒ HTTParty::Response

Returns the desired trigger

Parameters:

  • id (String)

    The numerical ID of the desired trigger

Returns:

  • (HTTParty::Response)

Requires APIKEY?:

  • Yes



20
21
22
# File 'lib/giraffi/client/triggers.rb', line 20

def find_trigger(id)
  self.class.get("/triggers/#{id}.json?apikey=#{apikey}")
end

#find_triggers(options = {}) ⇒ HTTParty::Response

Returns the desired trigger

Parameters:

  • options (Hash) (defaults to: {})

    The request params to retrieve the desired triggers

Returns:

  • (HTTParty::Response)

Requires APIKEY?:

  • Yes



11
12
13
# 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) ⇒ HTTParty::Response

Removes an axion from the trigger

Parameters:

  • args (Array)

    A set of parmas to remove an axion from the trigger

Options Hash (*args):

  • The (String)

    numerical ID of the related trigger

  • The (String)

    numerical ID of the axion to remove

Returns:

  • (HTTParty::Response)

Raises:

  • (ArgumentError)

Requires APIKEY?:

  • Yes



88
89
90
91
# 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) ⇒ HTTParty::Response

Updates the axion related to the desired trigger

Parameters:

  • args (Array)

    A set of parmas to update the axion related to the trigger

Options Hash (*args):

  • The (String)

    numerical ID of the related trigger

  • The (String)

    numerical ID of the desired axion

  • The (String)

    kind of axion [problem, recovery] to update

Returns:

  • (HTTParty::Response)

Raises:

  • (ArgumentError)

Requires APIKEY?:

  • Yes



67
68
69
70
# 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 = {}) ⇒ HTTParty::Response

Updates the desired trigger

Parameters:

  • id (String)

    The numerical ID of the desired trigger

  • options (Hash) (defaults to: {})

    A set of attributes to update the trigger

Returns:

  • (HTTParty::Response)

Requires APIKEY?:

  • Yes



55
56
57
# 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