File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed
Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 11import asyncio
2+ import json
23import os
34
45import enapter
@@ -9,7 +10,7 @@ async def main():
910 device_id = os .environ ["DEVICE_ID" ]
1011 async with enapter .http .api .Client (config = config ) as client :
1112 device = await client .devices .get (device_id )
12- print (device )
13+ print (json . dumps ( device . to_dto ()) )
1314
1415
1516if __name__ == "__main__" :
Original file line number Diff line number Diff line change 1+ import asyncio
2+ import json
3+
4+ import enapter
5+
6+
7+ async def main ():
8+ config = enapter .http .api .Config .from_env ()
9+ async with enapter .http .api .Client (config = config ) as client :
10+ async with client .devices .list () as devices :
11+ async for device in devices :
12+ print (json .dumps (device .to_dto ()))
13+
14+
15+ if __name__ == "__main__" :
16+ asyncio .run (main ())
Original file line number Diff line number Diff line change 11import asyncio
2+ import json
23
34import enapter
45
56
67async def main ():
78 config = enapter .http .api .Config .from_env ()
89 async with enapter .http .api .Client (config = config ) as client :
9- async for site in client .sites .list ():
10- print (site )
10+ async with client .sites .list () as sites :
11+ async for site in sites :
12+ print (json .dumps (site .to_dto ()))
1113
1214
1315if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments