Class: Elastic::EnterpriseSearch::Client
- Inherits:
-
Object
- Object
- Elastic::EnterpriseSearch::Client
show all
- Includes:
- Actions, Request, Utils
- Defined in:
- lib/elastic/enterprise-search/client.rb
Overview
Constant Summary
collapse
- DEFAULT_TIMEOUT =
15
Constants included
from Utils
Utils::DEFAULT_HOST
Instance Method Summary
collapse
Methods included from Utils
#stringify_keys, symbolize_keys
Methods included from Actions
#health, #put_read_only, #read_only, #search_engines, #stats, #version
Methods included from Request
#basic_auth_header, #delete, #get, #post, #put, #request, #setup_authentication_header
Constructor Details
#initialize(options = {}) ⇒ Client
Create a new Elastic::EnterpriseSearch::Client client
66
67
68
69
|
# File 'lib/elastic/enterprise-search/client.rb', line 66
def initialize(options = {})
@options = options
@transport = transport
end
|
Instance Method Details
#adapter ⇒ Object
113
114
115
|
# File 'lib/elastic/enterprise-search/client.rb', line 113
def adapter
@options[:adapter]
end
|
#app_search(options = {}) ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/elastic/enterprise-search/client.rb', line 43
def app_search(options = {})
@app_search ||= Elastic::EnterpriseSearch::AppSearch::Client.new(
host: host,
http_auth: options[:http_auth],
transport: @transport
)
end
|
#host ⇒ Object
125
126
127
128
129
130
131
|
# File 'lib/elastic/enterprise-search/client.rb', line 125
def host
return DEFAULT_HOST unless @options[:host]
raise URI::InvalidURIError unless @options[:host] =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/
@options[:host]
end
|
#http_auth ⇒ Object
97
98
99
|
# File 'lib/elastic/enterprise-search/client.rb', line 97
def http_auth
@options[:http_auth] || { user: 'elastic', password: 'changeme' }
end
|
#http_auth=(http_auth) ⇒ Object
101
102
103
|
# File 'lib/elastic/enterprise-search/client.rb', line 101
def http_auth=(http_auth)
@options[:http_auth] = http_auth
end
|
#log ⇒ Object
105
106
107
|
# File 'lib/elastic/enterprise-search/client.rb', line 105
def log
@options[:log] || false
end
|
#logger ⇒ Object
109
110
111
|
# File 'lib/elastic/enterprise-search/client.rb', line 109
def logger
@options[:logger]
end
|
#open_timeout ⇒ Object
89
90
91
|
# File 'lib/elastic/enterprise-search/client.rb', line 89
def open_timeout
@options[:open_timeout] || DEFAULT_TIMEOUT
end
|
#overall_timeout ⇒ Object
93
94
95
|
# File 'lib/elastic/enterprise-search/client.rb', line 93
def overall_timeout
(@options[:overall_timeout] || DEFAULT_TIMEOUT).to_f
end
|
#trace ⇒ Object
121
122
123
|
# File 'lib/elastic/enterprise-search/client.rb', line 121
def trace
@options[:trace]
end
|
#tracer ⇒ Object
117
118
119
|
# File 'lib/elastic/enterprise-search/client.rb', line 117
def tracer
@options[:tracer]
end
|
#transport ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/elastic/enterprise-search/client.rb', line 71
def transport
@options[:transport] ||
Elastic::Transport::Client.new(
host: host,
log: log,
logger: logger,
request_timeout: overall_timeout,
adapter: adapter,
transport_options: {
request: { open_timeout: open_timeout },
headers: { user_agent: user_agent }
},
enable_meta_header: @options[:enable_meta_header] || true,
trace: trace,
tracer: tracer
)
end
|
#workplace_search(options = {}) ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/elastic/enterprise-search/client.rb', line 35
def workplace_search(options = {})
@workplace_search ||= Elastic::EnterpriseSearch::WorkplaceSearch::Client.new(
host: host,
http_auth: options[:http_auth],
transport: @transport
)
end
|