Skip to content

Commit 9e6d0c0

Browse files
committed
feat(devices): add new APIs for searching site device flow records and managing Zigbee events
1 parent d9b03b2 commit 9e6d0c0

2 files changed

Lines changed: 214 additions & 2 deletions

File tree

‎src/mistapi/api/v1/orgs/devices.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ def countOrgDeviceEvents(
175175
model: str | None = None,
176176
text: str | None = None,
177177
type: str | None = None,
178+
includes: str | None = None,
178179
start: str | None = None,
179180
end: str | None = None,
180181
duration: str | None = None,
@@ -195,7 +196,7 @@ def countOrgDeviceEvents(
195196
QUERY PARAMS
196197
------------
197198
distinct : str{'ap', 'apfw', 'model', 'org_id', 'site_id', 'text', 'timestamp', 'type'}, default: model
198-
Field used to group this count response. enum: `ap`, `apfw`, `model`, `org_id`, `site_id`, `text`, `timestamp`, `type`
199+
Field used to group this count response. enum: `ap`, `apfw`, `model`, `org_id`, `site_id`, `status`, `text`, `timestamp`, `type`
199200
site_id : str
200201
Filter results by site identifier
201202
ap : str
@@ -208,6 +209,8 @@ def countOrgDeviceEvents(
208209
Filter results by event message text
209210
type : str
210211
See [List Device Events Definitions](/#operations/listDeviceEventsDefinitions)
212+
includes : str
213+
Keyword to include events from additional indices (e.g. ext_tunnel for ext tunnel events)
211214
start : str
212215
Lower bound of the time range, as an epoch timestamp in seconds or a relative value such as `-1d` or `-1w`
213216
end : str
@@ -239,6 +242,8 @@ def countOrgDeviceEvents(
239242
query_params["text"] = str(text)
240243
if type:
241244
query_params["type"] = str(type)
245+
if includes:
246+
query_params["includes"] = str(includes)
242247
if start:
243248
query_params["start"] = str(start)
244249
if end:
@@ -295,7 +300,7 @@ def searchOrgDeviceEvents(
295300
last_by : str
296301
Return last/recent event for passed in field
297302
includes : str
298-
Keyword to include events from additional indices (e.g. ext_tunnel for prisma events)
303+
Keyword to include events from additional indices (e.g. ext_tunnel for ext tunnel events)
299304
limit : int, default: 100
300305
Maximum number of results to return per page
301306
start : str

‎src/mistapi/api/v1/sites/devices.py‎

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,6 +1953,99 @@ def getSiteDeviceConfigCmd(
19531953
return resp
19541954

19551955

1956+
def searchSiteDeviceFlowRecords(
1957+
mist_session: _APISession,
1958+
site_id: str,
1959+
device_id: str,
1960+
start: str | None = None,
1961+
end: str | None = None,
1962+
limit: int | None = None,
1963+
sort: str | None = None,
1964+
src_ip: str | None = None,
1965+
dst_ip: str | None = None,
1966+
src_port: str | None = None,
1967+
dst_port: str | None = None,
1968+
protocol: str | None = None,
1969+
state: str | None = None,
1970+
direction: str | None = None,
1971+
search_after: str | None = None,
1972+
) -> _APIResponse:
1973+
"""
1974+
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/utilities/lan/search-site-device-flow-records
1975+
1976+
PARAMS
1977+
-----------
1978+
mistapi.APISession : mist_session
1979+
mistapi session including authentication and Mist host information
1980+
1981+
PATH PARAMS
1982+
-----------
1983+
site_id : str
1984+
device_id : str
1985+
1986+
QUERY PARAMS
1987+
------------
1988+
start : str
1989+
Lower bound of the time range, as an epoch timestamp in seconds or a relative value such as `-1d` or `-1w`
1990+
end : str
1991+
Upper bound of the time range, as an epoch timestamp in seconds or a relative value such as `-1d`, `-2h`, or `now`
1992+
limit : int, default: 100
1993+
Maximum number of results to return per page
1994+
sort : str, default: timestamp
1995+
On which field the list should be sorted, -prefix represents DESC order
1996+
src_ip : str
1997+
Source IP address
1998+
dst_ip : str
1999+
Destination IP address
2000+
src_port : str
2001+
Source port
2002+
dst_port : str
2003+
Destination port
2004+
protocol : str
2005+
Protocol (e.g. `tcp`, `udp`, `icmp`)
2006+
state : str
2007+
Flow state
2008+
direction : str
2009+
Flow direction
2010+
search_after : str
2011+
Pagination cursor for retrieving subsequent pages of results. This value is automatically populated by Mist in the `next` URL from the previous response and should not be manually constructed.
2012+
2013+
RETURN
2014+
-----------
2015+
mistapi.APIResponse
2016+
response from the API call
2017+
"""
2018+
2019+
uri = f"/api/v1/sites/{site_id}/devices/{device_id}/flow_records/search"
2020+
query_params: dict[str, str] = {}
2021+
if start:
2022+
query_params["start"] = str(start)
2023+
if end:
2024+
query_params["end"] = str(end)
2025+
if limit:
2026+
query_params["limit"] = str(limit)
2027+
if sort:
2028+
query_params["sort"] = str(sort)
2029+
if src_ip:
2030+
query_params["src_ip"] = str(src_ip)
2031+
if dst_ip:
2032+
query_params["dst_ip"] = str(dst_ip)
2033+
if src_port:
2034+
query_params["src_port"] = str(src_port)
2035+
if dst_port:
2036+
query_params["dst_port"] = str(dst_port)
2037+
if protocol:
2038+
query_params["protocol"] = str(protocol)
2039+
if state:
2040+
query_params["state"] = str(state)
2041+
if direction:
2042+
query_params["direction"] = str(direction)
2043+
if search_after:
2044+
query_params["search_after"] = str(search_after)
2045+
resp = mist_session.mist_get(uri=uri, query=query_params)
2046+
return resp
2047+
2048+
19562049
def GetSiteDeviceHaClusterNode(
19572050
mist_session: _APISession, site_id: str, device_id: str
19582051
) -> _APIResponse:
@@ -3639,6 +3732,61 @@ def setSiteVcPort(
36393732
return resp
36403733

36413734

3735+
def startSiteDeviceZigbeeEventTrail(
3736+
mist_session: _APISession, site_id: str, device_id: str
3737+
) -> _APIResponse:
3738+
"""
3739+
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/sites/devices/wireless/start-site-device-zigbee-event-trail
3740+
3741+
PARAMS
3742+
-----------
3743+
mistapi.APISession : mist_session
3744+
mistapi session including authentication and Mist host information
3745+
3746+
PATH PARAMS
3747+
-----------
3748+
site_id : str
3749+
device_id : str
3750+
3751+
RETURN
3752+
-----------
3753+
mistapi.APIResponse
3754+
response from the API call
3755+
"""
3756+
3757+
uri = f"/api/v1/sites/{site_id}/devices/{device_id}/zigbee_event_trail"
3758+
resp = mist_session.mist_post(uri=uri)
3759+
return resp
3760+
3761+
3762+
def stopSiteDeviceZigbeeJoin(
3763+
mist_session: _APISession, site_id: str, device_id: str
3764+
) -> _APIResponse:
3765+
"""
3766+
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/sites/devices/wireless/stop-site-device-zigbee-join
3767+
3768+
PARAMS
3769+
-----------
3770+
mistapi.APISession : mist_session
3771+
mistapi session including authentication and Mist host information
3772+
3773+
PATH PARAMS
3774+
-----------
3775+
site_id : str
3776+
device_id : str
3777+
3778+
RETURN
3779+
-----------
3780+
mistapi.APIResponse
3781+
response from the API call
3782+
"""
3783+
3784+
uri = f"/api/v1/sites/{site_id}/devices/{device_id}/zigbee_join"
3785+
query_params: dict[str, str] = {}
3786+
resp = mist_session.mist_delete(uri=uri, query=query_params)
3787+
return resp
3788+
3789+
36423790
def enableSiteDeviceZigbeeJoin(
36433791
mist_session: _APISession, site_id: str, device_id: str, body: dict | list
36443792
) -> _APIResponse:
@@ -3669,3 +3817,62 @@ def enableSiteDeviceZigbeeJoin(
36693817
uri = f"/api/v1/sites/{site_id}/devices/{device_id}/zigbee_join"
36703818
resp = mist_session.mist_post(uri=uri, body=body)
36713819
return resp
3820+
3821+
3822+
def kickSiteDeviceZigbeeClients(
3823+
mist_session: _APISession, site_id: str, device_id: str, body: dict | list
3824+
) -> _APIResponse:
3825+
"""
3826+
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/sites/devices/wireless/kick-site-device-zigbee-clients
3827+
3828+
PARAMS
3829+
-----------
3830+
mistapi.APISession : mist_session
3831+
mistapi session including authentication and Mist host information
3832+
3833+
PATH PARAMS
3834+
-----------
3835+
site_id : str
3836+
device_id : str
3837+
3838+
BODY PARAMS
3839+
-----------
3840+
body : dict
3841+
JSON object to send to Mist Cloud (see API doc above for more details)
3842+
3843+
RETURN
3844+
-----------
3845+
mistapi.APIResponse
3846+
response from the API call
3847+
"""
3848+
3849+
uri = f"/api/v1/sites/{site_id}/devices/{device_id}/zigbee_kick"
3850+
resp = mist_session.mist_post(uri=uri, body=body)
3851+
return resp
3852+
3853+
3854+
def startSiteDeviceZigbeePacketTrail(
3855+
mist_session: _APISession, site_id: str, device_id: str
3856+
) -> _APIResponse:
3857+
"""
3858+
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/sites/devices/wireless/start-site-device-zigbee-packet-trail
3859+
3860+
PARAMS
3861+
-----------
3862+
mistapi.APISession : mist_session
3863+
mistapi session including authentication and Mist host information
3864+
3865+
PATH PARAMS
3866+
-----------
3867+
site_id : str
3868+
device_id : str
3869+
3870+
RETURN
3871+
-----------
3872+
mistapi.APIResponse
3873+
response from the API call
3874+
"""
3875+
3876+
uri = f"/api/v1/sites/{site_id}/devices/{device_id}/zigbee_packet_trail"
3877+
resp = mist_session.mist_post(uri=uri)
3878+
return resp

0 commit comments

Comments
 (0)