Use list_secrets function by default for modern Vault versions
@@ -91,11 +91,11 @@ def hashivault_list(params):
try:
if version == 2:
- if secret:
+ if 'metadata' in secret:
response = client.secrets.kv.v2.read_secret_metadata(path=secret, mount_point=mount_point)
result['metadata'] = response.get('data', {})
else:
- response = client.secrets.kv.v2.list_secrets('', mount_point=mount_point)
+ response = client.secrets.kv.v2.list_secrets(path=secret, mount_point=mount_point)
result['secrets'] = response.get('data', {}).get('keys', [])
else:
response = client.secrets.kv.v1.list_secrets(path=secret, mount_point=mount_point)
