forked from meraki/dashboard-api-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera.py
More file actions
442 lines (338 loc) · 21.6 KB
/
Copy pathcamera.py
File metadata and controls
442 lines (338 loc) · 21.6 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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
class Camera(object):
def __init__(self, session):
super(Camera, self).__init__()
self._session = session
def getDeviceCameraAnalyticsLive(self, serial: str):
"""
**Returns live state from camera of analytics zones**
https://developer.cisco.com/meraki/api-v1/#!get-device-camera-analytics-live
- serial (string): (required)
"""
metadata = {
'tags': ['camera', 'monitor', 'analytics', 'live'],
'operation': 'getDeviceCameraAnalyticsLive'
}
resource = f'/devices/{serial}/camera/analytics/live'
return self._session.get(metadata, resource)
def getDeviceCameraAnalyticsOverview(self, serial: str, **kwargs):
"""
**Returns an overview of aggregate analytics data for a timespan**
https://developer.cisco.com/meraki/api-v1/#!get-device-camera-analytics-overview
- serial (string): (required)
- t0 (string): The beginning of the timespan for the data. The maximum lookback period is 365 days from today.
- t1 (string): The end of the timespan for the data. t1 can be a maximum of 7 days after t0.
- timespan (number): The timespan for which the information will be fetched. If specifying timespan, do not specify parameters t0 and t1. The value must be in seconds and be less than or equal to 7 days. The default is 1 hour.
- objectType (string): [optional] The object type for which analytics will be retrieved. The default object type is person. The available types are [person, vehicle].
"""
kwargs.update(locals())
if 'objectType' in kwargs:
options = ['person', 'vehicle']
assert kwargs['objectType'] in options, f'''"objectType" cannot be "{kwargs['objectType']}", & must be set to one of: {options}'''
metadata = {
'tags': ['camera', 'monitor', 'analytics', 'overview'],
'operation': 'getDeviceCameraAnalyticsOverview'
}
resource = f'/devices/{serial}/camera/analytics/overview'
query_params = ['t0', 't1', 'timespan', 'objectType', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
return self._session.get(metadata, resource, params)
def getDeviceCameraAnalyticsRecent(self, serial: str, **kwargs):
"""
**Returns most recent record for analytics zones**
https://developer.cisco.com/meraki/api-v1/#!get-device-camera-analytics-recent
- serial (string): (required)
- objectType (string): [optional] The object type for which analytics will be retrieved. The default object type is person. The available types are [person, vehicle].
"""
kwargs.update(locals())
if 'objectType' in kwargs:
options = ['person', 'vehicle']
assert kwargs['objectType'] in options, f'''"objectType" cannot be "{kwargs['objectType']}", & must be set to one of: {options}'''
metadata = {
'tags': ['camera', 'monitor', 'analytics', 'recent'],
'operation': 'getDeviceCameraAnalyticsRecent'
}
resource = f'/devices/{serial}/camera/analytics/recent'
query_params = ['objectType', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
return self._session.get(metadata, resource, params)
def getDeviceCameraAnalyticsZones(self, serial: str):
"""
**Returns all configured analytic zones for this camera**
https://developer.cisco.com/meraki/api-v1/#!get-device-camera-analytics-zones
- serial (string): (required)
"""
metadata = {
'tags': ['camera', 'monitor', 'analytics', 'zones'],
'operation': 'getDeviceCameraAnalyticsZones'
}
resource = f'/devices/{serial}/camera/analytics/zones'
return self._session.get(metadata, resource)
def getDeviceCameraAnalyticsZoneHistory(self, serial: str, zoneId: str, **kwargs):
"""
**Return historical records for analytic zones**
https://developer.cisco.com/meraki/api-v1/#!get-device-camera-analytics-zone-history
- serial (string): (required)
- zoneId (string): (required)
- t0 (string): The beginning of the timespan for the data. The maximum lookback period is 365 days from today.
- t1 (string): The end of the timespan for the data. t1 can be a maximum of 14 hours after t0.
- timespan (number): The timespan for which the information will be fetched. If specifying timespan, do not specify parameters t0 and t1. The value must be in seconds and be less than or equal to 14 hours. The default is 1 hour.
- resolution (integer): The time resolution in seconds for returned data. The valid resolutions are: 60. The default is 60.
- objectType (string): [optional] The object type for which analytics will be retrieved. The default object type is person. The available types are [person, vehicle].
"""
kwargs.update(locals())
if 'objectType' in kwargs:
options = ['person', 'vehicle']
assert kwargs['objectType'] in options, f'''"objectType" cannot be "{kwargs['objectType']}", & must be set to one of: {options}'''
metadata = {
'tags': ['camera', 'monitor', 'analytics', 'zones', 'history'],
'operation': 'getDeviceCameraAnalyticsZoneHistory'
}
resource = f'/devices/{serial}/camera/analytics/zones/{zoneId}/history'
query_params = ['t0', 't1', 'timespan', 'resolution', 'objectType', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
return self._session.get(metadata, resource, params)
def generateDeviceCameraSnapshot(self, serial: str, **kwargs):
"""
**Generate a snapshot of what the camera sees at the specified time and return a link to that image.**
https://developer.cisco.com/meraki/api-v1/#!generate-device-camera-snapshot
- serial (string): (required)
- timestamp (string): [optional] The snapshot will be taken from this time on the camera. The timestamp is expected to be in ISO 8601 format. If no timestamp is specified, we will assume current time.
- fullframe (boolean): [optional] If set to "true" the snapshot will be taken at full sensor resolution. This will error if used with timestamp.
"""
kwargs.update(locals())
metadata = {
'tags': ['camera', 'monitor'],
'operation': 'generateDeviceCameraSnapshot'
}
resource = f'/devices/{serial}/camera/generateSnapshot'
body_params = ['timestamp', 'fullframe', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getDeviceCameraQualityAndRetention(self, serial: str):
"""
**Returns quality and retention settings for the given camera**
https://developer.cisco.com/meraki/api-v1/#!get-device-camera-quality-and-retention
- serial (string): (required)
"""
metadata = {
'tags': ['camera', 'configure', 'qualityAndRetention'],
'operation': 'getDeviceCameraQualityAndRetention'
}
resource = f'/devices/{serial}/camera/qualityAndRetention'
return self._session.get(metadata, resource)
def updateDeviceCameraQualityAndRetention(self, serial: str, **kwargs):
"""
**Update quality and retention settings for the given camera**
https://developer.cisco.com/meraki/api-v1/#!update-device-camera-quality-and-retention
- serial (string): (required)
- profileId (string): The ID of a quality and retention profile to assign to the camera. The profile's settings will override all of the per-camera quality and retention settings. If the value of this parameter is null, any existing profile will be unassigned from the camera.
- motionBasedRetentionEnabled (boolean): Boolean indicating if motion-based retention is enabled(true) or disabled(false) on the camera
- audioRecordingEnabled (boolean): Boolean indicating if audio recording is enabled(true) or disabled(false) on the camera
- restrictedBandwidthModeEnabled (boolean): Boolean indicating if restricted bandwidth is enabled(true) or disabled(false) on the camera
- quality (string): Quality of the camera. Can be one of 'Standard', 'High' or 'Enhanced'. Not all qualities are supported by every camera model.
- resolution (string): Resolution of the camera. Can be one of '1280x720', '1920x1080', '1080x1080' or '2058x2058'. Not all resolutions are supported by every camera model.
- motionDetectorVersion (integer): The version of the motion detector that will be used by the camera. Only applies to Gen 2 cameras. Defaults to v2.
"""
kwargs.update(locals())
if 'quality' in kwargs:
options = ['Standard', 'High', 'Enhanced']
assert kwargs['quality'] in options, f'''"quality" cannot be "{kwargs['quality']}", & must be set to one of: {options}'''
if 'resolution' in kwargs:
options = ['1280x720', '1920x1080', '1080x1080', '2058x2058']
assert kwargs['resolution'] in options, f'''"resolution" cannot be "{kwargs['resolution']}", & must be set to one of: {options}'''
if 'motionDetectorVersion' in kwargs:
options = [1, 2]
assert kwargs['motionDetectorVersion'] in options, f'''"motionDetectorVersion" cannot be "{kwargs['motionDetectorVersion']}", & must be set to one of: {options}'''
metadata = {
'tags': ['camera', 'configure', 'qualityAndRetention'],
'operation': 'updateDeviceCameraQualityAndRetention'
}
resource = f'/devices/{serial}/camera/qualityAndRetention'
body_params = ['profileId', 'motionBasedRetentionEnabled', 'audioRecordingEnabled', 'restrictedBandwidthModeEnabled', 'quality', 'resolution', 'motionDetectorVersion', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def getDeviceCameraSense(self, serial: str):
"""
**Returns sense settings for a given camera**
https://developer.cisco.com/meraki/api-v1/#!get-device-camera-sense
- serial (string): (required)
"""
metadata = {
'tags': ['camera', 'configure', 'sense'],
'operation': 'getDeviceCameraSense'
}
resource = f'/devices/{serial}/camera/sense'
return self._session.get(metadata, resource)
def updateDeviceCameraSense(self, serial: str, **kwargs):
"""
**Update sense settings for the given camera**
https://developer.cisco.com/meraki/api-v1/#!update-device-camera-sense
- serial (string): (required)
- senseEnabled (boolean): Boolean indicating if sense(license) is enabled(true) or disabled(false) on the camera
- mqttBrokerId (string): The ID of the MQTT broker to be enabled on the camera. A value of null will disable MQTT on the camera
- detectionModelId (string): The ID of the object detection model
"""
kwargs.update(locals())
metadata = {
'tags': ['camera', 'configure', 'sense'],
'operation': 'updateDeviceCameraSense'
}
resource = f'/devices/{serial}/camera/sense'
body_params = ['senseEnabled', 'mqttBrokerId', 'detectionModelId', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def getDeviceCameraSenseObjectDetectionModels(self, serial: str):
"""
**Returns the MV Sense object detection model list for the given camera**
https://developer.cisco.com/meraki/api-v1/#!get-device-camera-sense-object-detection-models
- serial (string): (required)
"""
metadata = {
'tags': ['camera', 'configure', 'sense', 'objectDetectionModels'],
'operation': 'getDeviceCameraSenseObjectDetectionModels'
}
resource = f'/devices/{serial}/camera/sense/objectDetectionModels'
return self._session.get(metadata, resource)
def getDeviceCameraVideoSettings(self, serial: str):
"""
**Returns video settings for the given camera**
https://developer.cisco.com/meraki/api-v1/#!get-device-camera-video-settings
- serial (string): (required)
"""
metadata = {
'tags': ['camera', 'configure', 'video', 'settings'],
'operation': 'getDeviceCameraVideoSettings'
}
resource = f'/devices/{serial}/camera/video/settings'
return self._session.get(metadata, resource)
def updateDeviceCameraVideoSettings(self, serial: str, **kwargs):
"""
**Update video settings for the given camera**
https://developer.cisco.com/meraki/api-v1/#!update-device-camera-video-settings
- serial (string): (required)
- externalRtspEnabled (boolean): Boolean indicating if external rtsp stream is exposed
"""
kwargs.update(locals())
metadata = {
'tags': ['camera', 'configure', 'video', 'settings'],
'operation': 'updateDeviceCameraVideoSettings'
}
resource = f'/devices/{serial}/camera/video/settings'
body_params = ['externalRtspEnabled', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def getDeviceCameraVideoLink(self, serial: str, **kwargs):
"""
**Returns video link to the specified camera**
https://developer.cisco.com/meraki/api-v1/#!get-device-camera-video-link
- serial (string): (required)
- timestamp (string): [optional] The video link will start at this time. The timestamp should be a string in ISO8601 format. If no timestamp is specified, we will assume current time.
"""
kwargs.update(locals())
metadata = {
'tags': ['camera', 'configure', 'videoLink'],
'operation': 'getDeviceCameraVideoLink'
}
resource = f'/devices/{serial}/camera/videoLink'
query_params = ['timestamp', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
return self._session.get(metadata, resource, params)
def getNetworkCameraQualityRetentionProfiles(self, networkId: str):
"""
**List the quality retention profiles for this network**
https://developer.cisco.com/meraki/api-v1/#!get-network-camera-quality-retention-profiles
- networkId (string): (required)
"""
metadata = {
'tags': ['camera', 'configure', 'qualityRetentionProfiles'],
'operation': 'getNetworkCameraQualityRetentionProfiles'
}
resource = f'/networks/{networkId}/camera/qualityRetentionProfiles'
return self._session.get(metadata, resource)
def createNetworkCameraQualityRetentionProfile(self, networkId: str, name: str, **kwargs):
"""
**Creates new quality retention profile for this network.**
https://developer.cisco.com/meraki/api-v1/#!create-network-camera-quality-retention-profile
- networkId (string): (required)
- name (string): The name of the new profile. Must be unique. This parameter is required.
- motionBasedRetentionEnabled (boolean): Deletes footage older than 3 days in which no motion was detected. Can be either true or false. Defaults to false.
- restrictedBandwidthModeEnabled (boolean): Disable features that require additional bandwidth such as Motion Recap. Can be either true or false. Defaults to false.
- audioRecordingEnabled (boolean): Whether or not to record audio. Can be either true or false. Defaults to false.
- cloudArchiveEnabled (boolean): Create redundant video backup using Cloud Archive. Can be either true or false. Defaults to false.
- motionDetectorVersion (integer): The version of the motion detector that will be used by the camera. Only applies to Gen 2 cameras. Defaults to v2.
- scheduleId (string): Schedule for which this camera will record video, or 'null' to always record.
- maxRetentionDays (integer): The maximum number of days for which the data will be stored, or 'null' to keep data until storage space runs out. If the former, it can be one of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 30, 60, 90] days
- videoSettings (object): Video quality and resolution settings for all the camera models.
"""
kwargs.update(locals())
metadata = {
'tags': ['camera', 'configure', 'qualityRetentionProfiles'],
'operation': 'createNetworkCameraQualityRetentionProfile'
}
resource = f'/networks/{networkId}/camera/qualityRetentionProfiles'
body_params = ['name', 'motionBasedRetentionEnabled', 'restrictedBandwidthModeEnabled', 'audioRecordingEnabled', 'cloudArchiveEnabled', 'motionDetectorVersion', 'scheduleId', 'maxRetentionDays', 'videoSettings', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getNetworkCameraQualityRetentionProfile(self, networkId: str, qualityRetentionProfileId: str):
"""
**Retrieve a single quality retention profile**
https://developer.cisco.com/meraki/api-v1/#!get-network-camera-quality-retention-profile
- networkId (string): (required)
- qualityRetentionProfileId (string): (required)
"""
metadata = {
'tags': ['camera', 'configure', 'qualityRetentionProfiles'],
'operation': 'getNetworkCameraQualityRetentionProfile'
}
resource = f'/networks/{networkId}/camera/qualityRetentionProfiles/{qualityRetentionProfileId}'
return self._session.get(metadata, resource)
def updateNetworkCameraQualityRetentionProfile(self, networkId: str, qualityRetentionProfileId: str, **kwargs):
"""
**Update an existing quality retention profile for this network.**
https://developer.cisco.com/meraki/api-v1/#!update-network-camera-quality-retention-profile
- networkId (string): (required)
- qualityRetentionProfileId (string): (required)
- name (string): The name of the new profile. Must be unique.
- motionBasedRetentionEnabled (boolean): Deletes footage older than 3 days in which no motion was detected. Can be either true or false. Defaults to false.
- restrictedBandwidthModeEnabled (boolean): Disable features that require additional bandwidth such as Motion Recap. Can be either true or false. Defaults to false.
- audioRecordingEnabled (boolean): Whether or not to record audio. Can be either true or false. Defaults to false.
- cloudArchiveEnabled (boolean): Create redundant video backup using Cloud Archive. Can be either true or false. Defaults to false.
- motionDetectorVersion (integer): The version of the motion detector that will be used by the camera. Only applies to Gen 2 cameras. Defaults to v2.
- scheduleId (string): Schedule for which this camera will record video, or 'null' to always record.
- maxRetentionDays (integer): The maximum number of days for which the data will be stored, or 'null' to keep data until storage space runs out. If the former, it can be one of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 30, 60, 90] days
- videoSettings (object): Video quality and resolution settings for all the camera models.
"""
kwargs.update(locals())
metadata = {
'tags': ['camera', 'configure', 'qualityRetentionProfiles'],
'operation': 'updateNetworkCameraQualityRetentionProfile'
}
resource = f'/networks/{networkId}/camera/qualityRetentionProfiles/{qualityRetentionProfileId}'
body_params = ['name', 'motionBasedRetentionEnabled', 'restrictedBandwidthModeEnabled', 'audioRecordingEnabled', 'cloudArchiveEnabled', 'motionDetectorVersion', 'scheduleId', 'maxRetentionDays', 'videoSettings', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def deleteNetworkCameraQualityRetentionProfile(self, networkId: str, qualityRetentionProfileId: str):
"""
**Delete an existing quality retention profile for this network.**
https://developer.cisco.com/meraki/api-v1/#!delete-network-camera-quality-retention-profile
- networkId (string): (required)
- qualityRetentionProfileId (string): (required)
"""
metadata = {
'tags': ['camera', 'configure', 'qualityRetentionProfiles'],
'operation': 'deleteNetworkCameraQualityRetentionProfile'
}
resource = f'/networks/{networkId}/camera/qualityRetentionProfiles/{qualityRetentionProfileId}'
return self._session.delete(metadata, resource)
def getNetworkCameraSchedules(self, networkId: str):
"""
**Returns a list of all camera recording schedules.**
https://developer.cisco.com/meraki/api-v1/#!get-network-camera-schedules
- networkId (string): (required)
"""
metadata = {
'tags': ['camera', 'configure', 'schedules'],
'operation': 'getNetworkCameraSchedules'
}
resource = f'/networks/{networkId}/camera/schedules'
return self._session.get(metadata, resource)