Skip to content

Commit 5f54faa

Browse files
kesmit13claude
andcommitted
refactor: extract auth token logic into private method
Extracted authentication token retrieval logic into a private method to improve code reusability and maintainability across management modules. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 11d8f8d commit 5f54faa

File tree

6 files changed

+647
-648
lines changed

6 files changed

+647
-648
lines changed

singlestoredb/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from .management import (
2828
manage_cluster, manage_workspaces, manage_files, manage_regions,
2929
manage_teams, manage_private_connections, manage_audit_logs,
30-
manage_users, manage_metrics, manage_storage_dr,
30+
manage_users,
3131
)
3232
from .types import (
3333
Date, Time, Timestamp, DateFromTicks, TimeFromTicks, TimestampFromTicks,

singlestoredb/management/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
from .cluster import manage_cluster
44
from .files import manage_files
55
from .manager import get_token
6-
from .metrics import manage_metrics
76
from .private_connections import manage_private_connections
87
from .region import manage_regions
9-
from .storage_dr import manage_storage_dr
108
from .teams import manage_teams
119
from .users import manage_users
1210
from .workspace import get_organization

singlestoredb/management/audit_logs.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class AuditLog(object):
2525
--------
2626
:meth:`AuditLogsManager.list_audit_logs`
2727
:attr:`AuditLogsManager.audit_logs`
28+
2829
"""
2930

3031
def __init__(
@@ -107,6 +108,7 @@ def from_dict(cls, obj: Dict[str, Any]) -> 'AuditLog':
107108
Returns
108109
-------
109110
:class:`AuditLog`
111+
110112
"""
111113
return cls(
112114
log_id=obj['logID'],
@@ -141,6 +143,7 @@ class AuditLogsManager(Manager):
141143
Version of the API to use
142144
base_url : str, optional
143145
Base URL of the management API
146+
144147
"""
145148

146149
#: Object type
@@ -196,11 +199,12 @@ def list_audit_logs(
196199
... )
197200
>>> for log in logs:
198201
... print(f"{log.timestamp}: {log.action} by {log.user_email}")
199-
202+
>>>
200203
>>> # Filter by time range
201204
>>> import datetime
202205
>>> start = datetime.datetime.now() - datetime.timedelta(days=7)
203206
>>> recent_logs = audit_mgr.list_audit_logs(start_time=start)
207+
204208
"""
205209
params = {}
206210

@@ -262,6 +266,7 @@ def get_audit_logs_for_user(
262266
>>> audit_mgr = singlestoredb.manage_audit_logs()
263267
>>> user_logs = audit_mgr.get_audit_logs_for_user("user-123")
264268
>>> print(f"Found {len(user_logs)} log entries for user")
269+
265270
"""
266271
return self.list_audit_logs(
267272
user_id=user_id,
@@ -306,6 +311,7 @@ def get_audit_logs_for_resource(
306311
... "workspace", "ws-123"
307312
... )
308313
>>> print(f"Found {len(workspace_logs)} log entries for workspace")
314+
309315
"""
310316
return self.list_audit_logs(
311317
resource_type=resource_type,
@@ -344,6 +350,7 @@ def get_failed_actions(
344350
>>> failed_logs = audit_mgr.get_failed_actions(limit=50)
345351
>>> for log in failed_logs:
346352
... print(f"{log.timestamp}: {log.action} failed - {log.error_message}")
353+
347354
"""
348355
return self.list_audit_logs(
349356
success=False,
@@ -383,6 +390,7 @@ def get_actions_by_type(
383390
>>> audit_mgr = singlestoredb.manage_audit_logs()
384391
>>> create_logs = audit_mgr.get_actions_by_type("CREATE_WORKSPACE")
385392
>>> print(f"Found {len(create_logs)} workspace creation events")
393+
386394
"""
387395
return self.list_audit_logs(
388396
action=action,
@@ -423,6 +431,7 @@ def manage_audit_logs(
423431
>>> audit_mgr = s2.manage_audit_logs()
424432
>>> logs = audit_mgr.audit_logs
425433
>>> print(f"Found {len(logs)} recent audit log entries")
434+
426435
"""
427436
return AuditLogsManager(
428437
access_token=access_token,

0 commit comments

Comments
 (0)