-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathaccesscontrol.py
More file actions
292 lines (242 loc) · 13.7 KB
/
Copy pathaccesscontrol.py
File metadata and controls
292 lines (242 loc) · 13.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
"""AccessControl service implementation."""
from onvif.operator import ONVIFOperator
from onvif.utils.service import ONVIFService
from onvif.utils.wsdl import ONVIFWSDL
# pylint: disable=invalid-name,too-many-public-methods
class AccessControl(ONVIFService):
"""AccessControl service client.
| Property | Details |
| --- | --- |
| **First introduced** | ONVIF Release 2.3 (May 2013) |
| **Binding name** | `PACSBinding` (`ver10/pacs/accesscontrol.wsdl`) |
| **Operations** | [accesscontrol.wsdl](https://developer.onvif.org/pub/specs/branches/development/wsdl/ver10/pacs/accesscontrol.wsdl) |
| **Specification** | [AccessControl.xml](https://developer.onvif.org/pub/specs/branches/development/doc/AccessControl.xml) |
"""
def __init__(self, xaddr=None, **kwargs):
definition = ONVIFWSDL.get_definition("accesscontrol")
self.operator = ONVIFOperator(
definition["path"],
binding=f"{{{definition['namespace']}}}{definition['binding']}",
service_path="AccessControl", # fallback
xaddr=xaddr,
**kwargs,
)
def GetServiceCapabilities(self):
"""This operation returns the capabilities of the access control service.
A device which provides the access control service shall implement this method.
"""
return self.operator.call("GetServiceCapabilities")
def GetAccessPointInfoList(self, Limit=None, StartReference=None):
"""This operation requests a list of all AccessPointInfo items provided by the
device.
A call to this method shall return a StartReference when not all data is
returned and more data is available. The reference shall be valid for retrieving
the next set of data. Please refer to section 4.8.3 in [ONVIF PACS Architecture
and Design Considerations] for more details. The number of items returned shall
not be greater than the Limit parameter.
"""
return self.operator.call(
"GetAccessPointInfoList", Limit=Limit, StartReference=StartReference
)
def GetAccessPointInfo(self, Token):
"""This operation requests a list of AccessPointInfo items matching the given
tokens.
The device shall ignore tokens it cannot resolve and shall return an empty list
if there are no items matching the specified tokens. The device shall not return
a fault in this case. If the number of requested items is greater than MaxLimit,
a TooManyItems fault shall be returned.
"""
return self.operator.call("GetAccessPointInfo", Token=Token)
def GetAccessPointList(self, Limit=None, StartReference=None):
"""This operation requests a list of all AccessPoint items provided by the
device.
A call to this method shall return a StartReference when not all data is
returned and more data is available. The reference shall be valid for retrieving
the next set of data. The number of items returned shall not be greater than the
Limit parameter.
"""
return self.operator.call(
"GetAccessPointList", Limit=Limit, StartReference=StartReference
)
def GetAccessPoints(self, Token):
"""This operation requests a list of AccessPoint items matching the given
tokens.
The device shall ignore tokens it cannot resolve and shall return an empty list
if there are no items matching the specified tokens. The device shall not return
a fault in this case. If the number of requested items is greater than MaxLimit,
a TooManyItems fault shall be returned.
"""
return self.operator.call("GetAccessPoints", Token=Token)
def CreateAccessPoint(self, AccessPoint):
"""This operation creates the specified access point in the device.
The token field of the AccessPoint structure shall be empty and the device shall
allocate a token for the access point. The allocated token shall be returned in
the response. If the client sends any value in the token field, the device shall
return InvalidArgVal as a generic fault code.
"""
return self.operator.call("CreateAccessPoint", AccessPoint=AccessPoint)
def SetAccessPoint(self, AccessPoint):
"""This method is used to synchronize an access point in a client with the
device.
If an access point with the specified token does not exist in the device, the
access point is created. If an access point with the specified token exists,
then the access point is modified. A call to this method takes an AccessPoint
structure as input parameter. The token field of the AccessPoint structure shall
not be empty. A device that signals support for the ClientSuppliedTokenSupported
capability shall implement this command. If no token was specified in the
request, the device shall return InvalidArgs as a generic fault code.
"""
return self.operator.call("SetAccessPoint", AccessPoint=AccessPoint)
def ModifyAccessPoint(self, AccessPoint):
"""This operation modifies the specified access point.
The token of the access point to modify is specified in the token field of the
AccessPoint structure and shall not be empty. All other fields in the structure
shall overwrite the fields in the specified access point. If no token was
specified in the request, the device shall return InvalidArgs as a generic fault
code.
"""
return self.operator.call("ModifyAccessPoint", AccessPoint=AccessPoint)
def DeleteAccessPoint(self, Token):
"""This operation deletes the specified access point.
If it is associated with one or more entities some devices may not be able to
delete the access point, and consequently a ReferenceInUse fault shall be
generated. If no token was specified in the request, the device shall return
InvalidArgs as a generic fault code.
"""
return self.operator.call("DeleteAccessPoint", Token=Token)
def SetAccessPointAuthenticationProfile(self, Token, AuthenticationProfileToken):
"""This operation defines the authentication behavior for an access point."""
return self.operator.call(
"SetAccessPointAuthenticationProfile",
Token=Token,
AuthenticationProfileToken=AuthenticationProfileToken,
)
def DeleteAccessPointAuthenticationProfile(self, Token):
"""This operation reverts the authentication behavior for an access point to its
default behavior."""
return self.operator.call("DeleteAccessPointAuthenticationProfile", Token=Token)
def GetAreaInfoList(self, Limit=None, StartReference=None):
"""This operation requests a list of all AreaInfo items provided by the device.
A call to this method shall return a StartReference when not all data is
returned and more data is available. The reference shall be valid for retrieving
the next set of data. The number of items returned shall not be greater than the
Limit parameter.
"""
return self.operator.call(
"GetAreaInfoList", Limit=Limit, StartReference=StartReference
)
def GetAreaInfo(self, Token):
"""This operation requests a list of AreaInfo items matching the given tokens.
The device shall ignore tokens it cannot resolve and shall return an empty list
if there are no items matching the specified tokens. The device shall not return
a fault in this case. If the number of requested items is greater than MaxLimit,
a TooManyItems fault shall be returned.
"""
return self.operator.call("GetAreaInfo", Token=Token)
def GetAreaList(self, Limit=None, StartReference=None):
"""This operation requests a list of all Area items provided by the device.
A call to this method shall return a StartReference when not all data is
returned and more data is available. The reference shall be valid for retrieving
the next set of data. The number of items returned shall not be greater than the
Limit parameter.
"""
return self.operator.call(
"GetAreaList", Limit=Limit, StartReference=StartReference
)
def GetAreas(self, Token):
"""This operation requests a list of Area items matching the given tokens.
The device shall ignore tokens it cannot resolve and shall return an empty list
if there are no items matching the specified tokens. The device shall not return
a fault in this case. If the number of requested items is greater than MaxLimit,
a TooManyItems fault shall be returned.
"""
return self.operator.call("GetAreas", Token=Token)
def CreateArea(self, Area):
"""This operation creates the specified area in the device.
The token field of the Area structure shall be empty and the device shall
allocate a token for the area. The allocated token shall be returned in the
response. If the client sends any value in the token field, the device shall
return InvalidArgVal as a generic fault code.
"""
return self.operator.call("CreateArea", Area=Area)
def SetArea(self, Area):
"""This method is used to synchronize an area in a client with the device.
If an area with the specified token does not exist in the device, the area is
created. If an area with the specified token exists, then the area is modified.
A call to this method takes an Area structure as input parameter. The token
field of the Area structure shall not be empty. A device that signals support
for the ClientSuppliedTokenSupported capability shall implement this command. If
no token was specified in the request, the device shall return InvalidArgs as a
generic fault code.
"""
return self.operator.call("SetArea", Area=Area)
def ModifyArea(self, Area):
"""This operation modifies the specified area.
The token of the area to modify is specified in the token field of the Area
structure and shall not be empty. All other fields in the structure shall
overwrite the fields in the specified area. If no token was specified in the
request, the device shall return InvalidArgs as a generic fault code.
"""
return self.operator.call("ModifyArea", Area=Area)
def DeleteArea(self, Token):
"""This operation deletes the specified area.
If it is associated with one or more entities some devices may not be able to
delete the area, and consequently a ReferenceInUse fault shall be generated. If
no token was specified in the request, the device shall return InvalidArgs as a
generic fault code.
"""
return self.operator.call("DeleteArea", Token=Token)
def GetAccessPointState(self, Token):
"""This operation requests the AccessPointState for the access point instance
specified by the token."""
return self.operator.call("GetAccessPointState", Token=Token)
def EnableAccessPoint(self, Token):
"""This operation allows enabling an access point.
A device that signals support for DisableAccessPoint capability for a particular
access point instance shall implement this command.
"""
return self.operator.call("EnableAccessPoint", Token=Token)
def DisableAccessPoint(self, Token):
"""This operation allows disabling an access point.
A device that signals support for the DisableAccessPoint capability for a
particular access point instance shall implement this command.
"""
return self.operator.call("DisableAccessPoint", Token=Token)
def Feedback(
self, AccessPointToken, FeedbackType, RecognitionType=None, TextMessage=None
):
"""This operation controls how the specified access point should indicate
feedback.
A client can instruct the access point about the door status or that one or more
identifiers are needed to grant access, etc. It is typically used in conjunction
with the AccessControl/Request/Identifier event and the ExternalAuthorization
operation to indicate progress and required recognition methods. The supported
feedback types are indicated in the SupportedFeedbackTypes field in the access
point capabilities. In cases where multiple combinations of recognition methods
are possible, the RecognitionType field can contain multiple values. E.g. for
the security level "Card+PIN or Card+Fingerprint", the feedback command for
requesting the second recognition method would contain both pt:PIN and
pt:Fingerprint in the RecognitionType field. If the device supports at least one
feedback type the device shall implement this command.
"""
return self.operator.call(
"Feedback",
AccessPointToken=AccessPointToken,
FeedbackType=FeedbackType,
RecognitionType=RecognitionType,
TextMessage=TextMessage,
)
def ExternalAuthorization(
self, AccessPointToken, Decision, CredentialToken=None, Reason=None
):
"""This operation allows to deny or grant decision at an access point instance.
A device that signals support for ExternalAuthorization capability for a
particular access point instance shall implement this method.
"""
return self.operator.call(
"ExternalAuthorization",
AccessPointToken=AccessPointToken,
CredentialToken=CredentialToken,
Reason=Reason,
Decision=Decision,
)