@@ -6,32 +6,34 @@ from typing import Dict
66from typing import List
77from typing import Optional
88
9- class GetTlsKeyResponse :
9+ from pydantic import BaseModel
10+
11+ class GetTlsKeyResponse (BaseModel ):
1012 key : str
1113 certificate_chain : List [str ]
1214 def as_uint8array (self , max_length : Optional [int ] = ...) -> bytes : ...
1315
14- class GetKeyResponse :
16+ class GetKeyResponse ( BaseModel ) :
1517 key : str
1618 signature_chain : List [str ]
1719 def decode_key (self ) -> bytes : ...
1820 def decode_signature_chain (self ) -> List [bytes ]: ...
1921
20- class GetQuoteResponse :
22+ class GetQuoteResponse ( BaseModel ) :
2123 quote : str
2224 event_log : str
2325 def decode_quote (self ) -> bytes : ...
2426 def decode_event_log (self ) -> List [EventLog ]: ...
2527 def replay_rtmrs (self ) -> Dict [int , str ]: ...
2628
27- class EventLog :
29+ class EventLog ( BaseModel ) :
2830 imr : int
2931 event_type : int
3032 digest : str
3133 event : str
3234 event_payload : str
3335
34- class TcbInfo :
36+ class TcbInfo ( BaseModel ) :
3537 mrtd : str
3638 rtmr0 : str
3739 rtmr1 : str
@@ -43,7 +45,7 @@ class TcbInfo:
4345 app_compose : str
4446 event_log : List [EventLog ]
4547
46- class InfoResponse :
48+ class InfoResponse ( BaseModel ) :
4749 app_id : str
4850 instance_id : str
4951 app_cert : str
@@ -62,37 +64,35 @@ class BusinessMethodsMixin:
6264 self , method : str , payload : Dict [str , Any ]
6365 ) -> Dict [str , Any ]: ...
6466
65- # Async methods
66- async def get_key (
67- self , path : str | None = ..., purpose : str | None = ...
68- ) -> GetKeyResponse : ...
69- async def get_quote (self , report_data : str | bytes ) -> GetQuoteResponse : ...
70- async def info (self ) -> InfoResponse : ...
71- async def emit_event (self , event : str , payload : str | bytes ) -> None : ...
72- async def get_tls_key (
67+ # Methods can be either async or sync depending on implementation
68+ def get_key (self , path : str | None = ..., purpose : str | None = ...) -> Any : ...
69+ def get_quote (self , report_data : str | bytes ) -> Any : ...
70+ def info (self ) -> Any : ...
71+ def emit_event (self , event : str , payload : str | bytes ) -> Any : ...
72+ def get_tls_key (
7373 self ,
7474 subject : str | None = ...,
7575 alt_names : List [str ] | None = ...,
7676 usage_ra_tls : bool = ...,
7777 usage_server_auth : bool = ...,
7878 usage_client_auth : bool = ...,
79- ) -> GetTlsKeyResponse : ...
80- async def is_reachable (self ) -> bool : ...
79+ ) -> Any : ...
80+ def is_reachable (self ) -> Any : ...
8181
8282class TappdMethodsMixin :
8383 @abstractmethod
8484 async def _send_rpc_request (
8585 self , method : str , payload : Dict [str , Any ]
8686 ) -> Dict [str , Any ]: ...
87- async def derive_key (
87+ def derive_key (
8888 self ,
8989 path : str | None = ...,
9090 subject : str | None = ...,
9191 alt_names : List [str ] | None = ...,
92- ) -> GetTlsKeyResponse : ...
93- async def tdx_quote (
92+ ) -> Any : ...
93+ def tdx_quote (
9494 self , report_data : str | bytes , hash_algorithm : str | None = ...
95- ) -> GetQuoteResponse : ...
95+ ) -> Any : ...
9696
9797class BaseClient : ...
9898
@@ -102,6 +102,23 @@ class AsyncDstackClient(BaseClient, BusinessMethodsMixin):
102102 self , method : str , payload : Dict [str , Any ]
103103 ) -> Dict [str , Any ]: ...
104104
105+ # Override with specific async return types
106+ async def get_key (
107+ self , path : str | None = ..., purpose : str | None = ...
108+ ) -> GetKeyResponse : ...
109+ async def get_quote (self , report_data : str | bytes ) -> GetQuoteResponse : ...
110+ async def info (self ) -> InfoResponse : ...
111+ async def emit_event (self , event : str , payload : str | bytes ) -> None : ...
112+ async def get_tls_key (
113+ self ,
114+ subject : str | None = ...,
115+ alt_names : List [str ] | None = ...,
116+ usage_ra_tls : bool = ...,
117+ usage_server_auth : bool = ...,
118+ usage_client_auth : bool = ...,
119+ ) -> GetTlsKeyResponse : ...
120+ async def is_reachable (self ) -> bool : ...
121+
105122class DstackClient (BaseClient , BusinessMethodsMixin ):
106123 def __init__ (self , endpoint : str | None = ...) -> None : ...
107124 async def _send_rpc_request (
@@ -128,6 +145,17 @@ class DstackClient(BaseClient, BusinessMethodsMixin):
128145class AsyncTappdClient (AsyncDstackClient , TappdMethodsMixin ):
129146 def __init__ (self , endpoint : str | None = ...) -> None : ...
130147
148+ # Override with specific async return types
149+ async def derive_key (
150+ self ,
151+ path : str | None = ...,
152+ subject : str | None = ...,
153+ alt_names : List [str ] | None = ...,
154+ ) -> GetTlsKeyResponse : ...
155+ async def tdx_quote (
156+ self , report_data : str | bytes , hash_algorithm : str | None = ...
157+ ) -> GetQuoteResponse : ...
158+
131159class TappdClient (DstackClient , TappdMethodsMixin ):
132160 def __init__ (self , endpoint : str | None = ...) -> None : ...
133161
0 commit comments