Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def filter_dev_category():
if auth == None or url == None: # checks to see if the imc credentials are already available
imc_creds()
global r
category = None
ip_range = None
get_dev_list_url = None
filter_by_cat = input("Do you want to filter by device category?\nY/N: ")
if filter_by_cat.lower() == "y":
print_dev_category()
category = input("Please select the device category: ")
get_dev_list_url = ("/imcrs/plat/res/device?resPrivilegeFilter=false&category="+category+"&start=0&size=10000&orderBy=id&desc=false&total=false")
#return get_dev_list_url
filter_by_ip = input("Do you want to filter by IP address network range?\nY/N: ")
if filter_by_ip.lower() == "y":
ip_range = input("What is the ip network range?\n Example: 10.101.16.\nFuzzy search is acceptible: ")
if category == None:
get_dev_list_url = ("/imcrs/plat/res/device?resPrivilegeFilter=false&ip="+ip_range+"&start=0&size=5&orderBy=id&desc=false&total=false")
else:
get_dev_list_url = ("/imcrs/plat/res/device?resPrivilegeFilter=false&category="+category+"&ip="+ip_range+"&start=0&size=10000&orderBy=id&desc=false&total=false")
f_url = url + get_dev_list_url
payload = None
r = requests.get(f_url, auth=auth, headers=headers) #creates the URL using the payload variable as the contents
r.status_code
if r.status_code == 200:
dev_list = (json.loads(r.text))["device"]
return dev_list
else:
print ("An Error has occured")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.