module Giraffi::Client::Items

Defines methods related to the items

Public Instance Methods

add_service_to_item(id, options={}) click to toggle source

Adds a service to the item

@requires_apikey Yes @param id [String] The numerical ID of the related item @param options [Hash] A set of attributes for a service to add to the item @return [HTTParty::Response]

# File lib/giraffi/client/items.rb, line 66
def add_service_to_item(id, options={})
  self.class.post("/items/#{id}/services.json?apikey=#{apikey}", :query => { :service => options })
end
create_item(options={}) click to toggle source

Creates a new item

@requires_apikey Yes @param options [Hash] A set of attributes to create a new item @return [HTTParty::Response]

# File lib/giraffi/client/items.rb, line 48
def create_item(options={})
  self.class.post("/items.json?apikey=#{apikey}", :query => { :item => options })
end
destroy_item(id) click to toggle source

Deletes the item

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

# File lib/giraffi/client/items.rb, line 85
def destroy_item(id)
  self.class.delete("/items/#{id}.json?apikey=#{apikey}")
end
find_agent(id) click to toggle source

Returns the desired agent related to the item

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

# File lib/giraffi/client/items.rb, line 29
def find_agent(id)
  # TODO
end
find_item(id) click to toggle source

Returns the desired item by the numerical ID

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

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

Returns the desired items

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

# File lib/giraffi/client/items.rb, line 11
def find_items(options={})
  self.class.get("/items.json?apikey=#{apikey}", :query => options)
end
find_services_by_item(id, options={}) click to toggle source

Returns all services related to the item

@requires_apikey Yes @param id [String] The numerical ID of the item @param options [Hash] A set of params to retrieve services related the item @return [HTTParty::Response]

# File lib/giraffi/client/items.rb, line 39
def find_services_by_item(id, options={})
  self.class.get("/items/#{id}/services.json?apikey=#{apikey}", :query => options)
end
reload_items() click to toggle source

Reloads all items

@requires_apikey Yes @return [HTTParty::Response]

# File lib/giraffi/client/items.rb, line 56
def reload_items
  self.class.post("/items/reload.json?apikey=#{apikey}")
end
remove_service_from_item(*args) click to toggle source

Removes a service from the item

@requires_apikey Yes @param args [Array] A set of params to remove a service from the item @option args [String] The numerical ID of the related item @option args [String] The numerical ID of the service to remove @return [HTTParty::Response]

# File lib/giraffi/client/items.rb, line 96
def remove_service_from_item(*args)
  raise ArgumentError.new('The method `remove_service_from_item` requires 2 arguments (item-id and service-id)') if args.size != 2
  self.class.delete("/items/#{args[0]}/services/#{args[-1]}.json?apikey=#{apikey}")
end
update_item(id, options={}) click to toggle source

Updates the desired item

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

# File lib/giraffi/client/items.rb, line 76
def update_item(id, options={})
  self.class.put("/items/#{id}.json?apikey=#{apikey}", :query => {:item => options}, :body => {})
end