-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpolicy.py
More file actions
62 lines (53 loc) · 2.02 KB
/
Copy pathpolicy.py
File metadata and controls
62 lines (53 loc) · 2.02 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
"""
--------------------------------------------------------------------------------
------------------------- Mist API Python CLI Session --------------------------
Written by: Thomas Munzer (tmunzer@juniper.net)
Github : https://github.com/tmunzer/mistapi_python
This package is licensed under the MIT License.
--------------------------------------------------------------------------------
"""
from mistapi import APISession as _APISession
from mistapi.__logger import logger as LOGGER
from mistapi.api.v1.sites import devices
from mistapi.device_utils.__tools.__ws_wrapper import UtilResponse
def clear_hit_count(
apissession: _APISession,
site_id: str,
device_id: str,
policy_name: str,
) -> UtilResponse:
"""
DEVICE: EX
Clears the policy hit count on a device.
PARAMS
-----------
apissession : _APISession
The API session to use for the request.
site_id : str
UUID of the site where the device is located.
device_id : str
UUID of the device to clear the policy hit count on.
policy_name : str
Name of the policy to clear the hit count for.
RETURNS
-----------
UtilResponse
A UtilResponse object containing the API response and a list of raw messages received from the WebSocket stream.
"""
trigger = devices.clearSiteDevicePolicyHitCount(
apissession,
site_id=site_id,
device_id=device_id,
body={"policy_name": policy_name},
)
util_response = UtilResponse(trigger)
if trigger.status_code == 200:
LOGGER.info(f"Clear policy hit count command triggered for device {device_id}")
# util_response = await WebSocketWrapper(
# apissession, util_response, timeout=timeout
# ).startCmdEvents(site_id, device_id)
else:
LOGGER.error(
f"Failed to trigger clear policy hit count command: {trigger.status_code} - {trigger.data}"
) # Give the clear policy hit count command a moment to take effect
return util_response