Skip to content

Instantly share code, notes, and snippets.

@domenicbrosh
Created November 8, 2017 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domenicbrosh/8ad6c95163731eb2f901a17fc9988df3 to your computer and use it in GitHub Desktop.
Save domenicbrosh/8ad6c95163731eb2f901a17fc9988df3 to your computer and use it in GitHub Desktop.
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