Last active
November 23, 2016 09:45
-
-
Save lazymutt/97ab9bd8ae10c48b7a743cc41b678766 to your computer and use it in GitHub Desktop.
Queries and displays open invitation codes on your JSS
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
#!/usr/bin/python | |
# Copyright (c) 2015 University of Utah Student Computing Labs. ################ | |
# All Rights Reserved. | |
# | |
# Permission to use, copy, modify, and distribute this software and | |
# its documentation for any purpose and without fee is hereby granted, | |
# provided that the above copyright notice appears in all copies and | |
# that both that copyright notice and this permission notice appear | |
# in supporting documentation, and that the name of The University | |
# of Utah not be used in advertising or publicity pertaining to | |
# distribution of the software without specific, written prior | |
# permission. This software is supplied as is without expressed or | |
# implied warranties of any kind. | |
################################################################################ | |
import json | |
import urllib2 | |
import base64 | |
def main(): | |
UsernameVar = "your_api_user" | |
PasswordVar = "your_api_password" | |
request = urllib2.Request('your_jss/JSSResource/computerinvitations') | |
request.add_header('Authorization', 'Basic ' + base64.b64encode(UsernameVar + ':' + PasswordVar)) | |
response = urllib2.urlopen(request) | |
call_output = json.loads(response.read()) | |
invites = call_output['computer_invitations'] | |
for invite_index in invites: | |
if invite_index['expiration_date'] == u'Unlimited': | |
print "%s: %s %s" % (invite_index['id'], invite_index['invitation'], invite_index['invitation_type']) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment