Class representing individual entities in Splunk.
Entity objects represent individual items such as indexes, users, roles, etc. They are usually contained within Collection objects.
The basic, identifying information for an Entity (name, namespace, path of the collection containing entity, and the service it's on) is all accessible via getters (name, namespace, resource, service). All the fields containing the Entity's state, such as the capabilities of a role or whether an app should check for updates, are accessible with the [] operator (for instance, role["capabilities"] or app["check_for_updates"]).
Entity objects cache their state, so each lookup of a field does not make a roundtrip to the server. The state may be refreshed by calling the refresh method on the Entity.
Updates the attribute key with value.
As for update, value may be anything that may be coerced sensibly to a String.
Returns: the new value.
# File lib/splunk-sdk-ruby/entity.rb, line 233 def []=(key, value) update(key => value) value end
Deletes this entity from the server.
Returns: nil.
# File lib/splunk-sdk-ruby/entity.rb, line 193 def delete() @service.request({:method => :DELETE, :namespace => @namespace, :resource => @resource + [name]}) end
Disables this entity.
After a subsequent refresh, the "disabled" field will be set to "1". Note that on some entities, such as indexes in Splunk 5.x, most other operations do not work until it is enabled again.
Returns: the Entity.
# File lib/splunk-sdk-ruby/entity.rb, line 247 def disable @service.request(:method => :POST, :namespace => @namespace, :resource => @resource + [name, "disable"]) self end
Enables this entity.
After a subsequent refresh, the "disabled" field will be set to "0".
Returns: the Entity.
# File lib/splunk-sdk-ruby/entity.rb, line 261 def enable @service.request(:method => :POST, :namespace => @namespace, :resource => @resource + [name, "enable"]) self end
Updates the values on the Entity specified in the arguments.
The arguments can be either a Hash or a sequence of key => value pairs. This method does not refresh the Entity, so if you want to see the new values, you must call refresh yourself.
Whatever values you pass will be coerced to Strings, so updating a numeric field with an Integer, for example, will work perfectly well.
Returns: the Entity.
Example:
service = Splunk::connect(:username => 'admin', :password => 'foo') index = service.indexes['main'] # You could use the string "61" as well here. index.update('rotatePeriodInSecs' => 61)
# File lib/splunk-sdk-ruby/entity.rb, line 217 def update(args) @service.request({:method => :POST, :namespace => @namespace, :resource => @resource + [name], :body => args}) self end
Generated with the Darkfish Rdoc Generator 2.