mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
Meraki modules - Added support for checking HTTP response codes (#42144)
* Added support for checking HTTP response codes - All request calls now check for response code before responding - If the response code isn't what it should be, it fails or returns nothing - Breaking this into multiple PRs to make backporting easier - Using status property in Meraki module utility which has the code * Change logic of HTTP checks so success is default
This commit is contained in:
@@ -150,7 +150,10 @@ class MerakiModule(object):
|
||||
|
||||
def get_orgs(self):
|
||||
"""Downloads all organizations for a user."""
|
||||
return self.request('/organizations', method='GET')
|
||||
response = self.request('/organizations', method='GET')
|
||||
if self.status != 200:
|
||||
self.fail_json(msg='Organization lookup failed')
|
||||
return response
|
||||
|
||||
def is_org_valid(self, data, org_name=None, org_id=None):
|
||||
"""Checks whether a specific org exists and is duplicated.
|
||||
@@ -195,6 +198,8 @@ class MerakiModule(object):
|
||||
org_id = self.get_org_id(org_name)
|
||||
path = self.construct_path('get_all', org_id=org_id, function='network')
|
||||
r = self.request(path, method='GET')
|
||||
if self.status != 200:
|
||||
self.fail_json(msg='Network lookup failed')
|
||||
return r
|
||||
|
||||
def get_net(self, org_name, net_name, data=None):
|
||||
|
||||
Reference in New Issue
Block a user