1+ from typing import Any
12from pydantic import BaseModel , validate_call , ConfigDict , PrivateAttr
23from rrelayer .api import API
34
45
56class Client (BaseModel ):
6- _serverURL : str = PrivateAttr ()
7- _auth_username : str = PrivateAttr ()
8- _auth_password : str = PrivateAttr ()
7+ _apiBaseConfig : dict [str , str ] = PrivateAttr ()
8+
99 _api : API = PrivateAttr ()
1010
11- relayer : "Client.Relayer" = None
11+ relayer : "Client.Relayer | None " = None
1212 network : "Client.Network | None" = None
1313 transaction : "Client.Transaction | None" = None
1414 allowlist : "Client.AllowList | None" = None
@@ -18,9 +18,11 @@ class Client(BaseModel):
1818 def __init__ (self , serverURL : str , auth_username : str , auth_password : str , ** data ):
1919 super ().__init__ (** data )
2020
21- self ._serverURL = serverURL
22- self ._auth_username = auth_username
23- self ._auth_password = auth_password
21+ self ._apiBaseConfig = {
22+ "serverURL" : serverURL ,
23+ "username" : auth_username ,
24+ "password" : auth_password ,
25+ }
2426
2527 self ._api = API ()
2628
@@ -35,28 +37,35 @@ def __init__(self, client: "Client"):
3537
3638 @validate_call
3739 async def create (self , chainId : int , name : str ):
38- pass
40+ return await self ._client ._api .postApi (
41+ self ._client ._apiBaseConfig , f"relayers/{ chainId } /new" , {"name" : name }
42+ )
3943
4044 @validate_call
4145 async def clone (self , relayerId : str , chainId : int , name : str ):
42- pass
46+ return await self ._client ._api .postApi (
47+ self ._client ._apiBaseConfig ,
48+ f"relayers/{ relayerId } /clone" ,
49+ {"newRelayerName" : name , "chainId" : chainId },
50+ )
4351
4452 @validate_call
4553 async def delete (self , id : str ):
46- pass
54+ _ = await self ._client ._api .deleteApi (
55+ self ._client ._apiBaseConfig , f"relayers/{ id } "
56+ )
4757
4858 @validate_call
49- async def get (self , id : str ):
50- pass
59+ async def get (self , id : str ) -> dict [str , Any ]:
60+ return await self ._client ._api .getApi (
61+ self ._client ._apiBaseConfig ,
62+ f"relayers/{ id } " ,
63+ )
5164
5265 @validate_call
5366 async def getAll (self ):
5467 pass
5568
56- def printValues (self ):
57- print ("Print Values" )
58- print (self ._client ._auth_username )
59-
6069 class Network :
6170 def __init__ (self , client : "Client" ):
6271 self ._client : "Client" = client
0 commit comments