Parent

Methods

Splunk::Inputs

A collection of specific inputs.

Public Class Methods

new(service, resource) click to toggle source
# File lib/splunk-sdk-ruby/collection/input_kinds.rb, line 87
def initialize(service, resource)
  super(service, resource)
  @always_fetch = true
end

Public Instance Methods

create(name, args={}) click to toggle source
# File lib/splunk-sdk-ruby/collection/input_kinds.rb, line 92
def create(name, args={})
  body_args = args.clone()
  body_args["name"] = name

  request_args = {
      :method => :POST,
      :resource => @resource,
      :body => body_args
  }
  if args.has_key?(:namespace)
    request_args[:namespace] = body_args.delete(:namespace)
  end

  @service.request(request_args)

  # If we have created a oneshot input, no actual entity
  # is created. We return nil here in that case.
  if @resource == ["data", "inputs", "oneshot"]
    return nil
  end

  # TCP and UDP inputs have a key restrictToHost. If it is set
  # then they are created with hostname:port as their resource
  # instead of just port, and we must adjust our behavior
  # accordingly.
  if args.has_key?(:restrictToHost)
    name = args[:restrictToHost] + ":" + name
  end

  fetch_args = {:method => :GET,
                :resource => @resource + [name]}
  if args.has_key?(:namespace)
    fetch_args[:namespace] = args[:namespace]
  end
  response = @service.request(fetch_args)

  feed = AtomFeed.new(response.body)
  raise StandardError.new("No entities returned") if feed.entries.empty?
  entity = atom_entry_to_entity(feed.entries[0])
  raise StandardError.new("Found nil entity.") if entity.nil?
  return entity
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.