Skip to content

Commit 21c936a

Browse files
committed
feat(securityzones): implement CRUD operations for organization security zones with API documentation
1 parent a32dc1f commit 21c936a

1 file changed

Lines changed: 174 additions & 0 deletions

File tree

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
"""
2+
--------------------------------------------------------------------------------
3+
------------------------- Mist API Python CLI Session --------------------------
4+
5+
Written by: Thomas Munzer (tmunzer@juniper.net)
6+
Github : https://github.com/tmunzer/mistapi_python
7+
8+
This package is licensed under the MIT License.
9+
10+
--------------------------------------------------------------------------------
11+
"""
12+
13+
from mistapi import APISession as _APISession
14+
from mistapi.__api_response import APIResponse as _APIResponse
15+
16+
17+
def listOrgSecurityZones(
18+
mist_session: _APISession,
19+
org_id: str,
20+
limit: int | None = None,
21+
page: int | None = None,
22+
) -> _APIResponse:
23+
"""
24+
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/security-zones/list-org-security-zones
25+
26+
PARAMS
27+
-----------
28+
mistapi.APISession : mist_session
29+
mistapi session including authentication and Mist host information
30+
31+
PATH PARAMS
32+
-----------
33+
org_id : str
34+
35+
QUERY PARAMS
36+
------------
37+
limit : int, default: 100
38+
Maximum number of results to return per page
39+
page : int, default: 1
40+
Select the page number to return when using page-based pagination; starts at `1`
41+
42+
RETURN
43+
-----------
44+
mistapi.APIResponse
45+
response from the API call
46+
"""
47+
48+
uri = f"/api/v1/orgs/{org_id}/securityzones"
49+
query_params: dict[str, str] = {}
50+
if limit:
51+
query_params["limit"] = str(limit)
52+
if page:
53+
query_params["page"] = str(page)
54+
resp = mist_session.mist_get(uri=uri, query=query_params)
55+
return resp
56+
57+
58+
def createOrgSecurityZone(
59+
mist_session: _APISession, org_id: str, body: dict | list
60+
) -> _APIResponse:
61+
"""
62+
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/security-zones/create-org-security-zone
63+
64+
PARAMS
65+
-----------
66+
mistapi.APISession : mist_session
67+
mistapi session including authentication and Mist host information
68+
69+
PATH PARAMS
70+
-----------
71+
org_id : str
72+
73+
BODY PARAMS
74+
-----------
75+
body : dict
76+
JSON object to send to Mist Cloud (see API doc above for more details)
77+
78+
RETURN
79+
-----------
80+
mistapi.APIResponse
81+
response from the API call
82+
"""
83+
84+
uri = f"/api/v1/orgs/{org_id}/securityzones"
85+
resp = mist_session.mist_post(uri=uri, body=body)
86+
return resp
87+
88+
89+
def getOrgSecurityZone(
90+
mist_session: _APISession, org_id: str, securityzone_id: str
91+
) -> _APIResponse:
92+
"""
93+
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/security-zones/get-org-security-zone
94+
95+
PARAMS
96+
-----------
97+
mistapi.APISession : mist_session
98+
mistapi session including authentication and Mist host information
99+
100+
PATH PARAMS
101+
-----------
102+
org_id : str
103+
securityzone_id : str
104+
105+
RETURN
106+
-----------
107+
mistapi.APIResponse
108+
response from the API call
109+
"""
110+
111+
uri = f"/api/v1/orgs/{org_id}/securityzones/{securityzone_id}"
112+
query_params: dict[str, str] = {}
113+
resp = mist_session.mist_get(uri=uri, query=query_params)
114+
return resp
115+
116+
117+
def deleteOrgSecurityZone(
118+
mist_session: _APISession, org_id: str, securityzone_id: str
119+
) -> _APIResponse:
120+
"""
121+
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/security-zones/delete-org-security-zone
122+
123+
PARAMS
124+
-----------
125+
mistapi.APISession : mist_session
126+
mistapi session including authentication and Mist host information
127+
128+
PATH PARAMS
129+
-----------
130+
org_id : str
131+
securityzone_id : str
132+
133+
RETURN
134+
-----------
135+
mistapi.APIResponse
136+
response from the API call
137+
"""
138+
139+
uri = f"/api/v1/orgs/{org_id}/securityzones/{securityzone_id}"
140+
query_params: dict[str, str] = {}
141+
resp = mist_session.mist_delete(uri=uri, query=query_params)
142+
return resp
143+
144+
145+
def updateOrgSecurityZone(
146+
mist_session: _APISession, org_id: str, securityzone_id: str, body: dict
147+
) -> _APIResponse:
148+
"""
149+
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/security-zones/update-org-security-zone
150+
151+
PARAMS
152+
-----------
153+
mistapi.APISession : mist_session
154+
mistapi session including authentication and Mist host information
155+
156+
PATH PARAMS
157+
-----------
158+
org_id : str
159+
securityzone_id : str
160+
161+
BODY PARAMS
162+
-----------
163+
body : dict
164+
JSON object to send to Mist Cloud (see API doc above for more details)
165+
166+
RETURN
167+
-----------
168+
mistapi.APIResponse
169+
response from the API call
170+
"""
171+
172+
uri = f"/api/v1/orgs/{org_id}/securityzones/{securityzone_id}"
173+
resp = mist_session.mist_put(uri=uri, body=body)
174+
return resp

0 commit comments

Comments
 (0)