python-terminusgps 1.17.1__py3-none-any.whl → 19.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_terminusgps-1.17.1.dist-info → python_terminusgps-19.0.0.dist-info}/METADATA +1 -1
- {python_terminusgps-1.17.1.dist-info → python_terminusgps-19.0.0.dist-info}/RECORD +13 -12
- terminusgps/wialon/constants.py +0 -58
- terminusgps/wialon/items/base.py +2 -7
- terminusgps/wialon/items/geofence.py +57 -0
- terminusgps/wialon/items/resource.py +21 -12
- terminusgps/wialon/items/retranslator.py +10 -14
- terminusgps/wialon/items/route.py +20 -11
- terminusgps/wialon/items/unit.py +14 -14
- terminusgps/wialon/items/unit_group.py +9 -10
- terminusgps/wialon/items/user.py +12 -15
- {python_terminusgps-1.17.1.dist-info → python_terminusgps-19.0.0.dist-info}/WHEEL +0 -0
- {python_terminusgps-1.17.1.dist-info → python_terminusgps-19.0.0.dist-info}/licenses/COPYING +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-terminusgps
|
|
3
|
-
Version:
|
|
3
|
+
Version: 19.0.0
|
|
4
4
|
Summary: Provides abstractions/utilities for working with Wialon API, Authorize.NET API, AWS API, and more.
|
|
5
5
|
Project-URL: Documentation, https://app.terminusgps.com/docs/apps/python-terminusgps/index.html
|
|
6
6
|
Project-URL: Repository, https://github.com/terminusgps/python-terminusgps
|
|
@@ -14,21 +14,22 @@ terminusgps/aws/ses.py,sha256=sDca2GjMaZvUt3kUPtGCpcqHiOkij9lMV1ogZofgYUU,2372
|
|
|
14
14
|
terminusgps/twilio/__init__.py,sha256=dYo41F2jft_eHDWSUtSpKGSRG1bewq_qClqilUJZkYM,33
|
|
15
15
|
terminusgps/twilio/caller.py,sha256=nHCIwUulo-C_v2orsp6OY0nuJA6YetSkxpMTwrRQ-uA,1831
|
|
16
16
|
terminusgps/wialon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
-
terminusgps/wialon/constants.py,sha256=
|
|
17
|
+
terminusgps/wialon/constants.py,sha256=5onrGqoX_L4ItQCWvdKyRz8O5IZiN-_xUO9MTtzVd6c,946
|
|
18
18
|
terminusgps/wialon/errors.py,sha256=Fl8A0peF5HpDdR3y0r3g86-iQ4kQgye3FYQZKGe3T7Y,984
|
|
19
19
|
terminusgps/wialon/flags.py,sha256=-OoH-eZM54yjRqxsAXL8VImdQu_7C0OAxCrFqaCEuko,13510
|
|
20
20
|
terminusgps/wialon/session.py,sha256=zCM3VXzRn8OhR34_3E45I2dPD9NtmFfKJOwKZzxerOs,10857
|
|
21
21
|
terminusgps/wialon/utils.py,sha256=KeZmV-MEdGOHXrsyn6IIoyX0EgVYiWYjvacXyZVr1u8,6501
|
|
22
22
|
terminusgps/wialon/items/__init__.py,sha256=cfUC5sfVsTwmpgsR-w9wA4ay6_EZYAPgEeuw2k06RJM,256
|
|
23
|
-
terminusgps/wialon/items/base.py,sha256
|
|
23
|
+
terminusgps/wialon/items/base.py,sha256=EAtzlnCvB7WTu3iX1bV1-S9TvwXc-Eez7e0X4TMiK9U,6943
|
|
24
|
+
terminusgps/wialon/items/geofence.py,sha256=auT3QDe3Vmuky9A2gsaMQUbqNqRX8HJGwl1nBXX41zk,1661
|
|
24
25
|
terminusgps/wialon/items/notification.py,sha256=6IrswN6fdEkJErIqtMq45bTl9xVARQw8nokDsy3x1MA,97
|
|
25
|
-
terminusgps/wialon/items/resource.py,sha256=
|
|
26
|
-
terminusgps/wialon/items/retranslator.py,sha256=
|
|
27
|
-
terminusgps/wialon/items/route.py,sha256=
|
|
28
|
-
terminusgps/wialon/items/unit.py,sha256=
|
|
29
|
-
terminusgps/wialon/items/unit_group.py,sha256=
|
|
30
|
-
terminusgps/wialon/items/user.py,sha256=
|
|
31
|
-
python_terminusgps-
|
|
32
|
-
python_terminusgps-
|
|
33
|
-
python_terminusgps-
|
|
34
|
-
python_terminusgps-
|
|
26
|
+
terminusgps/wialon/items/resource.py,sha256=79SwbCyE1zlaoeBfU0erEqvqBAYUC4KAKs8AOLJqflU,9652
|
|
27
|
+
terminusgps/wialon/items/retranslator.py,sha256=8q9EDc92w92MElnHIeEzH3Ra4kiPXrx4t9V5nPDZuRU,3728
|
|
28
|
+
terminusgps/wialon/items/route.py,sha256=PTJx1gmT_PGz7nlSSUS2VzjYD-aAuvkEOIdIFneUSSQ,1148
|
|
29
|
+
terminusgps/wialon/items/unit.py,sha256=PwF7xlpDWI5MpM_u6TmYZjNHWk6TSKM4rJ4OB9CIn4A,7533
|
|
30
|
+
terminusgps/wialon/items/unit_group.py,sha256=xc7zYitPE59_WYS-G857jeIQnQcUAxLBH3X6Y1VDg_8,4089
|
|
31
|
+
terminusgps/wialon/items/user.py,sha256=INwAibQVmjNNelepQXMfDevgJqMvIjHHgEjAMLRvhB0,7082
|
|
32
|
+
python_terminusgps-19.0.0.dist-info/METADATA,sha256=FJ1Auz5W81QVYJgTYsRLnAOej-6dD4sxWv8AiTzAMek,912
|
|
33
|
+
python_terminusgps-19.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
34
|
+
python_terminusgps-19.0.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
35
|
+
python_terminusgps-19.0.0.dist-info/RECORD,,
|
terminusgps/wialon/constants.py
CHANGED
|
@@ -1,43 +1,5 @@
|
|
|
1
|
-
from django.db import models
|
|
2
|
-
from django.utils.translation import gettext_lazy as _
|
|
3
|
-
|
|
4
1
|
from terminusgps.wialon import flags
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
class WialonCommandName(models.TextChoices):
|
|
8
|
-
SUB_BASIC = "Basic", _("Basic Subscription")
|
|
9
|
-
SUB_STANDARD = "Standard", _("Standard Subscription")
|
|
10
|
-
SUB_PREMIUM = "Premium", _("Premium Subscription")
|
|
11
|
-
STARTER_DISABLED = "Starter Disable On", _("Disable Starter")
|
|
12
|
-
STARTER_ENABLED = "Starter Disable Off", _("Enable Starter")
|
|
13
|
-
ENABLE = "On", _("Enable")
|
|
14
|
-
DISABLE = "Off", _("Disable")
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class WialonCommandType(models.TextChoices):
|
|
18
|
-
ENGINE_BLOCK = "block_engine", _("Block Engine")
|
|
19
|
-
ENGINE_UNBLOCK = "unblock_engine", _("Unblock Engine")
|
|
20
|
-
CUSTOM_MSG = "custom_msg", _("Custom Message")
|
|
21
|
-
DRIVER_MSG = "driver_msg", _("Message to Driver")
|
|
22
|
-
DOWNLOAD_MSG = "download_msgs", _("Download messages")
|
|
23
|
-
QUERY_POS = "query_pos", _("Query Position")
|
|
24
|
-
QUERY_PHOTO = "query_photo", _("Query Snapshot")
|
|
25
|
-
OUTPUT_ON = "output_on", _("Activate Output")
|
|
26
|
-
OUTPUT_OFF = "output_off", _("Deactive Output")
|
|
27
|
-
SEND_POS = "send_position", _("Send Coordinates")
|
|
28
|
-
SET_REPORT_INT = "set_report_interval", _("Set Data Transfer Interval")
|
|
29
|
-
UPLOAD_CFG = "upload_cfg", _("Upload Configuration")
|
|
30
|
-
UPLOAD_SW = "upload_sw", _("Upload Firmware")
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class WialonCommandLink(models.TextChoices):
|
|
34
|
-
AUTO = "", _("Auto")
|
|
35
|
-
TCP = "tcp", _("TCP")
|
|
36
|
-
UDP = "udp", _("UDP")
|
|
37
|
-
VRT = "vrt", _("Virtual")
|
|
38
|
-
GSM = "gsm", _("SMS")
|
|
39
|
-
|
|
40
|
-
|
|
41
3
|
ACCESSMASK_UNIT_BASIC: int = sum(
|
|
42
4
|
[
|
|
43
5
|
flags.ACCESSFLAG_VIEW_ITEM_BASIC,
|
|
@@ -56,26 +18,6 @@ ACCESSMASK_UNIT_BASIC: int = sum(
|
|
|
56
18
|
]
|
|
57
19
|
)
|
|
58
20
|
|
|
59
|
-
ACCESSMASK_UNIT_SUPER: int = sum(
|
|
60
|
-
[
|
|
61
|
-
flags.ACCESSFLAG_VIEW_ITEM_BASIC,
|
|
62
|
-
flags.ACCESSFLAG_VIEW_ITEM_DETAILED,
|
|
63
|
-
flags.ACCESSFLAG_RENAME_ITEM,
|
|
64
|
-
flags.ACCESSFLAG_VIEW_CUSTOM_FIELDS,
|
|
65
|
-
flags.ACCESSFLAG_MANAGE_CUSTOM_FIELDS,
|
|
66
|
-
flags.ACCESSFLAG_MANAGE_ICON,
|
|
67
|
-
flags.ACCESSFLAG_QUERY_REPORTS,
|
|
68
|
-
flags.ACCESSFLAG_VIEW_ATTACHED_FILES,
|
|
69
|
-
flags.ACCESSFLAG_UNIT_EXECUTE_COMMANDS,
|
|
70
|
-
flags.ACCESSFLAG_UNIT_VIEW_SERVICE_INTERVALS,
|
|
71
|
-
flags.ACCESSFLAG_UNIT_REGISTER_EVENTS,
|
|
72
|
-
flags.ACCESSFLAG_UNIT_IMPORT_MESSAGES,
|
|
73
|
-
flags.ACCESSFLAG_UNIT_EXPORT_MESSAGES,
|
|
74
|
-
]
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
ACCESSMASK_UNIT_FULL: int = flags.ACCESSFLAG_FULL_ACCESS
|
|
78
|
-
|
|
79
21
|
ACCESSMASK_UNIT_MIGRATION: int = sum(
|
|
80
22
|
[
|
|
81
23
|
flags.ACCESSFLAG_DELETE_ITEM,
|
terminusgps/wialon/items/base.py
CHANGED
|
@@ -7,18 +7,13 @@ from terminusgps.wialon.session import WialonSession
|
|
|
7
7
|
|
|
8
8
|
class WialonBase:
|
|
9
9
|
def __init__(
|
|
10
|
-
self,
|
|
11
|
-
id: str | int | None = None,
|
|
12
|
-
session: WialonSession | None = None,
|
|
13
|
-
**kwargs,
|
|
10
|
+
self, id: str | int | None, session: WialonSession, *args, **kwargs
|
|
14
11
|
) -> None:
|
|
15
|
-
if session is None:
|
|
16
|
-
raise ValueError("A valid Wialon API session is required.")
|
|
17
12
|
if isinstance(id, str) and not id.isdigit():
|
|
18
13
|
raise ValueError(f"'id' must be a digit. Got '{id}'.")
|
|
19
14
|
|
|
20
15
|
self._session = session
|
|
21
|
-
self._id = str(id if id else self.create(**kwargs))
|
|
16
|
+
self._id = str(id if id else self.create(*args, **kwargs))
|
|
22
17
|
self.populate()
|
|
23
18
|
|
|
24
19
|
def __str__(self) -> str:
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
from django.db import models
|
|
2
|
+
|
|
3
|
+
from terminusgps.wialon.items.base import WialonBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class WialonGeofence(WialonBase):
|
|
7
|
+
class WialonGeofenceShape(models.IntegerChoices):
|
|
8
|
+
LINE = 1
|
|
9
|
+
POLYGON = 2
|
|
10
|
+
CIRCLE = 3
|
|
11
|
+
|
|
12
|
+
class WialonGeofenceColor(models.IntegerChoices):
|
|
13
|
+
RED = int("ff0000", 16)
|
|
14
|
+
ORANGE = int("ff7b00", 16)
|
|
15
|
+
YELLOW = int("fffb00", 16)
|
|
16
|
+
GREEN = int("20ff00", 16)
|
|
17
|
+
BLUE = int("0090ff", 16)
|
|
18
|
+
PURPLE = int("7000ff", 16)
|
|
19
|
+
WHITE = int("f3f3f3", 16)
|
|
20
|
+
BLACK = int("030303", 16)
|
|
21
|
+
|
|
22
|
+
def create(
|
|
23
|
+
self,
|
|
24
|
+
resource_id: str | int,
|
|
25
|
+
name: str,
|
|
26
|
+
xpos: float,
|
|
27
|
+
ypos: float,
|
|
28
|
+
desc: str | None = None,
|
|
29
|
+
shape: int = WialonGeofenceShape.CIRCLE,
|
|
30
|
+
width: int = 100,
|
|
31
|
+
flags: int = 0x04,
|
|
32
|
+
color: int = WialonGeofenceColor.GREEN,
|
|
33
|
+
text_color: int = WialonGeofenceColor.BLACK,
|
|
34
|
+
text_size: int = 12,
|
|
35
|
+
min_zoom: int = 2,
|
|
36
|
+
max_zoom: int = 19,
|
|
37
|
+
) -> int | None:
|
|
38
|
+
response = self.session.wialon_api.resource_update_zone(
|
|
39
|
+
**{
|
|
40
|
+
"itemId": resource_id,
|
|
41
|
+
"id": 0,
|
|
42
|
+
"callMode": "create",
|
|
43
|
+
"n": name,
|
|
44
|
+
"d": desc if desc else name,
|
|
45
|
+
"t": shape,
|
|
46
|
+
"w": width,
|
|
47
|
+
"f": flags,
|
|
48
|
+
"c": color,
|
|
49
|
+
"tc": text_color,
|
|
50
|
+
"ts": text_size,
|
|
51
|
+
"min": min_zoom,
|
|
52
|
+
"max": max_zoom,
|
|
53
|
+
"p": [{"x": xpos, "y": ypos, "r": width}],
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
if response:
|
|
57
|
+
return int(response[0])
|
|
@@ -3,22 +3,31 @@ from terminusgps.wialon.items.base import WialonBase
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class WialonResource(WialonBase):
|
|
6
|
-
def create(self,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
def create(self, creator_id: str | int, name: str) -> int | None:
|
|
7
|
+
"""
|
|
8
|
+
Creates a new Wialon resource.
|
|
9
|
+
|
|
10
|
+
:param creator_id: A Wialon user id.
|
|
11
|
+
:type creator_id: :py:obj:`int` | :py:obj:`str`
|
|
12
|
+
:param name: A name for the resource.
|
|
13
|
+
:type name: :py:obj:`str`
|
|
14
|
+
:raises ValueError: If ``creator_id`` is not a digit.
|
|
15
|
+
:raises WialonError: If something goes wrong with Wialon.
|
|
16
|
+
:returns: The Wialon id for the new resource, if it was created.
|
|
17
|
+
:rtype: :py:obj:`int` | :py:obj:`None`
|
|
18
|
+
|
|
19
|
+
"""
|
|
20
|
+
if isinstance(creator_id, str) and not creator_id.isdigit():
|
|
21
|
+
raise ValueError(f"'creator_id' must be a digit, got '{creator_id}'.")
|
|
13
22
|
|
|
14
23
|
response = self.session.wialon_api.core_create_resource(
|
|
15
24
|
**{
|
|
16
|
-
"creatorId":
|
|
17
|
-
"name":
|
|
18
|
-
"dataFlags":
|
|
25
|
+
"creatorId": creator_id,
|
|
26
|
+
"name": name,
|
|
27
|
+
"dataFlags": flags.DATAFLAG_UNIT_BASE,
|
|
19
28
|
}
|
|
20
29
|
)
|
|
21
|
-
return response.get("item", {}).get("id")
|
|
30
|
+
return int(response.get("item", {}).get("id")) if response.get("item") else None
|
|
22
31
|
|
|
23
32
|
def delete(self) -> None:
|
|
24
33
|
"""
|
|
@@ -61,7 +70,7 @@ class WialonResource(WialonBase):
|
|
|
61
70
|
response = self.session.wialon_api.core_search_item(
|
|
62
71
|
**{"id": self.id, "flags": flags.DATAFLAG_RESOURCE_BILLING_PROPERTIES}
|
|
63
72
|
)
|
|
64
|
-
return response.get("item", {}).get("bact") == self.id
|
|
73
|
+
return int(response.get("item", {}).get("bact")) == self.id
|
|
65
74
|
|
|
66
75
|
def is_migrated(self, unit: WialonBase) -> bool:
|
|
67
76
|
"""
|
|
@@ -3,13 +3,13 @@ from terminusgps.wialon.items.base import WialonBase
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class WialonRetranslator(WialonBase):
|
|
6
|
-
def create(self,
|
|
6
|
+
def create(self, creator_id: str | int, name: str, config: dict) -> int | None:
|
|
7
7
|
"""
|
|
8
8
|
Creates a Wialon retranslator.
|
|
9
9
|
|
|
10
|
-
:param creator_id: A Wialon user
|
|
11
|
-
:type creator_id: :py:obj:`str`
|
|
12
|
-
:param name: A name for the
|
|
10
|
+
:param creator_id: A Wialon user id.
|
|
11
|
+
:type creator_id: :py:obj:`str` | :py:obj:`int`
|
|
12
|
+
:param name: A name for the retranslator.
|
|
13
13
|
:type name: :py:obj:`str`
|
|
14
14
|
:param config: A Wialon retranslator configuration object.
|
|
15
15
|
:type config: :py:obj:`dict`
|
|
@@ -19,22 +19,18 @@ class WialonRetranslator(WialonBase):
|
|
|
19
19
|
:rtype: :py:obj:`None`
|
|
20
20
|
|
|
21
21
|
"""
|
|
22
|
-
if not
|
|
23
|
-
raise ValueError("'creator_id'
|
|
24
|
-
if not kwargs.get("name"):
|
|
25
|
-
raise ValueError("'name' is required on creation.")
|
|
26
|
-
if not kwargs.get("config"):
|
|
27
|
-
raise ValueError("'config' is required on creation.")
|
|
22
|
+
if isinstance(creator_id, str) and not creator_id.isdigit():
|
|
23
|
+
raise ValueError(f"'creator_id' must be a digit, got '{creator_id}'.")
|
|
28
24
|
|
|
29
25
|
response = self.session.wialon_api.core_create_retranslator(
|
|
30
26
|
**{
|
|
31
|
-
"creatorId":
|
|
32
|
-
"name":
|
|
33
|
-
"config":
|
|
27
|
+
"creatorId": creator_id,
|
|
28
|
+
"name": name,
|
|
29
|
+
"config": config,
|
|
34
30
|
"dataFlags": flags.DATAFLAG_UNIT_BASE,
|
|
35
31
|
}
|
|
36
32
|
)
|
|
37
|
-
return response.get("item", {}).get("id")
|
|
33
|
+
return int(response.get("item", {}).get("id")) if response.get("item") else None
|
|
38
34
|
|
|
39
35
|
def update_config(self, new_config: dict) -> None:
|
|
40
36
|
"""
|
|
@@ -3,19 +3,28 @@ from terminusgps.wialon.items.base import WialonBase
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class WialonRoute(WialonBase):
|
|
6
|
-
def create(self,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
def create(self, creator_id: str | int, name: str) -> int | None:
|
|
7
|
+
"""
|
|
8
|
+
Creates a new Wialon route.
|
|
9
|
+
|
|
10
|
+
:param creator_id: A Wialon user id.
|
|
11
|
+
:type creator_id: :py:obj:`str` | :py:obj:`int`
|
|
12
|
+
:param name: A name for the route.
|
|
13
|
+
:type name: :py:obj:`str`
|
|
14
|
+
:raises ValueError: If ``creator_id`` is not a digit.
|
|
15
|
+
:raises WialonError: If something goes wrong with Wialon.
|
|
16
|
+
:returns: The Wialon id for the new route, if it was created.
|
|
17
|
+
:rtype: :py:obj:`int` | :py:obj:`None`
|
|
18
|
+
|
|
19
|
+
"""
|
|
20
|
+
if isinstance(creator_id, str) and not creator_id.isdigit():
|
|
21
|
+
raise ValueError(f"'creator_id' must be a digit, got '{creator_id}'.")
|
|
13
22
|
|
|
14
23
|
response = self.session.wialon_api.core_create_route(
|
|
15
24
|
**{
|
|
16
|
-
"creatorId":
|
|
17
|
-
"name":
|
|
18
|
-
"dataFlags":
|
|
25
|
+
"creatorId": creator_id,
|
|
26
|
+
"name": name,
|
|
27
|
+
"dataFlags": flags.DATAFLAG_UNIT_BASE,
|
|
19
28
|
}
|
|
20
29
|
)
|
|
21
|
-
return response.get("item", {}).get("id")
|
|
30
|
+
return int(response.get("item", {}).get("id")) if response.get("item") else None
|
terminusgps/wialon/items/unit.py
CHANGED
|
@@ -5,36 +5,36 @@ from terminusgps.wialon.items.base import WialonBase
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class WialonUnit(WialonBase):
|
|
8
|
-
def create(
|
|
8
|
+
def create(
|
|
9
|
+
self, creator_id: str | int, name: str, hw_type_id: str | int
|
|
10
|
+
) -> int | None:
|
|
9
11
|
"""
|
|
10
12
|
Creates a new Wialon unit.
|
|
11
13
|
|
|
12
14
|
:param creator_id: A Wialon user id.
|
|
13
|
-
:type creator_id: :py:obj:`int`
|
|
14
|
-
:param name: A
|
|
15
|
+
:type creator_id: :py:obj:`str` | :py:obj:`int`
|
|
16
|
+
:param name: A name for the unit.
|
|
15
17
|
:type name: :py:obj:`str`
|
|
16
18
|
:param hw_type_id: A Wialon hardware type ID.
|
|
17
|
-
:type hw_type_id: :py:obj:`str`
|
|
19
|
+
:type hw_type_id: :py:obj:`str` | :py:obj:`int`
|
|
18
20
|
:returns: The Wialon id for the new unit.
|
|
19
21
|
:rtype: :py:obj:`int` | :py:obj:`None`
|
|
20
22
|
|
|
21
23
|
"""
|
|
22
|
-
if not
|
|
23
|
-
raise ValueError("'creator_id'
|
|
24
|
-
if not
|
|
25
|
-
raise ValueError("'
|
|
26
|
-
if not kwargs.get("hw_type_id"):
|
|
27
|
-
raise ValueError("'hw_type_id' is required on creation.")
|
|
24
|
+
if isinstance(creator_id, str) and not creator_id.isdigit():
|
|
25
|
+
raise ValueError(f"'creator_id' must be a digit, got '{creator_id}'.")
|
|
26
|
+
if isinstance(hw_type_id, str) and not hw_type_id.isdigit():
|
|
27
|
+
raise ValueError(f"'hw_type_id' must be a digit, got '{hw_type_id}'.")
|
|
28
28
|
|
|
29
29
|
response = self.session.wialon_api.core_create_unit(
|
|
30
30
|
**{
|
|
31
|
-
"creatorId":
|
|
32
|
-
"name":
|
|
33
|
-
"hwTypeId":
|
|
31
|
+
"creatorId": creator_id,
|
|
32
|
+
"name": name,
|
|
33
|
+
"hwTypeId": hw_type_id,
|
|
34
34
|
"dataFlags": flags.DATAFLAG_UNIT_BASE,
|
|
35
35
|
}
|
|
36
36
|
)
|
|
37
|
-
return response.get("item", {}).get("id")
|
|
37
|
+
return int(response.get("item", {}).get("id")) if response.get("item") else None
|
|
38
38
|
|
|
39
39
|
@property
|
|
40
40
|
def available_commands(self) -> dict:
|
|
@@ -4,33 +4,32 @@ from terminusgps.wialon.items.base import WialonBase
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class WialonUnitGroup(WialonBase):
|
|
7
|
-
def create(self,
|
|
7
|
+
def create(self, creator_id: str | int, name: str) -> int | None:
|
|
8
8
|
"""
|
|
9
9
|
Creates a new Wialon unit group.
|
|
10
10
|
|
|
11
11
|
:param creator_id: A Wialon user id.
|
|
12
|
-
:type creator_id: :py:obj:`int`
|
|
12
|
+
:type creator_id: :py:obj:`str` | :py:obj:`int`
|
|
13
13
|
:param name: A name for the group.
|
|
14
14
|
:type name: :py:obj:`str`
|
|
15
|
+
:raises ValueError: If ``creator_id`` is not a digit.
|
|
15
16
|
:raises WialonError: If something goes wrong with Wialon.
|
|
16
|
-
:returns: The Wialon id for the new group.
|
|
17
|
+
:returns: The Wialon id for the new group, if it was created.
|
|
17
18
|
:rtype: :py:obj:`int` | :py:obj:`None`
|
|
18
19
|
|
|
19
20
|
"""
|
|
20
21
|
|
|
21
|
-
if not
|
|
22
|
-
raise ValueError("'creator_id'
|
|
23
|
-
if not kwargs.get("name"):
|
|
24
|
-
raise ValueError("'name' is required on creation.")
|
|
22
|
+
if isinstance(creator_id, str) and not creator_id.isdigit():
|
|
23
|
+
raise ValueError(f"'creator_id' must be a digit, got '{creator_id}'.")
|
|
25
24
|
|
|
26
25
|
response = self.session.wialon_api.core_create_unit_group(
|
|
27
26
|
**{
|
|
28
|
-
"creatorId":
|
|
29
|
-
"name":
|
|
27
|
+
"creatorId": creator_id,
|
|
28
|
+
"name": name,
|
|
30
29
|
"dataFlags": flags.DATAFLAG_UNIT_BASE,
|
|
31
30
|
}
|
|
32
31
|
)
|
|
33
|
-
return response.get("item", {}).get("id")
|
|
32
|
+
return int(response.get("item", {}).get("id")) if response.get("item") else None
|
|
34
33
|
|
|
35
34
|
def set_items(self, new_items: list[str]) -> None:
|
|
36
35
|
"""
|
terminusgps/wialon/items/user.py
CHANGED
|
@@ -5,37 +5,34 @@ from terminusgps.wialon.items.base import WialonBase
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class WialonUser(WialonBase):
|
|
8
|
-
def create(self,
|
|
8
|
+
def create(self, creator_id: str | int, name: str, password: str) -> int | None:
|
|
9
9
|
"""
|
|
10
10
|
Creates a new Wialon user.
|
|
11
11
|
|
|
12
12
|
:param creator_id: A Wialon user id.
|
|
13
|
-
:type creator_id: :py:obj:`int`
|
|
13
|
+
:type creator_id: :py:obj:`str` | :py:obj:`int`
|
|
14
14
|
:param name: A name for the user.
|
|
15
15
|
:type name: :py:obj:`str`
|
|
16
|
-
:param
|
|
17
|
-
:type
|
|
16
|
+
:param password: A password for the user.
|
|
17
|
+
:type password: :py:obj:`str`
|
|
18
|
+
:raises ValueError: If ``creator_id`` is not a digit.
|
|
18
19
|
:raises WialonError: If something goes wrong with Wialon.
|
|
19
|
-
:returns: The Wialon id for the new user.
|
|
20
|
+
:returns: The Wialon id for the new user, if it was created.
|
|
20
21
|
:rtype: :py:obj:`int` | :py:obj:`None`
|
|
21
22
|
|
|
22
23
|
"""
|
|
23
|
-
if not
|
|
24
|
-
raise ValueError("'creator_id'
|
|
25
|
-
if not kwargs.get("name"):
|
|
26
|
-
raise ValueError("'name' is required on creation.")
|
|
27
|
-
if not kwargs.get("password"):
|
|
28
|
-
raise ValueError("'password' is required on creation.")
|
|
24
|
+
if isinstance(creator_id, str) and not creator_id.isdigit():
|
|
25
|
+
raise ValueError(f"'creator_id' must be a digit, got '{creator_id}'.")
|
|
29
26
|
|
|
30
27
|
response = self.session.wialon_api.core_create_user(
|
|
31
28
|
**{
|
|
32
|
-
"creatorId":
|
|
33
|
-
"name":
|
|
34
|
-
"password":
|
|
29
|
+
"creatorId": creator_id,
|
|
30
|
+
"name": name,
|
|
31
|
+
"password": password,
|
|
35
32
|
"dataFlags": flags.DATAFLAG_UNIT_BASE,
|
|
36
33
|
}
|
|
37
34
|
)
|
|
38
|
-
return response.get("item", {}).get("id")
|
|
35
|
+
return int(response.get("item", {}).get("id")) if response.get("item") else None
|
|
39
36
|
|
|
40
37
|
def _get_access_response(self, hw_type: str) -> dict:
|
|
41
38
|
"""
|
|
File without changes
|
{python_terminusgps-1.17.1.dist-info → python_terminusgps-19.0.0.dist-info}/licenses/COPYING
RENAMED
|
File without changes
|