Class: Splunk::Pickaxe::FieldExtractions

Inherits:
Objects
  • Object
show all
Defined in:
lib/splunk/pickaxe/objects/field_extractions.rb

Instance Attribute Summary

Attributes inherited from Objects

#environment, #pickaxe_config, #service

Instance Method Summary collapse

Methods inherited from Objects

#config, #create, #entity_file_extensions, #initialize, #name, #skip?, #splunk_config, #sync

Constructor Details

This class inherits a constructor from Splunk::Pickaxe::Objects

Instance Method Details

#entity_dirObject



14
15
16
# File 'lib/splunk/pickaxe/objects/field_extractions.rb', line 14

def entity_dir
  DIR
end

#find(entity) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/splunk/pickaxe/objects/field_extractions.rb', line 18

def find(entity)
  # Splunk does some fun things by re-naming our field extraction to include
  # the stanza and type in the name when its created so do that here by
  # cloning the entity and editing its name before passing it to find
  find_entity = Hash.new(entity)
  find_entity['name'] = "#{entity['config']['stanza']} : #{entity['config']['type']}-#{entity['name']}"
  super(find_entity)
end

#needs_update?(splunk_entity, entity) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
35
# File 'lib/splunk/pickaxe/objects/field_extractions.rb', line 32

def needs_update?(splunk_entity, entity)
  # When updating splunk only cares about this field
  splunk_entity['value'] != splunk_config(entity)['value']
end

#splunk_resourceObject



10
11
12
# File 'lib/splunk/pickaxe/objects/field_extractions.rb', line 10

def splunk_resource
  %w[data props extractions]
end

#update(splunk_entity, entity) ⇒ Object



27
28
29
30
# File 'lib/splunk/pickaxe/objects/field_extractions.rb', line 27

def update(splunk_entity, entity)
  # When updating splunk only wants the value field
  splunk_entity.update('value' => splunk_config(entity)['value'])
end