python-terminusgps 20.5.0__tar.gz → 20.5.1__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 (60) hide show
  1. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/PKG-INFO +1 -1
  2. python_terminusgps-20.5.1/docs/source/authorizenet/profiles.rst +22 -0
  3. python_terminusgps-20.5.1/docs/source/wialon/examples.rst +118 -0
  4. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/docs/source/wialon/flags.rst +2 -0
  5. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/docs/source/wialon/index.rst +2 -0
  6. python_terminusgps-20.5.1/docs/source/wialon/items.rst +29 -0
  7. python_terminusgps-20.5.1/docs/source/wialon/session.rst +37 -0
  8. python_terminusgps-20.5.1/docs/source/wialon/settings.rst +59 -0
  9. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/docs/source/wialon/utils.rst +3 -10
  10. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/pyproject.toml +1 -1
  11. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/wialon/session.py +0 -17
  12. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/uv.lock +1 -1
  13. python_terminusgps-20.5.0/docs/source/authorizenet/profiles.rst +0 -2
  14. python_terminusgps-20.5.0/docs/source/wialon/items.rst +0 -537
  15. python_terminusgps-20.5.0/docs/source/wialon/session.rst +0 -155
  16. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/.gitignore +0 -0
  17. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/COPYING +0 -0
  18. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/README.md +0 -0
  19. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/docs/Makefile +0 -0
  20. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/docs/make.bat +0 -0
  21. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/docs/source/authorizenet/auth.rst +0 -0
  22. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/docs/source/authorizenet/index.rst +0 -0
  23. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/docs/source/aws/index.rst +0 -0
  24. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/docs/source/aws/secrets.rst +0 -0
  25. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/docs/source/conf.py +0 -0
  26. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/docs/source/index.rst +0 -0
  27. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/docs/source/twilio/caller.rst +0 -0
  28. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/docs/source/twilio/index.rst +0 -0
  29. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/docs/source/wialon/constants.rst +0 -0
  30. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/docs/source/wialon/errors.rst +0 -0
  31. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/__init__.py +0 -0
  32. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/authorizenet/__init__.py +0 -0
  33. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/authorizenet/auth.py +0 -0
  34. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/authorizenet/profiles/__init__.py +0 -0
  35. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/authorizenet/profiles/addresses.py +0 -0
  36. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/authorizenet/profiles/base.py +0 -0
  37. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/authorizenet/profiles/customers.py +0 -0
  38. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/authorizenet/profiles/payments.py +0 -0
  39. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/authorizenet/subscriptions.py +0 -0
  40. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/aws/__init__.py +0 -0
  41. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/aws/secrets.py +0 -0
  42. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/aws/ses.py +0 -0
  43. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/settings.py +0 -0
  44. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/twilio/__init__.py +0 -0
  45. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/twilio/caller.py +0 -0
  46. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/wialon/__init__.py +0 -0
  47. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/wialon/constants.py +0 -0
  48. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/wialon/flags.py +0 -0
  49. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/wialon/items/__init__.py +0 -0
  50. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/wialon/items/base.py +0 -0
  51. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/wialon/items/geofence.py +0 -0
  52. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/wialon/items/notification.py +0 -0
  53. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/wialon/items/resource.py +0 -0
  54. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/wialon/items/retranslator.py +0 -0
  55. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/wialon/items/route.py +0 -0
  56. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/wialon/items/unit.py +0 -0
  57. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/wialon/items/unit_group.py +0 -0
  58. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/wialon/items/user.py +0 -0
  59. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/wialon/logger.py +0 -0
  60. {python_terminusgps-20.5.0 → python_terminusgps-20.5.1}/terminusgps/wialon/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-terminusgps
3
- Version: 20.5.0
3
+ Version: 20.5.1
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
@@ -0,0 +1,22 @@
1
+ Profiles
2
+ ========
3
+
4
+ .. autoclass:: terminusgps.authorizenet.profiles.base.AuthorizenetProfileBase
5
+ :members:
6
+ :private-members:
7
+
8
+ .. autoclass:: terminusgps.authorizenet.profiles.base.AuthorizenetSubProfileBase
9
+ :members:
10
+ :private-members:
11
+
12
+ .. autoclass:: terminusgps.authorizenet.profiles.addresses.AddressProfile
13
+ :members:
14
+ :private-members:
15
+
16
+ .. autoclass:: terminusgps.authorizenet.profiles.customers.CustomerProfile
17
+ :members:
18
+ :private-members:
19
+
20
+ .. autoclass:: terminusgps.authorizenet.profiles.payments.PaymentProfile
21
+ :members:
22
+ :private-members:
@@ -0,0 +1,118 @@
1
+ Usage Examples
2
+ ==============
3
+
4
+ ===============================
5
+ Create a new unit and rename it
6
+ ===============================
7
+
8
+ 1. Import :py:obj:`~terminusgps.wialon.session.WialonSession` and :py:obj:`~terminusgps.wialon.items.WialonUnit`.
9
+
10
+ Let's also import :py:obj:`~terminusgps.wialon.utils.generate_wialon_password` so we don't have to come up with a valid Wialon password ourselves.
11
+
12
+ .. code:: python
13
+
14
+ from terminusgps.wialon.session import WialonSession
15
+ from terminusgps.wialon.items import WialonUnit
16
+ from terminusgps.wialon.utils import generate_wialon_password
17
+
18
+ 2. Open the session in a context manager and instantiate a unit.
19
+
20
+ .. code:: python
21
+
22
+ with WialonSession(token="my_wialon_api_token") as session:
23
+ unit = WialonUnit(
24
+ id=None,
25
+ session=session,
26
+ creator_id="123",
27
+ name="test_user",
28
+ password=generate_wialon_password(32)
29
+ )
30
+ print(f"{unit.name = }") # unit.name = "test_user"
31
+
32
+ 3. Within the context manager, :py:obj:`~terminusgps.wialon.items.WialonUnit` methods can be executed.
33
+
34
+ .. code:: python
35
+
36
+ with WialonSession(token="my_secure_wialon_token") as session:
37
+ ...
38
+
39
+ unit.rename("super_test_user")
40
+ # Session is logged out after exiting scope
41
+
42
+ -----------------
43
+ Full code example
44
+ -----------------
45
+
46
+ .. code:: python
47
+
48
+ from terminusgps.wialon.session import WialonSession
49
+ from terminusgps.wialon.items import WialonUnit
50
+ from terminusgps.wialon.utils import generate_wialon_password
51
+
52
+ with WialonSession(token="my_secure_wialon_token") as session:
53
+ unit = WialonUnit(
54
+ id=None,
55
+ session=session,
56
+ creator_id="123",
57
+ name="test_user",
58
+ password=generate_wialon_password(32)
59
+ )
60
+ unit.rename("super_test_user")
61
+
62
+
63
+ ============================================
64
+ Create an account and migrate a unit into it
65
+ ============================================
66
+
67
+ 1. Import :py:obj:`~terminusgps.wialon.session.WialonSession` and :py:obj:`~terminusgps.wialon.items`.
68
+
69
+ .. code:: python
70
+
71
+ from terminusgps.wialon.session import WialonSession
72
+ from terminusgps.wialon import items
73
+
74
+ 2. Create an account user.
75
+
76
+ .. code:: python
77
+
78
+ with WialonSession(token="my_secure_wialon_token") as session:
79
+
80
+
81
+ -----------------
82
+ Full code example
83
+ -----------------
84
+
85
+ .. code:: python
86
+
87
+ from django.conf import settings
88
+
89
+ from terminusgps.wialon import items, constants
90
+ from terminusgps.wialon.session import WialonSession
91
+ from terminusgps.wialon.utils import generate_wialon_password, get_hw_type_id
92
+
93
+ with WialonSession(token="my_secure_wialon_token") as session:
94
+ hw_type_id = get_hw_type_id("Test HW", session)
95
+
96
+ account_user = items.WialonUser(
97
+ id=None,
98
+ session=session,
99
+ creator_id=settings.WIALON_ADMIN_ID,
100
+ name="account_user",
101
+ password=generate_wialon_password(32),
102
+ )
103
+ account_resource = items.WialonResource(
104
+ id=None,
105
+ session=session,
106
+ creator_id=account_user.id, # Use the new account user to create this resource
107
+ name="account_resource",
108
+ )
109
+ unit = WialonUnit(
110
+ id=None,
111
+ session=session,
112
+ creator_id=settings.WIALON_ADMIN_ID, # Account user CANNOT create the unit
113
+ name="test_unit",
114
+ hw_type_id=hw_type_id,
115
+ )
116
+
117
+ account_user.grant_access(unit, access_mask=constants.ACCESSMASK_UNIT_MIGRATION)
118
+ account_resource.migrate_unit(unit)
@@ -1,6 +1,8 @@
1
1
  Flags
2
2
  =====
3
3
 
4
+ .. automodule:: terminusgps.wialon.flags
5
+
4
6
  .. currentmodule:: terminusgps.wialon.flags
5
7
 
6
8
  ============
@@ -9,7 +9,9 @@ Wialon API
9
9
 
10
10
  constants.rst
11
11
  errors.rst
12
+ examples.rst
12
13
  flags.rst
13
14
  items.rst
14
15
  session.rst
16
+ settings.rst
15
17
  utils.rst
@@ -0,0 +1,29 @@
1
+ Items
2
+ =====
3
+
4
+ .. autoclass:: terminusgps.wialon.items.base.WialonBase
5
+ :members:
6
+
7
+ .. autoclass:: terminusgps.wialon.items.geofence.WialonGeofence
8
+ :members:
9
+
10
+ .. autoclass:: terminusgps.wialon.items.notification.WialonNotification
11
+ :members:
12
+
13
+ .. autoclass:: terminusgps.wialon.items.resource.WialonResource
14
+ :members:
15
+
16
+ .. autoclass:: terminusgps.wialon.items.retranslator.WialonRetranslator
17
+ :members:
18
+
19
+ .. autoclass:: terminusgps.wialon.items.route.WialonRoute
20
+ :members:
21
+
22
+ .. autoclass:: terminusgps.wialon.items.unit.WialonUnit
23
+ :members:
24
+
25
+ .. autoclass:: terminusgps.wialon.items.unit_group.WialonUnitGroup
26
+ :members:
27
+
28
+ .. autoclass:: terminusgps.wialon.items.user.WialonUser
29
+ :members:
@@ -0,0 +1,37 @@
1
+ Wialon API Sessions
2
+ ===================
3
+
4
+ .. autoclass:: terminusgps.wialon.session.WialonSession
5
+ :members:
6
+
7
+ .. autoclass:: terminusgps.wialon.session.WialonSessionManager
8
+ :members:
9
+
10
+
11
+ =====
12
+ Usage
13
+ =====
14
+
15
+ .. code:: python
16
+
17
+ from terminusgps.wialon.session import WialonSession
18
+
19
+ # Create a session and login to it
20
+ session = WialonSession()
21
+ session.login(token="my_secure_token")
22
+
23
+ # Use the logged in session to perform API actions
24
+ session.wialon_api.core_search_item(**{"id": "123", "flags": 1})
25
+
26
+ # Don't forget to logout of the session
27
+ # Sessions are destroyed after 5min of inactivity
28
+ session.logout()
29
+
30
+ # Alternatively, use a context manager
31
+ # The context manager handles logging in and out of the session.
32
+ with WialonSession() as session:
33
+ session.wialon_api.core_search_item(**{"id": "123", "flags": 1})
34
+
35
+ # If you already have a session id, no need to login again
36
+ session = WialonSession(sid="my_valid_session_id")
37
+ session.wialon_api.core_search_item(**{"id": "123", "flags": 1})
@@ -0,0 +1,59 @@
1
+ Settings
2
+ ========
3
+
4
+ .. confval:: DEBUG
5
+
6
+ :type: :py:obj:`bool`
7
+ :default: :py:obj:`True`
8
+
9
+ Debug mode enabled.
10
+
11
+ .. confval:: MERCHANT_AUTH_LOGIN_ID
12
+
13
+ :type: :py:obj:`str`
14
+
15
+ An authorizenet merchant authentication login id.
16
+
17
+ .. confval:: MERCHANT_AUTH_TRANSACTION_KEY
18
+
19
+ :type: :py:obj:`str`
20
+
21
+ An authorizenet merchant authentication transaction key.
22
+
23
+ This key signs all Authorizenet transactions.
24
+
25
+ .. confval:: TWILIO_FROM_NUMBER
26
+
27
+ :type: :py:obj:`str`
28
+
29
+ A phone number to send Twilio notifications from.
30
+
31
+ .. confval:: TWILIO_MESSAGING_SID
32
+
33
+ :type: :py:obj:`str`
34
+
35
+ A Twilio API messaging session id.
36
+
37
+ .. confval:: TWILIO_SID
38
+
39
+ :type: :py:obj:`str`
40
+
41
+ A Twilio API session id.
42
+
43
+ .. confval:: TWILIO_TOKEN
44
+
45
+ :type: :py:obj:`str`
46
+
47
+ A Twilio API token.
48
+
49
+ .. confval:: WIALON_ADMIN_ID
50
+
51
+ :type: :py:obj:`str`
52
+
53
+ A Wialon user id to operate as during Wialon API session.
54
+
55
+ .. confval:: WIALON_TOKEN
56
+
57
+ :type: :py:obj:`str`
58
+
59
+ An active Wialon API token.
@@ -5,16 +5,9 @@ Utilities
5
5
  Functions
6
6
  =========
7
7
 
8
- .. currentmodule:: terminusgps.wialon.utils
9
-
10
- .. autosummary::
11
-
12
- get_hw_type_id
13
- get_id_from_iccid
14
- get_wialon_cls
15
- get_vin_info
16
- is_unique
17
- generate_wialon_password
8
+ .. automodule:: terminusgps.wialon.utils
9
+ :members:
10
+ :exclude-members: gen_wialon_password
18
11
 
19
12
  =====
20
13
  Usage
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "python-terminusgps"
3
- version = "20.5.0"
3
+ version = "20.5.1"
4
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" } ]
@@ -342,20 +342,3 @@ class WialonSessionManager:
342
342
  if not self._session:
343
343
  self._session = WialonSession(sid=sid, log_level=log_level)
344
344
  return self._session
345
-
346
-
347
- def main() -> None:
348
- # Usage example
349
- session = WialonSession(log_level=logging.DEBUG) # Instantiate session
350
- session.login(settings.WIALON_TOKEN) # Login to session
351
- session.wialon_api.avl_evts() # Call Wialon API
352
- session.logout() # Logout of session
353
-
354
- # Alternatively, use a context manager to handle logging in and out
355
- with WialonSession() as session:
356
- session.wialon_api.avl_evts() # Call Wialon API, logout when scope ends
357
- return
358
-
359
-
360
- if __name__ == "__main__":
361
- main()
@@ -504,7 +504,7 @@ wheels = [
504
504
 
505
505
  [[package]]
506
506
  name = "python-terminusgps"
507
- version = "20.5.0"
507
+ version = "20.5.1"
508
508
  source = { editable = "." }
509
509
  dependencies = [
510
510
  { name = "argparse" },
@@ -1,2 +0,0 @@
1
- Customer Profiles
2
- =================
@@ -1,537 +0,0 @@
1
- Items
2
- =====
3
-
4
- .. currentmodule:: terminusgps.wialon.items.base
5
-
6
- .. py:class:: WialonBase
7
-
8
- Base class for Wialon API objects.
9
-
10
- .. py:method:: create() -> int | None
11
-
12
- Creates a Wialon object and returns its id.
13
-
14
- :meta abstract:
15
- :returns: The new object's id.
16
- :rtype: :py:obj:`int` | :py:obj:`None`
17
-
18
- .. py:method:: rename(new_name) -> None
19
-
20
- Renames the Wialon object to the new name.
21
-
22
- :param new_name: A new name.
23
- :type new_name: :py:obj:`str`
24
- :returns: Nothing.
25
- :rtype: :py:obj:`None`
26
-
27
- .. py:method:: add_afield(field) -> None
28
-
29
- Adds an admin field to the Wialon object.
30
-
31
- :param field: A tuple containing the name of the field and the value of the field.
32
- :type field: :py:obj:`tuple`
33
- :returns: Nothing.
34
- :rtype: :py:obj:`None`
35
-
36
- .. py:method:: update_afield(field_id, field) -> None
37
-
38
- Updates an admin field by id to the Wialon object.
39
-
40
- :param field_id: The admin field id.
41
- :type field_id: :py:obj:`int`
42
- :param field: A tuple containing the name of the field and the value of the field.
43
- :type field: :py:obj:`tuple`
44
- :returns: Nothing.
45
- :rtype: :py:obj:`None`
46
-
47
-
48
- .. py:method:: add_cfield(field) -> None
49
-
50
- Adds a custom field to the Wialon object.
51
-
52
- :param field: A tuple containing the name of the field and the value of the field.
53
- :type field: :py:obj:`tuple`
54
- :returns: Nothing.
55
- :rtype: :py:obj:`None`
56
-
57
- .. py:method:: update_cfield(field_id, field) -> None
58
-
59
- Updates a custom field by id.
60
-
61
- :param field_id: The admin field id.
62
- :type field_id: :py:obj:`int`
63
- :param field: A tuple containing the name of the field and the value of the field.
64
- :type field: :py:obj:`tuple`
65
- :returns: Nothing.
66
- :rtype: :py:obj:`None`
67
-
68
- .. py:method:: add_cproperty(property) -> None
69
-
70
- Adds a custom property to the Wialon object.
71
-
72
- :param property: A tuple containing the name of the property and the value of the property.
73
- :type property: :py:obj:`tuple`
74
- :returns: Nothing.
75
- :rtype: :py:obj:`None`
76
-
77
- .. py:method:: add_profile_field(field) -> None
78
-
79
- Adds a profile field to the Wialon object.
80
-
81
- :param field: A tuple containing the name of the field and the value of the field.
82
- :type field: :py:obj:`tuple`
83
- :returns: Nothing.
84
- :rtype: :py:obj:`None`
85
-
86
- .. py:method:: delete() -> None
87
-
88
- Deletes the Wialon object.
89
-
90
- :raises WialonError: If something goes wrong with Wialon.
91
- :returns: Nothing.
92
- :rtype: :py:obj:`None`
93
-
94
-
95
- .. currentmodule:: terminusgps.wialon.items.geofence
96
-
97
- .. py:class:: WialonGeofence
98
-
99
- .. currentmodule:: terminusgps.wialon.items.notification
100
-
101
- .. py:class:: WialonNotification
102
-
103
- .. currentmodule:: terminusgps.wialon.items.resource
104
-
105
- .. py:class:: WialonResource
106
-
107
- .. py:method:: create(creator_id, name) -> int | None
108
-
109
- Creates a new Wialon resource.
110
-
111
- :param creator_id: A Wialon user id.
112
- :type creator_id: :py:obj:`int` | :py:obj:`str`
113
- :param name: A name for the resource.
114
- :type name: :py:obj:`str`
115
- :raises ValueError: If ``creator_id`` is not a digit.
116
- :raises WialonError: If something goes wrong with Wialon.
117
- :returns: The Wialon id for the new resource, if it was created.
118
- :rtype: :py:obj:`int` | :py:obj:`None`
119
-
120
- .. py:method:: delete() -> None
121
-
122
- Deletes all micro-objects assigned to the resource.
123
-
124
- If the resource is an account, instead deletes all macro-objects and micro-objects assigned to the account.
125
-
126
- :returns: Nothing.
127
- :rtype: :py:obj:`None`
128
-
129
- .. py:method:: is_migrated(unit) -> None
130
-
131
- Checks if a unit is migrated into the account.
132
-
133
- :param unit: A Wialon object.
134
- :type unit: :py:obj:`~terminusgps.wialon.items.base.WialonBase`
135
- :returns: Whether or not the unit is migrated into the account.
136
- :rtype: :py:obj:`bool`
137
-
138
- .. py:method:: set_dealer_rights(enabled) -> None
139
-
140
- Sets dealer rights on the account.
141
-
142
- You **probably don't** need to use this method.
143
-
144
- :param enabled: :py:obj:`True` to enable dealer rights, :py:obj:`False` to disable dealer rights. Default is :py:obj:`False`.
145
- :type enabled: :py:obj:`bool`
146
- :raises AssertionError: If the resource is not an account.
147
- :raises WialonError: If something goes wrong with Wialon.
148
- :returns: Nothing.
149
- :rtype: :py:obj:`None`
150
-
151
- .. py:method:: migrate_unit(unit) -> None
152
-
153
- Migrates a :py:obj:`WialonUnit` into the account.
154
-
155
- :param unit: A Wialon object.
156
- :type unit: :py:obj:`~terminusgps.wialon.items.base.WialonBase`
157
- :raises AssertionError: If the resource is not an account.
158
- :raises WialonError: If something goes wrong with Wialon.
159
- :returns: Nothing.
160
- :rtype: :py:obj:`None`
161
-
162
- .. py:method:: update_plan(new_plan) -> None
163
-
164
- Updates the account billing plan.
165
-
166
- :param new_plan: The name of a billing plan.
167
- :type new_plan: :py:obj:`str`
168
- :raises AssertionError: If the resource is not an account.
169
- :raises WialonError: If something goes wrong with Wialon.
170
- :returns: Nothing.
171
- :rtype: :py:obj:`None`
172
-
173
- .. py:method:: create_account(billing_plan) -> None
174
-
175
- Transforms the resource into an account.
176
-
177
- :param billing_plan: The name of a billing plan.
178
- :type billing_plan: :py:obj:`str`
179
- :raises AssertionError: If the resource is already account.
180
- :raises WialonError: If something goes wrong with Wialon.
181
- :returns: Nothing.
182
- :rtype: :py:obj:`None`
183
-
184
- .. py:method:: delete_account() -> None
185
-
186
- Deletes the account if it exists, as well as any micro-objects and macro-objects it contains.
187
-
188
- :raises AssertionError: If the resource is not an account.
189
- :raises WialonError: If something goes wrong with Wialon.
190
- :returns: Nothing.
191
- :rtype: :py:obj:`None`
192
-
193
- .. py:method:: enable_account() -> None
194
-
195
- Enables the Wialon account.
196
-
197
- :raises AssertionError: If the resource is not an account.
198
- :raises WialonError: If something goes wrong with Wialon.
199
- :returns: Nothing.
200
- :rtype: :py:obj:`None`
201
-
202
- .. py:method:: disable_account() -> None
203
-
204
- Disables the Wialon account.
205
-
206
- :raises AssertionError: If the resource is not an account.
207
- :raises WialonError: If something goes wrong with Wialon.
208
- :returns: Nothing.
209
- :rtype: :py:obj:`None`
210
-
211
- .. py:method:: set_minimum_days([days=0]) -> None
212
-
213
- Sets the minimum days counter value to ``days``.
214
-
215
- :param days: Number of days to set the counter to. Default is ``0``.
216
- :type days: :py:obj:`int`
217
- :raises AssertionError: If the resource is not an account.
218
- :raises WialonError: If something goes wrong with Wialon.
219
- :returns: Nothing.
220
- :rtype: :py:obj:`None`
221
-
222
- .. py:method:: add_days([days=30]) -> None
223
-
224
- Adds days to the account.
225
-
226
- :param days: Number of days to add to the account. Default is ``30``.
227
- :type days: :py:obj:`int`
228
- :raises AssertionError: If the resource is not an account.
229
- :raises WialonError: If something goes wrong with Wialon.
230
- :returns: Nothing.
231
- :rtype: :py:obj:`None`
232
-
233
- .. py:method:: set_settings_flags([flags=0x20, block_balance_val=0.00, deny_balance_val=0.00]) -> None
234
-
235
- Sets account settings flags.
236
-
237
- :param flags: A flag integer to set on the account.
238
- :type flags: :py:obj:`int`
239
- :param block_balance_val: Minimum amount on the account's balance before blocking the account.
240
- :type block_balance_val: :py:obj:`float`
241
- :param deny_balance_val: Minimum amount on the account's balance before denying the account.
242
- :type deny_balance_val: :py:obj:`float`
243
- :raises AssertionError: If the resource is not an account.
244
- :raises WialonError: If something goes wrong with Wialon.
245
- :returns: Nothing.
246
- :rtype: :py:obj:`None`
247
-
248
- .. py:property:: is_dealer
249
-
250
- Whether or not the resource/account has dealer rights.
251
-
252
- :type: :py:obj:`bool`
253
-
254
- .. py:property:: is_account
255
-
256
- Whether or not the resource is an account.
257
-
258
- :type: :py:obj:`bool`
259
-
260
- .. currentmodule:: terminusgps.wialon.items.retranslator
261
-
262
- .. py:class:: WialonRetranslator
263
-
264
- .. py:method:: create(creator_id, name) -> int | None
265
-
266
- Creates a new Wialon route.
267
-
268
- :param creator_id: A Wialon user id.
269
- :type creator_id: :py:obj:`str` | :py:obj:`int`
270
- :param name: A name for the route.
271
- :type name: :py:obj:`str`
272
- :raises ValueError: If ``creator_id`` is not a digit.
273
- :raises WialonError: If something goes wrong with Wialon.
274
- :returns: The Wialon id for the new route, if it was created.
275
- :rtype: :py:obj:`int` | :py:obj:`None`
276
-
277
- .. currentmodule:: terminusgps.wialon.items.unit
278
-
279
- .. py:class:: WialonUnit
280
-
281
- .. py:method:: create(creator_id, name, hw_type_id) -> int | None
282
-
283
- Creates a new Wialon unit.
284
-
285
- :param creator_id: A Wialon user id.
286
- :type creator_id: :py:obj:`str` | :py:obj:`int`
287
- :param name: A name for the unit.
288
- :type name: :py:obj:`str`
289
- :param hw_type_id: A Wialon hardware type ID.
290
- :type hw_type_id: :py:obj:`str` | :py:obj:`int`
291
- :returns: The Wialon id for the new unit.
292
- :rtype: :py:obj:`int` | :py:obj:`None`
293
-
294
- .. py:method:: execute_command(name, link_type, [timeout=5, flags=0, param=None]) -> None
295
-
296
- Executes a command on this Wialon unit.
297
-
298
- :param name: A Wialon command name.
299
- :type name: :py:obj:`str`
300
- :param link_type: A protocol to use for the Wialon command.
301
- :type link_type: :py:obj:`str`
302
- :param timeout: How long (in seconds) to wait before timing out command execution. Default is ``5``.
303
- :type timeout: :py:obj:`int`
304
- :param flags: Flags to pass to the Wialon command execution.
305
- :type flags: :py:obj:`int`
306
- :param param: Additional parameters to execute the command with.
307
- :type param: :py:obj:`dict` | :py:obj:`None`
308
- :returns: Nothing.
309
- :rtype: :py:obj:`None`
310
-
311
- .. py:method:: set_access_password(password) -> None
312
-
313
- Sets a new access password for this Wialon unit.
314
-
315
- :param password: A new access password.
316
- :type name: :py:obj:`str`
317
- :raises WialonError: If something goes wrong with Wialon.
318
- :returns: Nothing.
319
- :rtype: :py:obj:`None`
320
-
321
- .. py:method:: activate() -> None
322
-
323
- Activates the Wialon unit.
324
-
325
- :raises WialonError: If something goes wrong with Wialon.
326
- :returns: Nothing.
327
- :rtype: :py:obj:`None`
328
-
329
- .. py:method:: deactivate() -> None
330
-
331
- Deactivates the Wialon unit.
332
-
333
- :raises WialonError: If something goes wrong with Wialon.
334
- :returns: Nothing.
335
- :rtype: :py:obj:`None`
336
-
337
- .. py:method:: assign_phone(phone) -> None
338
-
339
- Assigns a phone number to the Wialon unit.
340
-
341
- :param phone: A phone number beginning with a country code.
342
- :type phone: :py:obj:`str`
343
- :raises WialonError: If something goes wrong with Wialon.
344
- :returns: Nothing.
345
- :rtype: :py:obj:`None`
346
-
347
- .. py:method:: get_phone_numbers() -> list[str]
348
-
349
- Retrieves all phone numbers assigned to the unit.
350
-
351
- This includes any attached drivers, custom/admin fields, or otherwise assigned phone numbers.
352
-
353
- :raises WialonError: If something goes wrong with Wialon.
354
- :returns: A list of phone numbers.
355
- :rtype: :py:obj:`list`
356
-
357
- .. py:property:: imei_number
358
-
359
- Unique id for the unit.
360
-
361
- :type: :py:obj:`int` | :py:obj:`None`
362
-
363
- .. py:property:: image_uri
364
-
365
- Unit image universal resource identifier.
366
-
367
- :type: :py:obj:`str`
368
-
369
- .. py:property:: active
370
-
371
- Whether or not the unit is activated in Wialon.
372
-
373
- :type: :py:obj:`bool`
374
-
375
- .. currentmodule:: terminusgps.wialon.items.unit_group
376
-
377
- .. py:class:: WialonUnitGroup
378
-
379
- .. py:method:: create(creator_id, name) -> int | None
380
-
381
- Creates a new Wialon unit group.
382
-
383
- :param creator_id: A Wialon user id.
384
- :type creator_id: :py:obj:`str` | :py:obj:`int`
385
- :param name: A name for the group.
386
- :type name: :py:obj:`str`
387
- :raises ValueError: If ``creator_id`` is not a digit.
388
- :raises WialonError: If something goes wrong with Wialon.
389
- :returns: The Wialon id for the new group, if it was created.
390
- :rtype: :py:obj:`int` | :py:obj:`None`
391
-
392
- .. py:method:: set_items(new_items) -> None
393
-
394
- Sets this group's members to a list of Wialon unit ids.
395
-
396
- :param new_items: A list of Wialon unit ids.
397
- :type new_items: :py:obj:`list`
398
- :raises WialonError: If something goes wrong with Wialon.
399
- :returns: Nothing.
400
- :rtype: :py:obj:`None`
401
-
402
- .. py:method:: is_member(item) -> bool
403
-
404
- Determines whether or not ``item`` is a member of the group.
405
-
406
- :param item: A Wialon object.
407
- :type item: :py:obj:`~terminusgps.wialon.items.base.WialonBase`
408
- :raises WialonError: If something goes wrong with Wialon.
409
- :returns: :py:obj:`True` if ``item`` is a member of the group, else :py:obj:`False`.
410
- :rtype: :py:obj:`bool`
411
-
412
- .. py:method:: add_item(item) -> bool
413
-
414
- Adds a Wialon item to the group.
415
-
416
- :param item: A Wialon object.
417
- :type item: :py:obj:`~terminusgps.wialon.items.base.WialonBase`
418
- :raises WialonError: If something goes wrong with Wialon.
419
- :returns: Nothing.
420
- :rtype: :py:obj:`None`
421
-
422
- .. py:method:: rm_item(item) -> bool
423
-
424
- Removes a Wialon unit from the group, if it's a member of the group.
425
-
426
- :param item: A Wialon object.
427
- :type item: :py:obj:`~terminusgps.wialon.items.base.WialonBase`
428
- :raises AssertionError: If the item wasn't in the group.
429
- :raises WialonError: If something goes wrong with Wialon.
430
- :returns: Nothing.
431
- :rtype: :py:obj:`None`
432
-
433
- .. py:property:: items
434
-
435
- A list of Wialon object ids in the group.
436
-
437
- :type: :py:obj:`list`
438
-
439
- .. currentmodule:: terminusgps.wialon.items.user
440
-
441
- .. py:class:: WialonUser
442
-
443
- .. py::method:: create(creator_id, name, password) -> int | None
444
-
445
- Creates a new Wialon user.
446
-
447
- :param creator_id: A Wialon user id.
448
- :type creator_id: :py:obj:`str` | :py:obj:`int`
449
- :param name: A name for the user.
450
- :type name: :py:obj:`str`
451
- :param password: A password for the user.
452
- :type password: :py:obj:`str`
453
- :raises ValueError: If ``creator_id`` is not a digit.
454
- :raises WialonError: If something goes wrong with Wialon.
455
- :returns: The Wialon id for the new user, if it was created.
456
- :rtype: :py:obj:`int` | :py:obj:`None`
457
-
458
- .. py::method:: has_access(other) -> bool
459
-
460
- Checks if the user has access to ``other``.
461
-
462
- :param other: A Wialon object.
463
- :type phone: :py:obj:`~terminusgps.wialon.items.base.WialonBase`
464
- :raises WialonError: If something goes wrong with Wialon.
465
- :returns: :py:obj:`True` if the user can access ``other``, else :py:obj:`False`.
466
- :rtype: :py:obj:`bool`
467
-
468
- .. py::method:: assign_phone(phone) -> None
469
-
470
- Assigns a phone number to the user.
471
-
472
- :param phone: A phone number, including country code.
473
- :type phone: :py:obj:`str`
474
- :raises WialonError: If something goes wrong with Wialon.
475
- :returns: Nothing.
476
- :rtype: :py:obj:`None`
477
-
478
- .. py::method:: assign_email(email) -> None
479
-
480
- Assigns an email address to the user.
481
-
482
- :param phone: An email address.
483
- :type phone: :py:obj:`str`
484
- :raises WialonError: If something goes wrong with Wialon.
485
- :returns: Nothing.
486
- :rtype: :py:obj:`None`
487
-
488
- .. py::method:: grant_access(item) -> None
489
-
490
- Grants the user access to ``item``.
491
-
492
- :param item: A Wialon object.
493
- :type item: :py:obj:`~terminusgps.wialon.items.base.WialonBase`
494
- :param access_mask: A Wialon access mask integer.
495
- :type access_mask: :py:obj:`int`
496
- :raises WialonError: If something goes wrong with Wialon.
497
- :returns: Nothing.
498
- :rtype: :py:obj:`None`
499
-
500
- .. py::method:: set_settings_flags(flags, flags_mask) -> None
501
-
502
- Sets the user's settings flags.
503
-
504
- :param flags: The new user settings flags.
505
- :type flags: :py:obj:`int`
506
- :param flags_mask: A user settings flag mask.
507
- :type flags_mask: :py:obj:`int`
508
- :raises WialonError: If something goes wrong with Wialon.
509
- :returns: Nothing.
510
- :rtype: :py:obj:`None`
511
-
512
- .. py::method:: update_password(old_password, new_password) -> None
513
-
514
- Updates the password of the user.
515
-
516
- :param old_password: The user's original password.
517
- :type old_password: :py:obj:`str`
518
- :param new_password: A new password.
519
- :type new_password: :py:obj:`str`
520
- :raises WialonError: If something goes wrong with Wialon.
521
- :returns: Nothing.
522
- :rtype: :py:obj:`None`
523
-
524
- .. py::method:: verify_auth(destination, [method="email"]) -> None
525
-
526
- Sends an authentication code to ``destination`` via ``method``.
527
-
528
- ``Method`` can be ``"email"`` or ``"sms"``.
529
-
530
- :param destination: The email or phone number to send an auth code to.
531
- :type destination: :py:obj:`str`
532
- :param method: Email or sms. Default is ``"email"``.
533
- :type method: :py:obj:`str`
534
- :raises ValueError: If the method isn't ``"email"`` or ``"sms"``.
535
- :raises WialonError: If something goes wrong with Wialon.
536
- :returns: An auth code.
537
- :rtype: :py:obj:`str`
@@ -1,155 +0,0 @@
1
- Wialon API Sessions
2
- ===================
3
-
4
- .. currentmodule:: terminusgps.wialon.session
5
-
6
- .. py:class:: WialonSession
7
-
8
- Starts or continues a Wialon API session.
9
-
10
- :param token: An optional Wialon API token. Default is :confval:`WIALON_TOKEN`.
11
- :type token: :py:obj:`str` | :py:obj:`None`
12
- :param sid: An optional Wialon API session id. If provided, the session is continued.
13
- :type sid: :py:obj:`str` | :py:obj:`None`
14
- :param scheme: HTTP request scheme to use. Default is ``"https"``.
15
- :type scheme: :py:obj:`str`
16
- :param host: Wialon API host url. Default is ``"hst-api.wialon.com"``.
17
- :type host: :py:obj:`str`
18
- :param port: Wialon API host port. Default is ``443``.
19
- :type port: :py:obj:`int`
20
- :param log_level: Severity level at which log messages should be handled. Default is ``20`` (logging.INFO).
21
- :type log_level: :py:obj:`int`
22
-
23
-
24
- .. py:property:: gis_geocode
25
-
26
- GIS geocode URL.
27
-
28
- :type: :py:obj:`str` | :py:obj:`None`
29
- :value: :py:obj:`None`
30
-
31
- .. py:property:: gis_render
32
-
33
- GIS renderer URL.
34
-
35
- :type: :py:obj:`str` | :py:obj:`None`
36
- :value: :py:obj:`None`
37
-
38
- .. py:property:: gis_routing
39
-
40
- GIS routing URL.
41
-
42
- :type: :py:obj:`str` | :py:obj:`None`
43
- :value: :py:obj:`None`
44
-
45
- .. py:property:: gis_search
46
-
47
- GIS searching URL.
48
-
49
- :type: :py:obj:`str` | :py:obj:`None`
50
- :value: :py:obj:`None`
51
-
52
- .. py:property:: gis_sid
53
-
54
- GIS session id.
55
-
56
- :type: :py:obj:`str` | :py:obj:`None`
57
- :value: :py:obj:`None`
58
-
59
- .. py:property:: host
60
-
61
- Client IP address.
62
-
63
- :type: :py:obj:`str` | :py:obj:`None`
64
- :value: :py:obj:`None`
65
-
66
- .. py:property:: hw_gw_ip
67
-
68
- Hardware gateway ip.
69
-
70
- :type: :py:obj:`str` | :py:obj:`None`
71
- :value: :py:obj:`None`
72
-
73
- .. py:property:: hw_gw_dns
74
-
75
- Hardware gateway domain name.
76
-
77
- :type: :py:obj:`str` | :py:obj:`None`
78
- :value: :py:obj:`None`
79
-
80
- .. py:property:: wsdk_version
81
-
82
- Wialon Source Developer Kit (wsdk) version.
83
-
84
- :type: :py:obj:`str` | :py:obj:`None`
85
- :value: :py:obj:`None`
86
-
87
- .. py:property:: uid
88
-
89
- Wialon user id the session is operating as.
90
-
91
- :type: :py:obj:`str` | :py:obj:`None`
92
- :value: :py:obj:`None`
93
-
94
- .. py:property:: username
95
-
96
- Wialon username the session is operating as.
97
-
98
- :type: :py:obj:`str` | :py:obj:`None`
99
- :value: :py:obj:`None`
100
-
101
- .. py:property:: token
102
-
103
- A Wialon API token set during :py:meth:`~WialonSession.__init__`.
104
-
105
- :type: :py:obj:`str` | :py:obj:`None`
106
- :value: :py:obj:`None`
107
-
108
- .. py:method:: login(token, [flags,]) -> str
109
-
110
- Logs into the Wialon API, sets session attributes, and returns a session id.
111
-
112
- :param token: An activated Wialon API token.
113
- :type token: :py:obj:`str`
114
- :param flags: A login response flag integer. Default is ``35``.
115
- :type flags: :py:obj:`int`
116
- :raises WialonError: If the login fails.
117
- :raises AssertionError: If the login token was not set.
118
- :returns: The new session id.
119
- :rtype: :py:obj:`str`
120
-
121
- .. py:method:: logout() -> None
122
-
123
- Logs out of the Wialon API session.
124
-
125
- :raises WialonError: If something goes wrong during a Wialon API call.
126
- :returns: Nothing.
127
- :rtype: :py:obj:`None`
128
-
129
- =====
130
- Usage
131
- =====
132
-
133
- .. code:: python
134
-
135
- from terminusgps.wialon.session import WialonSession
136
-
137
- # Create a session and login to it
138
- session = WialonSession()
139
- session.login(token="my_secure_token")
140
-
141
- # Use the logged in session to perform API actions
142
- session.wialon_api.core_search_item(**{"id": "123", "flags": 1})
143
-
144
- # Don't forget to logout of the session
145
- # Sessions are destroyed after 5min of inactivity
146
- session.logout()
147
-
148
- # Alternatively, use a context manager
149
- # The context manager handles logging in and out of the session.
150
- with WialonSession() as session:
151
- session.wialon_api.core_search_item(**{"id": "123", "flags": 1})
152
-
153
- # If you already have a session id, no need to login again
154
- session = WialonSession(sid="my_valid_session_id")
155
- session.wialon_api.core_search_item(**{"id": "123", "flags": 1})