forked from meraki/dashboard-api-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsensor.py
More file actions
167 lines (115 loc) · 5.37 KB
/
Copy pathsensor.py
File metadata and controls
167 lines (115 loc) · 5.37 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
import urllib
class ActionBatchSensor(object):
def __init__(self):
super(ActionBatchSensor, self).__init__()
def updateDeviceSensorRelationships(self, serial: str, **kwargs):
"""
**Assign one or more sensor roles to a given sensor or camera device.**
https://developer.cisco.com/meraki/api-v1/#!update-device-sensor-relationships
- serial (string): Serial
- livestream (object): A role defined between an MT sensor and an MV camera that adds the camera's livestream to the sensor's details page. Snapshots from the camera will also appear in alert notifications that the sensor triggers.
"""
kwargs.update(locals())
metadata = {
'tags': ['sensor', 'configure', 'relationships'],
'operation': 'updateDeviceSensorRelationships'
}
resource = f'/devices/{serial}/sensor/relationships'
body_params = ['livestream', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
action = {
"resource": resource,
"operation": "update",
"body": payload
}
return action
def createNetworkSensorAlertsProfile(self, networkId: str, name: str, conditions: list, **kwargs):
"""
**Creates a sensor alert profile for a network.**
https://developer.cisco.com/meraki/api-v1/#!create-network-sensor-alerts-profile
- networkId (string): Network ID
- name (string): Name of the sensor alert profile.
- conditions (array): List of conditions that will cause the profile to send an alert.
- schedule (object): The sensor schedule to use with the alert profile.
- recipients (object): List of recipients that will recieve the alert.
- serials (array): List of device serials assigned to this sensor alert profile.
"""
kwargs.update(locals())
metadata = {
'tags': ['sensor', 'configure', 'alerts', 'profiles'],
'operation': 'createNetworkSensorAlertsProfile'
}
resource = f'/networks/{networkId}/sensor/alerts/profiles'
body_params = ['name', 'schedule', 'conditions', 'recipients', 'serials', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
action = {
"resource": resource,
"operation": "create",
"body": payload
}
return action
def updateNetworkSensorAlertsProfile(self, networkId: str, id: str, **kwargs):
"""
**Updates a sensor alert profile for a network.**
https://developer.cisco.com/meraki/api-v1/#!update-network-sensor-alerts-profile
- networkId (string): Network ID
- id (string): Id
- name (string): Name of the sensor alert profile.
- schedule (object): The sensor schedule to use with the alert profile.
- conditions (array): List of conditions that will cause the profile to send an alert.
- recipients (object): List of recipients that will recieve the alert.
- serials (array): List of device serials assigned to this sensor alert profile.
"""
kwargs.update(locals())
metadata = {
'tags': ['sensor', 'configure', 'alerts', 'profiles'],
'operation': 'updateNetworkSensorAlertsProfile'
}
resource = f'/networks/{networkId}/sensor/alerts/profiles/{id}'
body_params = ['name', 'schedule', 'conditions', 'recipients', 'serials', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
action = {
"resource": resource,
"operation": "update",
"body": payload
}
return action
def deleteNetworkSensorAlertsProfile(self, networkId: str, id: str):
"""
**Deletes a sensor alert profile from a network.**
https://developer.cisco.com/meraki/api-v1/#!delete-network-sensor-alerts-profile
- networkId (string): Network ID
- id (string): Id
"""
metadata = {
'tags': ['sensor', 'configure', 'alerts', 'profiles'],
'operation': 'deleteNetworkSensorAlertsProfile'
}
resource = f'/networks/{networkId}/sensor/alerts/profiles/{id}'
action = {
"resource": resource,
"operation": "destroy",
}
return action
def updateNetworkSensorMqttBroker(self, networkId: str, mqttBrokerId: str, enabled: bool):
"""
**Update the sensor settings of an MQTT broker**
https://developer.cisco.com/meraki/api-v1/#!update-network-sensor-mqtt-broker
- networkId (string): Network ID
- mqttBrokerId (string): Mqtt broker ID
- enabled (boolean): Set to true to enable MQTT broker for sensor network
"""
kwargs = locals()
metadata = {
'tags': ['sensor', 'configure', 'mqttBrokers'],
'operation': 'updateNetworkSensorMqttBroker'
}
resource = f'/networks/{networkId}/sensor/mqttBrokers/{mqttBrokerId}'
body_params = ['enabled', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
action = {
"resource": resource,
"operation": "update",
"body": payload
}
return action