Skip to content

Commit 9ec4854

Browse files
committed
0.54.4
1 parent 8e169a0 commit 9ec4854

28 files changed

+425
-149
lines changed

README.md

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
1313

1414

1515
## Features
16-
This package is build from the [Mist OpenAPI specifications](https://doc.mist-lab.fr) and is designed to simplify the use of the Mist APIs with Python scripts.
16+
This package is built from the [Mist OpenAPI specifications](https://doc.mist-lab.fr) and is designed to simplify the use of the Mist APIs with Python scripts.
1717

1818
* Manage Mist Authentication with login/password (and 2FA if required) or API Token
1919
* Provide interactive user inputs for login and org/site selections
2020
* Provide easy access to Mist APIs endpoints and documentation
2121

2222
## Installation
23-
This Python Package can be install with `pip`:
23+
This Python Package can be installed with `pip`:
2424
```python3
2525
# Linux/macOS
2626
python3 -m pip install mistapi
@@ -47,15 +47,15 @@ However, it is possible to set them in an `.env` file. The location of this file
4747
```
4848

4949
### Environment Variables
50-
| Variable Name | Type | Default | Comment |
51-
| ------------- | ---- | ------ | ------- |
52-
MIST_HOST | string | None | The Mist Cloud to use. It must be the "api" one (e.g. `api.mist.com`, `api.eu.mist.com`, ...) |
53-
MIST_APITOKEN | string | None | The API Token to use. |
54-
MIST_USER | string | None | The login to use if no API Token is provided (apitoken use is prefered) |
55-
MIST_PASSWORD | string | None | The password to use if no API Token is provided (apitoken use is prefered) |
56-
CONSOLE_LOG_LEVEL | int | 20 | The minimum log level to display on the console, using `logging` schema (0 = Disabled, 10 = Debug, 20 = Info, 30 = Warning, 40 = Error, 50 = Critical) |
57-
LOGGING_LOG_LEVEL | int | 10 | The minimum log level to log on the file, using `logging` schema (0 = Disabled, 10 = Debug, 20 = Info, 30 = Warning, 40 = Error, 50 = Critical). This is only used when the script calling `mistapi` is using Python `logging` package and is configured to log to a file |
58-
HTTPS_PROXY | string | None | configure the package to use an HTTP/HTTPS (e.g. http://user:passowrd@myproxy.com:3128)
50+
| Variable Name | Type | Default | Comment |
51+
|-------------------|--------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
52+
| MIST_HOST | string | None | The Mist Cloud to use. It must be the "api" one (e.g. `api.mist.com`, `api.eu.mist.com`, ...) |
53+
| MIST_APITOKEN | string | None | The API Token to use. |
54+
| MIST_USER | string | None | The login to use if no API Token is provided (apitoken use is preferred) |
55+
| MIST_PASSWORD | string | None | The password to use if no API Token is provided (apitoken use is preferred) |
56+
| CONSOLE_LOG_LEVEL | int | 20 | The minimum log level to display on the console, using `logging` schema (0 = Disabled, 10 = Debug, 20 = Info, 30 = Warning, 40 = Error, 50 = Critical) |
57+
| LOGGING_LOG_LEVEL | int | 10 | The minimum log level to log on the file, using `logging` schema (0 = Disabled, 10 = Debug, 20 = Info, 30 = Warning, 40 = Error, 50 = Critical). This is only used when the script calling `mistapi` is using Python `logging` package and is configured to log to a file |
58+
| HTTPS_PROXY | string | None | configure the package to use an HTTP/HTTPS (e.g. http://user:passowrd@myproxy.com:3128) |
5959

6060
An example of the environment file content is:
6161
```
@@ -66,28 +66,28 @@ MIST_APITOKEN = xxxxxx
6666
## Usage
6767
Usage examples are available in the [mist_library repository](https://github.com/tmunzer/mist_library).
6868

69-
To use it,
70-
### 1. `APISession` must be instanciated:
69+
To use it:
70+
### 1. `APISession` must be instantiated:
7171
```python3
7272
>>> import mistapi
7373
>>> apisession = mistapi.APISession()
7474
```
7575
This class accepts different parameters, all optionals:
7676

77-
| Parameter Name | Type | Default | Comment |
78-
| ------------- | ---- | ------ | ------- |
79-
email | str | None | used if login/password is used. Can be defined later |
80-
password | str | None | used if login/password is used. Can be defined later |
81-
apitoken | str | None | used if API Token is used. Can de defined later |
82-
host | str | None | Mist Cloud to reach (e.g. "api.mist.com"). Can de defined later |
83-
env_file | str | None | path to the env file to load. See README.md for allowed variables |
84-
console_log_level | int | 20 | The minimum log level to display on the console, using `logging` schema (0 = Disabled, 10 = Debug, 20 = Info, 30 = Warning, 40 = Error, 50 = Critical) |
85-
logging_log_level | int | 10 | The minimum log level to log on the file, using `logging` schema (0 = Disabled, 10 = Debug, 20 = Info, 30 = Warning, 40 = Error, 50 = Critical). This is only used when the script calling `mistapi` is using Python `logging` package and is configured to log to a file |
86-
https_proxy | string | None | configure the package to use an HTTP/HTTPS (e.g. http://user:passowrd@myproxy.com:3128)
77+
| Parameter Name | Type | Default | Comment |
78+
|-------------------|--------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
79+
| email | str | None | used if login/password is used. Can be defined later |
80+
| password | str | None | used if login/password is used. Can be defined later |
81+
| apitoken | str | None | used if API Token is used. Can de defined later |
82+
| host | str | None | Mist Cloud to reach (e.g. "api.mist.com"). Can de defined later |
83+
| env_file | str | None | path to the env file to load. See README.md for allowed variables |
84+
| console_log_level | int | 20 | The minimum log level to display on the console, using `logging` schema (0 = Disabled, 10 = Debug, 20 = Info, 30 = Warning, 40 = Error, 50 = Critical) |
85+
| logging_log_level | int | 10 | The minimum log level to log on the file, using `logging` schema (0 = Disabled, 10 = Debug, 20 = Info, 30 = Warning, 40 = Error, 50 = Critical). This is only used when the script calling `mistapi` is using Python `logging` package and is configured to log to a file |
86+
| https_proxy | string | None | configure the package to use an HTTP/HTTPS (e.g. http://user:passowrd@myproxy.com:3128) |
8787

8888
### 2. `login()` function must be called to validate the authentication.
8989

90-
#### 2.1. If the env file is provided and all the required information are valid, the session is validated:
90+
#### 2.1. If the env file is provided and all the required information is valid, the session is validated:
9191
```python3
9292
>>> import mistapi
9393
>>> apisession = mistapi.APISession(env_file="~/.mist_env")
@@ -147,7 +147,7 @@ Welcome Thomas Munzer!
147147
[{'model': 'AP41', 'type': 'ap', 'ap_type': 'aph', 'description': 'AP-41', 'display': 'AP41', 'has_wifi_band5': True, 'has_wifi_band24': True, 'has_scanning_radio': True, 'has_usb': True, 'has_vble': True, 'vble': {'power': 8, 'beacon_rate': 4, 'beams': 8}, 'band24': {'max_clients': 128, 'max_power': 19, 'min_power': 8}, 'fcc_dfs_ok': ...
148148
```
149149

150-
## Usefull functions
150+
## Useful functions
151151
* easily find an Org Id from the current account with `mistapi.cli.select_org(apisession)`
152152
```python3
153153
>>> mistapi.cli.select_org(apisession)
@@ -175,7 +175,9 @@ Select a Site (0 to 6, or q to exit): 0
175175
```
176176

177177
* get the next page or all the pages from a request
178-
For some requests, the Mist Cloud is using pagination to limit the size of the response. The required information the find the next page can either in the HTTP header (headers `X-Page-Total`, `X-Page-Limit` and `X-Page-Page`) or with the `next` key in the json document. To make it easier to request the next page or all the pages, the `mistapi` package is prossessing the response to extract or generate the URI to retrieve the next page.
178+
For some requests, the Mist Cloud is using pagination to limit the size of the response.
179+
The required information the find the next page can either in the HTTP header (headers `X-Page-Total`, `X-Page-Limit` and `X-Page-Page`) or with the `next` key in the JSON document.
180+
To make it easier to request the next page or all the pages, the `mistapi` package is possessing the response to extract or generate the URI to retrieve the next page.
179181
```python3
180182
>>> response = mistapi.api.v1.orgs.clients.searchOrgClientsEvents(apisession, my_org_id, duration="1d")
181183
>>> len(response.data["results"])
@@ -197,7 +199,8 @@ To get the next page, use the `mistapi.get_next()` function. The returned respon
197199
>>> len(response_2.data["results"])
198200
100
199201
```
200-
To retrieve all the pages, use the `mistapi.get_all()` function. The returned response will be a list with the concatained data from all the Mist responses:
202+
To retrieve all the pages, use the `mistapi.get_all()` function.
203+
The returned response will be a list with all the data from all the Mist responses:
201204
```python3
202205
>>> response = mistapi.api.v1.orgs.clients.searchOrgClientsEvents(apisession, my_org_id, duration="1d")
203206
>>> len(response.data["results"])

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77

88
[project]
99
name = "mistapi"
10-
version = "0.54.2"
10+
version = "0.54.4"
1111
authors = [{name="Thomas Munzer", email="tmunzer@juniper.net"}]
1212
description = "Python package to simplify the Mist System APIs usage"
1313
keywords = ["Mist", "Juniper", "API"]

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ deprecation
55
urllib3>=2.2.2 # not directly required, pinned by Snyk to avoid a vulnerability
66
twine
77
build
8+
pyyaml

src/mistapi/__api_session.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
{"short": "Global 02", "host": "api.gc1.mist.com", "cookies_ext": ".gc1"},
3535
{"short": "Global 03", "host": "api.ac2.mist.com", "cookies_ext": ".ac2"},
3636
{"short": "Global 04", "host": "api.gc2.mist.com", "cookies_ext": ".gc2"},
37+
{"short": "Global 05", "host": "api.gc4.mist.com", "cookies_ext": ".gc4"},
3738
]
3839

3940
#### PARAMETERS #####

src/mistapi/__version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "0.54.2"
1+
__version__ = "0.54.4"
22
__author__ = "Thomas Munzer <tmunzer@juniper.net>"

src/mistapi/api/v1/const/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from mistapi.api.v1.const import default_gateway_config
2222
from mistapi.api.v1.const import device_events
2323
from mistapi.api.v1.const import device_models
24+
from mistapi.api.v1.const import fingerprint_types
2425
from mistapi.api.v1.const import gateway_applications
2526
from mistapi.api.v1.const import insight_metrics
2627
from mistapi.api.v1.const import languages

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
from mistapi.__api_response import APIResponse as _APIResponse
1515
import deprecation
1616

17-
def listInstallerListOfRenctlyClaimedDevices(mist_session:_APISession, org_id:str, model:str=None, site_name:str=None, site_id:str=None, limit:int=100, page:int=1) -> _APIResponse:
17+
def listInstallerListOfRecentlyClaimedDevices(mist_session:_APISession, org_id:str, model:str=None, site_name:str=None, site_id:str=None, limit:int=100, page:int=1) -> _APIResponse:
1818
"""
19-
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/installer/list-installer-list-of-renctly-claimed-devices
19+
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/installer/list-installer-list-of-recently-claimed-devices
2020
2121
PARAMS
2222
-----------

src/mistapi/api/v1/orgs/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from mistapi.api.v1.orgs import orgs
1414
from mistapi.api.v1.orgs import ssr
15+
from mistapi.api.v1.orgs import aamwprofiles
1516
from mistapi.api.v1.orgs import admins
1617
from mistapi.api.v1.orgs import alarms
1718
from mistapi.api.v1.orgs import alarmtemplates

src/mistapi/api/v1/orgs/alarms.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def countOrgAlarms(mist_session:_APISession, org_id:str, distinct:str=None, star
106106
resp = mist_session.mist_get(uri=uri, query=query_params)
107107
return resp
108108

109-
def searchOrgAlarms(mist_session:_APISession, org_id:str, site_id:str=None, type:str=None, start:int=None, end:int=None, duration:str="1d", limit:int=100) -> _APIResponse:
109+
def searchOrgAlarms(mist_session:_APISession, org_id:str, site_id:str=None, type:str=None, status:str=None, start:int=None, end:int=None, duration:str="1d", limit:int=100) -> _APIResponse:
110110
"""
111111
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/alarms/search-org-alarms
112112
@@ -123,6 +123,7 @@ def searchOrgAlarms(mist_session:_APISession, org_id:str, site_id:str=None, type
123123
------------
124124
site_id : str
125125
type : str
126+
status : str
126127
start : int
127128
end : int
128129
duration : str, default: 1d
@@ -137,6 +138,7 @@ def searchOrgAlarms(mist_session:_APISession, org_id:str, site_id:str=None, type
137138
query_params={}
138139
if site_id: query_params["site_id"]=site_id
139140
if type: query_params["type"]=type
141+
if status: query_params["status"]=status
140142
if start: query_params["start"]=start
141143
if end: query_params["end"]=end
142144
if duration: query_params["duration"]=duration
@@ -171,9 +173,9 @@ def unackOrgMultipleAlarms(mist_session:_APISession, org_id:str, body:object) ->
171173
resp = mist_session.mist_post(uri=uri, body=body)
172174
return resp
173175

174-
def unackOrgAllArlarms(mist_session:_APISession, org_id:str, body:object) -> _APIResponse:
176+
def unackOrgAllAlarms(mist_session:_APISession, org_id:str, body:object) -> _APIResponse:
175177
"""
176-
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/alarms/unack-org-all-arlarms
178+
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/alarms/unack-org-all-alarms
177179
178180
PARAMS
179181
-----------

src/mistapi/api/v1/orgs/avprofiles.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def createOrgAntivirusProfile(mist_session:_APISession, org_id:str, body:object)
7171
resp = mist_session.mist_post(uri=uri, body=body)
7272
return resp
7373

74-
def getOrgAntivirusProfile(mist_session:_APISession, org_id:str, avprofiles_id:str) -> _APIResponse:
74+
def getOrgAntivirusProfile(mist_session:_APISession, org_id:str, avprofile_id:str) -> _APIResponse:
7575
"""
7676
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/antivirus-profiles/get-org-antivirus-profile
7777
@@ -83,19 +83,19 @@ def getOrgAntivirusProfile(mist_session:_APISession, org_id:str, avprofiles_id:s
8383
PATH PARAMS
8484
-----------
8585
org_id : str
86-
avprofiles_id : str
86+
avprofile_id : str
8787
8888
RETURN
8989
-----------
9090
mistapi.APIResponse
9191
response from the API call
9292
"""
93-
uri = f"/api/v1/orgs/{org_id}/avprofiles/{avprofiles_id}"
93+
uri = f"/api/v1/orgs/{org_id}/avprofiles/{avprofile_id}"
9494
query_params={}
9595
resp = mist_session.mist_get(uri=uri, query=query_params)
9696
return resp
9797

98-
def deleteOrgAntivirusProfile(mist_session:_APISession, org_id:str, avprofiles_id:str) -> _APIResponse:
98+
def deleteOrgAntivirusProfile(mist_session:_APISession, org_id:str, avprofile_id:str) -> _APIResponse:
9999
"""
100100
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/antivirus-profiles/delete-org-antivirus-profile
101101
@@ -107,19 +107,19 @@ def deleteOrgAntivirusProfile(mist_session:_APISession, org_id:str, avprofiles_i
107107
PATH PARAMS
108108
-----------
109109
org_id : str
110-
avprofiles_id : str
110+
avprofile_id : str
111111
112112
RETURN
113113
-----------
114114
mistapi.APIResponse
115115
response from the API call
116116
"""
117-
uri = f"/api/v1/orgs/{org_id}/avprofiles/{avprofiles_id}"
117+
uri = f"/api/v1/orgs/{org_id}/avprofiles/{avprofile_id}"
118118
query_params={}
119119
resp = mist_session.mist_delete(uri=uri, query=query_params)
120120
return resp
121121

122-
def updateOrgAntivirusProfile(mist_session:_APISession, org_id:str, avprofiles_id:str, body:object) -> _APIResponse:
122+
def updateOrgAntivirusProfile(mist_session:_APISession, org_id:str, avprofile_id:str, body:object) -> _APIResponse:
123123
"""
124124
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/antivirus-profiles/update-org-antivirus-profile
125125
@@ -131,7 +131,7 @@ def updateOrgAntivirusProfile(mist_session:_APISession, org_id:str, avprofiles_i
131131
PATH PARAMS
132132
-----------
133133
org_id : str
134-
avprofiles_id : str
134+
avprofile_id : str
135135
136136
BODY PARAMS
137137
-----------
@@ -143,7 +143,7 @@ def updateOrgAntivirusProfile(mist_session:_APISession, org_id:str, avprofiles_i
143143
mistapi.APIResponse
144144
response from the API call
145145
"""
146-
uri = f"/api/v1/orgs/{org_id}/avprofiles/{avprofiles_id}"
146+
uri = f"/api/v1/orgs/{org_id}/avprofiles/{avprofile_id}"
147147
resp = mist_session.mist_put(uri=uri, body=body)
148148
return resp
149149

0 commit comments

Comments
 (0)