consul.api.config module¶
- class consul.api.config.Config(agent)[source]¶
Bases:
objectGeneric CRUD for Consul config entries (service-defaults, service-router, service-splitter, service-resolver, service-intentions, ingress-gateway, terminating-gateway, proxy-defaults, mesh, exported-services, api-gateway, http-route, tcp-route, inline-certificate, file-system-certificate, and others) via the single /v1/config endpoint. Required ACLs and the body schema vary by kind – see Consul’s config entry reference for the schema of each kind; this client does not model kind-specific fields.
- set(kind, name, config_entry=None, token=None, dc=None, cas=None)[source]¶
Creates or updates the config entry of kind named name. :param kind: The config entry kind, e.g. “service-defaults”. :param name: The config entry name. :param config_entry: The kind-specific body; merged with Kind/Name. :param token: token with the write capability required by kind (varies by kind) :param dc: Optional datacenter to target; defaults to the client’s own dc. :param cas: Optional ModifyIndex to check-and-set against; the write only
applies if it still matches the entry’s current ModifyIndex.
- get(kind, name, token=None, dc=None)[source]¶
Reads the config entry of kind named name. :param token: token with the read capability required by kind :param dc: Optional datacenter to target; defaults to the client’s own dc.
- Parameters:
- Return type:
- list(kind, token=None, dc=None, filter_expr=None)[source]¶
Lists all config entries of kind. :param token: token with the read capability required by kind :param dc: Optional datacenter to target; defaults to the client’s own dc. :param filter_expr: Optional bexpr filter expression.
- Parameters:
- Return type:
builtins.list[ConfigEntry]
- delete(kind, name, token=None, dc=None, cas=None)[source]¶
Deletes the config entry of kind named name. :param token: token with the write capability required by kind :param dc: Optional datacenter to target; defaults to the client’s own dc. :param cas: Optional ModifyIndex to check-and-set against; the delete only
applies if it still matches the entry’s current ModifyIndex. Without it, deletion is unconditional (Consul returns an empty object rather than a boolean in that case, hence the two different callbacks below).