|
1 | 1 | """Nextcloud API for working with applications."""
|
2 | 2 |
|
3 | 3 | import dataclasses
|
| 4 | +import datetime |
4 | 5 | import typing
|
5 | 6 |
|
6 | 7 | from ._misc import require_capabilities
|
|
11 | 12 | class ExAppInfo:
|
12 | 13 | """Information about the External Application."""
|
13 | 14 |
|
14 |
| - app_id: str |
15 |
| - """`ID` of the application""" |
16 |
| - name: str |
17 |
| - """Display name""" |
18 |
| - version: str |
19 |
| - """Version of the application""" |
20 |
| - enabled: bool |
21 |
| - """Flag indicating if the application enabled""" |
22 |
| - last_check_time: int |
23 |
| - """UTC time of last successful application check""" |
24 |
| - system: bool |
25 |
| - """Flag indicating if the application is a system application""" |
26 |
| - |
27 | 15 | def __init__(self, raw_data: dict):
|
28 |
| - self.app_id = raw_data["id"] |
29 |
| - self.name = raw_data["name"] |
30 |
| - self.version = raw_data["version"] |
31 |
| - self.enabled = bool(raw_data["enabled"]) |
32 |
| - self.last_check_time = raw_data["last_check_time"] |
33 |
| - self.system = raw_data["system"] |
| 16 | + self._raw_data = raw_data |
| 17 | + |
| 18 | + @property |
| 19 | + def app_id(self) -> str: |
| 20 | + """`ID` of the application.""" |
| 21 | + return self._raw_data["id"] |
| 22 | + |
| 23 | + @property |
| 24 | + def name(self) -> str: |
| 25 | + """Display name.""" |
| 26 | + return self._raw_data["name"] |
| 27 | + |
| 28 | + @property |
| 29 | + def version(self) -> str: |
| 30 | + """Version of the application.""" |
| 31 | + return self._raw_data["version"] |
| 32 | + |
| 33 | + @property |
| 34 | + def enabled(self) -> bool: |
| 35 | + """Flag indicating if the application enabled.""" |
| 36 | + return bool(self._raw_data["enabled"]) |
| 37 | + |
| 38 | + @property |
| 39 | + def last_check_time(self) -> datetime.datetime: |
| 40 | + """Time of the last successful application check.""" |
| 41 | + return datetime.datetime.utcfromtimestamp(int(self._raw_data["last_check_time"])).replace( |
| 42 | + tzinfo=datetime.timezone.utc |
| 43 | + ) |
| 44 | + |
| 45 | + @property |
| 46 | + def system(self) -> bool: |
| 47 | + """Flag indicating if the application is a system application.""" |
| 48 | + return bool(self._raw_data["system"]) |
34 | 49 |
|
35 | 50 |
|
36 | 51 | class _AppsAPI:
|
|
0 commit comments