1+ from datetime import datetime
2+ from typing import List , cast
3+
14from glasses3 .g3typing import URI
2- from glasses3 .utils import APIComponent
5+ from glasses3 .utils import APIComponent , EndpointKind
36from glasses3 .websocket import G3WebSocketClientProtocol
47
58
@@ -14,3 +17,135 @@ def __init__(
1417 @property
1518 def uuid (self ):
1619 return self ._uuid
20+
21+ async def get_created (self ) -> datetime :
22+ created = cast (
23+ str ,
24+ await self ._connection .require_get (
25+ self .generate_endpoint_uri (EndpointKind .PROPERTY , "created" )
26+ ),
27+ )
28+ return datetime .fromisoformat (created .strip ("Z" ))
29+
30+ async def get_duration (self ) -> float :
31+ return cast (
32+ float ,
33+ await self ._connection .require_get (
34+ self .generate_endpoint_uri (EndpointKind .PROPERTY , "duration" )
35+ ),
36+ )
37+
38+ async def get_folder (self ) -> str :
39+ return cast (
40+ str ,
41+ await self ._connection .require_get (
42+ self .generate_endpoint_uri (EndpointKind .PROPERTY , "folder" )
43+ ),
44+ )
45+
46+ async def get_gaze_overlay (self ) -> bool :
47+ return cast (
48+ bool ,
49+ await self ._connection .require_get (
50+ self .generate_endpoint_uri (EndpointKind .PROPERTY , "gaze-overlay" )
51+ ),
52+ )
53+
54+ async def get_gaze_samples (self ) -> int :
55+ return cast (
56+ int ,
57+ await self ._connection .require_get (
58+ self .generate_endpoint_uri (EndpointKind .PROPERTY , "gaze-samples" )
59+ ),
60+ )
61+
62+ async def get_http_path (self ) -> str :
63+ return cast (
64+ str ,
65+ await self ._connection .require_get (
66+ self .generate_endpoint_uri (EndpointKind .PROPERTY , "http-path" )
67+ ),
68+ )
69+
70+ async def get_name (self ) -> str :
71+ return cast (
72+ str ,
73+ await self ._connection .require_get (
74+ self .generate_endpoint_uri (EndpointKind .PROPERTY , "name" )
75+ ),
76+ )
77+
78+ async def get_rtsp_path (self ) -> str :
79+ return cast (
80+ str ,
81+ await self ._connection .require_get (
82+ self .generate_endpoint_uri (EndpointKind .PROPERTY , "rtsp-path" )
83+ ),
84+ )
85+
86+ async def get_timezone (self ) -> str :
87+ return cast (
88+ str ,
89+ await self ._connection .require_get (
90+ self .generate_endpoint_uri (EndpointKind .PROPERTY , "timezone" )
91+ ),
92+ )
93+
94+ async def get_valid_gaze_samples (self ) -> int :
95+ return cast (
96+ int ,
97+ await self ._connection .require_get (
98+ self .generate_endpoint_uri (EndpointKind .PROPERTY , "valid-gaze-samples" )
99+ ),
100+ )
101+
102+ async def get_visible_name (self ) -> str :
103+ return cast (
104+ str ,
105+ await self ._connection .require_get (
106+ self .generate_endpoint_uri (EndpointKind .PROPERTY , "visible-name" )
107+ ),
108+ )
109+
110+ async def set_visible_name (self , value : str ) -> bool :
111+ return cast (
112+ bool ,
113+ await self ._connection .require_post (
114+ self .generate_endpoint_uri (EndpointKind .PROPERTY , "visible-name" ),
115+ body = value ,
116+ ),
117+ )
118+
119+ async def meta_insert (self , key : str , meta : str ) -> bool :
120+ return cast (
121+ bool ,
122+ await self ._connection .require_post (
123+ self .generate_endpoint_uri (EndpointKind .ACTION , "meta-insert" ),
124+ body = [key , meta ],
125+ ),
126+ )
127+
128+ async def meta_keys (self ) -> List [str ]:
129+ return cast (
130+ List [str ],
131+ await self ._connection .require_post (
132+ self .generate_endpoint_uri (EndpointKind .ACTION , "meta-keys" )
133+ ),
134+ )
135+
136+ async def meta_lookup (self , key : str ) -> str :
137+ return cast (
138+ str ,
139+ await self ._connection .require_post (
140+ self .generate_endpoint_uri (EndpointKind .ACTION , "meta-lookup" ),
141+ body = [key ],
142+ ),
143+ )
144+
145+ async def move (self , folder : str ) -> bool :
146+ return cast (
147+ bool ,
148+ await self ._connection .require_post (
149+ self .generate_endpoint_uri (EndpointKind .ACTION , "move" ), body = [folder ]
150+ ),
151+ )
0 commit comments