this script uses pandas. please install beforehand
'''

from snipeit import Assets, Categories, DataUtil
import html
import sys
if sys.version_info[0] >= 3:
    import PySimpleGUI as sg
else:
    import PySimpleGUI27 as sg
import pandas as pd

server='<your snipe-it server>'
token='<your token value'

A = Assets()
C = Categories()

def asset_browser():    
    categories = C.get(server, token)
    cat_jsondata = DataUtil.getjson(categories)        
    catdf = pd.DataFrame(cat_jsondata["rows"], columns=['name'])
    catdflist = catdf.values.tolist()
    catdflist = [item for sublist in catdflist for item in sublist]
    
    for cat in catdflist:
        if isinstance(cat,dict):
            cat = str(cat)
        catdflist[catdflist.index(cat)] = html.unescape(cat)
    
    next_offset=0    
#!/usr/bin/env python

from snipeit import Assets

server = 'http://snipeitserver.example.com'
token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjU5MjFlNDUxZDlkZGJjNjIyOWIyZGQxYzRkNzMyMTE0MzcyZTY2YTZmMmE5NTE2ZTMyNWM2Mzg2ODNjMjdlODMyODE4YmJmM2QxNTg4MjlhIn0.eyJhdWQiOiIxIiwianRpIjoiNTkyMWU0NTFkOWRkYmM2MjI5YjJkZDFjNGQ3MzIxMTQzNzJlNjZhNmYyYTk1MTZlMzI1YzYzODY4M2MyN2U4MzI4MThiYmYzZDE1ODgyOWEiLCJpYXQiOjE1MTUxODI1OTcsIm5iZiI6MTUxNTE4MjU5NywiZXhwIjoxNTQ2NzE4NTk3LCJzdWIiOiIyMzQ2Iiwic2NvcGVzIjpbXX0.E4aHV0NQDlylBXfkfexYl2UBr043wb2suoNrLD2dSwwptIFxNyy8NSWFQxgvYtVeenIbva9dUhI_dYkY7h0W56RZW3DAoqOlzKjFUnhDU3FEqBMsI-CuiGQPwVJ5QQRIzP9VZVpypqokOf-OTZyc-ZyxyGnqz9_dqMFySYZ7EicbtpdYvWVgelK5HF4gxodeBmLm7igVSNkRm_SxHesyjVIvsefnXFF5idUWSwHBn3jXhv-Jm0fhAz8xAw7XjsXMPQXGMAkQHXYpEmobiGSJsvlVPyf4aZjB7FJVzz-1EecFOqBMAS5ZE4YUYi-DOH4YtS6JL_54UOJMeJ3gPh22f4_3yzjNoZ20_ru_O4au2yraG7INCc53XyFj2qgfh9n9eKqRJH2pTB_5jemMCVLjZRDhXA7H0pMxGr_iSlWCXcJGpXjTtW3au53zlqXxgSYtYuti_pU5rahcQWgKEyh7QGdepOa-xaXG_td5pJs2ewmW1Qw3YfFw1ryVZICnloYrGwnoIehXH_7gCBpuUx-NhlKEzhXEQlV0Vcq_btKB5M-AdPD7XSP4Y5SaTmC8B38J6h-uT5cw8XAUv0vR0NMfY9gs-JXZExTqzVcu_GIhy1v_lkeeh7Xud8ZzSlvR6zdDN3LTxh1IReHZBEX8gSh7bFsGe-bGTp40S_RbSilF_pg'

A = Assets()
r = A.getID(server, token, "thisisunique17")
print r
Пример #3
0
#!/usr/bin/env python

from snipeit import Assets, Users, Categories
from snipeit import DataUtil
import json
import ast
import pandas as pd

server = '<your snipe-it server>'
token = '<your token>'

A = Assets()
r = A.get(server, token)  # Using default limit of 50 for results
jsondata = DataUtil.getjson(r)
print(DataUtil.prettyprint(r))
Пример #4
0
import subprocess, snipeit, json
from snipeit import Assets, Models, Company, Manufacturers

server = ''
token = ''
Asset = Assets()

'''
Gather Hardware info from System Profiler

'_name', 'activation_lock_status', 'boot_rom_version', 'cpu_type', 'current_processor_speed', 'l2_cache_core', 'l3_cache', 'machine_model', 'machine_name', 'number_processors', 'packages', 'physical_memory', 'platform_cpu_htt', 'platform_UUID', 'provisioning_UDID', 'serial_number'
'''
sysProfiler = subprocess.Popen(['system_profiler', 'SPHardwareDataType', '-json'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
outSP, errSP = sysProfiler.communicate()

currentHardware = json.loads(outSP)

serialNum = currentHardware["SPHardwareDataType"][0]['serial_number']
assetTag = serialNum
modelID = currentHardware["SPHardwareDataType"][0]['machine_model']
processorName = currentHardware["SPHardwareDataType"][0]['cpu_type']
processorSpeed = currentHardware["SPHardwareDataType"][0]['current_processor_speed']

# Get Model ID
Model = Models()
modelLookup = Model.search(server, token, keyword=modelID)
modelLookup = json.loads(modelLookup)
if modelLookup['rows'] == []:
	#ManufacturerID is the ID number. First manufacturer created is 1.
	ManufacturerID =  
	deviceName = currentHardware["SPHardwareDataType"][0]['machine_name']
#!/usr/bin/env python

from snipeit import Assets

server='http://snipeitserver.example.com'
token='eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjU5MjFlNDUxZDlkZGJjNjIyOWIyZGQxYzRkNzMyMTE0MzcyZTY2YTZmMmE5NTE2ZTMyNWM2Mzg2ODNjMjdlODMyODE4YmJmM2QxNTg4MjlhIn0.eyJhdWQiOiIxIiwianRpIjoiNTkyMWU0NTFkOWRkYmM2MjI5YjJkZDFjNGQ3MzIxMTQzNzJlNjZhNmYyYTk1MTZlMzI1YzYzODY4M2MyN2U4MzI4MThiYmYzZDE1ODgyOWEiLCJpYXQiOjE1MTUxODI1OTcsIm5iZiI6MTUxNTE4MjU5NywiZXhwIjoxNTQ2NzE4NTk3LCJzdWIiOiIyMzQ2Iiwic2NvcGVzIjpbXX0.E4aHV0NQDlylBXfkfexYl2UBr043wb2suoNrLD2dSwwptIFxNyy8NSWFQxgvYtVeenIbva9dUhI_dYkY7h0W56RZW3DAoqOlzKjFUnhDU3FEqBMsI-CuiGQPwVJ5QQRIzP9VZVpypqokOf-OTZyc-ZyxyGnqz9_dqMFySYZ7EicbtpdYvWVgelK5HF4gxodeBmLm7igVSNkRm_SxHesyjVIvsefnXFF5idUWSwHBn3jXhv-Jm0fhAz8xAw7XjsXMPQXGMAkQHXYpEmobiGSJsvlVPyf4aZjB7FJVzz-1EecFOqBMAS5ZE4YUYi-DOH4YtS6JL_54UOJMeJ3gPh22f4_3yzjNoZ20_ru_O4au2yraG7INCc53XyFj2qgfh9n9eKqRJH2pTB_5jemMCVLjZRDhXA7H0pMxGr_iSlWCXcJGpXjTtW3au53zlqXxgSYtYuti_pU5rahcQWgKEyh7QGdepOa-xaXG_td5pJs2ewmW1Qw3YfFw1ryVZICnloYrGwnoIehXH_7gCBpuUx-NhlKEzhXEQlV0Vcq_btKB5M-AdPD7XSP4Y5SaTmC8B38J6h-uT5cw8XAUv0vR0NMfY9gs-JXZExTqzVcu_GIhy1v_lkeeh7Xud8ZzSlvR6zdDN3LTxh1IReHZBEX8gSh7bFsGe-bGTp40S_RbSilF_pg'

A = Assets()
payload = '{"asset_tag":"thisisunique17","status_id":1,"model_id": 5}'
r = A.create(server, token, payload)
print r
#!/usr/bin/env python

from snipeit import Assets

server='http://snipeitserver.example.com'
token='eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjU5MjFlNDUxZDlkZGJjNjIyOWIyZGQxYzRkNzMyMTE0MzcyZTY2YTZmMmE5NTE2ZTMyNWM2Mzg2ODNjMjdlODMyODE4YmJmM2QxNTg4MjlhIn0.eyJhdWQiOiIxIiwianRpIjoiNTkyMWU0NTFkOWRkYmM2MjI5YjJkZDFjNGQ3MzIxMTQzNzJlNjZhNmYyYTk1MTZlMzI1YzYzODY4M2MyN2U4MzI4MThiYmYzZDE1ODgyOWEiLCJpYXQiOjE1MTUxODI1OTcsIm5iZiI6MTUxNTE4MjU5NywiZXhwIjoxNTQ2NzE4NTk3LCJzdWIiOiIyMzQ2Iiwic2NvcGVzIjpbXX0.E4aHV0NQDlylBXfkfexYl2UBr043wb2suoNrLD2dSwwptIFxNyy8NSWFQxgvYtVeenIbva9dUhI_dYkY7h0W56RZW3DAoqOlzKjFUnhDU3FEqBMsI-CuiGQPwVJ5QQRIzP9VZVpypqokOf-OTZyc-ZyxyGnqz9_dqMFySYZ7EicbtpdYvWVgelK5HF4gxodeBmLm7igVSNkRm_SxHesyjVIvsefnXFF5idUWSwHBn3jXhv-Jm0fhAz8xAw7XjsXMPQXGMAkQHXYpEmobiGSJsvlVPyf4aZjB7FJVzz-1EecFOqBMAS5ZE4YUYi-DOH4YtS6JL_54UOJMeJ3gPh22f4_3yzjNoZ20_ru_O4au2yraG7INCc53XyFj2qgfh9n9eKqRJH2pTB_5jemMCVLjZRDhXA7H0pMxGr_iSlWCXcJGpXjTtW3au53zlqXxgSYtYuti_pU5rahcQWgKEyh7QGdepOa-xaXG_td5pJs2ewmW1Qw3YfFw1ryVZICnloYrGwnoIehXH_7gCBpuUx-NhlKEzhXEQlV0Vcq_btKB5M-AdPD7XSP4Y5SaTmC8B38J6h-uT5cw8XAUv0vR0NMfY9gs-JXZExTqzVcu_GIhy1v_lkeeh7Xud8ZzSlvR6zdDN3LTxh1IReHZBEX8gSh7bFsGe-bGTp40S_RbSilF_pg'


A = Assets()
#payload = '{"asset_tag":"thisisunique17","model_id": 5,"_snipeit_application_3": "Test Application"}'
payload = '{"asset_tag":"thisisunique17","status_id": 1,"model_id": 5}'
r = A.updateDevice(server, token, "2654", payload)
print r
#!/usr/bin/env python

from snipeit import Assets

server = 'http://snipeitserver.example.com'
token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjU5MjFlNDUxZDlkZGJjNjIyOWIyZGQxYzRkNzMyMTE0MzcyZTY2YTZmMmE5NTE2ZTMyNWM2Mzg2ODNjMjdlODMyODE4YmJmM2QxNTg4MjlhIn0.eyJhdWQiOiIxIiwianRpIjoiNTkyMWU0NTFkOWRkYmM2MjI5YjJkZDFjNGQ3MzIxMTQzNzJlNjZhNmYyYTk1MTZlMzI1YzYzODY4M2MyN2U4MzI4MThiYmYzZDE1ODgyOWEiLCJpYXQiOjE1MTUxODI1OTcsIm5iZiI6MTUxNTE4MjU5NywiZXhwIjoxNTQ2NzE4NTk3LCJzdWIiOiIyMzQ2Iiwic2NvcGVzIjpbXX0.E4aHV0NQDlylBXfkfexYl2UBr043wb2suoNrLD2dSwwptIFxNyy8NSWFQxgvYtVeenIbva9dUhI_dYkY7h0W56RZW3DAoqOlzKjFUnhDU3FEqBMsI-CuiGQPwVJ5QQRIzP9VZVpypqokOf-OTZyc-ZyxyGnqz9_dqMFySYZ7EicbtpdYvWVgelK5HF4gxodeBmLm7igVSNkRm_SxHesyjVIvsefnXFF5idUWSwHBn3jXhv-Jm0fhAz8xAw7XjsXMPQXGMAkQHXYpEmobiGSJsvlVPyf4aZjB7FJVzz-1EecFOqBMAS5ZE4YUYi-DOH4YtS6JL_54UOJMeJ3gPh22f4_3yzjNoZ20_ru_O4au2yraG7INCc53XyFj2qgfh9n9eKqRJH2pTB_5jemMCVLjZRDhXA7H0pMxGr_iSlWCXcJGpXjTtW3au53zlqXxgSYtYuti_pU5rahcQWgKEyh7QGdepOa-xaXG_td5pJs2ewmW1Qw3YfFw1ryVZICnloYrGwnoIehXH_7gCBpuUx-NhlKEzhXEQlV0Vcq_btKB5M-AdPD7XSP4Y5SaTmC8B38J6h-uT5cw8XAUv0vR0NMfY9gs-JXZExTqzVcu_GIhy1v_lkeeh7Xud8ZzSlvR6zdDN3LTxh1IReHZBEX8gSh7bFsGe-bGTp40S_RbSilF_pg'

A = Assets()
r = A.delete(server, token, "2652")
print r