Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dccache

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
Expand All @@ -34,4 +34,4 @@ jobs:
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
if: matrix.python-version == '3.11' # Only upload once
if: matrix.python-version == '3.11' # Only upload once
2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/python_package.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.10
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/JelleZijlstra/autotyping
rev: 24.9.0
hooks:
- id: autotyping
types: [python]
args: [--safe] # or alternatively, --aggressive, or any of the other flags mentioned above

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-json
exclude: ".vscode/"
- id: check-added-large-files
- id: detect-private-key
- id: check-ast
- id: check-case-conflict

- repo: https://github.com/gitleaks/gitleaks
rev: v8.26.0
hooks:
- id: gitleaks

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.15.0
hooks:
- id: mypy
additional_dependencies:
[types-requests, pydantic, types-pyyaml, types-tabulate]

- repo: https://github.com/PyCQA/bandit
rev: 1.8.3
hooks:
- id: bandit
args: ["-c", "pyproject.toml"]
additional_dependencies: ["bandit[toml]"]

- repo: https://github.com/ubersan/pylic
rev: v5.0.1
hooks:
- id: pylic
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@
"**/.mypy_cache/**": true,
"**/.ruff_cache/**": true
}
}
}
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,13 @@ update: ## Update dependencies
sync: ## Sync dependencies
uv sync

check: clean format lint pre-commit test ## Run all checks and tests
pre-commit: ## Run pre-commit on all files
uvx pre-commit run --all-files

pre-commit-install: ## Install pre-commit hooks
uvx pre-commit install

pre-commit-update: ## Update pre-commit hooks
uvx pre-commit autoupdate

check: clean format lint pre-commit test ## Run all checks and tests
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# MISTAPI - Python Package to use MIST API


## MIT LICENSE

Copyright (c) 2023 Thomas Munzer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Expand Down Expand Up @@ -85,7 +85,7 @@ This class accepts different parameters, all optionals:
| 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 |
| https_proxy | string | None | configure the package to use an HTTP/HTTPS (e.g. http://user:[email protected]:3128) |

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

#### 2.1. If the env file is provided and all the required information is valid, the session is validated:
```python3
Expand Down Expand Up @@ -116,7 +116,7 @@ True
4) Global 03 (host: api.ac2.mist.com)
5) Global 04 (host: api.gc2.mist.com)

Select a Cloud (0 to 5, or q to exit):
Select a Cloud (0 to 5, or q to exit):
```
* if not authentication (`apitoken` or `email`/`password`) has been configured, an interactive input will ask for it. If login/password authentication is used and 2FA is requested by the Mist Cloud, the 2FA code will be asked.
```python3
Expand All @@ -125,7 +125,7 @@ Select a Cloud (0 to 5, or q to exit):
--------------------------- Login/Pwd authentication ---------------------------

Login: [email protected]
Password:
Password:
[ INFO ] Authentication successful!

Two Factor Authentication code required: 122749
Expand Down Expand Up @@ -175,7 +175,7 @@ Select a Site (0 to 6, or q to exit): 0
```

* get the next page or all the pages from a request
For some requests, the Mist Cloud is using pagination to limit the size of the response.
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 possessing the response to extract or generate the URI to retrieve the next page.
```python3
Expand Down Expand Up @@ -219,23 +219,23 @@ Help on function getOrgStats in module mistapi.api.v1.orgs.stats:

getOrgStats(mist_session: mistapi.__api_session.APISession, org_id: str, page: int = 1, limit: int = 100, start: int = None, end: int = None, duration: str = '1d') -> mistapi.__api_response.APIResponse
API doc: https://doc.mist-lab.fr/#operation/getOrgStats

PARAMS
-----------
:param APISession mist_session - mistapi session including authentication and Mist host information

PATH PARAMS
-----------
:param str org_id
:param str org_id

QUERY PARAMS
------------
:param int page
:param int limit
:param int start
:param int end
:param str duration(1d, 1h, 10m)

RETURN
-----------
:return APIResponse - response from the API call
Expand Down
2 changes: 1 addition & 1 deletion generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ git pull
cd ..

echo "Updating version in pyproject.toml to $1"
sed -e "s/version = .*/version = \"$1\"/g" pyproject.toml > new_pyproject.toml
sed -e "s/version = .*/version = \"$1\"/g" pyproject.toml > new_pyproject.toml
mv new_pyproject.toml pyproject.toml

echo "Updating version in __version.py to $1"
Expand Down
Loading
Loading