gallagher 0.1.0a1__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.
- gallagher-0.1.0a1/LICENSE +21 -0
- gallagher-0.1.0a1/PKG-INFO +213 -0
- gallagher-0.1.0a1/README.md +188 -0
- gallagher-0.1.0a1/gallagher/__init__.py +10 -0
- gallagher-0.1.0a1/gallagher/cc/__init__.py +62 -0
- gallagher-0.1.0a1/gallagher/cc/alarms/__init__.py +27 -0
- gallagher-0.1.0a1/gallagher/cc/alarms/day_category.py +24 -0
- gallagher-0.1.0a1/gallagher/cc/alarms/divisions.py +28 -0
- gallagher-0.1.0a1/gallagher/cc/alarms/event.py +24 -0
- gallagher-0.1.0a1/gallagher/cc/alarms/items.py +43 -0
- gallagher-0.1.0a1/gallagher/cc/alarms/schedule.py +22 -0
- gallagher-0.1.0a1/gallagher/cc/cardholders/__init__.py +3 -0
- gallagher-0.1.0a1/gallagher/cc/cardholders/card_type.py +25 -0
- gallagher-0.1.0a1/gallagher/cc/core.py +222 -0
- gallagher-0.1.0a1/gallagher/cc/status_overrides/__init__.py +0 -0
- gallagher-0.1.0a1/gallagher/const.py +36 -0
- gallagher-0.1.0a1/gallagher/dto/__init__.py +7 -0
- gallagher-0.1.0a1/gallagher/dto/access_group.py +85 -0
- gallagher-0.1.0a1/gallagher/dto/alarm.py +72 -0
- gallagher-0.1.0a1/gallagher/dto/card_type.py +43 -0
- gallagher-0.1.0a1/gallagher/dto/cardholder.py +38 -0
- gallagher-0.1.0a1/gallagher/dto/day_category.py +45 -0
- gallagher-0.1.0a1/gallagher/dto/discover.py +242 -0
- gallagher-0.1.0a1/gallagher/dto/division.py +53 -0
- gallagher-0.1.0a1/gallagher/dto/door.py +30 -0
- gallagher-0.1.0a1/gallagher/dto/event.py +37 -0
- gallagher-0.1.0a1/gallagher/dto/features.py +11 -0
- gallagher-0.1.0a1/gallagher/dto/items.py +79 -0
- gallagher-0.1.0a1/gallagher/dto/locker.py +11 -0
- gallagher-0.1.0a1/gallagher/dto/operator.py +11 -0
- gallagher-0.1.0a1/gallagher/dto/pdf.py +25 -0
- gallagher-0.1.0a1/gallagher/dto/reception.py +11 -0
- gallagher-0.1.0a1/gallagher/dto/role.py +25 -0
- gallagher-0.1.0a1/gallagher/dto/salto.py +36 -0
- gallagher-0.1.0a1/gallagher/dto/schedule.py +32 -0
- gallagher-0.1.0a1/gallagher/dto/utils.py +67 -0
- gallagher-0.1.0a1/gallagher/dto/visit.py +10 -0
- gallagher-0.1.0a1/gallagher/dto/visitor.py +34 -0
- gallagher-0.1.0a1/gallagher/dto/zone.py +18 -0
- gallagher-0.1.0a1/gallagher/exception.py +18 -0
- gallagher-0.1.0a1/pyproject.toml +32 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Anomaly Software Pty Ltd (http://anomaly.ltd)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: gallagher
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: Python idiomatic client for Gallagher Command Centre API
|
|
5
|
+
Author: Dev Mukherjee
|
|
6
|
+
Author-email: devraj@gmail.com
|
|
7
|
+
Requires-Python: >=3.11,<4.0
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Requires-Dist: annotated-types (>=0.6.0,<0.7.0)
|
|
12
|
+
Requires-Dist: anyio (>=4.1.0,<5.0.0)
|
|
13
|
+
Requires-Dist: certifi (>=2023.11.17,<2024.0.0)
|
|
14
|
+
Requires-Dist: coverage (>=7.3.2,<8.0.0)
|
|
15
|
+
Requires-Dist: httpx (>=0.25.2,<0.26.0)
|
|
16
|
+
Requires-Dist: idna (>=3.6,<4.0)
|
|
17
|
+
Requires-Dist: packaging (>=23.2,<24.0)
|
|
18
|
+
Requires-Dist: pluggy (>=1.3.0,<2.0.0)
|
|
19
|
+
Requires-Dist: pydantic (>=2.5.2,<3.0.0)
|
|
20
|
+
Requires-Dist: pytest (>=7.4.3,<8.0.0)
|
|
21
|
+
Requires-Dist: pytest-order (>=1.2.0,<2.0.0)
|
|
22
|
+
Requires-Dist: typing-extensions (>=4.8.0,<5.0.0)
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
> Currently under heavy development, please check for stable release before use
|
|
26
|
+
|
|
27
|
+
# Gallagher Command Centre REST API Client
|
|
28
|
+
|
|
29
|
+
> Python idiomatic client for Gallagher Command Centre API
|
|
30
|
+
|
|
31
|
+
Gallagher Security manufacture a variety of [security products](https://security.gallagher.com) all of which are controlled by their [Command Centre](https://products.security.gallagher.com/security/au/en_AU/products/software/command-centre/p/C201311) software. Traditionally Command Centre has been a Windows based server product. Version `8.6` introduced a REST API which allows you to interact with the system via HTTP requests. Gallagher also provide a [Cloud API Gateway](https://gallaghersecurity.github.io/docs/Command%20Centre%20Cloud%20Api%20Gateway%20TIP.pdf) which allows third party integrations to securely communicate with the Command Centre on site.
|
|
32
|
+
|
|
33
|
+
This API client is a Python wrapper around their REST API and is designed to work locally or via the Cloud API Gateway.
|
|
34
|
+
|
|
35
|
+
While Gallagher maintain a set of [Swagger definitions](https://github.com/gallaghersecurity/cc-rest-docs) for their API, they are primarily intended to generate the documentation [published on Github](https://gallaghersecurity.github.io/cc-rest-docs/ref/index.html). They use a tool called [Spectacle](https://github.com/sourcey/spectacle). Gallagher explicitly state that the Swagger definitions are not intended to be used to generate code. Due to this the API client is hand built and not auto-generated.
|
|
36
|
+
|
|
37
|
+
> Due to custom annotations the YAML files will not parse with any standard parser.
|
|
38
|
+
|
|
39
|
+
The client was designed while building products around the Gallagher API. It's design is highly opinionated and does not conform with how Gallagher design software interfaces. If you've worked with [stripe-python](https://github.com/stripe/stripe-python) the syntax may feel familiar.
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from gallagher import cc, const
|
|
43
|
+
|
|
44
|
+
cc.api_key = "GH_"
|
|
45
|
+
|
|
46
|
+
cc.discover()
|
|
47
|
+
cc.Customer.create()
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
> Note this project is **NOT** officially affiliated with Gallagher Security
|
|
51
|
+
|
|
52
|
+
## API Notes
|
|
53
|
+
|
|
54
|
+
The Gallagher API uses `href` attributes to provide a the destination of referenced objects in the responses. These are prefixed with the server origin i.e if you are using the Cloud Gateway then all your URLs will be prefixed with the appropriate gateway's address.
|
|
55
|
+
|
|
56
|
+
These appear in various forms, starting from as simple as the `href` itself:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
"cardholders": {
|
|
60
|
+
"href": "https://localhost:8904/api/access_groups/352/cardholders"
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
through to self recursive references with additional attributes:
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
"parent": {
|
|
68
|
+
"href": "https://localhost:8904/api/access_groups/100",
|
|
69
|
+
"name": "All R&D"
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
> Above examples have been taken from the Gallagher documentation
|
|
74
|
+
|
|
75
|
+
Our `schemas` provide a set of `Mixins` that are used to construct the Models. These are repeatable patterns that need not be repeated. The typical patter would be to subclass from the `Mixins` e.g:
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from .utils import AppBaseModel, IdentityMixin, HrefMixin
|
|
79
|
+
|
|
80
|
+
class AccessGroupRef(
|
|
81
|
+
AppBaseModel,
|
|
82
|
+
HrefMixin
|
|
83
|
+
):
|
|
84
|
+
""" Access Groups is what a user is assigned to to provide access to doors
|
|
85
|
+
"""
|
|
86
|
+
name: str
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
where the `HrefMixin` provides the `href` attribute:
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
class HrefMixin(BaseModel):
|
|
93
|
+
""" Href
|
|
94
|
+
|
|
95
|
+
This mixin is used to define the href field for all
|
|
96
|
+
responses from the Gallagher API.
|
|
97
|
+
"""
|
|
98
|
+
href: str
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
These `Mixin` classes can also be used to declare attributes that seek to use the same pattern:
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
class DivisionDetail(
|
|
105
|
+
AppBaseModel,
|
|
106
|
+
IdentityMixin,
|
|
107
|
+
):
|
|
108
|
+
"""
|
|
109
|
+
"""
|
|
110
|
+
|
|
111
|
+
name: str
|
|
112
|
+
description: Optional[str]
|
|
113
|
+
server_display_name: str
|
|
114
|
+
parent: Optional[HrefMixin]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
where `parent` is simply an `href` without any other attributes. In the cases where these attributes have more than just an `href` we defined `Reference` classes:
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
class AccessGroupRef(
|
|
121
|
+
AppBaseModel,
|
|
122
|
+
HrefMixin
|
|
123
|
+
):
|
|
124
|
+
""" Access Groups is what a user is assigned to to provide access to doors
|
|
125
|
+
"""
|
|
126
|
+
name: str
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
and use them to populate the attributes:
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
class VisitorTypeDetail(
|
|
133
|
+
AppBaseModel,
|
|
134
|
+
IdentityMixin
|
|
135
|
+
):
|
|
136
|
+
"""
|
|
137
|
+
"""
|
|
138
|
+
access_group : AccessGroupRef
|
|
139
|
+
host_access_groups: list[AccessGroupSummary]
|
|
140
|
+
visitor_access_groups: list[AccessGroupSummary]
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
In this example the `AppGroupRef` has a `name` attribute which is not present in the `HrefMixin` class.
|
|
144
|
+
|
|
145
|
+
> Please see the schema section for naming conventions for `schema` classes
|
|
146
|
+
|
|
147
|
+
## Design
|
|
148
|
+
|
|
149
|
+
This API client primarily depends on the following libraries:
|
|
150
|
+
|
|
151
|
+
- [httpx](https://www.python-httpx.org), fo transporting and parsing HTTP requests
|
|
152
|
+
- [pydantic](https://pydantic.dev), for validating responses and constructing request bodies
|
|
153
|
+
|
|
154
|
+
We use [Taskfile](https://taskfile.dev) to automate running tasks.
|
|
155
|
+
|
|
156
|
+
The project provides a comprehensive set of tests which can be run with `task test`. These tests do create objects in the Command Centre, we advice you to obtain a test license.
|
|
157
|
+
|
|
158
|
+
**DO NOT** run the tests against a production system.
|
|
159
|
+
|
|
160
|
+
### Data Transfer Objects
|
|
161
|
+
|
|
162
|
+
There are three types of schema definitions, each one of them suffixed with their intent:
|
|
163
|
+
|
|
164
|
+
- **Ref** are `References` to other objects, they using contain a `href` and possibly additional meta data such as a `name` or `id`
|
|
165
|
+
- **Summary** is what is returned by the Gallagher API in operations such as [searches](https://gallaghersecurity.github.io/cc-rest-docs/ref/cardholders.html), these are generally a subset of the full object
|
|
166
|
+
- **Detail** are the full object found at a particular `href`, they compound on the `Summary` schema and add additional attributes
|
|
167
|
+
|
|
168
|
+
In summary:
|
|
169
|
+
|
|
170
|
+
- `Refs` are the minimal pathway to an object
|
|
171
|
+
- `Summary` builds on a `Ref` and provides a subset of the attributes
|
|
172
|
+
- `Detail` builds on a `Summary` and provides the full set of attributes
|
|
173
|
+
|
|
174
|
+
### Resources
|
|
175
|
+
|
|
176
|
+
Resources are `fetchable`, `queryable`, `creatable`, `updatable` and `deletable`.
|
|
177
|
+
|
|
178
|
+
### Responses
|
|
179
|
+
|
|
180
|
+
Responses can be the object itself or a response layout
|
|
181
|
+
|
|
182
|
+
# Configuring the Command Centre
|
|
183
|
+
|
|
184
|
+
The following requires you to have an understanding of the Gallagher Command Centre and how to configure it. If you are unsure, please contact your Gallagher representative.
|
|
185
|
+
|
|
186
|
+
Before you being, please ensure:
|
|
187
|
+
|
|
188
|
+
- You are running Command Centre version `8.60` or higher, older versions predate the gateway so cannot support it
|
|
189
|
+
- The gateway enabled at the system level
|
|
190
|
+
- If it is, has the gateway been enabled for your specific API key
|
|
191
|
+
|
|
192
|
+
To check the system level gateway status:
|
|
193
|
+
|
|
194
|
+
- Open the Command Centre Configuration Client
|
|
195
|
+
- From the `Configure` menu, select `Services and Workstations`
|
|
196
|
+
- Find the `Command Centre Cloud` item and double-click it
|
|
197
|
+
- Switch to the `Configuration` page, it should look something like this:
|
|
198
|
+
|
|
199
|
+

|
|
200
|
+
|
|
201
|
+
To check your API key:
|
|
202
|
+
|
|
203
|
+
- Open the Command Centre Configuration Client
|
|
204
|
+
- From the `Configure` menu, select `Services and Workstations`
|
|
205
|
+
- Find the item that represents your REST Client
|
|
206
|
+
- Switch to the `Connections` page, it should look something like this
|
|
207
|
+
|
|
208
|
+

|
|
209
|
+
|
|
210
|
+
# License
|
|
211
|
+
|
|
212
|
+
Distributed under the MIT License.
|
|
213
|
+
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
> Currently under heavy development, please check for stable release before use
|
|
2
|
+
|
|
3
|
+
# Gallagher Command Centre REST API Client
|
|
4
|
+
|
|
5
|
+
> Python idiomatic client for Gallagher Command Centre API
|
|
6
|
+
|
|
7
|
+
Gallagher Security manufacture a variety of [security products](https://security.gallagher.com) all of which are controlled by their [Command Centre](https://products.security.gallagher.com/security/au/en_AU/products/software/command-centre/p/C201311) software. Traditionally Command Centre has been a Windows based server product. Version `8.6` introduced a REST API which allows you to interact with the system via HTTP requests. Gallagher also provide a [Cloud API Gateway](https://gallaghersecurity.github.io/docs/Command%20Centre%20Cloud%20Api%20Gateway%20TIP.pdf) which allows third party integrations to securely communicate with the Command Centre on site.
|
|
8
|
+
|
|
9
|
+
This API client is a Python wrapper around their REST API and is designed to work locally or via the Cloud API Gateway.
|
|
10
|
+
|
|
11
|
+
While Gallagher maintain a set of [Swagger definitions](https://github.com/gallaghersecurity/cc-rest-docs) for their API, they are primarily intended to generate the documentation [published on Github](https://gallaghersecurity.github.io/cc-rest-docs/ref/index.html). They use a tool called [Spectacle](https://github.com/sourcey/spectacle). Gallagher explicitly state that the Swagger definitions are not intended to be used to generate code. Due to this the API client is hand built and not auto-generated.
|
|
12
|
+
|
|
13
|
+
> Due to custom annotations the YAML files will not parse with any standard parser.
|
|
14
|
+
|
|
15
|
+
The client was designed while building products around the Gallagher API. It's design is highly opinionated and does not conform with how Gallagher design software interfaces. If you've worked with [stripe-python](https://github.com/stripe/stripe-python) the syntax may feel familiar.
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from gallagher import cc, const
|
|
19
|
+
|
|
20
|
+
cc.api_key = "GH_"
|
|
21
|
+
|
|
22
|
+
cc.discover()
|
|
23
|
+
cc.Customer.create()
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
> Note this project is **NOT** officially affiliated with Gallagher Security
|
|
27
|
+
|
|
28
|
+
## API Notes
|
|
29
|
+
|
|
30
|
+
The Gallagher API uses `href` attributes to provide a the destination of referenced objects in the responses. These are prefixed with the server origin i.e if you are using the Cloud Gateway then all your URLs will be prefixed with the appropriate gateway's address.
|
|
31
|
+
|
|
32
|
+
These appear in various forms, starting from as simple as the `href` itself:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
"cardholders": {
|
|
36
|
+
"href": "https://localhost:8904/api/access_groups/352/cardholders"
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
through to self recursive references with additional attributes:
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
"parent": {
|
|
44
|
+
"href": "https://localhost:8904/api/access_groups/100",
|
|
45
|
+
"name": "All R&D"
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
> Above examples have been taken from the Gallagher documentation
|
|
50
|
+
|
|
51
|
+
Our `schemas` provide a set of `Mixins` that are used to construct the Models. These are repeatable patterns that need not be repeated. The typical patter would be to subclass from the `Mixins` e.g:
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from .utils import AppBaseModel, IdentityMixin, HrefMixin
|
|
55
|
+
|
|
56
|
+
class AccessGroupRef(
|
|
57
|
+
AppBaseModel,
|
|
58
|
+
HrefMixin
|
|
59
|
+
):
|
|
60
|
+
""" Access Groups is what a user is assigned to to provide access to doors
|
|
61
|
+
"""
|
|
62
|
+
name: str
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
where the `HrefMixin` provides the `href` attribute:
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
class HrefMixin(BaseModel):
|
|
69
|
+
""" Href
|
|
70
|
+
|
|
71
|
+
This mixin is used to define the href field for all
|
|
72
|
+
responses from the Gallagher API.
|
|
73
|
+
"""
|
|
74
|
+
href: str
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
These `Mixin` classes can also be used to declare attributes that seek to use the same pattern:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
class DivisionDetail(
|
|
81
|
+
AppBaseModel,
|
|
82
|
+
IdentityMixin,
|
|
83
|
+
):
|
|
84
|
+
"""
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
name: str
|
|
88
|
+
description: Optional[str]
|
|
89
|
+
server_display_name: str
|
|
90
|
+
parent: Optional[HrefMixin]
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
where `parent` is simply an `href` without any other attributes. In the cases where these attributes have more than just an `href` we defined `Reference` classes:
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
class AccessGroupRef(
|
|
97
|
+
AppBaseModel,
|
|
98
|
+
HrefMixin
|
|
99
|
+
):
|
|
100
|
+
""" Access Groups is what a user is assigned to to provide access to doors
|
|
101
|
+
"""
|
|
102
|
+
name: str
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
and use them to populate the attributes:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
class VisitorTypeDetail(
|
|
109
|
+
AppBaseModel,
|
|
110
|
+
IdentityMixin
|
|
111
|
+
):
|
|
112
|
+
"""
|
|
113
|
+
"""
|
|
114
|
+
access_group : AccessGroupRef
|
|
115
|
+
host_access_groups: list[AccessGroupSummary]
|
|
116
|
+
visitor_access_groups: list[AccessGroupSummary]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
In this example the `AppGroupRef` has a `name` attribute which is not present in the `HrefMixin` class.
|
|
120
|
+
|
|
121
|
+
> Please see the schema section for naming conventions for `schema` classes
|
|
122
|
+
|
|
123
|
+
## Design
|
|
124
|
+
|
|
125
|
+
This API client primarily depends on the following libraries:
|
|
126
|
+
|
|
127
|
+
- [httpx](https://www.python-httpx.org), fo transporting and parsing HTTP requests
|
|
128
|
+
- [pydantic](https://pydantic.dev), for validating responses and constructing request bodies
|
|
129
|
+
|
|
130
|
+
We use [Taskfile](https://taskfile.dev) to automate running tasks.
|
|
131
|
+
|
|
132
|
+
The project provides a comprehensive set of tests which can be run with `task test`. These tests do create objects in the Command Centre, we advice you to obtain a test license.
|
|
133
|
+
|
|
134
|
+
**DO NOT** run the tests against a production system.
|
|
135
|
+
|
|
136
|
+
### Data Transfer Objects
|
|
137
|
+
|
|
138
|
+
There are three types of schema definitions, each one of them suffixed with their intent:
|
|
139
|
+
|
|
140
|
+
- **Ref** are `References` to other objects, they using contain a `href` and possibly additional meta data such as a `name` or `id`
|
|
141
|
+
- **Summary** is what is returned by the Gallagher API in operations such as [searches](https://gallaghersecurity.github.io/cc-rest-docs/ref/cardholders.html), these are generally a subset of the full object
|
|
142
|
+
- **Detail** are the full object found at a particular `href`, they compound on the `Summary` schema and add additional attributes
|
|
143
|
+
|
|
144
|
+
In summary:
|
|
145
|
+
|
|
146
|
+
- `Refs` are the minimal pathway to an object
|
|
147
|
+
- `Summary` builds on a `Ref` and provides a subset of the attributes
|
|
148
|
+
- `Detail` builds on a `Summary` and provides the full set of attributes
|
|
149
|
+
|
|
150
|
+
### Resources
|
|
151
|
+
|
|
152
|
+
Resources are `fetchable`, `queryable`, `creatable`, `updatable` and `deletable`.
|
|
153
|
+
|
|
154
|
+
### Responses
|
|
155
|
+
|
|
156
|
+
Responses can be the object itself or a response layout
|
|
157
|
+
|
|
158
|
+
# Configuring the Command Centre
|
|
159
|
+
|
|
160
|
+
The following requires you to have an understanding of the Gallagher Command Centre and how to configure it. If you are unsure, please contact your Gallagher representative.
|
|
161
|
+
|
|
162
|
+
Before you being, please ensure:
|
|
163
|
+
|
|
164
|
+
- You are running Command Centre version `8.60` or higher, older versions predate the gateway so cannot support it
|
|
165
|
+
- The gateway enabled at the system level
|
|
166
|
+
- If it is, has the gateway been enabled for your specific API key
|
|
167
|
+
|
|
168
|
+
To check the system level gateway status:
|
|
169
|
+
|
|
170
|
+
- Open the Command Centre Configuration Client
|
|
171
|
+
- From the `Configure` menu, select `Services and Workstations`
|
|
172
|
+
- Find the `Command Centre Cloud` item and double-click it
|
|
173
|
+
- Switch to the `Configuration` page, it should look something like this:
|
|
174
|
+
|
|
175
|
+

|
|
176
|
+
|
|
177
|
+
To check your API key:
|
|
178
|
+
|
|
179
|
+
- Open the Command Centre Configuration Client
|
|
180
|
+
- From the `Configure` menu, select `Services and Workstations`
|
|
181
|
+
- Find the item that represents your REST Client
|
|
182
|
+
- Switch to the `Connections` page, it should look something like this
|
|
183
|
+
|
|
184
|
+

|
|
185
|
+
|
|
186
|
+
# License
|
|
187
|
+
|
|
188
|
+
Distributed under the MIT License.
|
|
@@ -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
|
+
)
|