2323class AlfrescoAuthClient :
2424 """
2525 Individual client for Alfresco AUTH API.
26-
26+
2727 Features:
2828 - Uses generated HTTP client internally
2929 - Automatic authentication with AuthUtil
3030 - Pydantic model integration
3131 - Both sync and async methods
3232 """
33-
33+
3434 def __init__ (
3535 self ,
3636 base_url : str ,
@@ -40,7 +40,7 @@ def __init__(
4040 ):
4141 """
4242 Initialize auth client.
43-
43+
4444 Args:
4545 base_url: Base URL of Alfresco instance
4646 auth_util: Optional AuthUtil instance for authentication
@@ -51,11 +51,11 @@ def __init__(
5151 self .auth_util = auth_util
5252 self .verify_ssl = verify_ssl
5353 self .timeout = timeout
54-
54+
5555 # Initialize the generated client
5656 self ._init_generated_client ()
57-
58- def _init_generated_client (self ) -> None :
57+
58+ def _init_generated_client (self ):
5959 """Initialize the generated HTTP client"""
6060 try :
6161 from client import Client
@@ -65,56 +65,16 @@ def _init_generated_client(self) -> None:
6565 print (f"⚠️ Generated client not available for auth: { e } " )
6666 self .client = None
6767 self ._client_available = False
68-
68+
6969 def is_available (self ) -> bool :
7070 """Check if the generated client is available"""
7171 return self ._client_available
72-
73- async def _ensure_auth (self ) -> None :
72+
73+ async def _ensure_auth (self ):
7474 """Ensure authentication before API calls"""
7575 if self .auth_util :
7676 await self .auth_util .ensure_authenticated ()
77-
78- async def create_ticket (self , ticket_body ) -> Any :
79- """Create authentication ticket"""
80- if not self ._client_available :
81- # Simplified mock response for when client isn't available
82- print ("⚠️ Auth client not fully initialized - using basic auth" )
83- return type ('MockTicketResponse' , (), {
84- 'entry' : type ('Entry' , (), {'id' : 'mock-ticket-basic-auth' })()
85- })()
86-
87- try :
88- # Try to use the actual generated client
89- import httpx
90-
91- # Build request directly
92- url = f"{ self .base_url } /alfresco/api/-default-/public/authentication/versions/1/tickets"
93-
94- # Convert ticket_body to dict
95- if hasattr (ticket_body , 'model_dump' ):
96- data = ticket_body .model_dump ()
97- elif hasattr (ticket_body , 'dict' ):
98- data = ticket_body .dict ()
99- else :
100- data = ticket_body
101-
102- async with httpx .AsyncClient (verify = self .verify_ssl , timeout = self .timeout ) as client :
103- response = await client .post (url , json = data )
104-
105- if response .status_code == 201 :
106- result = response .json ()
107- return type ('TicketResponse' , (), {
108- 'entry' : type ('Entry' , (), {'id' : result .get ('entry' , {}).get ('id' , 'no-ticket' )})()
109- })()
110- else :
111- print (f"⚠️ Auth request failed with status { response .status_code } " )
112- return None
113-
114- except Exception as e :
115- print (f"⚠️ Auth fallback: { e } " )
116- return None
117-
77+
11878 def get_client_info (self ) -> Dict [str , Any ]:
11979 """Get information about this client"""
12080 return {
0 commit comments