ReadOnlyEntity represents entities that can be read, but not created or updated, via the REST API. The canonical example is a modular input kind.
Fetch a field on this entity.
Returns: a String.
# File lib/splunk-sdk-ruby/entity.rb, line 94 synonym "[]", "fetch"
Fetches the field key on this entity.
You may provide a default value. All values are returned as strings.
Returns: a String.
# File lib/splunk-sdk-ruby/entity.rb, line 85 def fetch(key, default=nil) @state["content"].fetch(key, default) end
Returns a Hash of the links associated with this entity.
The links typically include keys such as "list", "edit", or "disable".
Returns: a Hash of Strings to URL objects.
# File lib/splunk-sdk-ruby/entity.rb, line 104 def links() return @state["links"] end
DEPRECATED. Use fetch and [] instead (since entities now cache their state).
Returns all or a specified subset of key/value pairs on this Entity
In the absence of arguments, returns a Hash of all the fields on this Entity. If you specify one or more Strings or Arrays of Strings, all the keys specified in the arguments will be returned in the Hash.
Returns: a Hash with Strings as keys, and Strings or Hashes or Arrays as values.
# File lib/splunk-sdk-ruby/entity.rb, line 121 def read(*field_list) warn "[DEPRECATION] Entity#read is deprecated. Use [] and fetch instead." if field_list.empty? return @state["content"].clone() else field_list = field_list.flatten() result = {} field_list.each() do |key| result[key] = fetch(key).clone() end return result end end
Returns the metadata for this Entity.
This method is identical to
entity.read('eai:acl', 'eai:attributes')
Returns: a Hash with the keys "+eai:acl+" and "+eai:attributes+".
# File lib/splunk-sdk-ruby/entity.rb, line 144 def readmeta read('eai:acl', 'eai:attributes') end
Refreshes the cached state of this Entity.
Returns: the Entity.
# File lib/splunk-sdk-ruby/entity.rb, line 153 def refresh() response = @service.request(:resource => @resource + [name], :namespace => @namespace) if response.code == 204 or response.body.nil? # This code is here primarily to handle the case of a job not yet being # ready, in which case you get back empty bodies. raise EntityNotReady.new((@resource + [name]).join("/")) end # We are guaranteed a unique entity, since entities must have # exact namespaces. feed = AtomFeed.new(response.body) @state = feed.entries[0] self end
Generated with the Darkfish Rdoc Generator 2.