3030# _snipeit_custom_name_1234567890 = subset jamf_key
3131#
3232# A list of valid subsets are:
33- version = "1.0.1 "
33+ version = "1.0.2 "
3434
3535validsubset = [
3636 "general" ,
@@ -813,12 +813,9 @@ for jamf_type in jamf_types:
813813 if jamf_type == 'mobile_devices' :
814814 logging .debug ("Payload is being made for a mobile device" )
815815 newasset = {'asset_tag' : jamf_asset_tag , 'model_id' : modelnumbers ['{}' .format (jamf ['general' ]['model_identifier' ])], 'name' : jamf ['general' ]['name' ], 'status_id' : defaultStatus ,'serial' : jamf ['general' ]['serial_number' ]}
816- logging .debug (newasset )
817- new_snipe_asset = create_snipe_asset (newasset )
818816 elif jamf_type == 'computers' :
819817 logging .debug ("Payload is being made for a computer" )
820818 newasset = {'asset_tag' : jamf_asset_tag ,'model_id' : modelnumbers ['{}' .format (jamf ['hardware' ]['model_identifier' ])], 'name' : jamf ['general' ]['name' ], 'status_id' : defaultStatus ,'serial' : jamf ['general' ]['serial_number' ]}
821- new_snipe_asset = create_snipe_asset (newasset )
822819 else :
823820 for snipekey in config ['{}-api-mapping' .format (jamf_type )]:
824821 jamfsplit = config ['{}-api-mapping' .format (jamf_type )][snipekey ].split ()
@@ -840,21 +837,14 @@ for jamf_type in jamf_types:
840837 newasset [snipekey ] = jamf_value
841838 except KeyError :
842839 continue
843- # Reset the payload without the asset_tag if auto_incrementing flag is set.
840+ # Reset the payload without the asset_tag if auto_incrementing flag is set.
844841 if user_args .auto_incrementing :
845842 newasset .pop ('asset_tag' , None )
846- new_snipe_asset = create_snipe_asset (newasset )
847- logging .debug (new_snipe_asset )
848- if new_snipe_asset [0 ] != "AssetCreated" :
849- continue
843+ new_snipe_asset = create_snipe_asset (newasset )
844+ logging .debug (new_snipe_asset )
845+ if new_snipe_asset [0 ] != "AssetCreated" :
846+ continue
850847 if user_args .users or user_args .users_force or user_args .users_inverse :
851- jamfsplit = config ['user-mapping' ]['jamf_api_field' ].split ()
852- if jamfsplit [1 ] not in jamf [jamfsplit [0 ]]:
853- logging .info ("Couldn't find {} for this device in {}, not checking it out." .format (jamfsplit [1 ], jamfsplit [0 ]))
854- continue
855- logging .info ('Checking out new item {} to user {}' .format (jamf ['general' ]['name' ], jamf ['{}' .format (jamfsplit [0 ])]['{}' .format (jamfsplit [1 ])]))
856- checkout_snipe_asset (jamf ['{}' .format (jamfsplit [0 ])]['{}' .format (jamfsplit [1 ])],new_snipe_asset [1 ].json ()['payload' ]['id' ], "NewAsset" )
857-
858848 # Log an error if there's an issue, or more than once match.
859849 elif snipe == 'MultiMatch' :
860850 logging .warning ("WARN: You need to resolve multiple assets with the same serial number in your inventory. If you can't find them in your inventory, you might need to purge your deleted records. You can find that in the Snipe Admin settings. Skipping serial number {} for now." .format (jamf ['general' ]['serial_number' ]))
@@ -948,4 +938,4 @@ for jamf_type in jamf_types:
948938 update_jamf_mobiledevice_asset_tag ("{}" .format (jamf ['general' ]['id' ]), '{}' .format (snipe ['rows' ][0 ]['asset_tag' ]))
949939 logging .info ("Device is a mobile device, updating the mobile device record" )
950940
951- logging .debug ('Total amount of API calls made: {}' .format (api_count ))
941+ logging .debug ('Total amount of API calls made: {}' .format (api_count ))
0 commit comments