30 #include "aossl/core/include/base_http_client.h" 31 #include "aossl/core/include/buffers.h" 33 #include "Poco/StreamCopier.h" 35 #include "Poco/Net/Context.h" 36 #include "Poco/Net/HTTPRequest.h" 37 #include "Poco/Net/HTTPSClientSession.h" 38 #include "Poco/Net/HTTPResponse.h" 39 #include "Poco/Net/SSLException.h" 41 #include "consul_interface.h" 44 #ifndef AOSSL_CONSUL_INCLUDE_CONSUL_ADMIN_H_ 45 #define AOSSL_CONSUL_INCLUDE_CONSUL_ADMIN_H_ 59 inline static bool is_base64(
unsigned char c) {
60 return (isalnum(c) || (c ==
'+') || (c ==
'/'));
83 ConsulAdmin(std::string& caddr,
int tout, std::string& cert) :
\ 88 ConsulAdmin(std::string& caddr,
int tout, std::string& cert, std::string& token) :
\ 148 std::string url =
"/v1/kv/";
149 url = url.append(key);
157 std::string url =
"/v1/kv/";
158 url = url.append(key);
166 std::string url =
"/v1/kv/";
167 url = url.append(key);
180 #endif // AOSSL_CONSUL_INCLUDE_CONSUL_ADMIN_H_ StringBuffer * services_dc(std::string data_center)
Query the catalog for the services in a particular datacenter.
StringBuffer * agent_info()
Query the local agent for it's info.
A Structure for holding a single value.
Definition: buffers.h:42
void get_opt(std::string key, StringBuffer &val)
Get an option by key.
Definition: consul_admin.h:165
StringBuffer * healthy_services()
Query for healthy services only.
StringBuffer * nodes_dc(std::string data_center)
Query the catalog for the nodes in a particular datacenter.
bool set_config_value(std::string key, std::string val)
Set a configuration value.
bool del_config_value(std::string key)
Delete a configuration value.
BaseHttpClient(std::string &vaddr, int tout, std::string &cert)
Construct a secured HTTP Client.
Definition: base_http_client.h:123
StringBuffer * services()
Query the local agent for services registered.
Definition: consul_admin.h:58
StringBuffer * base64_decode_safe(std::string const &encoded_string)
Convinience Method for base64 decoding.
The Consul Administrator, who handles configuration & service discovery.
Definition: consul_interface.h:115
void set_acl_token(std::string token_name, std::string new_token)
Add an ACL Token.
Definition: base_http_client.h:160
A Service class which can be registered with Consul for each app instance.
Definition: consul_interface.h:57
StringBuffer * nodes_service(std::string service)
Query the catalog for the nodes running a particular service.
bool success
Success flag.
Definition: buffers.h:35
bool register_service(const ServiceInterface &s)
Register the Service.
void get_by_reference(std::string &query_url, AOSSL::StringBuffer &ret_buffer)
Execute a Get query.
Definition: base_http_client.h:148
StringBuffer * datacenters()
Query the catalog for datacenters.
void load_config()
Re-load configuration.
Definition: consul_admin.h:173
StringBuffer * get_opt(std::string key)
Get an option by key.
Definition: consul_admin.h:156
StringBuffer * services_node(std::string node, std::string data_center)
Query the catalog for the services provided by a particular node.
void base64_decode_by_reference(std::string const &encoded_string, StringBuffer &ret_buffer)
Convinience Method for base64 decoding.
bool opt_exist(std::string key)
Does a key exist?
Definition: consul_admin.h:147
bool deregister_service(const ServiceInterface &s)
Deregister the Service.
Base HTTP Client.
Definition: base_http_client.h:46
void add_acl_token(std::string &token)
Add an ACL Token to the Consul Admin.
Definition: consul_admin.h:68