Skip to content

Commit 1dfdc15

Browse files
author
Shiyue Cheng
committed
Updated with 1.0.0b5 & 0.110.2 releases
1 parent e8a85ca commit 1dfdc15

18 files changed

Lines changed: 1056 additions & 158 deletions

meraki/__init__.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@
8181
from .api.wireless_health import WirelessHealth
8282
from .api.wireless_settings import WirelessSettings
8383
from .config import (
84-
API_KEY_ENVIRONMENT_VARIABLE, DEFAULT_BASE_URL, SINGLE_REQUEST_TIMEOUT, CERTIFICATE_PATH, WAIT_ON_RATE_LIMIT,
85-
NGINX_429_RETRY_WAIT_TIME, ACTION_BATCH_RETRY_WAIT_TIME, RETRY_4XX_ERROR, RETRY_4XX_ERROR_WAIT_TIME,
86-
MAXIMUM_RETRIES, OUTPUT_LOG, LOG_PATH, LOG_FILE_PREFIX, PRINT_TO_CONSOLE, SUPPRESS_LOGGING, SIMULATE_API_CALLS,
87-
BE_GEO_ID, MERAKI_PYTHON_SDK_CALLER
84+
API_KEY_ENVIRONMENT_VARIABLE, DEFAULT_BASE_URL, SINGLE_REQUEST_TIMEOUT, CERTIFICATE_PATH, REQUESTS_PROXY,
85+
WAIT_ON_RATE_LIMIT, NGINX_429_RETRY_WAIT_TIME, ACTION_BATCH_RETRY_WAIT_TIME, RETRY_4XX_ERROR,
86+
RETRY_4XX_ERROR_WAIT_TIME, MAXIMUM_RETRIES, OUTPUT_LOG, LOG_PATH, LOG_FILE_PREFIX, PRINT_TO_CONSOLE,
87+
SUPPRESS_LOGGING, SIMULATE_API_CALLS, BE_GEO_ID, MERAKI_PYTHON_SDK_CALLER
8888
)
8989

9090

91-
__version__ = '0.110.1'
91+
__version__ = '0.110.2'
9292

9393

9494
class DashboardAPI(object):
@@ -99,6 +99,7 @@ class DashboardAPI(object):
9999
- base_url (string): preceding all endpoint resources
100100
- single_request_timeout (integer): maximum number of seconds for each API call
101101
- certificate_path (string): path for TLS/SSL certificate verification if behind local proxy
102+
- requests_proxy (string): proxy server and port, if needed, for HTTPS
102103
- wait_on_rate_limit (boolean): retry if 429 rate limit error encountered?
103104
- nginx_429_retry_wait_time (integer): Nginx 429 retry wait time
104105
- action_batch_retry_wait_time (integer): action batch concurrency error retry wait time
@@ -116,13 +117,13 @@ class DashboardAPI(object):
116117
"""
117118

118119
def __init__(self, api_key=None, base_url=DEFAULT_BASE_URL, single_request_timeout=SINGLE_REQUEST_TIMEOUT,
119-
certificate_path=CERTIFICATE_PATH, wait_on_rate_limit=WAIT_ON_RATE_LIMIT,
120-
nginx_429_retry_wait_time=NGINX_429_RETRY_WAIT_TIME,
121-
action_batch_retry_wait_time=ACTION_BATCH_RETRY_WAIT_TIME,
122-
retry_4xx_error=RETRY_4XX_ERROR, retry_4xx_error_wait_time=RETRY_4XX_ERROR_WAIT_TIME,
123-
maximum_retries=MAXIMUM_RETRIES, output_log=OUTPUT_LOG, log_path=LOG_PATH,
124-
log_file_prefix=LOG_FILE_PREFIX, print_console=PRINT_TO_CONSOLE, suppress_logging=SUPPRESS_LOGGING,
125-
simulate=SIMULATE_API_CALLS, be_geo_id=BE_GEO_ID, caller=MERAKI_PYTHON_SDK_CALLER):
120+
certificate_path=CERTIFICATE_PATH, requests_proxy=REQUESTS_PROXY,
121+
wait_on_rate_limit=WAIT_ON_RATE_LIMIT, nginx_429_retry_wait_time=NGINX_429_RETRY_WAIT_TIME,
122+
action_batch_retry_wait_time=ACTION_BATCH_RETRY_WAIT_TIME, retry_4xx_error=RETRY_4XX_ERROR,
123+
retry_4xx_error_wait_time=RETRY_4XX_ERROR_WAIT_TIME, maximum_retries=MAXIMUM_RETRIES,
124+
output_log=OUTPUT_LOG, log_path=LOG_PATH, log_file_prefix=LOG_FILE_PREFIX,
125+
print_console=PRINT_TO_CONSOLE, suppress_logging=SUPPRESS_LOGGING, simulate=SIMULATE_API_CALLS,
126+
be_geo_id=BE_GEO_ID, caller=MERAKI_PYTHON_SDK_CALLER):
126127
# Check API key
127128
api_key = api_key or os.environ.get(API_KEY_ENVIRONMENT_VARIABLE)
128129
if not api_key:
@@ -167,6 +168,7 @@ def __init__(self, api_key=None, base_url=DEFAULT_BASE_URL, single_request_timeo
167168
base_url=base_url,
168169
single_request_timeout=single_request_timeout,
169170
certificate_path=certificate_path,
171+
requests_proxy=requests_proxy,
170172
wait_on_rate_limit=wait_on_rate_limit,
171173
nginx_429_retry_wait_time=nginx_429_retry_wait_time,
172174
action_batch_retry_wait_time=action_batch_retry_wait_time,

meraki/aio/__init__.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@
8080
from .api.wireless_health import AsyncWirelessHealth
8181
from .api.wireless_settings import AsyncWirelessSettings
8282
from ..config import (
83-
API_KEY_ENVIRONMENT_VARIABLE, DEFAULT_BASE_URL, SINGLE_REQUEST_TIMEOUT, CERTIFICATE_PATH, WAIT_ON_RATE_LIMIT,
84-
NGINX_429_RETRY_WAIT_TIME, ACTION_BATCH_RETRY_WAIT_TIME, RETRY_4XX_ERROR, RETRY_4XX_ERROR_WAIT_TIME,
85-
MAXIMUM_RETRIES, OUTPUT_LOG, LOG_PATH, LOG_FILE_PREFIX, PRINT_TO_CONSOLE, SUPPRESS_LOGGING, SIMULATE_API_CALLS,
86-
AIO_MAXIMUM_CONCURRENT_REQUESTS, BE_GEO_ID, MERAKI_PYTHON_SDK_CALLER
83+
API_KEY_ENVIRONMENT_VARIABLE, DEFAULT_BASE_URL, SINGLE_REQUEST_TIMEOUT, CERTIFICATE_PATH, REQUESTS_PROXY,
84+
WAIT_ON_RATE_LIMIT, NGINX_429_RETRY_WAIT_TIME, ACTION_BATCH_RETRY_WAIT_TIME, RETRY_4XX_ERROR,
85+
RETRY_4XX_ERROR_WAIT_TIME, MAXIMUM_RETRIES, OUTPUT_LOG, LOG_PATH, LOG_FILE_PREFIX, PRINT_TO_CONSOLE,
86+
SUPPRESS_LOGGING, SIMULATE_API_CALLS, AIO_MAXIMUM_CONCURRENT_REQUESTS, BE_GEO_ID, MERAKI_PYTHON_SDK_CALLER
8787
)
8888

8989

@@ -95,6 +95,7 @@ class AsyncDashboardAPI:
9595
- base_url (string): preceding all endpoint resources
9696
- single_request_timeout (integer): maximum number of seconds for each API call
9797
- certificate_path (string): path for TLS/SSL certificate verification if behind local proxy
98+
- requests_proxy (string): proxy server and port, if needed, for HTTPS
9899
- wait_on_rate_limit (boolean): retry if 429 rate limit error encountered?
99100
- nginx_429_retry_wait_time (integer): Nginx 429 retry wait time
100101
- action_batch_retry_wait_time (integer): action batch concurrency error retry wait time
@@ -113,14 +114,13 @@ class AsyncDashboardAPI:
113114
"""
114115

115116
def __init__(self, api_key=None, base_url=DEFAULT_BASE_URL, single_request_timeout=SINGLE_REQUEST_TIMEOUT,
116-
certificate_path=CERTIFICATE_PATH, wait_on_rate_limit=WAIT_ON_RATE_LIMIT,
117-
nginx_429_retry_wait_time=NGINX_429_RETRY_WAIT_TIME,
118-
action_batch_retry_wait_time=ACTION_BATCH_RETRY_WAIT_TIME,
119-
retry_4xx_error=RETRY_4XX_ERROR, retry_4xx_error_wait_time=RETRY_4XX_ERROR_WAIT_TIME,
120-
maximum_retries=MAXIMUM_RETRIES, output_log=OUTPUT_LOG, log_path=LOG_PATH,
121-
log_file_prefix=LOG_FILE_PREFIX, print_console=PRINT_TO_CONSOLE, suppress_logging=SUPPRESS_LOGGING,
122-
simulate=SIMULATE_API_CALLS, maximum_concurrent_requests=AIO_MAXIMUM_CONCURRENT_REQUESTS,
123-
be_geo_id=BE_GEO_ID, caller=MERAKI_PYTHON_SDK_CALLER):
117+
certificate_path=CERTIFICATE_PATH, requests_proxy=REQUESTS_PROXY,
118+
wait_on_rate_limit=WAIT_ON_RATE_LIMIT, nginx_429_retry_wait_time=NGINX_429_RETRY_WAIT_TIME,
119+
action_batch_retry_wait_time=ACTION_BATCH_RETRY_WAIT_TIME, retry_4xx_error=RETRY_4XX_ERROR,
120+
retry_4xx_error_wait_time=RETRY_4XX_ERROR_WAIT_TIME, maximum_retries=MAXIMUM_RETRIES,
121+
output_log=OUTPUT_LOG, log_path=LOG_PATH, log_file_prefix=LOG_FILE_PREFIX,
122+
print_console=PRINT_TO_CONSOLE, suppress_logging=SUPPRESS_LOGGING, simulate=SIMULATE_API_CALLS,
123+
maximum_concurrent_requests=AIO_MAXIMUM_CONCURRENT_REQUESTS, be_geo_id=BE_GEO_ID, caller=MERAKI_PYTHON_SDK_CALLER):
124124
# Check API key
125125
api_key = api_key or os.environ.get(API_KEY_ENVIRONMENT_VARIABLE)
126126
if not api_key:
@@ -165,6 +165,7 @@ def __init__(self, api_key=None, base_url=DEFAULT_BASE_URL, single_request_timeo
165165
base_url=base_url,
166166
single_request_timeout=single_request_timeout,
167167
certificate_path=certificate_path,
168+
requests_proxy=requests_proxy,
168169
wait_on_rate_limit=wait_on_rate_limit,
169170
nginx_429_retry_wait_time=nginx_429_retry_wait_time,
170171
action_batch_retry_wait_time=action_batch_retry_wait_time,

meraki/aio/rest_session.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def __init__(
6464
base_url=DEFAULT_BASE_URL,
6565
single_request_timeout=SINGLE_REQUEST_TIMEOUT,
6666
certificate_path=CERTIFICATE_PATH,
67+
requests_proxy=REQUESTS_PROXY,
6768
wait_on_rate_limit=WAIT_ON_RATE_LIMIT,
6869
nginx_429_retry_wait_time=NGINX_429_RETRY_WAIT_TIME,
6970
action_batch_retry_wait_time=ACTION_BATCH_RETRY_WAIT_TIME,
@@ -82,6 +83,7 @@ def __init__(
8283
self._base_url = str(base_url)
8384
self._single_request_timeout = single_request_timeout
8485
self._certificate_path = certificate_path
86+
self._requests_proxy = requests_proxy
8587
self._wait_on_rate_limit = wait_on_rate_limit
8688
self._nginx_429_retry_wait_time = nginx_429_retry_wait_time
8789
self._action_batch_retry_wait_time = action_batch_retry_wait_time
@@ -142,6 +144,8 @@ async def _request(self, metadata, method, url, **kwargs):
142144
# Update request kwargs with session defaults
143145
if self._certificate_path:
144146
kwargs.setdefault("ssl", self._sslcontext)
147+
if self._requests_proxy:
148+
kwargs.setdefault("proxy", self._requests_proxy)
145149
kwargs.setdefault("timeout", self._single_request_timeout)
146150

147151
# Ensure proper base URL
@@ -268,26 +272,15 @@ async def get_pages(
268272

269273
# Get additional pages if more than one requested
270274
while total_pages != 1:
271-
# Parse Link from headers
272-
links = response.headers["Link"].split(",")
273-
first = prev = next = last = None
274-
for l in links:
275-
if "rel=first" in l:
276-
first = l[l.find("<") + 1 : l.find(">")]
277-
elif "rel=prev" in l:
278-
prev = l[l.find("<") + 1 : l.find(">")]
279-
elif "rel=next" in l:
280-
next = l[l.find("<") + 1 : l.find(">")]
281-
elif "rel=last" in l:
282-
last = l[l.find("<") + 1 : l.find(">")]
275+
links = response.links
283276

284277
# GET the subsequent page
285-
if direction == "next" and next:
278+
if direction == 'next' and "next" in links:
286279
metadata["page"] += 1
287-
response = await self.request(metadata, "GET", next)
288-
elif direction == "prev" and prev:
289-
metadata["page"] += 1
290-
response = await self.request(metadata, "GET", prev)
280+
response = await self.request(metadata, "GET", links["next"]["url"])
281+
elif direction == 'prev' and "prev" in links:
282+
metadata['page'] += 1
283+
response = await self.request(metadata, 'GET', links["prev"]["url"])
291284
else:
292285
break
293286

meraki/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# Path for TLS/SSL certificate verification if behind local proxy
1313
CERTIFICATE_PATH = ''
1414

15+
# Proxy server and port, if needed, for HTTPS
16+
REQUESTS_PROXY = ''
17+
1518
# Retry if 429 rate limit error encountered?
1619
WAIT_ON_RATE_LIMIT = True
1720

meraki/rest_session.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def __init__(
6363
base_url=DEFAULT_BASE_URL,
6464
single_request_timeout=SINGLE_REQUEST_TIMEOUT,
6565
certificate_path=CERTIFICATE_PATH,
66+
requests_proxy=REQUESTS_PROXY,
6667
wait_on_rate_limit=WAIT_ON_RATE_LIMIT,
6768
nginx_429_retry_wait_time=NGINX_429_RETRY_WAIT_TIME,
6869
action_batch_retry_wait_time=ACTION_BATCH_RETRY_WAIT_TIME,
@@ -80,6 +81,7 @@ def __init__(
8081
self._base_url = str(base_url)
8182
self._single_request_timeout = single_request_timeout
8283
self._certificate_path = certificate_path
84+
self._requests_proxy = requests_proxy
8385
self._wait_on_rate_limit = wait_on_rate_limit
8486
self._nginx_429_retry_wait_time = nginx_429_retry_wait_time
8587
self._action_batch_retry_wait_time = action_batch_retry_wait_time
@@ -123,6 +125,8 @@ def request(self, metadata, method, url, **kwargs):
123125
# Update request kwargs with session defaults
124126
if self._certificate_path:
125127
kwargs.setdefault('verify', self._certificate_path)
128+
if self._requests_proxy:
129+
kwargs.setdefault('proxies', {'https': self._requests_proxy})
126130
kwargs.setdefault('timeout', self._single_request_timeout)
127131

128132
# Ensure proper base URL
@@ -271,29 +275,17 @@ def get_pages(self, metadata, url, params=None, total_pages=-1, direction='next'
271275

272276
# Get additional pages if more than one requested
273277
while total_pages != 1:
274-
# Parse Link from headers
275-
links = response.headers['Link'].split(',')
276-
first = prev = next = last = None
277-
for l in links:
278-
if 'rel=first' in l:
279-
first = l[l.find('<')+1:l.find('>')]
280-
elif 'rel=prev' in l:
281-
prev = l[l.find('<')+1:l.find('>')]
282-
elif 'rel=next' in l:
283-
next = l[l.find('<')+1:l.find('>')]
284-
elif 'rel=last' in l:
285-
last = l[l.find('<')+1:l.find('>')]
286-
278+
links = response.links
287279
response.close()
288280
response = None
289281

290282
# GET the subsequent page
291-
if direction == 'next' and next:
283+
if direction == 'next' and 'next' in links:
292284
metadata['page'] += 1
293-
response = self.request(metadata, 'GET', next)
294-
elif direction == 'prev' and prev:
285+
response = self.request(metadata, 'GET', links['next']['url'])
286+
elif direction == 'prev' and 'prev' in links:
295287
metadata['page'] += 1
296-
response = self.request(metadata, 'GET', prev)
288+
response = self.request(metadata, 'GET', links['prev']['url'])
297289
else:
298290
break
299291

meraki_v1/__init__.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@
77
from .api.organizations import Organizations
88
from .api.networks import Networks
99
from .api.devices import Devices
10-
from .api.insight import Insight
11-
from .api.wireless import Wireless
12-
from .api.camera import Camera
1310
from .api.appliance import Appliance
14-
from .api.switch import Switch
11+
from .api.camera import Camera
1512
from .api.cellular_gateway import CellularGateway
13+
from .api.insight import Insight
1614
from .api.sm import Sm
15+
from .api.switch import Switch
16+
from .api.wireless import Wireless
1717
from .config import (
18-
API_KEY_ENVIRONMENT_VARIABLE, DEFAULT_BASE_URL, SINGLE_REQUEST_TIMEOUT, CERTIFICATE_PATH, WAIT_ON_RATE_LIMIT,
19-
NGINX_429_RETRY_WAIT_TIME, ACTION_BATCH_RETRY_WAIT_TIME, RETRY_4XX_ERROR, RETRY_4XX_ERROR_WAIT_TIME,
20-
MAXIMUM_RETRIES, OUTPUT_LOG, LOG_PATH, LOG_FILE_PREFIX, PRINT_TO_CONSOLE, SUPPRESS_LOGGING, SIMULATE_API_CALLS,
21-
BE_GEO_ID, MERAKI_PYTHON_SDK_CALLER
18+
API_KEY_ENVIRONMENT_VARIABLE, DEFAULT_BASE_URL, SINGLE_REQUEST_TIMEOUT, CERTIFICATE_PATH, REQUESTS_PROXY,
19+
WAIT_ON_RATE_LIMIT, NGINX_429_RETRY_WAIT_TIME, ACTION_BATCH_RETRY_WAIT_TIME, RETRY_4XX_ERROR,
20+
RETRY_4XX_ERROR_WAIT_TIME, MAXIMUM_RETRIES, OUTPUT_LOG, LOG_PATH, LOG_FILE_PREFIX, PRINT_TO_CONSOLE,
21+
SUPPRESS_LOGGING, SIMULATE_API_CALLS, BE_GEO_ID, MERAKI_PYTHON_SDK_CALLER
2222
)
2323

24-
__version__ = '1.0.0b4'
24+
__version__ = '1.0.0b5'
2525

2626
class DashboardAPI(object):
2727
"""
@@ -31,6 +31,7 @@ class DashboardAPI(object):
3131
- base_url (string): preceding all endpoint resources
3232
- single_request_timeout (integer): maximum number of seconds for each API call
3333
- certificate_path (string): path for TLS/SSL certificate verification if behind local proxy
34+
- requests_proxy (string): proxy server and port, if needed, for HTTPS
3435
- wait_on_rate_limit (boolean): retry if 429 rate limit error encountered?
3536
- nginx_429_retry_wait_time (integer): Nginx 429 retry wait time
3637
- action_batch_retry_wait_time (integer): action batch concurrency error retry wait time
@@ -48,13 +49,13 @@ class DashboardAPI(object):
4849
"""
4950

5051
def __init__(self, api_key=None, base_url=DEFAULT_BASE_URL, single_request_timeout=SINGLE_REQUEST_TIMEOUT,
51-
certificate_path=CERTIFICATE_PATH, wait_on_rate_limit=WAIT_ON_RATE_LIMIT,
52-
nginx_429_retry_wait_time=NGINX_429_RETRY_WAIT_TIME,
53-
action_batch_retry_wait_time=ACTION_BATCH_RETRY_WAIT_TIME,
54-
retry_4xx_error=RETRY_4XX_ERROR, retry_4xx_error_wait_time=RETRY_4XX_ERROR_WAIT_TIME,
55-
maximum_retries=MAXIMUM_RETRIES, output_log=OUTPUT_LOG, log_path=LOG_PATH,
56-
log_file_prefix=LOG_FILE_PREFIX, print_console=PRINT_TO_CONSOLE, suppress_logging=SUPPRESS_LOGGING,
57-
simulate=SIMULATE_API_CALLS, be_geo_id=BE_GEO_ID, caller=MERAKI_PYTHON_SDK_CALLER):
52+
certificate_path=CERTIFICATE_PATH, requests_proxy=REQUESTS_PROXY,
53+
wait_on_rate_limit=WAIT_ON_RATE_LIMIT, nginx_429_retry_wait_time=NGINX_429_RETRY_WAIT_TIME,
54+
action_batch_retry_wait_time=ACTION_BATCH_RETRY_WAIT_TIME, retry_4xx_error=RETRY_4XX_ERROR,
55+
retry_4xx_error_wait_time=RETRY_4XX_ERROR_WAIT_TIME, maximum_retries=MAXIMUM_RETRIES,
56+
output_log=OUTPUT_LOG, log_path=LOG_PATH, log_file_prefix=LOG_FILE_PREFIX,
57+
print_console=PRINT_TO_CONSOLE, suppress_logging=SUPPRESS_LOGGING, simulate=SIMULATE_API_CALLS,
58+
be_geo_id=BE_GEO_ID, caller=MERAKI_PYTHON_SDK_CALLER):
5859
# Check API key
5960
api_key = api_key or os.environ.get(API_KEY_ENVIRONMENT_VARIABLE)
6061
if not api_key:
@@ -99,6 +100,7 @@ def __init__(self, api_key=None, base_url=DEFAULT_BASE_URL, single_request_timeo
99100
base_url=base_url,
100101
single_request_timeout=single_request_timeout,
101102
certificate_path=certificate_path,
103+
requests_proxy=requests_proxy,
102104
wait_on_rate_limit=wait_on_rate_limit,
103105
nginx_429_retry_wait_time=nginx_429_retry_wait_time,
104106
action_batch_retry_wait_time=action_batch_retry_wait_time,
@@ -114,10 +116,10 @@ def __init__(self, api_key=None, base_url=DEFAULT_BASE_URL, single_request_timeo
114116
self.organizations = Organizations(self._session)
115117
self.networks = Networks(self._session)
116118
self.devices = Devices(self._session)
117-
self.insight = Insight(self._session)
118-
self.wireless = Wireless(self._session)
119-
self.camera = Camera(self._session)
120119
self.appliance = Appliance(self._session)
121-
self.switch = Switch(self._session)
120+
self.camera = Camera(self._session)
122121
self.cellulargateway = CellularGateway(self._session)
122+
self.insight = Insight(self._session)
123123
self.sm = Sm(self._session)
124+
self.switch = Switch(self._session)
125+
self.wireless = Wireless(self._session)

0 commit comments

Comments
 (0)