Go to the documentation of this file.
14 #include <initializer_list>
15 #include <type_traits>
38 std::unique_ptr<Implementation> impl;
57 virtual void accept(Implementation &)
const = 0;
80 void accept(Implementation &)
const override;
88 void accept(Implementation &)
const override;
94 class ProxiesOptionImplementation;
95 std::unique_ptr<ProxiesOptionImplementation> impl;
102 const std::initializer_list<std::pair<const std::string, std::string>> &proxies);
105 void accept(Implementation &)
const override;
111 class SSLOptionImplementation;
112 std::unique_ptr<SSLOptionImplementation> impl;
123 template <
typename... T>
132 virtual void accept(SSLOptionImplementation &)
const = 0;
137 explicit CertFile(std::string path): path(std::move(path)) {}
138 void accept(SSLOptionImplementation &)
const override;
144 explicit KeyFile(std::string path, std::string password = {})
145 : path(std::move(path)), password(std::move(password))
147 void accept(SSLOptionImplementation &)
const override;
149 std::string password;
154 explicit CaInfo(std::string path): path(std::move(path)) {}
155 void accept(SSLOptionImplementation &)
const override;
161 explicit VerifyHost(
bool verify): verify(verify) {}
162 void accept(SSLOptionImplementation &)
const override;
168 explicit VerifyPeer(
bool verify): verify(verify) {}
169 void accept(SSLOptionImplementation &)
const override;
177 void accept(Implementation &)
const override;
180 template <
typename T>
182 static_assert(std::is_base_of<SSLOptionType, T>::value,
183 "Record must be derived from SSLOptionType");
188 template<
typename T,
typename... TRest>
190 static_assert(std::is_base_of<SSLOptionType, T>::value,
191 "Record must be derived from SSLOptionType");
204 explicit Client(
const std::vector<std::string> &hostUrlList,
205 std::int32_t timeout = 6000);
215 const std::vector<std::string> &hostUrlList,
216 std::int32_t timeout,
217 const std::initializer_list<std::pair<const std::string, std::string>>& proxyUrlList);
227 template <
typename... Opts>
228 Client(
const std::vector<std::string> &hostUrlList,
232 optionConstructHelper(std::move(opts)...);
256 const std::string &urlPath,
257 const std::string &body);
270 cpr::Response
search(
const std::string &indexName,
271 const std::string &docType,
272 const std::string &body,
273 const std::string &routing = std::string());
286 cpr::Response
get(
const std::string &indexName,
287 const std::string &docType,
288 const std::string &
id = std::string(),
289 const std::string &routing = std::string());
303 cpr::Response
index(
const std::string &indexName,
304 const std::string &docType,
305 const std::string &
id,
306 const std::string &body,
307 const std::string &routing = std::string());
320 cpr::Response
remove(
const std::string &indexName,
321 const std::string &docType,
322 const std::string &
id,
323 const std::string &routing = std::string());
326 template <
typename T>
327 void optionConstructHelper(T&& opt) {
328 static_assert(std::is_base_of<ClientOption, T>::value,
329 "Record must be derived from ClientOption");
334 template <
typename T,
typename... TRest>
335 void optionConstructHelper(T&& opt, TRest&&... rest) {
336 static_assert(std::is_base_of<ClientOption, T>::value,
337 "Record must be derived from ClientOption");
338 optionConstructHelper(std::forward<T>(opt));
339 optionConstructHelper(std::move(rest)...);
Client(const std::vector< std::string > &hostUrlList, Opts &&... opts)
Definition: client.h:228
Helper class holding single value for ClientOption implementations.
Definition: client.h:62
void accept(SSLOptionImplementation &) const override
Visitor initiation to setup specific option by derived classes.
Client(const std::vector< std::string > &hostUrlList, std::int32_t timeout=6000)
Path to the certificate key file.
Definition: client.h:143
ProxiesOption(const std::initializer_list< std::pair< const std::string, std::string >> &proxies)
void accept(SSLOptionImplementation &) const override
Visitor initiation to setup specific option by derived classes.
The timeout [ms] setting for client connection.
Definition: client.h:76
Options to setup SSL for client connection.
Definition: client.h:109
void setSslOption(const SSLOptionType &)
Set single option - see SSLOptionType derived structs above.
void accept(SSLOptionImplementation &) const override
Visitor initiation to setup specific option by derived classes.
virtual void accept(Implementation &) const =0
HTTPMethod
Enum for kinds of supported HTTP methods in performRequest.
Definition: client.h:42
void accept(Implementation &) const override
SSLOption(T... args)
Definition: client.h:124
cpr::Response remove(const std::string &indexName, const std::string &docType, const std::string &id, const std::string &routing=std::string())
Flag whether to verify peer.
Definition: client.h:167
Flag whether to verify host.
Definition: client.h:160
cpr::Response index(const std::string &indexName, const std::string &docType, const std::string &id, const std::string &body, const std::string &routing=std::string())
cpr::Response search(const std::string &indexName, const std::string &docType, const std::string &body, const std::string &routing=std::string())
virtual void accept(SSLOptionImplementation &) const =0
Visitor initiation to setup specific option by derived classes.
void optSetter(T &&t)
Helper method to setup ssl options with SSLOptionType instances.
Definition: client.h:181
The elasticlient namespace.
Definition: bulk.h:15
Proxies option for client connection.
Definition: client.h:92
void accept(SSLOptionImplementation &) const override
Visitor initiation to setup specific option by derived classes.
cpr::Response performRequest(HTTPMethod method, const std::string &urlPath, const std::string &body)
void accept(Implementation &) const override
cpr::Response get(const std::string &indexName, const std::string &docType, const std::string &id=std::string(), const std::string &routing=std::string())
Path to the custom CA bundle.
Definition: client.h:153
Path to the certificate.
Definition: client.h:136
Abstract class for various options passed to Client constructor.
Definition: client.h:51
The connection timeout [ms] for client.
Definition: client.h:84
Abstract base class for specific SSL options.
Definition: client.h:129
void accept(Implementation &) const override
void accept(SSLOptionImplementation &) const override
Visitor initiation to setup specific option by derived classes.
Class for managing Elasticsearch connection in one Elasticsearch cluster.
Definition: client.h:35
void optSetter(T &&t, TRest &&... ts)
Helper method to setup ssl options with SSLOptionType instances.
Definition: client.h:189
void setClientOption(const ClientOption &opt)
void accept(Implementation &) const override