gallagher 0.1.0a1__py3-none-any.whl
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.
- gallagher/__init__.py +10 -0
- gallagher/cc/__init__.py +62 -0
- gallagher/cc/alarms/__init__.py +27 -0
- gallagher/cc/alarms/day_category.py +24 -0
- gallagher/cc/alarms/divisions.py +28 -0
- gallagher/cc/alarms/event.py +24 -0
- gallagher/cc/alarms/items.py +43 -0
- gallagher/cc/alarms/schedule.py +22 -0
- gallagher/cc/cardholders/__init__.py +3 -0
- gallagher/cc/cardholders/card_type.py +25 -0
- gallagher/cc/core.py +222 -0
- gallagher/cc/status_overrides/__init__.py +0 -0
- gallagher/const.py +36 -0
- gallagher/dto/__init__.py +7 -0
- gallagher/dto/access_group.py +85 -0
- gallagher/dto/alarm.py +72 -0
- gallagher/dto/card_type.py +43 -0
- gallagher/dto/cardholder.py +38 -0
- gallagher/dto/day_category.py +45 -0
- gallagher/dto/discover.py +242 -0
- gallagher/dto/division.py +53 -0
- gallagher/dto/door.py +30 -0
- gallagher/dto/event.py +37 -0
- gallagher/dto/features.py +11 -0
- gallagher/dto/items.py +79 -0
- gallagher/dto/locker.py +11 -0
- gallagher/dto/operator.py +11 -0
- gallagher/dto/pdf.py +25 -0
- gallagher/dto/reception.py +11 -0
- gallagher/dto/role.py +25 -0
- gallagher/dto/salto.py +36 -0
- gallagher/dto/schedule.py +32 -0
- gallagher/dto/utils.py +67 -0
- gallagher/dto/visit.py +10 -0
- gallagher/dto/visitor.py +34 -0
- gallagher/dto/zone.py +18 -0
- gallagher/exception.py +18 -0
- gallagher-0.1.0a1.dist-info/LICENSE +21 -0
- gallagher-0.1.0a1.dist-info/METADATA +213 -0
- gallagher-0.1.0a1.dist-info/RECORD +41 -0
- gallagher-0.1.0a1.dist-info/WHEEL +4 -0
gallagher/__init__.py
ADDED
gallagher/cc/__init__.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
""" Command Centre bindings
|
|
2
|
+
|
|
3
|
+
After enabling the Gateway for your server and REST API user, you need
|
|
4
|
+
only to replace the local server's URL with the cloud API Gateway one.
|
|
5
|
+
|
|
6
|
+
Example Local request:
|
|
7
|
+
|
|
8
|
+
<client certificate thumbprint e89ef121958...>
|
|
9
|
+
GET https://servername.yourcompany.local:8904/api/cardholders
|
|
10
|
+
Authorization: GGL-API-KEY F6F0-C8F0-
|
|
11
|
+
|
|
12
|
+
Equivalent Gateway request:
|
|
13
|
+
|
|
14
|
+
<client certificate thumbprint e89ef121958...>
|
|
15
|
+
GET https://commandcentre-api-au.security.gallagher.cloud/api/cardholders
|
|
16
|
+
Authorization: GGL-API-KEY F6F0-C8F0-60AF-
|
|
17
|
+
|
|
18
|
+
The API client takes of appending the headers onto the requests.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
from typing import Optional
|
|
24
|
+
|
|
25
|
+
from ..const import URL
|
|
26
|
+
|
|
27
|
+
from ..dto.discover import (
|
|
28
|
+
DiscoveryResponse,
|
|
29
|
+
FeaturesDetail,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
# Follow the instructions in the Gallagher documentation
|
|
33
|
+
# to obtain an API key
|
|
34
|
+
api_key: str = None
|
|
35
|
+
|
|
36
|
+
# By default the base API is set to the Australian Gateway
|
|
37
|
+
# Override this with the US gateway or a local DNS/IP address
|
|
38
|
+
api_base: str = URL.CLOUD_GATEWAY_AU
|
|
39
|
+
|
|
40
|
+
# Default is set to the library, set this to your application
|
|
41
|
+
client_id: str = "gallagher-py"
|
|
42
|
+
|
|
43
|
+
# By default connections are sent straight to the server
|
|
44
|
+
# should you wish to use a proxy, set this to the proxy URL
|
|
45
|
+
proxy: Optional[str] = None
|
|
46
|
+
|
|
47
|
+
# Discover response object, each endpoint will reference
|
|
48
|
+
# one of the instance variable Href property to get the
|
|
49
|
+
# path to the endpoint.
|
|
50
|
+
#
|
|
51
|
+
# Gallagher recommends that the endpoints not be hardcoded
|
|
52
|
+
# into the client and instead be discovered at runtime.
|
|
53
|
+
#
|
|
54
|
+
# Note that if a feature has not been licensed by a client
|
|
55
|
+
# then the path will be set to None, if the client attempts
|
|
56
|
+
# to access the endpoint then the library will throw an exception
|
|
57
|
+
#
|
|
58
|
+
# This value is memoized and should perform
|
|
59
|
+
CAPABILITIES = DiscoveryResponse(
|
|
60
|
+
version="0.0.0", # Indicates that it's not been discovered
|
|
61
|
+
features=FeaturesDetail()
|
|
62
|
+
)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from ..core import (
|
|
7
|
+
APIEndpoint,
|
|
8
|
+
EndpointConfig
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
from ...dto.alarm import (
|
|
12
|
+
AlarmResponse,
|
|
13
|
+
AlarmZoneSummary
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Alarms(
|
|
18
|
+
APIEndpoint
|
|
19
|
+
):
|
|
20
|
+
""" Alarms
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
__config__ = EndpointConfig(
|
|
24
|
+
endpoint="alarms",
|
|
25
|
+
dto_list=AlarmResponse,
|
|
26
|
+
dto_retrieve=AlarmZoneSummary,
|
|
27
|
+
)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from ..core import (
|
|
7
|
+
APIEndpoint,
|
|
8
|
+
EndpointConfig
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
from ...dto.day_category import (
|
|
12
|
+
DayCategoryResponse
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class DayCategory(APIEndpoint):
|
|
17
|
+
""" Day Categories
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
__config__ = EndpointConfig(
|
|
21
|
+
endpoint="day_categories",
|
|
22
|
+
dto_list=DayCategoryResponse,
|
|
23
|
+
dto_retrieve=DayCategoryResponse,
|
|
24
|
+
)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from ..core import (
|
|
6
|
+
APIEndpoint,
|
|
7
|
+
EndpointConfig
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
from ...dto.division import (
|
|
11
|
+
DivisionDetailResponse,
|
|
12
|
+
DivisionDetail,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Division(APIEndpoint):
|
|
17
|
+
"""
|
|
18
|
+
Gallagher advises against hardcoding the URLs for divisions, and instead
|
|
19
|
+
recommends using the /api endpoint to discover the URLs from
|
|
20
|
+
events.divisions.href and alarms.division.href.
|
|
21
|
+
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
__config__ = EndpointConfig(
|
|
25
|
+
endpoint="divisions",
|
|
26
|
+
dto_list=DivisionDetailResponse,
|
|
27
|
+
dto_retrieve=DivisionDetail,
|
|
28
|
+
)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
""" Events that the Command Centre
|
|
2
|
+
|
|
3
|
+
Command Centre has about 80 event types that occur when somebody
|
|
4
|
+
authenticates at a device, usually by badging a card.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from ..core import (
|
|
8
|
+
APIEndpoint,
|
|
9
|
+
EndpointConfig
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Event(
|
|
14
|
+
APIEndpoint
|
|
15
|
+
):
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
__config__ = EndpointConfig(
|
|
21
|
+
endpoint="events",
|
|
22
|
+
dto_list=EventResponse,
|
|
23
|
+
dto_retrieve=EventDetail,
|
|
24
|
+
)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
""" Items
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from gallagher.cc import CAPABILITIES
|
|
7
|
+
|
|
8
|
+
from ..core import (
|
|
9
|
+
APIEndpoint,
|
|
10
|
+
EndpointConfig,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
from ...dto.items import (
|
|
14
|
+
ItemTypesResponse,
|
|
15
|
+
ItemsSummaryResponse,
|
|
16
|
+
ItemDetail
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ItemsTypes(APIEndpoint):
|
|
21
|
+
"""
|
|
22
|
+
Gallagher
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
__config__ = EndpointConfig(
|
|
26
|
+
endpoint="items/types",
|
|
27
|
+
dto_list=ItemTypesResponse,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class Item(APIEndpoint):
|
|
32
|
+
"""
|
|
33
|
+
Gallagher advises against hardcoding the URLs for divisions, and instead
|
|
34
|
+
recommends using the /api endpoint to discover the URLs from
|
|
35
|
+
events.divisions.href and alarms.division.href.
|
|
36
|
+
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
__config__ = EndpointConfig(
|
|
40
|
+
endpoint="items",
|
|
41
|
+
dto_list=ItemsSummaryResponse,
|
|
42
|
+
dto_retrieve=ItemDetail,
|
|
43
|
+
)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from ..core import (
|
|
6
|
+
APIEndpoint,
|
|
7
|
+
EndpointConfig
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
from ...dto.schedule import (
|
|
11
|
+
ScheduleSummaryResponse
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Schedule(APIEndpoint):
|
|
16
|
+
""" Schedules
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
__config__ = EndpointConfig(
|
|
20
|
+
endpoint="schedules",
|
|
21
|
+
dto_list=ScheduleSummaryResponse,
|
|
22
|
+
)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
from ..core import (
|
|
5
|
+
APIEndpoint,
|
|
6
|
+
EndpointConfig
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
from ...dto.card_type import (
|
|
10
|
+
CardTypeResponse
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class CardType(APIEndpoint):
|
|
15
|
+
""" Card Types provide a list of support card types for the instance.
|
|
16
|
+
|
|
17
|
+
These can vary between using physical cards, mobile credentials, or
|
|
18
|
+
biometrics. The card type is used to dynamically determine the types
|
|
19
|
+
of credentials available on this particular instance.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
__config__ = EndpointConfig(
|
|
23
|
+
endpoint="card_types",
|
|
24
|
+
dto_list=CardTypeResponse,
|
|
25
|
+
)
|
gallagher/cc/core.py
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
""" Utilities for the Gallagher Command Centre API
|
|
2
|
+
|
|
3
|
+
This package provides a set of utilities that are used that each endpoint
|
|
4
|
+
uses to communicate with the Gallagher Command Centre API.
|
|
5
|
+
|
|
6
|
+
Every endpoint inherits from the APIEndpoint class and must define
|
|
7
|
+
a configuration that is assigned to the variable __config__.
|
|
8
|
+
|
|
9
|
+
The endpoint variable in the EndpointConfig should be assigned to a reference
|
|
10
|
+
to the endpoint in the DiscoveryResponse object. When initialised the
|
|
11
|
+
endpoint will be assigned to None but will self heal as part of
|
|
12
|
+
the bootstrapping process.
|
|
13
|
+
"""
|
|
14
|
+
from typing import Optional
|
|
15
|
+
from dataclasses import dataclass
|
|
16
|
+
|
|
17
|
+
import httpx
|
|
18
|
+
|
|
19
|
+
from gallagher.exception import (
|
|
20
|
+
UnlicensedFeatureException
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
from ..dto.discover import (
|
|
24
|
+
DiscoveryResponse,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def check_api_key_format(api_key):
|
|
29
|
+
""" Validates that the Gallagher Key is in the right format.
|
|
30
|
+
|
|
31
|
+
It's not possible for the API client to validate the key against
|
|
32
|
+
Gallagher servers but it will validate that the key is in the
|
|
33
|
+
right format.
|
|
34
|
+
"""
|
|
35
|
+
api_tokens = api_key.split('-')
|
|
36
|
+
return (api_tokens.count() == 8)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def get_authorization_headers():
|
|
40
|
+
""" Creates an authorization header for Gallagher API calls
|
|
41
|
+
|
|
42
|
+
The server expects an Authorization header with GGL-API-KEY
|
|
43
|
+
set to the API key provided by Gallagher Command Centre.
|
|
44
|
+
|
|
45
|
+
This API key is what allows the cloud proxy to determine where
|
|
46
|
+
the request should be routed to.
|
|
47
|
+
|
|
48
|
+
See the Authorization section here for more information
|
|
49
|
+
https://gallaghersecurity.github.io/cc-rest-docs/ref/events.html
|
|
50
|
+
|
|
51
|
+
from gallagher import cc, const
|
|
52
|
+
|
|
53
|
+
cc.api_key = "GH_"
|
|
54
|
+
|
|
55
|
+
"""
|
|
56
|
+
from . import api_key
|
|
57
|
+
return {
|
|
58
|
+
'Authorization': f'GGL-API-KEY {api_key}'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@dataclass
|
|
63
|
+
class EndpointConfig:
|
|
64
|
+
""" A configuration for an API endpoint
|
|
65
|
+
|
|
66
|
+
Each API endpoint has a configuration that defines how
|
|
67
|
+
the APIBase should attempt to parse responses from the
|
|
68
|
+
Gallagher servers.
|
|
69
|
+
|
|
70
|
+
Additionally it provides defaults for various parameters
|
|
71
|
+
that are commonly accepted by endpoints.
|
|
72
|
+
|
|
73
|
+
Not assigning a configuration to an endpoint will result
|
|
74
|
+
in APIBase raising an exception.
|
|
75
|
+
|
|
76
|
+
The configuration is assigned a special variable called
|
|
77
|
+
__config__ which is set to None by default.
|
|
78
|
+
|
|
79
|
+
"""
|
|
80
|
+
endpoint: str # partial path to the endpoint e.g. day_category
|
|
81
|
+
dto_list: Optional[any] = None # DTO to be used for list requests
|
|
82
|
+
dto_retrieve: Optional[any] = None # DTO to be used for retrieve requests
|
|
83
|
+
|
|
84
|
+
top: Optional[int] = 10 # Number of response to download
|
|
85
|
+
sort: Optional[str] = "id" # Can be set to id or -id
|
|
86
|
+
# fields: list[str] = [] # Optional list of fields
|
|
87
|
+
|
|
88
|
+
@classmethod
|
|
89
|
+
def validate_endpoint(cls):
|
|
90
|
+
""" Check to see if the feature is licensed and available
|
|
91
|
+
|
|
92
|
+
Gallagher REST API is licensed per feature, if a feature is not
|
|
93
|
+
the endpoint is set to none and we should throw an exception
|
|
94
|
+
"""
|
|
95
|
+
if not cls.endpoint:
|
|
96
|
+
raise UnlicensedFeatureException(
|
|
97
|
+
"Endpoint not defined"
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class APIEndpoint():
|
|
102
|
+
""" Base class for all API objects
|
|
103
|
+
|
|
104
|
+
All API endpoints must inherit from this class and provide a Config class
|
|
105
|
+
that automates the implementation of many of the API methods.
|
|
106
|
+
|
|
107
|
+
If the endpoints provide additional methods then they are to implement them
|
|
108
|
+
based on the same standards as this base class.
|
|
109
|
+
|
|
110
|
+
"""
|
|
111
|
+
|
|
112
|
+
# This must be overridden by each child class that inherits
|
|
113
|
+
# from this base class.
|
|
114
|
+
__config__ = None
|
|
115
|
+
|
|
116
|
+
@classmethod
|
|
117
|
+
def _discover(cls):
|
|
118
|
+
""" The Command Centre root API endpoint
|
|
119
|
+
|
|
120
|
+
Much of Gallagher's API documentation suggests that we don't
|
|
121
|
+
hard code the URL, but instead use the discovery endpoint by
|
|
122
|
+
calling the root endpoint.
|
|
123
|
+
|
|
124
|
+
This should be a singleton which is instantiated upon initialisation
|
|
125
|
+
and then used across the other endpoints.
|
|
126
|
+
|
|
127
|
+
For example features.events.events.href is the endpoint for the events
|
|
128
|
+
where as features.events.events.updates is the endpoint for getting
|
|
129
|
+
updates to the changes to events.
|
|
130
|
+
|
|
131
|
+
This differs per endpoint that we work with.
|
|
132
|
+
"""
|
|
133
|
+
|
|
134
|
+
# Auto-discovery of the API endpoints, this will
|
|
135
|
+
# be called as part of the bootstrapping process
|
|
136
|
+
from . import api_base
|
|
137
|
+
response = httpx.get(
|
|
138
|
+
api_base,
|
|
139
|
+
headers=get_authorization_headers(),
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
parsed_obj = DiscoveryResponse.model_validate(
|
|
143
|
+
response.json()
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
from gallagher.cc import CAPABILITIES
|
|
147
|
+
CAPABILITIES = parsed_obj
|
|
148
|
+
|
|
149
|
+
@classmethod
|
|
150
|
+
def list(cls, skip=0):
|
|
151
|
+
""" For a list of objects for the given resource
|
|
152
|
+
|
|
153
|
+
Most resources can be searched which is exposed by this method.
|
|
154
|
+
Resources also allow pagination which can be controlled by the skip
|
|
155
|
+
"""
|
|
156
|
+
cls._discover()
|
|
157
|
+
|
|
158
|
+
from . import api_base
|
|
159
|
+
response = httpx.get(
|
|
160
|
+
f'{api_base}{cls.__config__.endpoint}',
|
|
161
|
+
headers=get_authorization_headers(),
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
parsed_obj = cls.__config__.dto_list.model_validate(
|
|
165
|
+
response.json()
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
return parsed_obj
|
|
169
|
+
|
|
170
|
+
@classmethod
|
|
171
|
+
def retrieve(cls, id):
|
|
172
|
+
""" Retrieve a single object for the given resource
|
|
173
|
+
|
|
174
|
+
Most objects have an ID which is numeral or UUID.
|
|
175
|
+
Each resource also provides a href and pagination for
|
|
176
|
+
children.
|
|
177
|
+
"""
|
|
178
|
+
cls._discover()
|
|
179
|
+
|
|
180
|
+
from . import api_base
|
|
181
|
+
response = httpx.get(
|
|
182
|
+
f'{api_base}{cls.__config__.endpoint}/{id}',
|
|
183
|
+
headers=get_authorization_headers(),
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
parsed_obj = cls.__config__.dto_retrieve.model_validate(
|
|
187
|
+
response.json()
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
return parsed_obj
|
|
191
|
+
|
|
192
|
+
@classmethod
|
|
193
|
+
def modify(cls):
|
|
194
|
+
"""
|
|
195
|
+
|
|
196
|
+
"""
|
|
197
|
+
pass
|
|
198
|
+
|
|
199
|
+
@classmethod
|
|
200
|
+
def create(cls, **params):
|
|
201
|
+
"""
|
|
202
|
+
|
|
203
|
+
"""
|
|
204
|
+
pass
|
|
205
|
+
|
|
206
|
+
@classmethod
|
|
207
|
+
def delete(cls):
|
|
208
|
+
"""
|
|
209
|
+
|
|
210
|
+
"""
|
|
211
|
+
pass
|
|
212
|
+
|
|
213
|
+
@classmethod
|
|
214
|
+
def search(cls, **kwargs):
|
|
215
|
+
""" Search
|
|
216
|
+
|
|
217
|
+
"""
|
|
218
|
+
pass
|
|
219
|
+
|
|
220
|
+
@classmethod
|
|
221
|
+
def updates(cls):
|
|
222
|
+
pass
|
|
File without changes
|
gallagher/const.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
""" Constants for the Gallagher Cloud ecosystem
|
|
2
|
+
|
|
3
|
+
Gallagher publishes a set of networking constants for their cloud gateways
|
|
4
|
+
these should be updated as the documentation is updated.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class URL:
|
|
9
|
+
""" DNS names for the cloud gateways
|
|
10
|
+
|
|
11
|
+
These are published by Gallagher on Github
|
|
12
|
+
https://gallaghersecurity.github.io/commandcentre-cloud-api-gateway.html
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
CLOUD_GATEWAY_AU: str = \
|
|
16
|
+
"https://commandcentre-api-au.security.gallagher.cloud/api/"
|
|
17
|
+
CLOUD_GATEWAY_US: str = \
|
|
18
|
+
"https://commandcentre-api-us.security.gallagher.cloud/api/"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class IP_ADDR:
|
|
22
|
+
""" IP addresses for the cloud gateways
|
|
23
|
+
|
|
24
|
+
These are published by Gallagher on Github
|
|
25
|
+
https://gallaghersecurity.github.io/commandcentre-cloud-api-gateway.html
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
CLOUD_GATEWAY_AU = [
|
|
29
|
+
"3.106.1.6",
|
|
30
|
+
"3.106.100.112"
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
CLOUD_GATEWAY_US = [
|
|
34
|
+
"44.193.42.111",
|
|
35
|
+
"3.209.194.103"
|
|
36
|
+
]
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
from .utils import (
|
|
5
|
+
AppBaseModel,
|
|
6
|
+
IdentityMixin,
|
|
7
|
+
HrefMixin
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
from .division import DivisionDetail
|
|
11
|
+
from .pdf import PDFRef
|
|
12
|
+
from .schedule import ScheduleRef
|
|
13
|
+
from .zone import AccessZoneRef
|
|
14
|
+
from .salto import SaltoAccessItemSummary
|
|
15
|
+
from .alarm import AlarmZoneSummary
|
|
16
|
+
|
|
17
|
+
class AccessSummary(
|
|
18
|
+
AppBaseModel
|
|
19
|
+
):
|
|
20
|
+
""" Access is zone paired with a schedule
|
|
21
|
+
"""
|
|
22
|
+
access_zone: AccessZoneRef
|
|
23
|
+
schedule: ScheduleRef
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class AccessGroupRef(
|
|
27
|
+
AppBaseModel,
|
|
28
|
+
HrefMixin
|
|
29
|
+
):
|
|
30
|
+
""" Access Groups is what a user is assigned to to provide access to doors
|
|
31
|
+
"""
|
|
32
|
+
name: str
|
|
33
|
+
|
|
34
|
+
class AccessGroupSummary(
|
|
35
|
+
AccessGroupRef
|
|
36
|
+
):
|
|
37
|
+
""" AccessGroup Summary is what the API returns on searches
|
|
38
|
+
|
|
39
|
+
This builds on the Ref class to add the summary fields and is
|
|
40
|
+
extended by the Detail class to add the fully remainder of
|
|
41
|
+
the fields
|
|
42
|
+
"""
|
|
43
|
+
description: Optional[str]
|
|
44
|
+
parent: Optional[AccessGroupRef]
|
|
45
|
+
division: IdentityMixin
|
|
46
|
+
cardholders: Optional[HrefMixin]
|
|
47
|
+
server_display_name: Optional[str]
|
|
48
|
+
|
|
49
|
+
class AccessGroupDetail(
|
|
50
|
+
AccessGroupSummary
|
|
51
|
+
):
|
|
52
|
+
"""
|
|
53
|
+
"""
|
|
54
|
+
description: Optional[str]
|
|
55
|
+
parent: Optional[AccessGroupRef]
|
|
56
|
+
division: DivisionDetail
|
|
57
|
+
cardholders: Optional[HrefMixin]
|
|
58
|
+
server_display_name: Optional[str]
|
|
59
|
+
children: list[AccessGroupRef]
|
|
60
|
+
personal_data_definitions: list[PDFRef]
|
|
61
|
+
|
|
62
|
+
visitor: bool
|
|
63
|
+
escort_visitors: bool
|
|
64
|
+
lock_unlock_access_zones: bool
|
|
65
|
+
enter_during_lockdown: bool
|
|
66
|
+
first_card_unlock: bool
|
|
67
|
+
override_aperio_privacy: bool
|
|
68
|
+
aperio_offline_access: bool
|
|
69
|
+
disarm_alarm_zones: bool
|
|
70
|
+
arm_alarm_zones: bool
|
|
71
|
+
hvLf_fence_zones: bool
|
|
72
|
+
view_alarms: bool
|
|
73
|
+
shunt: bool
|
|
74
|
+
lock_out_fence_zones: bool
|
|
75
|
+
cancel_fence_zone_lockout: bool
|
|
76
|
+
ack_all: bool
|
|
77
|
+
ack_below_high: bool
|
|
78
|
+
select_alarm_zone: bool
|
|
79
|
+
arm_while_alarm: bool
|
|
80
|
+
arm_while_active_alarm: bool
|
|
81
|
+
isolate_alarm_zones: bool
|
|
82
|
+
|
|
83
|
+
access: list[AccessSummary]
|
|
84
|
+
salto_access: list[SaltoAccessItemSummary]
|
|
85
|
+
alarm_zones: list[AlarmZoneSummary]
|
gallagher/dto/alarm.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
7
|
+
from .utils import (
|
|
8
|
+
AppBaseModel,
|
|
9
|
+
HrefMixin,
|
|
10
|
+
IdentityMixin,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
from .event import EventType
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class AlarmSource(
|
|
17
|
+
AppBaseModel,
|
|
18
|
+
HrefMixin,
|
|
19
|
+
IdentityMixin,
|
|
20
|
+
):
|
|
21
|
+
""" AlarmSource represents a device that has triggered an alarm
|
|
22
|
+
"""
|
|
23
|
+
name: str
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class AlarmZoneRef(
|
|
27
|
+
AppBaseModel,
|
|
28
|
+
HrefMixin
|
|
29
|
+
):
|
|
30
|
+
""" AccessZone represents
|
|
31
|
+
"""
|
|
32
|
+
name: str
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class AlarmZoneSummary(
|
|
36
|
+
AppBaseModel,
|
|
37
|
+
HrefMixin,
|
|
38
|
+
IdentityMixin,
|
|
39
|
+
):
|
|
40
|
+
""" #TODO: Revise this if it shows up in other places
|
|
41
|
+
|
|
42
|
+
I have literally named this class to model the alarm_zones
|
|
43
|
+
property in the access_group schema. I don't know if this
|
|
44
|
+
is appropriate
|
|
45
|
+
"""
|
|
46
|
+
time: str
|
|
47
|
+
message: str
|
|
48
|
+
source: AlarmSource
|
|
49
|
+
type: str
|
|
50
|
+
event_type: Optional[EventType] = None
|
|
51
|
+
priority: int
|
|
52
|
+
state: str
|
|
53
|
+
active: bool
|
|
54
|
+
division: HrefMixin
|
|
55
|
+
event: Optional[HrefMixin] = None
|
|
56
|
+
note_presets: list[str] = []
|
|
57
|
+
view: HrefMixin
|
|
58
|
+
comment: HrefMixin
|
|
59
|
+
acknowledge: Optional[HrefMixin] = None
|
|
60
|
+
acknowledge_with_comment: Optional[HrefMixin] = None
|
|
61
|
+
process: Optional[HrefMixin] = None
|
|
62
|
+
process_with_comment: Optional[HrefMixin] = None
|
|
63
|
+
force_process: Optional[HrefMixin] = None
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class AlarmResponse(
|
|
67
|
+
AppBaseModel,
|
|
68
|
+
):
|
|
69
|
+
""" AlarmResponse represents a single alarm
|
|
70
|
+
"""
|
|
71
|
+
alarms: list[AlarmZoneSummary]
|
|
72
|
+
updates: HrefMixin
|