meraki / dashboard-api-python

Official Dashboard API library (SDK) for Python
MIT License
289 stars 151 forks source link

getOrganizationNetworks() with Iterator Returns No Results #183

Closed aque closed 2 years ago

aque commented 2 years ago

Using meraki.DashboardAPI(use_iterator_for_get_pages=True), getOrganizationNetworks() returns no results with the default perPage=1000 value. I get results when perPage is limited to 650 or less. This is on version 1.18.2 running under Python 3.9.2.

Iterator with default perPage

Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import meraki
>>> dashboard = meraki.DashboardAPI(use_iterator_for_get_pages=True, simulate=True)  
2022-02-19 14:11:40       meraki:     INFO > Meraki dashboard API session initialized with these parameters: {
'version': '1.18.2', 'api_key': '************************************ab6d', 'base_url': 'https://api.meraki.com/api/v1',
'single_request_timeout': 60, 'certificate_path': '', 'requests_proxy': '', 'wait_on_rate_limit': True,
'nginx_429_retry_wait_time': 60, 'action_batch_retry_wait_time': 60, 'retry_4xx_error': False,
'retry_4xx_error_wait_time': 60, 'maximum_retries': 2, 'simulate': True,
'be_geo_id': None, 'caller': None, 'use_iterator_for_get_pages': True}

>>> nets = dashboard.organizations.getOrganizationNetworks(organizationId='nnnnnn') 
>>> next(nets).keys()
2022-02-19 14:12:19       meraki:     INFO > GET https://api.meraki.com/api/v1/organizations/nnnnnn/networks
2022-02-19 14:12:20       meraki:     INFO > organizations, getOrganizationNetworks; page 1 - 200 OK
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
StopIteration

Iterator with perPage=650

Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import meraki
>>> dashboard = meraki.DashboardAPI(use_iterator_for_get_pages=True, simulate=True)
2022-02-19 14:18:59       meraki:     INFO > Meraki dashboard API session initialized with these parameters: {
'version': '1.18.2', 'api_key': '************************************ab6d', 'base_url': 'https://api.meraki.com/api/v1',
'single_request_timeout': 60, 'certificate_path': '', 'requests_proxy': '', 'wait_on_rate_limit': True,
'nginx_429_retry_wait_time': 60, 'action_batch_retry_wait_time': 60, 'retry_4xx_error': False,
'retry_4xx_error_wait_time': 60, 'maximum_retries': 2, 'simulate': True,
'be_geo_id': None, 'caller': None, 'use_iterator_for_get_pages': True}

>>> nets = dashboard.organizations.getOrganizationNetworks(organizationId='nnnnnn', perPage=650) 
>>> next(nets).keys()
2022-02-19 14:19:06       meraki:     INFO > GET https://api.meraki.com/api/v1/organizations/nnnnnn/networks
2022-02-19 14:19:08       meraki:     INFO > organizations, getOrganizationNetworks; page 1 - 200 OK
dict_keys(['id', 'organizationId', 'name', 'productTypes', 'timeZone', 'tags', 'enrollmentString', 'url', 'notes'])
TKIPisalegacycipher commented 2 years ago

@coreGreenberet does this look correct?

coreGreenberet commented 2 years ago

Yeah that was a bug =( PR #184 is out

aque commented 2 years ago

I finally updated my project to use 1.20.0 and this issue is not fixed. Looks like getOrganizationNetworks() is using meraki/rest_session.py instead ofmeraki/aio/rest_session.py. @coreGreenberet, can you update the other copy?

stuckeysnewband commented 2 years ago

Allan, Thanks for the help.. there seems to be something not quite right… Traffic is not passing. It looks like the firewall settings did not change. I am unable to edit the Layer 3 inbound rules, which I should be able to after you enable No-Nat. It may be that it’s taking a bit for the changes to manifest, but I wanted to reach out and let you know.

Jim Shoemaker | Senior Engineer | CCNA Intellicom Phone: (308)-237-0684 ext. 248 E-mail: @.**@.> Web: www.intellicominc.comhttp://www.intellicominc.com/ Blog: http://blog.intellicominc.comhttp://blog.intellicominc.com/

@. @. @.***

From: Allan Que @.> Sent: Tuesday, May 3, 2022 11:15 AM To: meraki/dashboard-api-python @.> Cc: Subscribed @.***> Subject: [EXTERNAL] Re: [meraki/dashboard-api-python] getOrganizationNetworks() with Iterator Returns No Results (Issue #183)

I finally updated my project to use 1.20.0 and this issue is not fixed. Looks like getOrganizationNetworks() is using meraki/rest_session.pyhttps://github.com/meraki/dashboard-api-python/blob/4e327084cb1c138c63670cdca1f97484414afe03/meraki/rest_session.py#L347-L348 instead ofmeraki/aio/rest_session.py. @coreGreenberethttps://github.com/coreGreenberet, can you update the other copy?

— Reply to this email directly, view it on GitHubhttps://github.com/meraki/dashboard-api-python/issues/183#issuecomment-1116282513, or unsubscribehttps://github.com/notifications/unsubscribe-auth/APQGSLG5QTZ53Q5NL6ZTGRTVIFGJPANCNFSM5O3N4VCQ. You are receiving this because you are subscribed to this thread.Message ID: @.**@.>>


CONFIDENTIALITY NOTICE: This communication and any files or attachments transmitted with it may contain information that is confidential, privileged and exempt from disclosure under applicable law. It is intended solely for the use of the intended recipient. If you are not the intended recipient, you are hereby notified that any unauthorized review, use, disclosure, dissemination, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender by reply E-mail and destroy all copies of the original message. Additionally, we will take the appropriate action to avoid sending you an unintended E-mail in the future. Thank you for your cooperation.

aque commented 2 years ago

Allan, Thanks for the help.. there seems to be something not quite right… Traffic is not passing. It looks like the firewall settings did not change. I am unable to edit the Layer 3 inbound rules, which I should be able to after you enable No-Nat. It may be that it’s taking a bit for the changes to manifest, but I wanted to reach out and let you know.

Jim, I'm afraid I do not know what you are referring to in your comment.