Skip to content

Commit 7e587ea

Browse files
Black linting updates
Linting update (Black)
1 parent ae54481 commit 7e587ea

12 files changed

Lines changed: 308 additions & 211 deletions

README.md

Lines changed: 80 additions & 35 deletions
Large diffs are not rendered by default.

generator/generate_library.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import getopt
22
import os
3-
import sys
43
import platform
4+
import sys
55

66
import jinja2
77
import requests

generator/generate_snippets.py

Lines changed: 178 additions & 136 deletions
Large diffs are not rendered by default.

generator/readme.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
# Generating the Meraki Dashboard API Python Library
22

3-
Generally speaking, you will not need to generate this yourself. Simply use the official PyPI package via `pip install --update meraki`.
3+
Generally speaking, you will not need to generate this yourself. Simply use the official PyPI package
4+
via `pip install --update meraki`.
45

5-
However, if you participate in Early Access features, you may want to generate a library to match your org's spec. In which case, follow along.
6+
However, if you participate in Early Access features, you may want to generate a library to match your org's spec. In
7+
which case, follow along.
68

79
> **NB:** The generator requires Python 3.10 or later.
810
911
1. Clone this repo locally.
1012
2. Open a terminal in this `generator` folder.
11-
3. *Optional:* If you want to work with beta endpoints, then first [review the warnings, and then opt one of your orgs into the Early API Access program](https://community.meraki.com/t5/Developers-APIs/UPDATED-Beta-testing-with-the-Meraki-Developer-Early-Access/m-p/145344#M5808).
13+
3. *Optional:* If you want to work with beta endpoints, then
14+
first [review the warnings, and then opt one of your orgs into the Early API Access program](https://community.meraki.com/t5/Developers-APIs/UPDATED-Beta-testing-with-the-Meraki-Developer-Early-Access/m-p/145344#M5808).
1215
4. Run `python generate_library.py -v locally_generated -o YOUR_ORG_ID -k YOUR_API_KEY` making these replacements:
13-
* Replace `YOUR_ORG_ID` with the org ID you want to use as reference. Use the one opted into Early API access if you want the beta endpoints.
16+
17+
* Replace `YOUR_ORG_ID` with the org ID you want to use as reference. Use the one opted into Early API access if you
18+
want the beta endpoints.
1419
* Replace `YOUR_API_KEY` with an API key that has org admin privileges on that org.
15-
* NB: Your local system may require minor syntax tweaks (e.g. Windows may require you prepend `generate_library.py` with `.\`)
16-
5. You will now have a `meraki` module folder inside `generator`, which you can locally reference in your scripts. Simply copy the `meraki` folder to those projects which require it.
17-
6. In some cases, if you've already installed the official library, your scripts may prefer that one over the local folder. If that happens, then calls to early access endpoints will fail. So, if necessary, uninstall any instances of the meraki package that may have been installed in your venv or system, or replace the version installed in your venv with that which you generated here.
20+
* NB: Your local system may require minor syntax tweaks (e.g. Windows may require you prepend `generate_library.py`
21+
with `.\`)
22+
23+
5. You will now have a `meraki` module folder inside `generator`, which you can locally reference in your scripts.
24+
Simply copy the `meraki` folder to those projects which require it.
25+
6. In some cases, if you've already installed the official library, your scripts may prefer that one over the local
26+
folder. If that happens, then calls to early access endpoints will fail. So, if necessary, uninstall any instances of
27+
the meraki package that may have been installed in your venv or system, or replace the version installed in your venv
28+
with that which you generated here.

meraki/__init__.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
import logging
22
import os
33

4-
from meraki.rest_session import *
54
from meraki.api.administered import Administered
6-
from meraki.api.organizations import Organizations
7-
from meraki.api.networks import Networks
8-
from meraki.api.devices import Devices
95
from meraki.api.appliance import Appliance
6+
# Batch class imports
7+
from meraki.api.batch import Batch
108
from meraki.api.camera import Camera
119
from meraki.api.cellularGateway import CellularGateway
10+
from meraki.api.devices import Devices
1211
from meraki.api.insight import Insight
1312
from meraki.api.licensing import Licensing
13+
from meraki.api.networks import Networks
14+
from meraki.api.organizations import Organizations
1415
from meraki.api.sensor import Sensor
1516
from meraki.api.sm import Sm
1617
from meraki.api.switch import Switch
1718
from meraki.api.wireless import Wireless
18-
19-
# Batch class imports
20-
from meraki.api.batch import Batch
21-
2219
# Config import
2320
from meraki.config import (
2421
API_KEY_ENVIRONMENT_VARIABLE,
@@ -44,6 +41,7 @@
4441
MERAKI_PYTHON_SDK_CALLER,
4542
USE_ITERATOR_FOR_GET_PAGES,
4643
)
44+
from meraki.rest_session import *
4745

4846
__version__ = '1.38.0'
4947

meraki/aio/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22
import os
33

4-
from meraki.aio.rest_session import *
54
from meraki.aio.api.administered import AsyncAdministered
65
from meraki.aio.api.appliance import AsyncAppliance
76
from meraki.aio.api.camera import AsyncCamera
@@ -15,10 +14,9 @@
1514
from meraki.aio.api.sm import AsyncSm
1615
from meraki.aio.api.switch import AsyncSwitch
1716
from meraki.aio.api.wireless import AsyncWireless
18-
17+
from meraki.aio.rest_session import *
1918
# Batch class imports
2019
from meraki.api.batch import Batch
21-
2220
# Config import
2321
from meraki.config import (
2422
API_KEY_ENVIRONMENT_VARIABLE,

meraki/aio/rest_session.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import random
2-
import time
31
import asyncio
42
import json
5-
import sys
3+
import random
64
import ssl
7-
5+
import sys
6+
import time
87
import urllib.parse
98
from datetime import datetime
9+
1010
import aiohttp
1111

1212
from meraki.__init__ import __version__

meraki/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
def check_python_version():
66
# Check minimum Python version
77

8-
if not (int(platform.python_version_tuple()[0]) == 3 and int(platform.python_version_tuple()[1]) >= 8):
8+
if not (
9+
int(platform.python_version_tuple()[0]) == 3
10+
and int(platform.python_version_tuple()[1]) >= 8
11+
):
912
message = (
1013
f"This library requires Python 3.8 at minimum. Python versions 3.7 and below "
1114
f"no longer receive security updates since reaching end of life and of support "

meraki/config.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# Package Constants
22

33
# Meraki dashboard API key, set either at instantiation or as an environment variable
4-
API_KEY_ENVIRONMENT_VARIABLE = 'MERAKI_DASHBOARD_API_KEY'
4+
API_KEY_ENVIRONMENT_VARIABLE = "MERAKI_DASHBOARD_API_KEY"
55

66
# Base URL preceding all endpoint resources
7-
DEFAULT_BASE_URL = 'https://api.meraki.com/api/v1'
7+
DEFAULT_BASE_URL = "https://api.meraki.com/api/v1"
88

99
# Maximum number of seconds for each API call
1010
SINGLE_REQUEST_TIMEOUT = 60
1111

1212
# Path for TLS/SSL certificate verification if behind local proxy
13-
CERTIFICATE_PATH = ''
13+
CERTIFICATE_PATH = ""
1414

1515
# Proxy server and port, if needed, for HTTPS
16-
REQUESTS_PROXY = ''
16+
REQUESTS_PROXY = ""
1717

1818
# Retry if 429 rate limit error encountered?
1919
WAIT_ON_RATE_LIMIT = True
@@ -40,10 +40,10 @@
4040
OUTPUT_LOG = True
4141

4242
# Path to output log; by default, working directory of script if not specified
43-
LOG_PATH = ''
43+
LOG_PATH = ""
4444

4545
# Log file name appended with date and timestamp
46-
LOG_FILE_PREFIX = 'meraki_api_'
46+
LOG_FILE_PREFIX = "meraki_api_"
4747

4848
# Print output logging to console?
4949
PRINT_TO_CONSOLE = True
@@ -65,7 +65,7 @@
6565
AIO_MAXIMUM_CONCURRENT_REQUESTS = 8
6666

6767
# Legacy partner identifier for API usage tracking; can also be set as an environment variable BE_GEO_ID
68-
BE_GEO_ID = ''
68+
BE_GEO_ID = ""
6969

7070
# Optional identifier for API usage tracking; can also be set as an environment variable MERAKI_PYTHON_SDK_CALLER
7171
# It's good practice to use this to identify your application using the format:
@@ -83,4 +83,4 @@
8383
# don't want to report version number, then you would use, at minimum: 'SunshineRainbows hunter2ForLife'
8484
# The choice is yours as long as you follow the format. You should **not** include other information in this string.
8585
# If you are an official ecosystem partner, this is required.
86-
MERAKI_PYTHON_SDK_CALLER = ''
86+
MERAKI_PYTHON_SDK_CALLER = ""

meraki/exceptions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ class PythonVersionError(Exception):
104104
"""Exception raised for unsupported Python versions."""
105105

106106
def __init__(self, message):
107-
108107
self.message = message
109108

110109
super().__init__(self.message)

0 commit comments

Comments
 (0)