elastic-enterprise-search 7.10.0.beta.1 → 7.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ci/jobs/elastic+enterprise-search-ruby+7.10.0.beta.1.yml +12 -0
- data/.ci/test-matrix.yml +2 -1
- data/.github/workflows/testing.yml +1 -1
- data/.gitignore +1 -0
- data/CONTRIBUTING.md +43 -0
- data/Gemfile +1 -0
- data/README.md +7 -225
- data/Rakefile +1 -24
- data/docs/guide/app-search-api.asciidoc +172 -0
- data/docs/guide/connecting.asciidoc +125 -0
- data/docs/guide/development.asciidoc +42 -0
- data/docs/guide/enterprise-search-api.asciidoc +46 -0
- data/docs/guide/index.asciidoc +17 -0
- data/docs/guide/installation.asciidoc +18 -0
- data/docs/guide/overview.asciidoc +59 -0
- data/docs/guide/workplace-search-api.asciidoc +121 -0
- data/elastic-enterprise-search.gemspec +5 -4
- data/lib/elastic/app-search/api/add_meta_engine_source.rb +7 -4
- data/lib/elastic/app-search/api/api_logs.rb +15 -16
- data/lib/elastic/app-search/api/count_analytics.rb +7 -5
- data/lib/elastic/app-search/api/create_curation.rb +8 -6
- data/lib/elastic/app-search/api/create_engine.rb +9 -7
- data/lib/elastic/app-search/api/create_synonym_set.rb +6 -5
- data/lib/elastic/app-search/api/curation.rb +6 -5
- data/lib/elastic/app-search/api/delete_curation.rb +6 -5
- data/lib/elastic/app-search/api/delete_documents.rb +7 -4
- data/lib/elastic/app-search/api/delete_engine.rb +5 -3
- data/lib/elastic/app-search/api/delete_meta_engine_source.rb +7 -4
- data/lib/elastic/app-search/api/delete_synonym_set.rb +6 -5
- data/lib/elastic/app-search/api/documents.rb +7 -4
- data/lib/elastic/app-search/api/engine.rb +5 -3
- data/lib/elastic/app-search/api/index_documents.rb +7 -4
- data/lib/elastic/app-search/api/list_curations.rb +7 -5
- data/lib/elastic/app-search/api/list_documents.rb +7 -5
- data/lib/elastic/app-search/api/list_engines.rb +7 -5
- data/lib/elastic/app-search/api/list_synonym_sets.rb +7 -5
- data/lib/elastic/app-search/api/log_clickthrough.rb +10 -7
- data/lib/elastic/app-search/api/multi_search.rb +8 -7
- data/lib/elastic/app-search/api/put_curation.rb +9 -8
- data/lib/elastic/app-search/api/put_documents.rb +7 -4
- data/lib/elastic/app-search/api/put_schema.rb +7 -4
- data/lib/elastic/app-search/api/put_search_settings.rb +6 -3
- data/lib/elastic/app-search/api/put_synonym_set.rb +7 -7
- data/lib/elastic/app-search/api/query_suggestion.rb +8 -6
- data/lib/elastic/app-search/api/reset_search_settings.rb +5 -3
- data/lib/elastic/app-search/api/schema.rb +6 -4
- data/lib/elastic/app-search/api/search.rb +5 -3
- data/lib/elastic/app-search/api/search_settings.rb +6 -4
- data/lib/elastic/app-search/api/synonym_set.rb +6 -5
- data/lib/elastic/app-search/api/top_clicks_analytics.rb +9 -7
- data/lib/elastic/app-search/api/top_queries_analytics.rb +8 -6
- data/lib/elastic/app-search/app_search.rb +19 -2
- data/lib/elastic/enterprise-search/api/health.rb +6 -1
- data/lib/elastic/enterprise-search/api/put_read_only.rb +5 -1
- data/lib/elastic/enterprise-search/api/read_only.rb +6 -1
- data/lib/elastic/enterprise-search/api/stats.rb +6 -2
- data/lib/elastic/enterprise-search/api/version.rb +6 -1
- data/lib/elastic/enterprise-search/client.rb +15 -2
- data/lib/elastic/enterprise-search/request.rb +25 -13
- data/lib/elastic/enterprise-search/utils.rb +5 -6
- data/lib/elastic/enterprise-search/version.rb +1 -1
- data/lib/elastic/enterprise_search.rb +1 -1
- data/lib/elastic/workplace-search/api/add_user_permissions.rb +10 -9
- data/lib/elastic/workplace-search/api/create_analytics_event.rb +59 -0
- data/lib/elastic/workplace-search/api/create_external_identity.rb +9 -7
- data/lib/elastic/workplace-search/api/delete_documents.rb +9 -7
- data/lib/elastic/workplace-search/api/delete_external_identity.rb +10 -6
- data/lib/elastic/workplace-search/api/external_identity.rb +10 -6
- data/lib/elastic/workplace-search/api/index_documents.rb +11 -8
- data/lib/elastic/workplace-search/api/list_external_identities.rb +11 -7
- data/lib/elastic/workplace-search/api/list_permissions.rb +11 -7
- data/lib/elastic/workplace-search/api/put_external_identity.rb +10 -9
- data/lib/elastic/workplace-search/api/put_user_permissions.rb +10 -9
- data/lib/elastic/workplace-search/api/remove_user_permissions.rb +10 -9
- data/lib/elastic/workplace-search/api/search.rb +19 -1
- data/lib/elastic/workplace-search/api/user_permissions.rb +10 -6
- data/lib/elastic/workplace-search/workplace_search.rb +26 -1
- data/spec/app-search/api_curations_spec.rb +97 -0
- data/spec/app-search/api_documents_spec.rb +20 -6
- data/spec/app-search/api_engines_spec.rb +4 -4
- data/{lib/generator/templates/_license.erb → spec/app-search/api_log_clickthrough_spec.rb} +18 -0
- data/spec/app-search/api_meta_engines_spec.rb +72 -0
- data/spec/app-search/api_query_suggestion_spec.rb +39 -0
- data/spec/app-search/api_schema_spec.rb +17 -3
- data/spec/app-search/api_search_settings_spec.rb +76 -0
- data/spec/app-search/api_synonyms_spec.rb +79 -0
- data/spec/app-search/client_spec.rb +20 -0
- data/spec/enterprise-search/client_spec.rb +11 -0
- data/spec/enterprise-search/request_spec.rb +22 -0
- data/spec/enterprise-search/utils_spec.rb +46 -0
- data/spec/fixtures/vcr/app_search/add_meta_engine_source.yml +109 -0
- data/spec/fixtures/vcr/app_search/api_documents.yml +56 -0
- data/spec/fixtures/vcr/app_search/{index_documents.yml → api_index_documents.yml} +11 -10
- data/spec/fixtures/vcr/app_search/api_log_clickthrough.yml +54 -0
- data/spec/fixtures/vcr/app_search/api_put_schema.yml +109 -0
- data/spec/fixtures/vcr/app_search/api_put_search_settings.yml +56 -0
- data/spec/fixtures/vcr/app_search/api_query_suggestion.yml +59 -0
- data/spec/fixtures/vcr/app_search/api_reset_search_settings.yml +56 -0
- data/spec/fixtures/vcr/app_search/{schema.yml → api_schema.yml} +12 -11
- data/spec/fixtures/vcr/app_search/api_search_settings.yml +56 -0
- data/spec/fixtures/vcr/app_search/create_curation.yml +113 -0
- data/spec/fixtures/vcr/{create_engine.yml → app_search/create_engine.yml} +0 -0
- data/spec/fixtures/vcr/app_search/create_meta_engine.yml +56 -0
- data/spec/fixtures/vcr/app_search/create_synonym_set.yml +56 -0
- data/spec/fixtures/vcr/app_search/delete_curation.yml +56 -0
- data/spec/fixtures/vcr/{delete_engine.yml → app_search/delete_engine.yml} +0 -0
- data/spec/fixtures/vcr/app_search/delete_meta_engine_source.yml +56 -0
- data/spec/fixtures/vcr/app_search/delete_synonym_set.yml +56 -0
- data/spec/fixtures/vcr/app_search/get_curation.yml +56 -0
- data/spec/fixtures/vcr/{get_engine.yml → app_search/get_engine.yml} +0 -0
- data/spec/fixtures/vcr/app_search/list_curations.yml +56 -0
- data/spec/fixtures/vcr/{list_engines.yml → app_search/list_engines.yml} +0 -0
- data/spec/fixtures/vcr/app_search/list_synonym_sets.yml +56 -0
- data/spec/fixtures/vcr/app_search/multi_query_search.yml +2 -2
- data/spec/fixtures/vcr/app_search/put_curation.yml +113 -0
- data/spec/fixtures/vcr/app_search/put_synonym_set.yml +56 -0
- data/spec/fixtures/vcr/app_search/synonym_set.yml +56 -0
- data/spec/fixtures/vcr/{add_user_permissions.yml → workplace_search/add_user_permissions.yml} +11 -9
- data/spec/fixtures/vcr/{clear_user_permissions.yml → workplace_search/clear_user_permissions.yml} +11 -9
- data/spec/fixtures/vcr/workplace_search/create_analytics_event.yml +55 -0
- data/spec/fixtures/vcr/workplace_search/create_external_identity.yml +53 -0
- data/spec/fixtures/vcr/{delete_documents.yml → workplace_search/delete_documents.yml} +11 -9
- data/spec/fixtures/vcr/workplace_search/delete_external_identity.yml +53 -0
- data/spec/fixtures/vcr/{index_documents.yml → workplace_search/index_documents.yml} +11 -9
- data/spec/fixtures/vcr/workplace_search/list_external_identities.yml +53 -0
- data/spec/fixtures/vcr/{list_permissions.yml → workplace_search/list_permissions.yml} +11 -9
- data/spec/fixtures/vcr/workplace_search/oauth_request_token.yml +57 -0
- data/spec/fixtures/vcr/workplace_search/put_external_identity.yml +53 -0
- data/spec/fixtures/vcr/{put_user_permissions.yml → workplace_search/put_user_permissions.yml} +22 -18
- data/spec/fixtures/vcr/{remove_user_permissions.yml → workplace_search/remove_user_permissions.yml} +11 -9
- data/spec/fixtures/vcr/workplace_search/retrieve_external_identity.yml +53 -0
- data/spec/fixtures/vcr/workplace_search/search_request.yml +60 -0
- data/spec/fixtures/vcr/{user_permissions_empty.yml → workplace_search/user_permissions_empty.yml} +11 -9
- data/spec/integration/enterprise_search_api_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -0
- data/spec/workplace-search/client_spec.rb +10 -2
- data/spec/workplace-search/create_analytics_event_spec.rb +59 -0
- data/spec/workplace-search/documents_spec.rb +80 -0
- data/spec/workplace-search/external_identities_spec.rb +84 -0
- data/spec/workplace-search/{api_spec.rb → permissions_spec.rb} +14 -66
- data/spec/workplace-search/search_spec.rb +53 -0
- metadata +96 -36
- data/lib/generator/documentation_helper.rb +0 -94
- data/lib/generator/endpoint_generator.rb +0 -119
- data/lib/generator/parameters_exceptions.rb +0 -40
- data/lib/generator/parameters_helper.rb +0 -144
- data/lib/generator/templates/endpoint_template.erb +0 -29
- data/lib/generator/templates/spec_template.erb +0 -1
- data/lib/generator/utils.rb +0 -70
- data/spec/fixtures/vcr/create_document.yml +0 -54
@@ -25,8 +25,8 @@ module Elastic
|
|
25
25
|
#
|
26
26
|
# @param engine_name [String] (*Required*)
|
27
27
|
# @param arguments [Hash] endpoint arguments
|
28
|
-
# @option body
|
29
|
-
#
|
28
|
+
# @option arguments [Object] :body Search request parameters
|
29
|
+
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
30
30
|
#
|
31
31
|
# @see https://www.elastic.co/guide/en/app-search/current/search.html#search-single
|
32
32
|
#
|
@@ -34,12 +34,14 @@ module Elastic
|
|
34
34
|
raise ArgumentError, "Required parameter 'engine_name' missing" unless engine_name
|
35
35
|
|
36
36
|
body = arguments.delete(:body) || {}
|
37
|
+
headers = arguments.delete(:headers) || {}
|
37
38
|
|
38
39
|
request(
|
39
40
|
:post,
|
40
41
|
"api/as/v1/engines/#{engine_name}/search/",
|
41
42
|
arguments,
|
42
|
-
body
|
43
|
+
body,
|
44
|
+
headers
|
43
45
|
)
|
44
46
|
end
|
45
47
|
end
|
@@ -21,12 +21,12 @@ module Elastic
|
|
21
21
|
module EnterpriseSearch
|
22
22
|
module AppSearch
|
23
23
|
module Actions
|
24
|
-
# Searchsettings -
|
24
|
+
# Searchsettings - Retrieve current search settings for the engine
|
25
25
|
#
|
26
26
|
# @param engine_name [String] (*Required*)
|
27
27
|
# @param arguments [Hash] endpoint arguments
|
28
|
-
# @option body
|
29
|
-
#
|
28
|
+
# @option arguments [Hash] :body The request body
|
29
|
+
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
30
30
|
#
|
31
31
|
# @see https://www.elastic.co/guide/en/app-search/current/search-settings.html#search-settings-show
|
32
32
|
#
|
@@ -34,12 +34,14 @@ module Elastic
|
|
34
34
|
raise ArgumentError, "Required parameter 'engine_name' missing" unless engine_name
|
35
35
|
|
36
36
|
body = arguments.delete(:body) || {}
|
37
|
+
headers = arguments.delete(:headers) || {}
|
37
38
|
|
38
39
|
request(
|
39
40
|
:get,
|
40
41
|
"api/as/v1/engines/#{engine_name}/search_settings/",
|
41
42
|
arguments,
|
42
|
-
body
|
43
|
+
body,
|
44
|
+
headers
|
43
45
|
)
|
44
46
|
end
|
45
47
|
end
|
@@ -25,9 +25,9 @@ module Elastic
|
|
25
25
|
#
|
26
26
|
# @param engine_name [String] (*Required*)
|
27
27
|
# @param arguments [Hash] endpoint arguments
|
28
|
-
# @option
|
29
|
-
# @option body
|
30
|
-
#
|
28
|
+
# @option arguments [String] :synonym_set_id (*Required*)
|
29
|
+
# @option arguments [Hash] :body The request body
|
30
|
+
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
31
31
|
#
|
32
32
|
# @see https://www.elastic.co/guide/en/app-search/current/synonyms.html#synonyms-list-one
|
33
33
|
#
|
@@ -36,14 +36,15 @@ module Elastic
|
|
36
36
|
raise ArgumentError, "Required parameter 'synonym_set_id' missing" unless arguments[:synonym_set_id]
|
37
37
|
|
38
38
|
synonym_set_id = arguments[:synonym_set_id]
|
39
|
-
|
40
39
|
body = arguments.delete(:body) || {}
|
40
|
+
headers = arguments.delete(:headers) || {}
|
41
41
|
|
42
42
|
request(
|
43
43
|
:get,
|
44
44
|
"api/as/v1/engines/#{engine_name}/synonyms/#{synonym_set_id}/",
|
45
45
|
arguments,
|
46
|
-
body
|
46
|
+
body,
|
47
|
+
headers
|
47
48
|
)
|
48
49
|
end
|
49
50
|
end
|
@@ -25,12 +25,12 @@ module Elastic
|
|
25
25
|
#
|
26
26
|
# @param engine_name [String] (*Required*)
|
27
27
|
# @param arguments [Hash] endpoint arguments
|
28
|
-
# @option
|
29
|
-
# @option
|
30
|
-
# @option
|
31
|
-
# @option
|
32
|
-
# @option body
|
33
|
-
#
|
28
|
+
# @option arguments [String] :query Filter clicks over a search query
|
29
|
+
# @option arguments [String] :current_page The page to fetch. Defaults to 1
|
30
|
+
# @option arguments [String] :page_size The number of results per page
|
31
|
+
# @option arguments [Array] :filters Analytics filters
|
32
|
+
# @option arguments [Hash] :body The request body
|
33
|
+
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
34
34
|
#
|
35
35
|
# @see https://www.elastic.co/guide/en/app-search/current/clicks.html
|
36
36
|
#
|
@@ -38,12 +38,14 @@ module Elastic
|
|
38
38
|
raise ArgumentError, "Required parameter 'engine_name' missing" unless engine_name
|
39
39
|
|
40
40
|
body = arguments.delete(:body) || {}
|
41
|
+
headers = arguments.delete(:headers) || {}
|
41
42
|
|
42
43
|
request(
|
43
44
|
:get,
|
44
45
|
"api/as/v1/engines/#{engine_name}/analytics/clicks/",
|
45
46
|
arguments,
|
46
|
-
body
|
47
|
+
body,
|
48
|
+
headers
|
47
49
|
)
|
48
50
|
end
|
49
51
|
end
|
@@ -25,11 +25,11 @@ module Elastic
|
|
25
25
|
#
|
26
26
|
# @param engine_name [String] (*Required*)
|
27
27
|
# @param arguments [Hash] endpoint arguments
|
28
|
-
# @option
|
29
|
-
# @option
|
30
|
-
# @option
|
31
|
-
# @option body
|
32
|
-
#
|
28
|
+
# @option arguments [String] :current_page The page to fetch. Defaults to 1
|
29
|
+
# @option arguments [String] :page_size The number of results per page
|
30
|
+
# @option arguments [Array] :filters Analytics filters
|
31
|
+
# @option arguments [Hash] :body The request body
|
32
|
+
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
33
33
|
#
|
34
34
|
# @see https://www.elastic.co/guide/en/app-search/current/queries.html#queries-top-queries
|
35
35
|
#
|
@@ -37,12 +37,14 @@ module Elastic
|
|
37
37
|
raise ArgumentError, "Required parameter 'engine_name' missing" unless engine_name
|
38
38
|
|
39
39
|
body = arguments.delete(:body) || {}
|
40
|
+
headers = arguments.delete(:headers) || {}
|
40
41
|
|
41
42
|
request(
|
42
43
|
:get,
|
43
44
|
"api/as/v1/engines/#{engine_name}/analytics/queries/",
|
44
45
|
arguments,
|
45
|
-
body
|
46
|
+
body,
|
47
|
+
headers
|
46
48
|
)
|
47
49
|
end
|
48
50
|
end
|
@@ -17,6 +17,8 @@
|
|
17
17
|
|
18
18
|
# frozen_string_literal: true
|
19
19
|
|
20
|
+
require 'jwt'
|
21
|
+
|
20
22
|
module Elastic
|
21
23
|
module EnterpriseSearch
|
22
24
|
# App Search client for Enterprise Search.
|
@@ -37,9 +39,8 @@ module Elastic
|
|
37
39
|
class Client < Elastic::EnterpriseSearch::Client
|
38
40
|
include Elastic::EnterpriseSearch::AppSearch::Actions
|
39
41
|
include Elastic::EnterpriseSearch::AppSearch::Request
|
40
|
-
include Elastic::EnterpriseSearch::Utils
|
41
42
|
|
42
|
-
#
|
43
|
+
# Create a new Elastic::EnterpriseSearch::AppSearch::Client client
|
43
44
|
#
|
44
45
|
# @param options [Hash] a hash of configuration options
|
45
46
|
# @option options [String] :host_identifier A unique string that represents your account.
|
@@ -48,6 +49,22 @@ module Elastic
|
|
48
49
|
super(options)
|
49
50
|
end
|
50
51
|
|
52
|
+
SIGNED_KEY_ALGORITHM = 'HS256'
|
53
|
+
|
54
|
+
class << self
|
55
|
+
# Build a JWT for authentication
|
56
|
+
#
|
57
|
+
# @param [String] api_key the API Key to sign the request with
|
58
|
+
# @param [String] api_key_name the unique name for the API Key
|
59
|
+
# @option options see the {App Search API}[https://www.elastic.co/guide/en/app-search/current/authentication.html#authentication-signed] for supported search options.
|
60
|
+
#
|
61
|
+
# @return [String] the JWT to use for authentication
|
62
|
+
def create_signed_search_key(api_key, api_key_name, options = {})
|
63
|
+
payload = Elastic::EnterpriseSearch::Utils.symbolize_keys(options).merge(api_key_name: api_key_name)
|
64
|
+
JWT.encode(payload, api_key, SIGNED_KEY_ALGORITHM)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
51
68
|
def http_auth
|
52
69
|
@options[:http_auth]
|
53
70
|
end
|
@@ -23,14 +23,19 @@ module Elastic
|
|
23
23
|
# Health - Get information on the health of a deployment and basic statistics around resource usage
|
24
24
|
# Get information on the health of a deployment and basic statistics around resource usage
|
25
25
|
#
|
26
|
+
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
27
|
+
#
|
26
28
|
# @see https://www.elastic.co/guide/en/enterprise-search/current/monitoring-apis.html#health-api-example
|
27
29
|
#
|
28
30
|
def health(arguments = {})
|
31
|
+
headers = arguments.delete(:headers) || {}
|
32
|
+
|
29
33
|
request(
|
30
34
|
:get,
|
31
35
|
'api/ent/v1/internal/health/',
|
32
36
|
arguments,
|
33
|
-
{}
|
37
|
+
{},
|
38
|
+
headers
|
34
39
|
)
|
35
40
|
end
|
36
41
|
end
|
@@ -23,16 +23,20 @@ module Elastic
|
|
23
23
|
# Read-Only - Update the read-only flag's state
|
24
24
|
# Update the read-only flag's state
|
25
25
|
#
|
26
|
+
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
27
|
+
#
|
26
28
|
# @see https://www.elastic.co/guide/en/enterprise-search/current/read-only-api.html#setting-read-only-state
|
27
29
|
#
|
28
30
|
def put_read_only(arguments = {})
|
29
31
|
body = arguments.delete(:body) || {}
|
32
|
+
headers = arguments.delete(:headers) || {}
|
30
33
|
|
31
34
|
request(
|
32
35
|
:put,
|
33
36
|
'api/ent/v1/internal/read_only_mode/',
|
34
37
|
arguments,
|
35
|
-
body
|
38
|
+
body,
|
39
|
+
headers
|
36
40
|
)
|
37
41
|
end
|
38
42
|
end
|
@@ -23,14 +23,19 @@ module Elastic
|
|
23
23
|
# Read-Only - Get the read-only flag's state
|
24
24
|
# Get the read-only flag's state
|
25
25
|
#
|
26
|
+
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
27
|
+
#
|
26
28
|
# @see https://www.elastic.co/guide/en/enterprise-search/current/read-only-api.html#getting-read-only-state
|
27
29
|
#
|
28
30
|
def read_only(arguments = {})
|
31
|
+
headers = arguments.delete(:headers) || {}
|
32
|
+
|
29
33
|
request(
|
30
34
|
:get,
|
31
35
|
'api/ent/v1/internal/read_only_mode/',
|
32
36
|
arguments,
|
33
|
-
{}
|
37
|
+
{},
|
38
|
+
headers
|
34
39
|
)
|
35
40
|
end
|
36
41
|
end
|
@@ -24,16 +24,20 @@ module Elastic
|
|
24
24
|
# Get information about the resource usage of the application, the state of different internal queues, etc.
|
25
25
|
#
|
26
26
|
# @param arguments [Hash] endpoint arguments
|
27
|
-
# @option
|
27
|
+
# @option arguments [Array] :include Comma-separated list of stats to return
|
28
|
+
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
28
29
|
#
|
29
30
|
# @see https://www.elastic.co/guide/en/enterprise-search/current/monitoring-apis.html#stats-api-example
|
30
31
|
#
|
31
32
|
def stats(arguments = {})
|
33
|
+
headers = arguments.delete(:headers) || {}
|
34
|
+
|
32
35
|
request(
|
33
36
|
:get,
|
34
37
|
'api/ent/v1/internal/stats/',
|
35
38
|
arguments,
|
36
|
-
{}
|
39
|
+
{},
|
40
|
+
headers
|
37
41
|
)
|
38
42
|
end
|
39
43
|
end
|
@@ -23,14 +23,19 @@ module Elastic
|
|
23
23
|
# Version - Get version information for this server
|
24
24
|
# Get version information for this server
|
25
25
|
#
|
26
|
+
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
27
|
+
#
|
26
28
|
# @see https://www.elastic.co/guide/en/enterprise-search/current/management-apis.html
|
27
29
|
#
|
28
30
|
def version(arguments = {})
|
31
|
+
headers = arguments.delete(:headers) || {}
|
32
|
+
|
29
33
|
request(
|
30
34
|
:get,
|
31
35
|
'api/ent/v1/internal/version/',
|
32
36
|
arguments,
|
33
|
-
{}
|
37
|
+
{},
|
38
|
+
headers
|
34
39
|
)
|
35
40
|
end
|
36
41
|
end
|
@@ -17,12 +17,22 @@
|
|
17
17
|
|
18
18
|
# frozen_string_literal: true
|
19
19
|
|
20
|
-
# TODO: CONFIG require 'elastic/enterprise-search/configuration'
|
21
20
|
require 'elastic/enterprise-search/request'
|
22
21
|
require 'elastic/enterprise-search/utils'
|
23
22
|
require 'elasticsearch-transport'
|
24
23
|
|
25
24
|
module Elastic
|
25
|
+
# If the version is X.X.X.pre/alpha/beta, use X.X.Xp for the meta-header:
|
26
|
+
def self.client_meta_version
|
27
|
+
regexp = /^([0-9]+\.[0-9]+\.[0-9]+)\.?([a-z0-9.-]+)?$/
|
28
|
+
match = Elastic::EnterpriseSearch::VERSION.match(regexp)
|
29
|
+
return "#{match[1]}p" if match[2]
|
30
|
+
|
31
|
+
Elastic::EnterpriseSearch::VERSION
|
32
|
+
end
|
33
|
+
|
34
|
+
META_HEADER_SERVICE_VERSION = [:ent, client_meta_version].freeze
|
35
|
+
|
26
36
|
module EnterpriseSearch
|
27
37
|
# API client for the {Elastic Enterprise Search API}[https://www.elastic.co/enterprise-search].
|
28
38
|
# This is the main client from which the Workplace Search and App Search clients inherit.
|
@@ -59,6 +69,8 @@ module Elastic
|
|
59
69
|
# @option options [String] :proxy url of proxy to use, ex: "http://localhost:8888"
|
60
70
|
# @option options [Boolean] :log Use the default logger (disabled by default)
|
61
71
|
# @option arguments [Object] :logger An instance of a Logger-compatible object
|
72
|
+
# @option enable_meta_header [Boolean] :enable_meta_header Enable sending the meta data header to Cloud.
|
73
|
+
# (Default: true)
|
62
74
|
def initialize(options = {})
|
63
75
|
@options = options
|
64
76
|
@transport = transport
|
@@ -73,7 +85,8 @@ module Elastic
|
|
73
85
|
request_timeout: overall_timeout,
|
74
86
|
transport_options: {
|
75
87
|
request: { open_timeout: open_timeout }
|
76
|
-
}
|
88
|
+
},
|
89
|
+
enable_meta_header: @options[:enable_meta_header] || true
|
77
90
|
)
|
78
91
|
end
|
79
92
|
|
@@ -29,30 +29,32 @@ module Elastic
|
|
29
29
|
|
30
30
|
# Module included in Elastic::Enterprise::Client for http requests.
|
31
31
|
module Request
|
32
|
-
def get(path, params = {})
|
33
|
-
request(:get, path, params)
|
32
|
+
def get(path, params = {}, headers = {})
|
33
|
+
request(:get, path, params, headers)
|
34
34
|
end
|
35
35
|
|
36
|
-
def post(path, params = {}, body = {})
|
37
|
-
request(:post, path, params, body)
|
36
|
+
def post(path, params = {}, body = {}, headers = {})
|
37
|
+
request(:post, path, params, body, headers)
|
38
38
|
end
|
39
39
|
|
40
|
-
def put(path, params = {}, body = {})
|
41
|
-
request(:put, path, params, body)
|
40
|
+
def put(path, params = {}, body = {}, headers = {})
|
41
|
+
request(:put, path, params, body, headers)
|
42
42
|
end
|
43
43
|
|
44
|
-
def delete(path, params = {})
|
45
|
-
request(:delete, path, params)
|
44
|
+
def delete(path, params = {}, headers = {})
|
45
|
+
request(:delete, path, params, headers)
|
46
46
|
end
|
47
47
|
|
48
48
|
# Construct and send a request to the API.
|
49
49
|
#
|
50
50
|
# @raise [Timeout::Error] when the timeout expires
|
51
|
-
def request(method, path, params = {}, body = {})
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
def request(method, path, params = {}, body = {}, headers = {})
|
52
|
+
meta_headers = { authorization: decide_authorization(params), user_agent: request_user_agent }
|
53
|
+
headers = if headers.nil? || !headers.is_a?(Hash)
|
54
|
+
meta_headers
|
55
|
+
else
|
56
|
+
headers.merge(meta_headers)
|
57
|
+
end
|
56
58
|
|
57
59
|
@transport.perform_request(method.to_s.upcase, path, params, body, headers)
|
58
60
|
end
|
@@ -74,6 +76,16 @@ module Elastic
|
|
74
76
|
meta << "elasticsearch-transport: #{Elasticsearch::Transport::VERSION}"
|
75
77
|
"#{ua} (#{meta.join('; ')})"
|
76
78
|
end
|
79
|
+
|
80
|
+
def decide_authorization(params)
|
81
|
+
if params[:grant_type] == 'authorization_code'
|
82
|
+
"Bearer #{params[:code]}"
|
83
|
+
elsif params[:access_token]
|
84
|
+
"Bearer #{params.delete(:access_token)}"
|
85
|
+
else
|
86
|
+
setup_authentication_header
|
87
|
+
end
|
88
|
+
end
|
77
89
|
end
|
78
90
|
end
|
79
91
|
end
|
@@ -31,12 +31,11 @@ module Elastic
|
|
31
31
|
output
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
34
|
+
def self.symbolize_keys(hash)
|
35
|
+
hash.each_with_object({}) do |(key, value), out|
|
36
|
+
new_key = key.respond_to?(:to_sym) ? key.to_sym : key
|
37
|
+
out[new_key] = value
|
38
|
+
end
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|