Created
November 8, 2017 22:08
-
-
Save domenicbrosh/8ad6c95163731eb2f901a17fc9988df3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import getpass | |
def getoverdue (): | |
"""Connect to JSS and return nodes which are overude for check-in""" | |
user = input('Username: ') | |
passwd = getpass.getpass(prompt='Password: ') | |
url = 'https://jss.shsu.edu:8443/JSSResource/computergroups/name/Check-In Overdue' | |
headers = {'Accept': 'application/json'} | |
req = requests.get(url, headers=headers, auth=(user, passwd)) | |
if req.status_code == 200: | |
nodelist = [] | |
parsed = req.json() | |
for node in parsed['computer_group']['computers']: | |
nodelist.append(node['name']) | |
return nodelist | |
else: | |
print ('Cannot Connect to JSS') | |
exit(1) | |
if __name__ == '__main__': | |
print(getoverdue()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment