pyGuardPoint 2.0.1__tar.gz → 2.0.3__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 (67) hide show
  1. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/PKG-INFO +1 -1
  2. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_cardholders.py +11 -8
  3. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_customizedfields.py +33 -1
  4. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/_async_guardpoint_cardholders.py +12 -9
  5. pyguardpoint-2.0.3/pyGuardPoint/gp_asyncio/_async_guardpoint_customizedfields.py +67 -0
  6. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/guardpoint_dataclasses.py +35 -0
  7. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint.egg-info/PKG-INFO +1 -1
  8. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/setup.py +1 -1
  9. pyguardpoint-2.0.1/pyGuardPoint/gp_asyncio/_async_guardpoint_customizedfields.py +0 -36
  10. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/LICENSE.txt +0 -0
  11. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/README.rst +0 -0
  12. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/CustomWebsocketTransport.py +0 -0
  13. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/CustomWebsocketTransportOld.py +0 -0
  14. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/__init__.py +0 -0
  15. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_accessgroups.py +0 -0
  16. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_alarmstates.py +0 -0
  17. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_alarmzones.py +0 -0
  18. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_areas.py +0 -0
  19. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_cardholdertypes.py +0 -0
  20. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_cards.py +0 -0
  21. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_controllers.py +0 -0
  22. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_departments.py +0 -0
  23. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_diagnostic.py +0 -0
  24. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_events.py +0 -0
  25. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_genericinformation.py +0 -0
  26. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_inputs.py +0 -0
  27. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_manualevents.py +0 -0
  28. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_ouputs.py +0 -0
  29. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_personaldetails.py +0 -0
  30. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_readers.py +0 -0
  31. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_scheduledmags.py +0 -0
  32. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_securitygroups.py +0 -0
  33. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_guardpoint_sites.py +0 -0
  34. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_odata_filter.py +0 -0
  35. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/_str_match_algo.py +0 -0
  36. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/__init__.py +0 -0
  37. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/_async_guardpoint_accessgroups.py +0 -0
  38. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/_async_guardpoint_alarmstates.py +0 -0
  39. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/_async_guardpoint_alarmzones.py +0 -0
  40. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/_async_guardpoint_areas.py +0 -0
  41. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/_async_guardpoint_cardholdertypes.py +0 -0
  42. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/_async_guardpoint_cards.py +0 -0
  43. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/_async_guardpoint_controllers.py +0 -0
  44. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/_async_guardpoint_departments.py +0 -0
  45. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/_async_guardpoint_diagnostic.py +0 -0
  46. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/_async_guardpoint_events.py +0 -0
  47. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/_async_guardpoint_genericinformation.py +0 -0
  48. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/_async_guardpoint_manualevents.py +0 -0
  49. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/_async_guardpoint_ouputs.py +0 -0
  50. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/_async_guardpoint_personaldetails.py +0 -0
  51. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/_async_guardpoint_readers.py +0 -0
  52. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/_async_guardpoint_scheduledmags.py +0 -0
  53. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/_async_guardpoint_securitygroups.py +0 -0
  54. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/_async_guardpoint_sites.py +0 -0
  55. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/gp_asyncio/guardpoint_connection_asyncio.py +0 -0
  56. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/guardpoint.py +0 -0
  57. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/guardpoint_asyncio.py +0 -0
  58. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/guardpoint_connection.py +0 -0
  59. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/guardpoint_error.py +0 -0
  60. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/guardpoint_threaded.py +0 -0
  61. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint/guardpoint_utils.py +0 -0
  62. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint.egg-info/SOURCES.txt +0 -0
  63. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint.egg-info/dependency_links.txt +0 -0
  64. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint.egg-info/not-zip-safe +0 -0
  65. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint.egg-info/requires.txt +0 -0
  66. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/pyGuardPoint.egg-info/top_level.txt +0 -0
  67. {pyguardpoint-2.0.1 → pyguardpoint-2.0.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyGuardPoint
3
- Version: 2.0.1
3
+ Version: 2.0.3
4
4
  Summary: Python wrapper for GuardPoint 10 Access Control System
5
5
  Author: John Owen
6
6
  Maintainer-email: sales@sensoraccess.co.uk
@@ -231,19 +231,22 @@ class CardholdersAPI:
231
231
  if code == 201: # HTTP CREATED
232
232
  new_cardholder = Cardholder(json_body)
233
233
  if cardholder.cardholderPersonalDetail:
234
- self.update_personal_details(cardholder_uid=new_cardholder.uid,
234
+ if len(cardholder.cardholderPersonalDetail.changed_attributes) > 0:
235
+ self.update_personal_details(cardholder_uid=new_cardholder.uid,
235
236
  personal_details=cardholder.cardholderPersonalDetail)
236
237
  if cardholder.cardholderCustomizedField:
237
- self.update_custom_fields(cardholder_uid=new_cardholder.uid,
238
- customFields=cardholder.cardholderCustomizedField)
238
+ if len(cardholder.cardholderCustomizedField.changed_attributes) > 0:
239
+ self.update_custom_fields(cardholder_uid=new_cardholder.uid,
240
+ customFields=cardholder.cardholderCustomizedField)
239
241
  if cardholder.cards:
240
242
  if isinstance(cardholder.cards, list):
241
243
  for card in cardholder.cards:
242
- if validators.uuid(card.uid):
243
- self.update_card(card)
244
- else:
245
- card.cardholderUID = new_cardholder.uid
246
- self.new_card(card)
244
+ if len(card.changed_attributes) > 0:
245
+ if validators.uuid(card.uid):
246
+ self.update_card(card)
247
+ else:
248
+ card.cardholderUID = new_cardholder.uid
249
+ self.new_card(card)
247
250
 
248
251
  return self._get_card_holder(new_cardholder.uid)
249
252
 
@@ -1,7 +1,7 @@
1
1
  import validators
2
2
  from .guardpoint_utils import GuardPointResponse
3
3
  from .guardpoint_error import GuardPointError, GuardPointUnauthorized
4
- from .guardpoint_dataclasses import CardholderCustomizedField
4
+ from .guardpoint_dataclasses import CardholderCustomizedField, CustomizedField
5
5
 
6
6
 
7
7
  class CustomizedFieldsAPI:
@@ -14,6 +14,38 @@ class CustomizedFieldsAPI:
14
14
  Updates the custom fields for a specified cardholder.
15
15
  """
16
16
 
17
+ def get_custom_fields(self):
18
+ url = "/odata/API_CustomizedFields"
19
+ headers = {
20
+ 'Content-Type': 'application/json',
21
+ 'Accept': 'application/json'
22
+ }
23
+
24
+ code, json_body = self.gp_json_query("GET", headers=headers, url=url)
25
+
26
+ if code != 200:
27
+ error_msg = GuardPointResponse.extract_error_msg(json_body)
28
+
29
+ if code == 401:
30
+ raise GuardPointUnauthorized(f"Unauthorized - ({error_msg})")
31
+ elif code == 404: # Not Found
32
+ raise GuardPointError(f"CustomizedFields Not Found")
33
+ else:
34
+ raise GuardPointError(f"{error_msg}")
35
+
36
+ if not isinstance(json_body, dict):
37
+ raise GuardPointError("Badly formatted response.")
38
+ if 'value' not in json_body:
39
+ raise GuardPointError("Badly formatted response.")
40
+ if not isinstance(json_body['value'], list):
41
+ raise GuardPointError("Badly formatted response.")
42
+
43
+ customizedFields = []
44
+ for x in json_body['value']:
45
+ customizedFields.append(CustomizedField(x))
46
+ return customizedFields
47
+
48
+
17
49
  def update_custom_fields(self, cardholder_uid: str, customFields: CardholderCustomizedField):
18
50
  """
19
51
  Update custom fields for a specific cardholder.
@@ -160,19 +160,22 @@ class CardholdersAPI:
160
160
  if code == 201: # HTTP CREATED
161
161
  new_cardholder = Cardholder(json_body)
162
162
  if cardholder.cardholderPersonalDetail:
163
- await self.update_personal_details(cardholder_uid=new_cardholder.uid,
164
- personal_details=cardholder.cardholderPersonalDetail)
163
+ if len(cardholder.cardholderPersonalDetail.changed_attributes) > 0:
164
+ await self.update_personal_details(cardholder_uid=new_cardholder.uid,
165
+ personal_details=cardholder.cardholderPersonalDetail)
165
166
  if cardholder.cardholderCustomizedField:
166
- await self.update_custom_fields(cardholder_uid=new_cardholder.uid,
167
- customFields=cardholder.cardholderCustomizedField)
167
+ if len(cardholder.cardholderCustomizedField.changed_attributes) > 0:
168
+ await self.update_custom_fields(cardholder_uid=new_cardholder.uid,
169
+ customFields=cardholder.cardholderCustomizedField)
168
170
  if cardholder.cards:
169
171
  if isinstance(cardholder.cards, list):
170
172
  for card in cardholder.cards:
171
- if validators.uuid(card.uid):
172
- await self.update_card(card)
173
- else:
174
- card.cardholderUID = new_cardholder.uid
175
- await self.new_card(card)
173
+ if len(card.changed_attributes) > 0:
174
+ if validators.uuid(card.uid):
175
+ await self.update_card(card)
176
+ else:
177
+ card.cardholderUID = new_cardholder.uid
178
+ await self.new_card(card)
176
179
 
177
180
  return await self._get_card_holder(new_cardholder.uid)
178
181
 
@@ -0,0 +1,67 @@
1
+ import validators
2
+ from ..guardpoint_utils import GuardPointResponse
3
+ from ..guardpoint_error import GuardPointError, GuardPointUnauthorized
4
+ from ..guardpoint_dataclasses import CardholderCustomizedField, CustomizedField
5
+
6
+
7
+ class CustomizedFieldsAPI:
8
+
9
+ async def get_custom_fields(self):
10
+ url = "/odata/API_CustomizedFields"
11
+ headers = {
12
+ 'Content-Type': 'application/json',
13
+ 'Accept': 'application/json'
14
+ }
15
+
16
+ code, json_body = await self.gp_json_query("GET", headers=headers, url=url)
17
+
18
+ if code != 200:
19
+ error_msg = GuardPointResponse.extract_error_msg(json_body)
20
+
21
+ if code == 401:
22
+ raise GuardPointUnauthorized(f"Unauthorized - ({error_msg})")
23
+ elif code == 404: # Not Found
24
+ raise GuardPointError(f"CustomizedFields Not Found")
25
+ else:
26
+ raise GuardPointError(f"{error_msg}")
27
+
28
+ if not isinstance(json_body, dict):
29
+ raise GuardPointError("Badly formatted response.")
30
+ if 'value' not in json_body:
31
+ raise GuardPointError("Badly formatted response.")
32
+ if not isinstance(json_body['value'], list):
33
+ raise GuardPointError("Badly formatted response.")
34
+
35
+ customizedFields = []
36
+ for x in json_body['value']:
37
+ customizedFields.append(CustomizedField(x))
38
+ return customizedFields
39
+
40
+ async def update_custom_fields(self, cardholder_uid: str, customFields: CardholderCustomizedField):
41
+ if not validators.uuid(cardholder_uid):
42
+ raise ValueError(f'Malformed Cardholder UID {cardholder_uid}')
43
+
44
+ url = "/odata/API_CardholderCustomizedFields"
45
+ url_query_params = f"({cardholder_uid})"
46
+
47
+ headers = {
48
+ 'Content-Type': 'application/json',
49
+ 'Accept': 'application/json',
50
+ # 'IgnoreNonEditable': ''
51
+ }
52
+
53
+ ch = customFields.dict(changed_only=True)
54
+
55
+ code, json_body = await self.gp_json_query("PATCH", headers=headers, url=(url + url_query_params), json_body=ch)
56
+
57
+ if code != 204: # HTTP NO_CONTENT
58
+ error_msg = GuardPointResponse.extract_error_msg(json_body)
59
+
60
+ if code == 401:
61
+ raise GuardPointUnauthorized(f"Unauthorized - ({error_msg})")
62
+ elif code == 404: # Not Found
63
+ raise GuardPointError(f"Cardholder Not Found")
64
+ else:
65
+ raise GuardPointError(f"{error_msg}")
66
+
67
+ return True
@@ -62,6 +62,41 @@ class CardholderOrderBy(Enum):
62
62
  fromDateValid_DESC = 0,
63
63
  lastPassDate_DESC = 1
64
64
 
65
+ @dataclass
66
+ class CustomizedField:
67
+ customizedFieldType: str = ""
68
+ description: str = ""
69
+ cardholderCFName: str = ""
70
+ name: str = ""
71
+ uid: str = ""
72
+ booleanDefaultValue: any = None
73
+ dateTimeDefaultValue: any = None
74
+ fromValue: any = None
75
+ toValue: any = None
76
+ numberDefaultValue: any = None
77
+ minValue: any = None
78
+ maxValue: any = None
79
+ stringDefaultValue: str = ""
80
+ isMultiLine: any = None
81
+
82
+ def __init__(self, *args, **kwargs):
83
+ super().__init__()
84
+ cf_dict = sanitise_args(self, args, kwargs)
85
+
86
+ for property_name in cf_dict:
87
+ if isinstance(cf_dict[property_name], (str, type(None), bool, int, dict)):
88
+ setattr(self, property_name, cf_dict[property_name])
89
+
90
+ def dict(self):
91
+ cf_dict = {}
92
+ for k, v in asdict(self).items():
93
+ if isinstance(v, (list, dict, bool, int)):
94
+ cf_dict[k] = v
95
+ elif isinstance(v, type(None)):
96
+ cf_dict[k] = None
97
+ else:
98
+ cf_dict[k] = str(v)
99
+
65
100
  @dataclass
66
101
  class ManualEvent:
67
102
  uid: str = ""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyGuardPoint
3
- Version: 2.0.1
3
+ Version: 2.0.3
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,7 @@ long_description = open('README.rst').read()
5
5
  setup(name="pyGuardPoint",
6
6
  python_requires='>3.9.0',
7
7
  packages=find_packages(),
8
- version="2.0.1",
8
+ version="2.0.3",
9
9
  author="John Owen",
10
10
  description="Python wrapper for GuardPoint 10 Access Control System",
11
11
  long_description_content_type='text/markdown',
@@ -1,36 +0,0 @@
1
- import validators
2
- from ..guardpoint_utils import GuardPointResponse
3
- from ..guardpoint_error import GuardPointError, GuardPointUnauthorized
4
- from ..guardpoint_dataclasses import CardholderCustomizedField
5
-
6
-
7
- class CustomizedFieldsAPI:
8
-
9
- async def update_custom_fields(self, cardholder_uid: str, customFields: CardholderCustomizedField):
10
- if not validators.uuid(cardholder_uid):
11
- raise ValueError(f'Malformed Cardholder UID {cardholder_uid}')
12
-
13
- url = "/odata/API_CardholderCustomizedFields"
14
- url_query_params = f"({cardholder_uid})"
15
-
16
- headers = {
17
- 'Content-Type': 'application/json',
18
- 'Accept': 'application/json',
19
- # 'IgnoreNonEditable': ''
20
- }
21
-
22
- ch = customFields.dict(changed_only=True)
23
-
24
- code, json_body = await self.gp_json_query("PATCH", headers=headers, url=(url + url_query_params), json_body=ch)
25
-
26
- if code != 204: # HTTP NO_CONTENT
27
- error_msg = GuardPointResponse.extract_error_msg(json_body)
28
-
29
- if code == 401:
30
- raise GuardPointUnauthorized(f"Unauthorized - ({error_msg})")
31
- elif code == 404: # Not Found
32
- raise GuardPointError(f"Cardholder Not Found")
33
- else:
34
- raise GuardPointError(f"{error_msg}")
35
-
36
- return True
File without changes
File without changes
File without changes