Skip to content

Commit e8a85ca

Browse files
author
Shiyue Cheng
committed
Updated with 1.0.0b4 & 0.110.1 releases
1 parent e7d3c0f commit e8a85ca

16 files changed

Lines changed: 229 additions & 223 deletions

meraki/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
)
8989

9090

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

9393

9494
class DashboardAPI(object):

meraki/aio/api/mx_warm_spare_settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ def __init__(self, session):
33
super().__init__()
44
self._session = session
55

6-
async def swapNetworkWarmspare(self, networkId: str):
6+
async def swapNetworkWarmSpare(self, networkId: str):
77
"""
88
**Swap MX primary and warm spare appliances**
9-
https://developer.cisco.com/docs/meraki-api-v0/#!swap-network-warmspare
9+
https://developer.cisco.com/docs/meraki-api-v0/#!swap-network-warm-spare
1010
1111
- networkId (string)
1212
"""
1313

1414
metadata = {
1515
'tags': ['MX warm spare settings'],
16-
'operation': 'swapNetworkWarmspare',
16+
'operation': 'swapNetworkWarmSpare',
1717
}
1818
resource = f'/networks/{networkId}/swapWarmSpare'
1919

meraki/aio/api/security_events.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def __init__(self, session):
55

66
async def getNetworkClientSecurityEvents(self, networkId: str, clientId: str, total_pages=1, direction='next', **kwargs):
77
"""
8-
**List the security events for a client. Clients can be identified by a client key or either the MAC or IP depending on whether the network uses Track-by-IP.**
8+
**List the security events (intrusion detection only) for a client. Clients can be identified by a client key or either the MAC or IP depending on whether the network uses Track-by-IP.**
99
https://developer.cisco.com/docs/meraki-api-v0/#!get-network-client-security-events
1010
1111
- networkId (string)
@@ -36,7 +36,7 @@ async def getNetworkClientSecurityEvents(self, networkId: str, clientId: str, to
3636

3737
async def getNetworkSecurityEvents(self, networkId: str, total_pages=1, direction='next', **kwargs):
3838
"""
39-
**List the security events for a network**
39+
**List the security events (intrusion detection only) for a network**
4040
https://developer.cisco.com/docs/meraki-api-v0/#!get-network-security-events
4141
4242
- networkId (string)
@@ -66,7 +66,7 @@ async def getNetworkSecurityEvents(self, networkId: str, total_pages=1, directio
6666

6767
async def getOrganizationSecurityEvents(self, organizationId: str, total_pages=1, direction='next', **kwargs):
6868
"""
69-
**List the security events for an organization**
69+
**List the security events (intrusion detection only) for an organization**
7070
https://developer.cisco.com/docs/meraki-api-v0/#!get-organization-security-events
7171
7272
- organizationId (string)

meraki/aio/rest_session.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import json
33
import platform
4+
import random
45
import ssl
56
import sys
67
import urllib.parse
@@ -207,7 +208,7 @@ async def _request(self, metadata, method, url, **kwargs):
207208
if "Retry-After" in response.headers:
208209
wait = int(response.headers["Retry-After"])
209210
else:
210-
wait = self._nginx_429_retry_wait_time
211+
wait = random.randint(1, self._nginx_429_retry_wait_time)
211212
if self._logger:
212213
self._logger.warning(f"{tag}, {operation} > {abs_url} - {status} {reason}, retrying in {wait} seconds")
213214
await asyncio.sleep(wait)
@@ -221,7 +222,7 @@ async def _request(self, metadata, method, url, **kwargs):
221222
try:
222223
message = await response.json()
223224
except aiohttp.client_exceptions.ContentTypeError:
224-
message = (await response.text())[:100]
225+
message = (await response.content())[:100]
225226

226227
# Check specifically for action batch concurrency error
227228
action_batch_concurrency_error = {
@@ -236,7 +237,7 @@ async def _request(self, metadata, method, url, **kwargs):
236237
await asyncio.sleep(wait)
237238

238239
elif self._retry_4xx_error:
239-
wait = self._retry_4xx_error_wait_time
240+
wait = random.randint(1, self._retry_4xx_error_wait_time)
240241
if self._logger:
241242
self._logger.warning(f"{tag}, {operation} > {abs_url} - {status} {reason}, retrying in {wait} seconds")
242243
await asyncio.sleep(wait)

meraki/api/mx_warm_spare_settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ def __init__(self, session):
33
super(MXWarmSpareSettings, self).__init__()
44
self._session = session
55

6-
def swapNetworkWarmspare(self, networkId: str):
6+
def swapNetworkWarmSpare(self, networkId: str):
77
"""
88
**Swap MX primary and warm spare appliances**
9-
https://developer.cisco.com/docs/meraki-api-v0/#!swap-network-warmspare
9+
https://developer.cisco.com/docs/meraki-api-v0/#!swap-network-warm-spare
1010
1111
- networkId (string)
1212
"""
1313

1414
metadata = {
1515
'tags': ['MX warm spare settings'],
16-
'operation': 'swapNetworkWarmspare',
16+
'operation': 'swapNetworkWarmSpare',
1717
}
1818
resource = f'/networks/{networkId}/swapWarmSpare'
1919

meraki/api/security_events.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def __init__(self, session):
55

66
def getNetworkClientSecurityEvents(self, networkId: str, clientId: str, total_pages=1, direction='next', **kwargs):
77
"""
8-
**List the security events for a client. Clients can be identified by a client key or either the MAC or IP depending on whether the network uses Track-by-IP.**
8+
**List the security events (intrusion detection only) for a client. Clients can be identified by a client key or either the MAC or IP depending on whether the network uses Track-by-IP.**
99
https://developer.cisco.com/docs/meraki-api-v0/#!get-network-client-security-events
1010
1111
- networkId (string)
@@ -36,7 +36,7 @@ def getNetworkClientSecurityEvents(self, networkId: str, clientId: str, total_pa
3636

3737
def getNetworkSecurityEvents(self, networkId: str, total_pages=1, direction='next', **kwargs):
3838
"""
39-
**List the security events for a network**
39+
**List the security events (intrusion detection only) for a network**
4040
https://developer.cisco.com/docs/meraki-api-v0/#!get-network-security-events
4141
4242
- networkId (string)
@@ -66,7 +66,7 @@ def getNetworkSecurityEvents(self, networkId: str, total_pages=1, direction='nex
6666

6767
def getOrganizationSecurityEvents(self, organizationId: str, total_pages=1, direction='next', **kwargs):
6868
"""
69-
**List the security events for an organization**
69+
**List the security events (intrusion detection only) for an organization**
7070
https://developer.cisco.com/docs/meraki-api-v0/#!get-organization-security-events
7171
7272
- organizationId (string)

meraki/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(self, metadata, response):
1919
try:
2020
self.message = self.response.json() if self.response is not None and self.response.json() else None
2121
except ValueError:
22-
self.message = self.response.text[:100]
22+
self.message = self.response.content[:100]
2323
super(APIError, self).__init__(f'{self.tag}, {self.operation} - {self.status} {self.reason}, {self.message}')
2424

2525
def __repr__(self):

meraki/rest_session.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import platform
3+
import random
34
import sys
45
import time
56
import urllib.parse
@@ -91,6 +92,7 @@ def __init__(
9192

9293
# Initialize a new `requests` session
9394
self._req_session = requests.session()
95+
self._req_session.encoding = 'utf-8'
9496

9597
# Check base URL
9698
if 'v1' in self._base_url:
@@ -176,7 +178,7 @@ def request(self, metadata, method, url, **kwargs):
176178
self._logger.info(f'{tag}, {operation} - {status} {reason}')
177179
# For non-empty response to GET, ensure valid JSON
178180
try:
179-
if method == 'GET' and response.text.strip():
181+
if method == 'GET' and response.content.strip():
180182
response.json()
181183
return response
182184
except json.decoder.JSONDecodeError as e:
@@ -194,7 +196,7 @@ def request(self, metadata, method, url, **kwargs):
194196
if 'Retry-After' in response.headers:
195197
wait = int(response.headers['Retry-After'])
196198
else:
197-
wait = self._nginx_429_retry_wait_time
199+
wait = random.randint(1, self._nginx_429_retry_wait_time)
198200
if self._logger:
199201
self._logger.warning(f'{tag}, {operation} - {status} {reason}, retrying in {wait} seconds')
200202
time.sleep(wait)
@@ -216,7 +218,7 @@ def request(self, metadata, method, url, **kwargs):
216218
try:
217219
message = response.json()
218220
except ValueError:
219-
message = response.text[:100]
221+
message = response.content[:100]
220222

221223
# Check specifically for action batch concurrency error
222224
action_batch_concurrency_error = {'errors': [
@@ -231,7 +233,7 @@ def request(self, metadata, method, url, **kwargs):
231233
if retries == 0:
232234
raise APIError(metadata, response)
233235
elif self._retry_4xx_error:
234-
wait = self._retry_4xx_error_wait_time
236+
wait = random.randint(1, self._retry_4xx_error_wait_time)
235237
if self._logger:
236238
self._logger.warning(f'{tag}, {operation} - {status} {reason}, retrying in {wait} seconds')
237239
time.sleep(wait)
@@ -252,7 +254,7 @@ def get(self, metadata, url, params=None):
252254
response = self.request(metadata, 'GET', url, params=params)
253255
ret = None
254256
if response:
255-
if response.text.strip():
257+
if response.content.strip():
256258
ret = response.json()
257259
response.close()
258260
return ret
@@ -323,7 +325,7 @@ def post(self, metadata, url, json=None):
323325
response = self.request(metadata, 'POST', url, json=json)
324326
ret = None
325327
if response:
326-
if response.text.strip():
328+
if response.content.strip():
327329
ret = response.json()
328330
response.close()
329331
return ret
@@ -335,7 +337,7 @@ def put(self, metadata, url, json=None):
335337
response = self.request(metadata, 'PUT', url, json=json)
336338
ret = None
337339
if response:
338-
if response.text.strip():
340+
if response.content.strip():
339341
ret = response.json()
340342
response.close()
341343
return ret

meraki_v1/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
BE_GEO_ID, MERAKI_PYTHON_SDK_CALLER
2222
)
2323

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

2626
class DashboardAPI(object):
2727
"""

0 commit comments

Comments
 (0)