logstash-integration-elastic_enterprise_search 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 2f0c1374a08bc723fd7452e115e7372c8e0bb416c6e7e2e6d10769b15b571b7c
         | 
| 4 | 
            +
              data.tar.gz: 53debfd033dae11b5d5c80809c51c8a6db5997c80f5eeb3901414932c0d48e17
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: dcb96b16bafc1b85a0e4e375925b8d6ad5e6f3366044e1ea13b4318ab0c5b75b84d342fe76077ddcc30f4b0423f0e47028b474d2012e34570357a07ad9ff94e8
         | 
| 7 | 
            +
              data.tar.gz: fab4c000386cca49902de6f11aa392d95032b4fd7897826fc7515dac40012315c2356d1c624485b4689faf229b7455176845ac40cdf3c298e596ad517a545a93
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            ## 2.2.1
         | 
| 2 | 
            +
             - Fix, change implementation of connectivity check method to be compatible with version `v8.0+` of Workplace Search [#16](https://github.com/logstash-plugins/logstash-integration-elastic_enterprise_search/pull/16) 
         | 
| 1 3 |  | 
| 2 4 | 
             
            ## 2.2.0
         | 
| 3 5 | 
             
             - Feature, switch the connection library to elastic-enterprise-search [#3](https://github.com/logstash-plugins/logstash-integration-elastic_enterprise_search/pull/3)
         | 
| @@ -101,6 +101,7 @@ class LogStash::Outputs::ElasticWorkplaceSearch < LogStash::Outputs::Base | |
| 101 101 | 
             
              end
         | 
| 102 102 |  | 
| 103 103 | 
             
              def check_connection!
         | 
| 104 | 
            -
                 | 
| 104 | 
            +
                # This is the preferred way to check compatibility across different versions of Workplace Search service.
         | 
| 105 | 
            +
                @client.index_documents(@source, {:documents => []})
         | 
| 105 106 | 
             
              end
         | 
| 106 107 | 
             
            end
         | 
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            Gem::Specification.new do |s|
         | 
| 2 2 | 
             
              s.name          = 'logstash-integration-elastic_enterprise_search'
         | 
| 3 | 
            -
              s.version         = '2.2. | 
| 3 | 
            +
              s.version         = '2.2.1'
         | 
| 4 4 | 
             
              s.licenses        = ['Apache-2.0']
         | 
| 5 5 | 
             
              s.summary         = "Integration with Elastic Enterprise Search - output plugins"
         | 
| 6 6 | 
             
              s.description     = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline "+
         | 
| @@ -8,25 +8,68 @@ require "base64" | |
| 8 8 |  | 
| 9 9 | 
             
            describe "indexing against running Workplace Search", :integration => true do
         | 
| 10 10 |  | 
| 11 | 
            +
              def is_version7?
         | 
| 12 | 
            +
                ENV['ELASTIC_STACK_VERSION'].strip.start_with?("7")
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 11 15 | 
             
              let(:url) { ENV['ENTERPRISE_SEARCH_URL'] }
         | 
| 12 16 | 
             
              let(:auth) { Base64.strict_encode64("#{ENV['ENTERPRISE_SEARCH_USERNAME']}:#{ENV['ENTERPRISE_SEARCH_PASSWORD']}")}
         | 
| 13 17 | 
             
              let(:source) do
         | 
| 18 | 
            +
                if is_version7?
         | 
| 19 | 
            +
                  response = Faraday.get(
         | 
| 20 | 
            +
                    "#{url}/api/ws/v1/whoami",
         | 
| 21 | 
            +
                    {"get_token" => true},
         | 
| 22 | 
            +
                    {"Content-Type" => "application/json",
         | 
| 23 | 
            +
                    "Accept" => "application/json",
         | 
| 24 | 
            +
                    "Authorization" => "Basic #{auth}"}
         | 
| 25 | 
            +
                  )
         | 
| 26 | 
            +
                  JSON.load(response.body)
         | 
| 27 | 
            +
                else
         | 
| 28 | 
            +
                  # Workplace Search v8.0+ provides the api_tokens API to create or retrieve
         | 
| 29 | 
            +
                  # the key to be use as access_token
         | 
| 30 | 
            +
                  conn = Faraday.new(url: url)
         | 
| 31 | 
            +
                  conn.basic_auth(ENV['ENTERPRISE_SEARCH_USERNAME'], ENV['ENTERPRISE_SEARCH_PASSWORD'])
         | 
| 32 | 
            +
                  response = conn.post('/ws/org/api_tokens',
         | 
| 33 | 
            +
                                        '{"name":"ls-integration-test-key"}',
         | 
| 34 | 
            +
                                        {"Content-Type" => "application/json", "Accept" => "application/json"})
         | 
| 35 | 
            +
                  create_response_json = JSON.load(response.body)
         | 
| 36 | 
            +
                  if create_response_json.has_key?("errors") && create_response_json["errors"].include?("Name is already taken")
         | 
| 37 | 
            +
                    # when a key with the name already exists, retrieve it
         | 
| 38 | 
            +
                    response = conn.get('/ws/org/api_tokens', nil,  {"Content-Type" => "application/json", "Accept" => "application/json"})
         | 
| 39 | 
            +
                    retrieve_token_response_json = JSON.load(response.body)
         | 
| 40 | 
            +
                    response_json = retrieve_token_response_json["results"].find {|res| res["id"] == "ls-integration-test-key"}
         | 
| 41 | 
            +
                  else
         | 
| 42 | 
            +
                    response_json = create_response_json
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  conn.close
         | 
| 46 | 
            +
                  response_json
         | 
| 47 | 
            +
                end
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
              let(:access_token) do
         | 
| 50 | 
            +
                if is_version7?
         | 
| 51 | 
            +
                  source.fetch("access_token")
         | 
| 52 | 
            +
                else
         | 
| 53 | 
            +
                  source.fetch("key")
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
              end
         | 
| 56 | 
            +
              let(:source_id) do
         | 
| 14 57 | 
             
                response = Faraday.post(
         | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
                JSON.load(response.body)
         | 
| 58 | 
            +
                      "#{url}/api/ws/v1/sources",
         | 
| 59 | 
            +
                       JSON.dump("service_type" => "custom", "name" => "whatever"),
         | 
| 60 | 
            +
                      {"Content-Type" => "application/json",
         | 
| 61 | 
            +
                      "Accept" => "application/json",
         | 
| 62 | 
            +
                      "Authorization" => "Bearer #{access_token}"}
         | 
| 63 | 
            +
                    )
         | 
| 64 | 
            +
                source_response_json = JSON.load(response.body)
         | 
| 65 | 
            +
                source_response_json.fetch("id")
         | 
| 22 66 | 
             
              end
         | 
| 23 | 
            -
              let(:source_id) { source.fetch("id") }
         | 
| 24 67 |  | 
| 25 68 | 
             
              let(:config) do
         | 
| 26 69 | 
             
                {
         | 
| 27 70 | 
             
                  "url" => url,
         | 
| 28 71 | 
             
                  "source" => source_id,
         | 
| 29 | 
            -
                  "access_token" =>  | 
| 72 | 
            +
                  "access_token" => access_token
         | 
| 30 73 | 
             
                }
         | 
| 31 74 | 
             
              end
         | 
| 32 75 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: logstash-integration-elastic_enterprise_search
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2.2. | 
| 4 | 
            +
              version: 2.2.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Elastic
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2022-01- | 
| 11 | 
            +
            date: 2022-01-28 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              requirement: !ruby/object:Gem::Requirement
         |