Class: Splunk::Configurations
- Inherits:
-
Collection
- Object
- ReadOnlyCollection
- Collection
- Splunk::Configurations
- Defined in:
- lib/splunk-sdk-ruby/collection/configurations.rb
Overview
Class representing a collection of configuration files.
The API of Configurations is identical to Collection, so the user should not need to be aware of this class.
Instance Attribute Summary
Attributes inherited from ReadOnlyCollection
#entity_class, #resource, #service
Instance Method Summary collapse
- #atom_entry_to_entity(entry) ⇒ Object
- #create(name, args = {}) ⇒ Object
- #delete(name) ⇒ Object
- #fetch(name) ⇒ Object
-
#initialize(service) ⇒ Configurations
constructor
:nodoc:.
Methods inherited from Collection
Methods inherited from ReadOnlyCollection
#assoc, #each, #each_key, #each_pair, #each_value, #empty?, #has_key?, #keys, #length, #values
Constructor Details
#initialize(service) ⇒ Configurations
:nodoc:
34 35 36 |
# File 'lib/splunk-sdk-ruby/collection/configurations.rb', line 34 def initialize(service) super(service, PATH_CONFS, entity_class=ConfigurationFile) end |
Instance Method Details
#atom_entry_to_entity(entry) ⇒ Object
38 39 40 41 |
# File 'lib/splunk-sdk-ruby/collection/configurations.rb', line 38 def atom_entry_to_entity(entry) name = entry["title"] return ConfigurationFile.new(@service, name) end |
#create(name, args = {}) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/splunk-sdk-ruby/collection/configurations.rb', line 43 def create(name, args={}) # Don't bother catching the response. It either succeeds and returns # an empty body, or fails and throws a +SplunkHTTPError+. request_args = {:method => :POST, :resource => PATH_CONFS, :body => {"__conf" => name}} if args.has_key?(:namespace) request_args[:namespace] = args[:namespace] end @service.request(request_args) return ConfigurationFile.new(@service, name, args[:namespace] || @service.namespace) end |
#delete(name) ⇒ Object
57 58 59 60 |
# File 'lib/splunk-sdk-ruby/collection/configurations.rb', line 57 def delete(name) raise IllegalOperation.new("Cannot delete configuration files from" + " the REST API.") end |
#fetch(name) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/splunk-sdk-ruby/collection/configurations.rb', line 62 def fetch(name) begin # Make a request to the server to see if _name_ exists. # We don't actually use any information returned from the server # besides the status code. request_args = {:resource => PATH_CONFS + [name]} @service.request(request_args) return ConfigurationFile.new(@service, name) rescue SplunkHTTPError => err if err.code == 404 return nil else raise err end end end |