Skip to content

Commit ff8533e

Browse files
hvac: add types for hvac.api.secrets_engines.consul
Types generated from the provided docstring on the class. The adapter on VaultApiBase already carries its response type, but VaultApiBase currently erases it with Adapter[Any]. We introduce a local generic without affecting the wider hvac API. - RawAdapter methods return Response. - JSONAdapter methods return Response | dict[Any, Any]. - Unparameterized Consul defaults to the standard JSON adapter union. Co-Authored-By: Factory Droid (GPT-5.6 Sol)
1 parent a746e49 commit ff8533e

1 file changed

Lines changed: 27 additions & 9 deletions

File tree

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
1+
from typing import Any, Final, Generic, TypeVar
2+
3+
from hvac.adapters import Adapter
14
from hvac.api.vault_api_base import VaultApiBase
5+
from requests import Response
6+
7+
DEFAULT_MOUNT_POINT: Final = "consul"
28

3-
DEFAULT_MOUNT_POINT: str
9+
_R = TypeVar("_R", default=Response | dict[Any, Any])
410

5-
class Consul(VaultApiBase):
6-
def configure_access(self, address, token, scheme=None, mount_point="consul"): ...
11+
# TODO: Make `hvac.api.vault_api_base.VaultApiBase` generic, and eventually propagate all the way from:
12+
# - `hvac.api.secrets_engines.SecretsEngines`
13+
# - `hvac.v1.Client`
14+
class Consul(VaultApiBase, Generic[_R]):
15+
def __init__(self, adapter: Adapter[_R]) -> None: ...
16+
def configure_access(self, address: str, token: str, scheme: str | None = None, mount_point: str = "consul") -> _R: ...
717
def create_or_update_role(
8-
self, name, policy=None, policies=None, token_type=None, local=None, ttl=None, max_ttl=None, mount_point="consul"
9-
): ...
10-
def read_role(self, name, mount_point="consul"): ...
11-
def list_roles(self, mount_point="consul"): ...
12-
def delete_role(self, name, mount_point="consul"): ...
13-
def generate_credentials(self, name, mount_point="consul"): ...
18+
self,
19+
name: str,
20+
policy: str | None = None,
21+
policies: list[str] | None = None,
22+
token_type: str | None = None,
23+
local: bool | None = None,
24+
ttl: str | None = None,
25+
max_ttl: str | None = None,
26+
mount_point: str = "consul",
27+
) -> _R: ...
28+
def read_role(self, name: str, mount_point: str = "consul") -> _R: ...
29+
def list_roles(self, mount_point: str = "consul") -> _R: ...
30+
def delete_role(self, name: str, mount_point: str = "consul") -> _R: ...
31+
def generate_credentials(self, name: str, mount_point: str = "consul") -> _R: ...

0 commit comments

Comments
 (0)