You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30-27Lines changed: 30 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,14 +13,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
13
13
14
14
15
15
## 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.
17
17
18
18
* Manage Mist Authentication with login/password (and 2FA if required) or API Token
19
19
* Provide interactive user inputs for login and org/site selections
20
20
* Provide easy access to Mist APIs endpoints and documentation
21
21
22
22
## Installation
23
-
This Python Package can be install with `pip`:
23
+
This Python Package can be installed with `pip`:
24
24
```python3
25
25
# Linux/macOS
26
26
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
47
47
```
48
48
49
49
### 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)
|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)|
59
59
60
60
An example of the environment file content is:
61
61
```
@@ -66,28 +66,28 @@ MIST_APITOKEN = xxxxxx
66
66
## Usage
67
67
Usage examples are available in the [mist_library repository](https://github.com/tmunzer/mist_library).
68
68
69
-
To use it,
70
-
### 1. `APISession` must be instanciated:
69
+
To use it:
70
+
### 1. `APISession` must be instantiated:
71
71
```python3
72
72
>>>import mistapi
73
73
>>> apisession = mistapi.APISession()
74
74
```
75
75
This class accepts different parameters, all optionals:
76
76
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)
|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)|
87
87
88
88
### 2. `login()` function must be called to validate the authentication.
89
89
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:
* easily find an Org Id from the current account with`mistapi.cli.select_org(apisession)`
152
152
```python3
153
153
>>> mistapi.cli.select_org(apisession)
@@ -175,7 +175,9 @@ Select a Site (0 to 6, or q to exit): 0
175
175
```
176
176
177
177
* get the next page orall 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`) orwith the `next` key in the json document. To make it easier to request the next page orall 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`) orwith the `next` key in the JSON document.
180
+
To make it easier to request the next page orall the pages, the `mistapi` package is possessing the response to extract or generate the URI to retrieve the next page.
@@ -197,7 +199,8 @@ To get the next page, use the `mistapi.get_next()` function. The returned respon
197
199
>>>len(response_2.data["results"])
198
200
100
199
201
```
200
-
To retrieve all the pages, use the `mistapi.get_all()` function. The returned response will be a listwith the concatained data fromall the Mist responses:
202
+
To retrieve all the pages, use the `mistapi.get_all()` function.
203
+
The returned response will be a listwithall the data fromall the Mist responses:
0 commit comments