consul.base module

class consul.base.Response(code, headers, body)

Bases: tuple

Create new instance of Response(code, headers, body)

body

Alias for field number 2

code

Alias for field number 0

headers

Alias for field number 1

class consul.base.HTTPClient(host='127.0.0.1', port=8500, scheme='http', verify=True, cert=None)[source]

Bases: object

Parameters:
uri(path, params=None)[source]
Parameters:
abstractmethod get(callback, path, params=None, headers=None)[source]
Parameters:

headers (dict[str, str] | None)

abstractmethod put(callback, path, params=None, data='', headers=None)[source]
Parameters:
abstractmethod delete(callback, path, params=None, headers=None)[source]
Parameters:

headers (dict[str, str] | None)

abstractmethod post(callback, path, params=None, data='', headers=None)[source]
Parameters:
abstractmethod close()[source]
class consul.base.Consul(host=None, port=None, token=None, scheme=None, consistency='default', dc=None, verify=None, cert=None)[source]

Bases: object

token is an optional `ACL token`_. If supplied it will be used by default for all requests made with this client session. It’s still possible to override this token by passing a token explicitly for a request.

consistency sets the consistency mode to use by default for all reads that support the consistency option. It’s still possible to override this by passing explicitly for a given request. consistency can be either ‘default’, ‘consistent’ or ‘stale’.

dc is the datacenter that this agent will communicate with. By default the datacenter of the host is used.

verify is whether to verify the SSL certificate for HTTPS requests

cert client side certificates for HTTPS requests

Parameters:
  • host (str | None)

  • port (int | None)

  • token (str | None)

  • scheme (str | None)

  • consistency (str)

  • verify (bool | str | None)

abstractmethod http_connect(host, port, scheme, verify=True, cert=None)[source]
Parameters:
prepare_headers(token=None)[source]
Parameters:

token (str | None)

Return type:

dict[str, str]