Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 12 additions & 27 deletions meraki.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,26 +793,28 @@ def __hasorgaccess(apikey, targetorg):
Returns: None, raises OrgPermissionError if API Key does not have access to the specified Meraki Organization

"""
geturl = '{0}/organizations'.format(str(base_url))
geturl = '{0}/organizations/{1}'.format(str(base_url), str(targetorg))
headers = {
'x-cisco-meraki-api-key': format(str(apikey)),
'Content-Type': 'application/json'
}

dashboard = requests.get(geturl, headers=headers)
currentorgs = json.loads(dashboard.text)
orgs = []

validjson = __isjson(dashboard.text)

if validjson is True:
for org in currentorgs:
if int(org['id']) == int(targetorg):
orgs.append(org['id'])
return None
else:
pass
currentorg = json.loads(dashboard.text)

if int(currentorg['id']) == int(targetorg):
return None
else:
raise OrgPermissionError

else:
raise OrgPermissionError
return None

return None

def __validemail(emailaddress):

Expand Down Expand Up @@ -1298,23 +1300,6 @@ def getclients(apikey, serialnum, timestamp=86400, suppressprint=False):
return result


# Return the client associated with the given identifier. This endpoint will lookup by client ID or either the MAC or IP depending on whether the network uses Track-by-IP.
# https://api.meraki.com/api_doc#return-the-client-associated-with-the-given-identifier
def getclient(apikey, networkid, identifier, suppressprint=False):
calltype = 'Device Clients'
geturl = '{0}/networks/{1}/clients/{2}'.format(str(base_url), str(networkid), str(identifier))
headers = {
'x-cisco-meraki-api-key': format(str(apikey)),
'Content-Type': 'application/json'
}
dashboard = requests.get(geturl, headers=headers)
#
# Call return handler function to parse Dashboard response
#
result = __returnhandler(dashboard.status_code, dashboard.text, calltype, suppressprint)
return result


# Return the policy assigned to a client on the network.
# https://api.meraki.com/api_docs#return-the-policy-assigned-to-a-client-on-the-network
def getclientpolicy(apikey, networkid, clientmac, timestamp=86400, suppressprint=False):
Expand Down