Deprecate legacy login/register methods with warnings
- Add DeprecationWarning to login() and register() static methods - Update docstrings with .. deprecated:: notices - Sync types with backend changes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
024ea8ee97
commit
47a8038e8d
4 files changed
+329
-9
No files matched your search
+76
-4
@@ -3,6 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
import warnings
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
|
||||
import requests
|
||||
@@ -14,8 +15,10 @@ from .types import (
|
||||
AuthLoginResponse,
|
||||
AuthRegisterResponse,
|
||||
CreateExportResponse,
|
||||
DeepHealthResponse,
|
||||
DeleteAgentResponse,
|
||||
EOR,
|
||||
FreezeAgentResponse,
|
||||
GetAgentResponse,
|
||||
GetEpochResponse,
|
||||
GetExportResponse,
|
||||
@@ -23,6 +26,9 @@ from .types import (
|
||||
GetOperationResponse,
|
||||
HealthResponse,
|
||||
IssueApiTokenResponse,
|
||||
ListAdminEventsResponse,
|
||||
ListMembersResponse,
|
||||
ListWebhooksResponse,
|
||||
RotateApiTokenResponse,
|
||||
JWKSResponse,
|
||||
ListAgentsResponse,
|
||||
@@ -30,7 +36,10 @@ from .types import (
|
||||
ListExportsResponse,
|
||||
RegisterAgentRequest,
|
||||
RegisterAgentResponse,
|
||||
RegisterWebhookResponse,
|
||||
SubmitOperationResponse,
|
||||
UnfreezeAgentResponse,
|
||||
UpdateAgentResponse,
|
||||
VerifyOperationResponse,
|
||||
)
|
||||
from .utils import generate_nonce, generate_uuidv7
|
||||
@@ -169,7 +178,16 @@ class ElydoraClient:
|
||||
display_name: Optional[str] = None,
|
||||
org_name: Optional[str] = None,
|
||||
) -> AuthRegisterResponse:
|
||||
"""Register a new user and organization."""
|
||||
"""Register a new user and organization.
|
||||
|
||||
.. deprecated::
|
||||
Use Better Auth endpoints directly. See docs.
|
||||
"""
|
||||
warnings.warn(
|
||||
"ElydoraClient.register() is deprecated. Use Better Auth endpoints directly. See docs.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
url = f"{base_url.rstrip('/')}/v1/auth/register"
|
||||
body: Dict[str, Any] = {"email": email, "password": password}
|
||||
if display_name is not None:
|
||||
@@ -181,7 +199,16 @@ class ElydoraClient:
|
||||
|
||||
@staticmethod
|
||||
def login(base_url: str, email: str, password: str) -> AuthLoginResponse:
|
||||
"""Authenticate and receive a session token."""
|
||||
"""Authenticate and receive a session token.
|
||||
|
||||
.. deprecated::
|
||||
Use Better Auth endpoints directly. See docs.
|
||||
"""
|
||||
warnings.warn(
|
||||
"ElydoraClient.login() is deprecated. Use Better Auth endpoints directly. See docs.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
url = f"{base_url.rstrip('/')}/v1/auth/login"
|
||||
body = {"email": email, "password": password}
|
||||
resp = requests.post(url, json=body, headers={"Content-Type": "application/json"}, timeout=30)
|
||||
@@ -226,9 +253,13 @@ class ElydoraClient:
|
||||
"""List all agents for the organization."""
|
||||
return self._request("GET", "/v1/agents")
|
||||
|
||||
def unfreeze_agent(self, agent_id: str, reason: str) -> None:
|
||||
def unfreeze_agent(self, agent_id: str, reason: str) -> UnfreezeAgentResponse:
|
||||
"""Unfreeze an agent."""
|
||||
self._request("POST", f"/v1/agents/{agent_id}/unfreeze", json_body={"reason": reason})
|
||||
return self._request("POST", f"/v1/agents/{agent_id}/unfreeze", json_body={"reason": reason})
|
||||
|
||||
def update_agent(self, agent_id: str, integration_type: str) -> UpdateAgentResponse:
|
||||
"""Update an agent's integration type."""
|
||||
return self._request("PATCH", f"/v1/agents/{agent_id}", json_body={"integration_type": integration_type})
|
||||
|
||||
def delete_agent(self, agent_id: str) -> DeleteAgentResponse:
|
||||
"""Delete an agent."""
|
||||
@@ -389,6 +420,41 @@ class ElydoraClient:
|
||||
self._handle_response(resp)
|
||||
return resp.content
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Webhooks
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
def list_webhooks(self) -> ListWebhooksResponse:
|
||||
"""List all webhooks for the organization."""
|
||||
return self._request("GET", "/v1/webhooks")
|
||||
|
||||
def register_webhook(self, endpoint_url: str, events: list, secret: str) -> RegisterWebhookResponse:
|
||||
"""Register a new webhook."""
|
||||
return self._request("POST", "/v1/webhooks", json_body={"endpoint_url": endpoint_url, "events": events, "secret": secret})
|
||||
|
||||
def delete_webhook(self, webhook_id: str) -> None:
|
||||
"""Delete a webhook."""
|
||||
self._request("DELETE", f"/v1/webhooks/{webhook_id}")
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Members
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
def list_members(self) -> ListMembersResponse:
|
||||
"""List all members in the organization."""
|
||||
return self._request("GET", "/v1/members")
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Admin events
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
def list_admin_events(self, limit: Optional[int] = None) -> ListAdminEventsResponse:
|
||||
"""List recent admin events."""
|
||||
params: Dict[str, str] = {}
|
||||
if limit is not None:
|
||||
params["limit"] = str(limit)
|
||||
return self._request("GET", "/v1/admin/events", params=params)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# JWKS
|
||||
# -----------------------------------------------------------------
|
||||
@@ -408,3 +474,9 @@ class ElydoraClient:
|
||||
url = f"{self.base_url}/v1/health"
|
||||
resp = self._session.get(url, timeout=30)
|
||||
return self._handle_response(resp)
|
||||
|
||||
def deep_health(self) -> DeepHealthResponse:
|
||||
"""Check API deep health (public, no auth required)."""
|
||||
url = f"{self.base_url}/v1/health/deep"
|
||||
resp = self._session.get(url, timeout=30)
|
||||
return self._handle_response(resp)
|
||||
Reference in new issue
Block a user