python-terminusgps 1.0.1__tar.gz → 1.1.0__tar.gz

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.

Potentially problematic release.


This version of python-terminusgps might be problematic. Click here for more details.

Files changed (27) hide show
  1. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/PKG-INFO +3 -2
  2. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/pyproject.toml +3 -2
  3. python_terminusgps-1.1.0/terminusgps/aws/__init__.py +0 -0
  4. python_terminusgps-1.1.0/terminusgps/aws/secrets.py +9 -0
  5. python_terminusgps-1.1.0/terminusgps/wialon/items/user.py +80 -0
  6. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/terminusgps/wialon/utils.py +3 -1
  7. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/uv.lock +68 -13
  8. python_terminusgps-1.0.1/terminusgps/wialon/items/user.py +0 -22
  9. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/.gitignore +0 -0
  10. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/COPYING +0 -0
  11. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/README.md +0 -0
  12. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/requirements.txt +0 -0
  13. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/terminusgps/__init__.py +0 -0
  14. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/terminusgps/authorizenet/__init__.py +0 -0
  15. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/terminusgps/authorizenet/auth.py +0 -0
  16. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/terminusgps/wialon/__init__.py +0 -0
  17. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/terminusgps/wialon/constants.py +0 -0
  18. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/terminusgps/wialon/errors.py +0 -0
  19. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/terminusgps/wialon/flags.py +0 -0
  20. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/terminusgps/wialon/items/__init__.py +0 -0
  21. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/terminusgps/wialon/items/base.py +0 -0
  22. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/terminusgps/wialon/items/resource.py +0 -0
  23. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/terminusgps/wialon/items/retranslator.py +0 -0
  24. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/terminusgps/wialon/items/route.py +0 -0
  25. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/terminusgps/wialon/items/unit.py +0 -0
  26. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/terminusgps/wialon/items/unit_group.py +0 -0
  27. {python_terminusgps-1.0.1 → python_terminusgps-1.1.0}/terminusgps/wialon/session.py +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: python-terminusgps
3
- Version: 1.0.1
4
- Summary: Provides abstractions/utilities for working with Wialon and Authorize.NET APIs.
3
+ Version: 1.1.0
4
+ Summary: Provides abstractions/utilities for working with Wialon API, Authorize.NET API, AWS API, and more.
5
5
  Author-email: Blake Nall <blake@terminusgps.com>
6
6
  Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
7
7
  Classifier: Operating System :: OS Independent
@@ -11,4 +11,5 @@ Classifier: Programming Language :: Python :: 3.13
11
11
  Requires-Python: >=3.12
12
12
  Requires-Dist: argparse>=1.4.0
13
13
  Requires-Dist: authorizenet>=1.1.5
14
+ Requires-Dist: boto3>=1.35.80
14
15
  Requires-Dist: python-wialon>=1.2.4
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "python-terminusgps"
3
- version = "1.0.1"
4
- description = "Provides abstractions/utilities for working with Wialon and Authorize.NET APIs."
3
+ version = "1.1.0"
4
+ description = "Provides abstractions/utilities for working with Wialon API, Authorize.NET API, AWS API, and more."
5
5
  readme = "README.md"
6
6
  authors = [ {name = "Blake Nall", email = "blake@terminusgps.com" } ]
7
7
  classifiers = [
@@ -15,6 +15,7 @@ requires-python = ">=3.12"
15
15
  dependencies = [
16
16
  "argparse>=1.4.0",
17
17
  "authorizenet>=1.1.5",
18
+ "boto3>=1.35.80",
18
19
  "python-wialon>=1.2.4",
19
20
  ]
20
21
 
File without changes
@@ -0,0 +1,9 @@
1
+ import boto3
2
+ import json
3
+
4
+
5
+ def get_secret(name: str, region: str = "us-east-1") -> dict[str, str]:
6
+ """Logs into the default AWS CLI session and returns a secret value."""
7
+ client = boto3.Session().client(service_name="secretsmanager", region_name=region)
8
+ secret = client.get_secret_value(SecretId=name)["SecretString"]
9
+ return json.loads(secret)
@@ -0,0 +1,80 @@
1
+ from urllib.parse import quote_plus
2
+
3
+ from terminusgps.wialon import flags
4
+ from terminusgps.wialon.items.base import WialonBase
5
+ from terminusgps.wialon import constants
6
+
7
+
8
+ class WialonUser(WialonBase):
9
+ def create(self, **kwargs) -> int | None:
10
+ if not kwargs.get("owner_id"):
11
+ raise ValueError("'owner_id' is required on creation.")
12
+ if not kwargs.get("name"):
13
+ raise ValueError("'name' is required on creation.")
14
+ if not kwargs.get("password"):
15
+ raise ValueError("'password' is required on creation.")
16
+
17
+ response = self.session.wialon_api.core_create_user(
18
+ **{
19
+ "creatorId": kwargs["owner_id"],
20
+ "name": kwargs["name"],
21
+ "password": kwargs["password"],
22
+ "dataFlags": flags.DATAFLAG_UNIT_BASE,
23
+ }
24
+ )
25
+ return response.get("item", {}).get("id")
26
+
27
+ def _get_access_response(self, hw_type: str) -> dict:
28
+ return self.session.wialon_api.user_get_items_access(
29
+ **{
30
+ "userId": self.id,
31
+ "directAccess": True,
32
+ "itemSuperclass": hw_type,
33
+ "flags": 0x2,
34
+ }
35
+ )
36
+
37
+ @property
38
+ def units(self) -> list[str]:
39
+ response = self._get_access_response(hw_type="avl_unit")
40
+ return [key for key in response.keys()]
41
+
42
+ @property
43
+ def groups(self) -> list[str]:
44
+ response = self._get_access_response(hw_type="avl_unit_group")
45
+ return [key for key in response.keys()]
46
+
47
+ def has_access(self, other_item: WialonBase) -> bool:
48
+ response = self._get_access_response(hw_type=other_item.hw_type)
49
+ items = [key for key in response.keys()]
50
+ if str(other_item.id) in items:
51
+ return True
52
+ return False
53
+
54
+ def assign_phone(self, phone: str) -> None:
55
+ self.add_cproperty(("phone", quote_plus(phone)))
56
+
57
+ def assign_email(self, email: str) -> None:
58
+ self.add_cproperty(("email", email))
59
+
60
+ def assign_item(
61
+ self, item: WialonBase, access_mask: int = constants.ACCESSMASK_UNIT_BASIC
62
+ ) -> None:
63
+ """Assigns an item to this user according to the supplied access mask integer."""
64
+ self.session.wialon_api.user_update_item_access(
65
+ **{"userId": self.id, "itemId": item.id, "accessMask": access_mask}
66
+ )
67
+
68
+ def set_settings_flags(self, flags: int, flags_mask: int) -> None:
69
+ self.session.wialon_api.user_update_user_flags(
70
+ **{"userId": self.id, "flags": flags, "flagsMask": flags_mask}
71
+ )
72
+
73
+ def update_password(self, old_password: str, new_password: str) -> None:
74
+ self.session.wialon_api.user_update_password(
75
+ **{
76
+ "userId": self.id,
77
+ "oldPassword": old_password,
78
+ "newPassword": new_password,
79
+ }
80
+ )
@@ -13,10 +13,12 @@ def is_unique(value: str, session: WialonSession, items_type: str = "avl_unit")
13
13
  return not bool(result)
14
14
 
15
15
 
16
- def gen_wialon_password(length: int = 32) -> str:
16
+ def gen_wialon_password(length: int = 16) -> str:
17
17
  """Generates a Wialon compliant password."""
18
18
  if length > 64:
19
19
  raise ValueError(f"Passwords cannot be greater than 64 chars. Got '{length}'.")
20
+ if length < 4:
21
+ raise ValueError(f"Password cannot be less than 4 chars. Got '{length}'.")
20
22
 
21
23
  symbols: str = "!@#$%^*()[]-_+"
22
24
  alphabet: str = string.ascii_letters + string.digits + symbols
@@ -21,6 +21,34 @@ dependencies = [
21
21
  ]
22
22
  sdist = { url = "https://files.pythonhosted.org/packages/2d/9a/61c151f508a9b32014b622c9c65b614c7c32068201eee1d93c93010558bc/authorizenet-1.1.5.tar.gz", hash = "sha256:ba8b538028201c01d7ed097ea0842f7732c220472006d105b4a6b948ddcaf4dc", size = 158959 }
23
23
 
24
+ [[package]]
25
+ name = "boto3"
26
+ version = "1.35.80"
27
+ source = { registry = "https://pypi.org/simple" }
28
+ dependencies = [
29
+ { name = "botocore" },
30
+ { name = "jmespath" },
31
+ { name = "s3transfer" },
32
+ ]
33
+ sdist = { url = "https://files.pythonhosted.org/packages/81/cd/58de9a4e792176bca4f2e4b4248a9db4a47ae217bc20ac6adb3052b029d3/boto3-1.35.80.tar.gz", hash = "sha256:50dae461ab5fbedfb81b690895d48a918fed0d5fdff37be1c4232770c0dc9712", size = 111009 }
34
+ wheels = [
35
+ { url = "https://files.pythonhosted.org/packages/0a/72/f6724a19acaac7a7cdfc088ac95d2d0ea3626c00d5a5197a99e49bde474d/boto3-1.35.80-py3-none-any.whl", hash = "sha256:21a3b18c3a7fd20e463708fe3fa035983105dc7f3a1c274e1903e1583ab91159", size = 139179 },
36
+ ]
37
+
38
+ [[package]]
39
+ name = "botocore"
40
+ version = "1.35.80"
41
+ source = { registry = "https://pypi.org/simple" }
42
+ dependencies = [
43
+ { name = "jmespath" },
44
+ { name = "python-dateutil" },
45
+ { name = "urllib3" },
46
+ ]
47
+ sdist = { url = "https://files.pythonhosted.org/packages/81/e3/b10f8c2c58fd144d99de10e5f964bd1b0e609d27cb05513bebfdfa47e3eb/botocore-1.35.80.tar.gz", hash = "sha256:b8dfceca58891cb2711bd6455ec4f7159051f3796e0f64adef9bb334f19d8a92", size = 13456944 }
48
+ wheels = [
49
+ { url = "https://files.pythonhosted.org/packages/f6/cc/7ecef0f0e883f4bd8e23a04e86d98f8c7d6aa6a821efcec67b3547388d2e/botocore-1.35.80-py3-none-any.whl", hash = "sha256:36e589dccb62380abd628b08fecfa2f7c89b99f41ec9fc42c467c94008c0be4a", size = 13263229 },
50
+ ]
51
+
24
52
  [[package]]
25
53
  name = "certifi"
26
54
  version = "2024.8.30"
@@ -87,6 +115,15 @@ wheels = [
87
115
  { url = "https://files.pythonhosted.org/packages/76/c6/c88e154df9c4e1a2a66ccf0005a88dfb2650c1dffb6f5ce603dfbd452ce3/idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3", size = 70442 },
88
116
  ]
89
117
 
118
+ [[package]]
119
+ name = "jmespath"
120
+ version = "1.0.1"
121
+ source = { registry = "https://pypi.org/simple" }
122
+ sdist = { url = "https://files.pythonhosted.org/packages/00/2a/e867e8531cf3e36b41201936b7fa7ba7b5702dbef42922193f05c8976cd6/jmespath-1.0.1.tar.gz", hash = "sha256:90261b206d6defd58fdd5e85f478bf633a2901798906be2ad389150c5c60edbe", size = 25843 }
123
+ wheels = [
124
+ { url = "https://files.pythonhosted.org/packages/31/b4/b9b800c45527aadd64d5b442f9b932b00648617eb5d63d2c7a6587b7cafc/jmespath-1.0.1-py3-none-any.whl", hash = "sha256:02e2e4cc71b5bcab88332eebf907519190dd9e6e82107fa7f83b1003a6252980", size = 20256 },
125
+ ]
126
+
90
127
  [[package]]
91
128
  name = "lxml"
92
129
  version = "4.9.4"
@@ -102,31 +139,37 @@ wheels = [
102
139
  { url = "https://files.pythonhosted.org/packages/5f/df/6d15cc415e04724ba4c141051cf43709e09bbcdd9868a6c2e7a7073ef498/lxml-4.9.4-cp312-cp312-win_amd64.whl", hash = "sha256:f1faee2a831fe249e1bae9cbc68d3cd8a30f7e37851deee4d7962b17c410dd56", size = 3773977 },
103
140
  ]
104
141
 
142
+ [[package]]
143
+ name = "python-dateutil"
144
+ version = "2.9.0.post0"
145
+ source = { registry = "https://pypi.org/simple" }
146
+ dependencies = [
147
+ { name = "six" },
148
+ ]
149
+ sdist = { url = "https://files.pythonhosted.org/packages/66/c0/0c8b6ad9f17a802ee498c46e004a0eb49bc148f2fd230864601a86dcf6db/python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3", size = 342432 }
150
+ wheels = [
151
+ { url = "https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427", size = 229892 },
152
+ ]
153
+
105
154
  [[package]]
106
155
  name = "python-terminusgps"
107
- version = "1.0.0"
156
+ version = "1.1.0"
108
157
  source = { editable = "." }
109
158
  dependencies = [
110
159
  { name = "argparse" },
111
160
  { name = "authorizenet" },
161
+ { name = "boto3" },
112
162
  { name = "python-wialon" },
113
163
  ]
114
164
 
115
- [package.dev-dependencies]
116
- dev = [
117
- { name = "setuptools" },
118
- ]
119
-
120
165
  [package.metadata]
121
166
  requires-dist = [
122
167
  { name = "argparse", specifier = ">=1.4.0" },
123
168
  { name = "authorizenet", specifier = ">=1.1.5" },
169
+ { name = "boto3", specifier = ">=1.35.80" },
124
170
  { name = "python-wialon", specifier = ">=1.2.4" },
125
171
  ]
126
172
 
127
- [package.metadata.requires-dev]
128
- dev = [{ name = "setuptools", specifier = ">=75.6.0" }]
129
-
130
173
  [[package]]
131
174
  name = "python-wialon"
132
175
  version = "1.2.4"
@@ -165,12 +208,15 @@ wheels = [
165
208
  ]
166
209
 
167
210
  [[package]]
168
- name = "setuptools"
169
- version = "75.6.0"
211
+ name = "s3transfer"
212
+ version = "0.10.4"
170
213
  source = { registry = "https://pypi.org/simple" }
171
- sdist = { url = "https://files.pythonhosted.org/packages/43/54/292f26c208734e9a7f067aea4a7e282c080750c4546559b58e2e45413ca0/setuptools-75.6.0.tar.gz", hash = "sha256:8199222558df7c86216af4f84c30e9b34a61d8ba19366cc914424cdbd28252f6", size = 1337429 }
214
+ dependencies = [
215
+ { name = "botocore" },
216
+ ]
217
+ sdist = { url = "https://files.pythonhosted.org/packages/c0/0a/1cdbabf9edd0ea7747efdf6c9ab4e7061b085aa7f9bfc36bb1601563b069/s3transfer-0.10.4.tar.gz", hash = "sha256:29edc09801743c21eb5ecbc617a152df41d3c287f67b615f73e5f750583666a7", size = 145287 }
172
218
  wheels = [
173
- { url = "https://files.pythonhosted.org/packages/55/21/47d163f615df1d30c094f6c8bbb353619274edccf0327b185cc2493c2c33/setuptools-75.6.0-py3-none-any.whl", hash = "sha256:ce74b49e8f7110f9bf04883b730f4765b774ef3ef28f722cce7c273d253aaf7d", size = 1224032 },
219
+ { url = "https://files.pythonhosted.org/packages/66/05/7957af15543b8c9799209506df4660cba7afc4cf94bfb60513827e96bed6/s3transfer-0.10.4-py3-none-any.whl", hash = "sha256:244a76a24355363a68164241438de1b72f8781664920260c48465896b712a41e", size = 83175 },
174
220
  ]
175
221
 
176
222
  [[package]]
@@ -208,6 +254,15 @@ wheels = [
208
254
  { url = "https://files.pythonhosted.org/packages/0d/e7/f9fafbd4f39793a20cc52e77bbd766f7384312526d402c382928dc7667f6/simplejson-3.19.3-py3-none-any.whl", hash = "sha256:49cc4c7b940d43bd12bf87ec63f28cbc4964fc4e12c031cc8cd01650f43eb94e", size = 57004 },
209
255
  ]
210
256
 
257
+ [[package]]
258
+ name = "six"
259
+ version = "1.17.0"
260
+ source = { registry = "https://pypi.org/simple" }
261
+ sdist = { url = "https://files.pythonhosted.org/packages/94/e7/b2c673351809dca68a0e064b6af791aa332cf192da575fd474ed7d6f16a2/six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81", size = 34031 }
262
+ wheels = [
263
+ { url = "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size = 11050 },
264
+ ]
265
+
211
266
  [[package]]
212
267
  name = "urllib3"
213
268
  version = "2.2.3"
@@ -1,22 +0,0 @@
1
- from terminusgps.wialon import flags
2
- from terminusgps.wialon.items.base import WialonBase
3
-
4
-
5
- class WialonUser(WialonBase):
6
- def create(self, **kwargs) -> int | None:
7
- if not kwargs.get("owner_id"):
8
- raise ValueError("'owner_id' is required on creation.")
9
- if not kwargs.get("name"):
10
- raise ValueError("'name' is required on creation.")
11
- if not kwargs.get("password"):
12
- raise ValueError("'password' is required on creation.")
13
-
14
- response = self.session.wialon_api.core_create_user(
15
- **{
16
- "creatorId": kwargs["owner_id"],
17
- "name": kwargs["name"],
18
- "password": kwargs["password"],
19
- "dataFlags": flags.DATAFLAG_UNIT_BASE,
20
- }
21
- )
22
- return response.get("item", {}).get("id")