pyGuardPoint 1.4.2__tar.gz → 1.4.4__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.
Files changed (52) hide show
  1. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/PKG-INFO +1 -1
  2. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/_guardpoint_controllers.py +50 -0
  3. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/_guardpoint_customizedfields.py +26 -0
  4. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/_guardpoint_diagnostic.py +27 -8
  5. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/guardpoint.py +64 -14
  6. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint.egg-info/PKG-INFO +1 -1
  7. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/setup.py +1 -1
  8. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/LICENSE.txt +0 -0
  9. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/README.rst +0 -0
  10. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/CustomWebsocketTransport.py +0 -0
  11. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/__init__.py +0 -0
  12. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/_guardpoint_alarms.py +0 -0
  13. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/_guardpoint_areas.py +0 -0
  14. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/_guardpoint_cardholders.py +0 -0
  15. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/_guardpoint_cardholdertypes.py +0 -0
  16. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/_guardpoint_cards.py +0 -0
  17. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/_guardpoint_events.py +0 -0
  18. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/_guardpoint_ouputs.py +0 -0
  19. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/_guardpoint_personaldetails.py +0 -0
  20. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/_guardpoint_readers.py +0 -0
  21. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/_guardpoint_scheduledmags.py +0 -0
  22. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/_guardpoint_securitygroups.py +0 -0
  23. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/_odata_filter.py +0 -0
  24. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/_str_match_algo.py +0 -0
  25. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/gp_asyncio/__init__.py +0 -0
  26. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/gp_asyncio/_async_guardpoint_alarms.py +0 -0
  27. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/gp_asyncio/_async_guardpoint_areas.py +0 -0
  28. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/gp_asyncio/_async_guardpoint_cardholders.py +0 -0
  29. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/gp_asyncio/_async_guardpoint_cardholdertypes.py +0 -0
  30. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/gp_asyncio/_async_guardpoint_cards.py +0 -0
  31. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/gp_asyncio/_async_guardpoint_controllers.py +0 -0
  32. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/gp_asyncio/_async_guardpoint_customizedfields.py +0 -0
  33. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/gp_asyncio/_async_guardpoint_diagnostic.py +0 -0
  34. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/gp_asyncio/_async_guardpoint_events.py +0 -0
  35. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/gp_asyncio/_async_guardpoint_ouputs.py +0 -0
  36. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/gp_asyncio/_async_guardpoint_personaldetails.py +0 -0
  37. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/gp_asyncio/_async_guardpoint_readers.py +0 -0
  38. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/gp_asyncio/_async_guardpoint_scheduledmags.py +0 -0
  39. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/gp_asyncio/_async_guardpoint_securitygroups.py +0 -0
  40. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/gp_asyncio/guardpoint_connection_asyncio.py +0 -0
  41. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/guardpoint_asyncio.py +0 -0
  42. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/guardpoint_connection.py +0 -0
  43. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/guardpoint_dataclasses.py +0 -0
  44. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/guardpoint_error.py +0 -0
  45. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/guardpoint_threaded.py +0 -0
  46. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint/guardpoint_utils.py +0 -0
  47. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint.egg-info/SOURCES.txt +0 -0
  48. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint.egg-info/dependency_links.txt +0 -0
  49. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint.egg-info/not-zip-safe +0 -0
  50. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint.egg-info/requires.txt +0 -0
  51. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/pyGuardPoint.egg-info/top_level.txt +0 -0
  52. {pyguardpoint-1.4.2 → pyguardpoint-1.4.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyGuardPoint
3
- Version: 1.4.2
3
+ Version: 1.4.4
4
4
  Summary: Python wrapper for GuardPoint 10 Access Control System
5
5
  Author: John Owen
6
6
  Maintainer-email: sales@sensoraccess.co.uk
@@ -5,7 +5,42 @@ from .guardpoint_error import GuardPointError, GuardPointUnauthorized
5
5
 
6
6
 
7
7
  class ControllersAPI:
8
+ """
9
+ API for interacting with controller resources.
10
+
11
+ This class provides methods to retrieve information about controllers
12
+ from a remote API.
13
+
14
+ Methods
15
+ -------
16
+ get_controllers()
17
+ Retrieves a list of all controllers.
18
+
19
+ get_controller(controller_uid: str)
20
+ Retrieves a specific controller by its unique identifier.
21
+ """
8
22
  def get_controllers(self, ):
23
+ """
24
+ Retrieve a list of controllers from the GuardPoint API.
25
+
26
+ This method sends a GET request to the GuardPoint API to fetch a list of controllers.
27
+ It processes the response and returns a list of `Controller` objects.
28
+
29
+ :raises GuardPointUnauthorized: If the API response status code is 401 (Unauthorized).
30
+ :raises GuardPointError: If the API response status code is 404 (Not Found) or if the response is badly formatted.
31
+
32
+ :return: A list of `Controller` objects.
33
+ :rtype: list
34
+
35
+ Example usage:
36
+
37
+ .. code-block:: python
38
+
39
+ controllers = guardpoint_instance.get_controllers()
40
+ for controller in controllers:
41
+ print(controller)
42
+
43
+ """
9
44
  url = "/odata/API_Controllers"
10
45
  headers = {
11
46
  'Content-Type': 'application/json',
@@ -37,6 +72,21 @@ class ControllersAPI:
37
72
  return controllers
38
73
 
39
74
  def get_controller(self, controller_uid: str):
75
+ """
76
+ Retrieve a controller object by its unique identifier (UID).
77
+
78
+ This method sends a GET request to the GuardPoint API to fetch details
79
+ of a controller specified by the `controller_uid`. If the UID is not
80
+ a valid UUID, a `ValueError` is raised. If the API response indicates
81
+ an error or is not properly formatted, a `GuardPointError` is raised.
82
+
83
+ :param controller_uid: The unique identifier of the controller to retrieve.
84
+ :type controller_uid: str
85
+ :raises ValueError: If the `controller_uid` is not a valid UUID.
86
+ :raises GuardPointError: If the API response indicates an error or is not properly formatted.
87
+ :return: A `Controller` object if the controller is found, otherwise `None`.
88
+ :rtype: Controller or None
89
+ """
40
90
  if not validators.uuid(controller_uid):
41
91
  raise ValueError(f"Malformed controller_uid: {controller_uid}")
42
92
 
@@ -5,8 +5,34 @@ from .guardpoint_dataclasses import CardholderCustomizedField
5
5
 
6
6
 
7
7
  class CustomizedFieldsAPI:
8
+ """
9
+ API class for updating customized fields of a cardholder.
10
+
11
+ Methods
12
+ -------
13
+ update_custom_fields(cardholder_uid: str, customFields: CardholderCustomizedField)
14
+ Updates the custom fields for a specified cardholder.
15
+ """
8
16
 
9
17
  def update_custom_fields(self, cardholder_uid: str, customFields: CardholderCustomizedField):
18
+ """
19
+ Update custom fields for a specific cardholder.
20
+
21
+ This method updates the custom fields of a cardholder identified by the given UID.
22
+ It sends a PATCH request to the GuardPoint API with the updated custom fields.
23
+
24
+ :param cardholder_uid: The unique identifier of the cardholder.
25
+ :type cardholder_uid: str
26
+ :param customFields: An instance of `CardholderCustomizedField` containing the custom fields to be updated.
27
+ :type customFields: CardholderCustomizedField
28
+
29
+ :raises ValueError: If the provided `cardholder_uid` is not a valid UUID.
30
+ :raises GuardPointUnauthorized: If the request is unauthorized (HTTP 401).
31
+ :raises GuardPointError: If the cardholder is not found (HTTP 404) or any other error occurs.
32
+
33
+ :return: True if the update is successful.
34
+ :rtype: bool
35
+ """
10
36
  if not validators.uuid(cardholder_uid):
11
37
  raise ValueError(f'Malformed Cardholder UID {cardholder_uid}')
12
38
 
@@ -5,15 +5,34 @@ from .guardpoint_error import GuardPointError, GuardPointUnauthorized
5
5
 
6
6
 
7
7
  class DiagnosticAPI:
8
- '''
9
- {
10
- "controllersUIDs" :[
11
- "B3C0976A-3F8C-4B52-AE65-CB6F88FFD813"
12
- ],
13
- "command": "7901000000000A28"
14
- }
15
- '''
8
+ """
9
+ A class to interact with the diagnostic API for simulating access events.
10
+
11
+ Methods
12
+ -------
13
+ simulate_access_event(controller_uid: str, reader_num: int, card_code: str) -> bool
14
+ Simulates an access event for a given controller, reader, and card code.
15
+ """
16
16
  def simulate_access_event(self, controller_uid: str, reader_num: int, card_code: str):
17
+ """
18
+ Simulates an access event by sending a command to the specified controller.
19
+
20
+ This method sends a command to the controller identified by `controller_uid` to simulate an access event
21
+ using the specified `reader_num` and `card_code`. It performs validation on the inputs and handles
22
+ the response from the server.
23
+
24
+ :param controller_uid: The unique identifier of the controller.
25
+ :type controller_uid: str
26
+ :param reader_num: The reader number (must be between 0 and 255).
27
+ :type reader_num: int
28
+ :param card_code: The card code (must be at least 8 characters long).
29
+ :type card_code: str
30
+ :raises ValueError: If `controller_uid` is not a valid UUID, `card_code` is too short, or `reader_num` is greater than 255.
31
+ :raises GuardPointUnauthorized: If the server responds with a 401 Unauthorized status.
32
+ :raises GuardPointError: If the server responds with an error or the response is badly formatted.
33
+ :return: True if the access event simulation was successful, False otherwise.
34
+ :rtype: bool
35
+ """
17
36
  if not validators.uuid(controller_uid):
18
37
  raise ValueError(f"Malformed controller_uid: {controller_uid}")
19
38
  if len(card_code) < 8:
@@ -31,17 +31,9 @@ def stop_listening(client: SignalRClient):
31
31
  await client._transport.close()
32
32
 
33
33
  asyncio.run(stop_signal_client())
34
- '''if not self.task:
35
- return
36
34
 
37
- self.task.cancel()
38
- while not self.task.cancelled():
39
- sleep(1)'''
40
35
 
41
-
42
- class GuardPoint(GuardPointConnection, CardsAPI, CardholdersAPI, AreasAPI, SecurityGroupsAPI,
43
- CustomizedFieldsAPI, PersonalDetailsAPI, ScheduledMagsAPI, CardholderTypesAPI,
44
- OutputsAPI, DiagnosticAPI, ReadersAPI, ControllersAPI, AlarmsAPI, EventsAPI):
36
+ class GuardPoint(GuardPointConnection, CardsAPI, CardholdersAPI, AreasAPI, SecurityGroupsAPI, CustomizedFieldsAPI, PersonalDetailsAPI, ScheduledMagsAPI, CardholderTypesAPI, OutputsAPI, DiagnosticAPI, ReadersAPI, ControllersAPI, AlarmsAPI, EventsAPI):
45
37
  """
46
38
  A class to interface with the GuardPoint system, providing various APIs for managing cards, cardholders, areas,
47
39
  security groups, customized fields, personal details, scheduled mags, cardholder types, outputs, diagnostics,
@@ -52,7 +44,7 @@ class GuardPoint(GuardPointConnection, CardsAPI, CardholdersAPI, AreasAPI, Secur
52
44
 
53
45
  Methods
54
46
  -------
55
- __init__(**kwargs)
47
+ __init__(\**kwargs)
56
48
  Initializes the GuardPoint instance with the provided configuration.
57
49
  get_cardholder_count()
58
50
  Retrieves the total number of cardholders.
@@ -65,6 +57,26 @@ class GuardPoint(GuardPointConnection, CardsAPI, CardholdersAPI, AreasAPI, Secur
65
57
  task = None
66
58
 
67
59
  def __init__(self, **kwargs):
60
+ """
61
+ Initialize the connection with the given parameters.
62
+
63
+ :param kwargs: Keyword arguments for configuration.
64
+ - host (str): The hostname or IP address of the server. Defaults to "localhost".
65
+ - port (int): The port number to connect to. Defaults to None.
66
+ - auth (GuardPointAuthType): The authentication type. Defaults to GuardPointAuthType.BEARER_TOKEN.
67
+ - username (str): The username for authentication. Defaults to "admin".
68
+ - pwd (str): The password for authentication. Defaults to "admin".
69
+ - key (str): The key for authentication. Defaults to "00000000-0000-0000-0000-000000000000".
70
+ - token (str): The token for authentication. Defaults to None.
71
+ - cert_file (str): Path to the certificate file. Defaults to None.
72
+ - key_file (str): Path to the key file. Defaults to None.
73
+ - ca_file (str): Path to the CA file. Defaults to None.
74
+ - timeout (int): The timeout duration in seconds. Defaults to 5.
75
+ - p12_file (str): Path to the PKCS#12 file. Defaults to None.
76
+ - p12_pwd (str): Password for the PKCS#12 file. Defaults to an empty string.
77
+
78
+ :raises ValueError: If the host is not provided or is invalid.
79
+ """
68
80
  # Set default values if not present
69
81
  host = kwargs.get('host', "localhost")
70
82
  port = kwargs.get('port', None)
@@ -90,6 +102,18 @@ class GuardPoint(GuardPointConnection, CardsAPI, CardholdersAPI, AreasAPI, Secur
90
102
  p12_file=p12_file, p12_pwd=p12_pwd)
91
103
 
92
104
  def get_cardholder_count(self):
105
+ """
106
+ Retrieve the total count of cardholders from the GuardPoint system.
107
+
108
+ This method sends a GET request to the GuardPoint API to fetch the total number of cardholders.
109
+ It handles various error scenarios, including unauthorized access and improperly formatted responses.
110
+
111
+ :raises GuardPointUnauthorized: If the API response indicates unauthorized access (HTTP 401).
112
+ :raises GuardPointError: If the API response is not properly formatted or if there is no response body.
113
+
114
+ :return: The total number of cardholders.
115
+ :rtype: int
116
+ """
93
117
  url = self.baseurl + "/odata/GetCardholdersCount"
94
118
  code, json_body = self.gp_json_query("GET", url=url)
95
119
 
@@ -113,6 +137,24 @@ class GuardPoint(GuardPointConnection, CardsAPI, CardholdersAPI, AreasAPI, Secur
113
137
  return int(json_body['totalItems'])
114
138
 
115
139
  def get_signal_client(self):
140
+ """
141
+ Creates and configures a SignalR client for connecting to the EventsHub.
142
+
143
+ This method initializes a `SignalRClient` instance with the appropriate URL and sets up
144
+ the necessary headers for authentication based on the specified authentication type.
145
+ It also configures a custom WebSocket transport for the client with various parameters.
146
+
147
+ :returns: Configured `SignalRClient` instance ready for use.
148
+ :rtype: SignalRClient
149
+
150
+ :raises ValueError: If the authentication type is not supported.
151
+
152
+ Example usage::
153
+
154
+ client = self.get_signal_client()
155
+ client.start()
156
+
157
+ """
116
158
  client = SignalRClient(self.baseurl + "/Hub/EventsHub")
117
159
  headers = {}
118
160
  if self.authType == GuardPointAuthType.BASIC:
@@ -134,11 +176,19 @@ class GuardPoint(GuardPointConnection, CardsAPI, CardholdersAPI, AreasAPI, Secur
134
176
  return client
135
177
 
136
178
  def start_listening(self, client: SignalRClient):
179
+ """
180
+ Start listening to the SignalR client by running it in an asynchronous task.
181
+
182
+ This method creates and runs an asynchronous task to execute the `run` method of the provided
183
+ `SignalRClient` instance. The task is named "sigR_task" for identification purposes. If the task
184
+ is cancelled, a message indicating the cancellation is printed.
185
+
186
+ :param client: An instance of `SignalRClient` that will be run in an asynchronous task.
187
+ :type client: SignalRClient
188
+
189
+ :raises asyncio.CancelledError: If the asynchronous task is cancelled.
190
+ """
137
191
  async def run_signal_client() -> None:
138
- '''group = gp_asyncio.gather(
139
- client.run(),
140
- )
141
- await group'''
142
192
  self.task = asyncio.create_task(client.run(), name = "sigR_task")
143
193
  await self.task
144
194
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyGuardPoint
3
- Version: 1.4.2
3
+ Version: 1.4.4
4
4
  Summary: Python wrapper for GuardPoint 10 Access Control System
5
5
  Author: John Owen
6
6
  Maintainer-email: sales@sensoraccess.co.uk
@@ -4,7 +4,7 @@ long_description = open('README.rst').read()
4
4
 
5
5
  setup(name="pyGuardPoint",
6
6
  packages=find_packages(),
7
- version="1.4.2",
7
+ version="1.4.4",
8
8
  author="John Owen",
9
9
  description="Python wrapper for GuardPoint 10 Access Control System",
10
10
  long_description_content_type='text/markdown',
File without changes
File without changes
File without changes