Sha256: ceb4725fa60af7e184c7f8fcd665fbe9ed9b74e927a8b238c9addc8db414e7ba

Contents?: true

Size: 886 Bytes

Versions: 59

Compression:

Stored size: 886 Bytes

Contents

# encoding: utf-8
module LogStash module Modules class ElasticsearchImporter
  include LogStash::Util::Loggable

  def initialize(client)
    @client = client
  end

  def put(resource, overwrite = true)
    path = resource.import_path
    logger.debug("Attempting PUT", :url_path => path, :file_path => resource.content_path)
    if !overwrite && content_exists?(path)
      logger.debug("Found existing Elasticsearch resource.", :resource => path)
      return
    end
    put_overwrite(path, resource.content)
  end

  private

  def put_overwrite(path, content)
    if content_exists?(path)
      response = @client.delete(path)
    end
    # hmmm, versioning?
    @client.put(path, content).status == 201
  end

  def content_exists?(path)
    response = @client.head(path)
    response.status >= 200 && response.status < 300
  end

end end end # class LogStash::Modules::Importer

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
logstash-core-6.7.1-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-7.0.0.rc2-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-7.0.0.rc1-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.7.0-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.6.2-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.6.1-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-7.0.0.beta1-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.6.0-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-7.0.0.alpha2-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.5.4-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.5.3-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.5.2-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.5.1-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-7.0.0.alpha1-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.5.0-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.4.3-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.4.2-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.4.1-java lib/logstash/modules/elasticsearch_importer.rb
logstash-core-6.4.0-java lib/logstash/modules/elasticsearch_importer.rb