patroni.request module¶
Facilities for handling communication with Patroni’s REST API.
- class patroni.request.HTTPSConnectionPool(host, port=None, strict=False, timeout=<object object>, maxsize=1, block=False, headers=None, retries=None, _proxy=None, _proxy_headers=None, key_file=None, cert_file=None, cert_reqs='CERT_REQUIRED', key_password=None, ca_certs='/etc/ssl/certs/ca-certificates.crt', ssl_version=None, assert_hostname=None, assert_fingerprint=None, ca_cert_dir=None, **conn_kw)¶
Bases:
HTTPSConnectionPool
- class patroni.request.PatroniRequest(config: Union[Config, Dict[str, Any]], insecure: Optional[bool] = None)¶
Bases:
object
Wrapper for performing requests to Patroni’s REST API.
Prepares the request manager with the configured settings before performing the request.
- reload_config(config: Union[Config, Dict[str, Any]]) None ¶
Apply config to request manager.
Configure these HTTP headers for requests:
authorization
: based on Patroni’ CTL or REST API authentication config;user-agent
: based onpatroni.utils.USER_AGENT
.
Also configure SSL related settings for requests:
ca_certs
is configured ifctl.cacert
orrestapi.cafile
is available;cert
,key
andkey_password
are configured ifctl.certfile
is available.
- Parameters:
config – Patroni YAML configuration.
- request(method: str, url: str, body: Optional[Any] = None, **kwargs: Any) HTTPResponse ¶
Perform an HTTP request.
- Parameters:
method – the HTTP method to be used, e.g.
GET
.url – the URL to be requested.
body – anything to be used as the request body.
kwargs – keyword arguments to be passed to
urllib3.PoolManager.request()
.
- Returns:
the response returned upon request.
- patroni.request.get(url: str, verify: bool = True, **kwargs: Any) HTTPResponse ¶
Perform an HTTP GET request.
Note
It uses
PatroniRequest
so all relevant configuration is applied before processing the request.- Parameters:
url – full URL for this GET request.
verify – if it should verify SSL certificates when processing the request.
- Returns:
the response returned from the request.