class Splunk::InputKinds

A collection of input types.

Inputs in the Splunk REST API are arranged in what looks like a directory structure, as in

monitor/
tcp/
  cooked/
  raw/
udp/

You get the top level directory by calling inputs on your Service. Then you can use it as if it were a Hash. If you fetch an entry that has subtypes, such as tcp, you get another InputKinds containing the types in that entry. If you fetch an entry that doesn't have subtypes, such as “udp”, then you get an Inputs object (a subclass of Collection) containing specific inputs.

Example:

# Returns an InputKinds collection
tcp_inputs = service.inputs["tcp"]
tcp_inputs.has_key?("raw")    # ==> true
tcp_inputs.has_key?("cooked") # ==> true

# A read only collection of all the inputs in Splunk.
service.inputs["all"]

# An Inputs object containing all the UDP inputs in Splunk.
service.inputs["udp"]

Public Instance Methods

fetch(name, namespace=nil) click to toggle source
# File lib/splunk-sdk-ruby/collection/input_kinds.rb, line 56
def fetch(name, namespace=nil)
  request_args = {:resource => @resource + [name]}
  if not namespace.nil?
    request_args[:namespace] = namespace
  end

  begin
    response = @service.request(request_args)
  rescue SplunkHTTPError => err
    if err.code == 404
      return nil
    else
      raise err
    end
  end

  feed = AtomFeed.new(response.body)
  if feed.metadata["links"].has_key?("create")
    Inputs.new(@service, resource + [name])
  elsif name == "all"
    ReadOnlyCollection.new(@service, resource + [name])
  else
    InputKinds.new(@service, resource + [name])
  end
end