File tree Expand file tree Collapse file tree 4 files changed +16
-17
lines changed
Expand file tree Collapse file tree 4 files changed +16
-17
lines changed Original file line number Diff line number Diff line change 66
77- SQL error when merging the Jamf device linked to a GLPI asset
88- SQL error when adding ` Event `
9+ - Fix ` Computer ` merge process
910
1011## [ 3.1.1]
1112
Original file line number Diff line number Diff line change 7777 $ plugin_sync_itemtype = 'PluginJamfMobileSync ' ;
7878 }
7979
80- $ jamf_item = PluginJamfAPI::getMobileDeviceByID ($ jamf_id , true );
80+ if ($ data ['jamf_type ' ] === 'MobileDevice ' ) {
81+ $ jamf_item = PluginJamfAPI::getMobileDeviceByID ($ jamf_id , true );
82+ } else {
83+ $ jamf_item = PluginJamfAPI::getComputerByID ($ jamf_id , true );
84+ }
85+
8186 if ($ jamf_item === null ) {
8287 // API error or device no longer exists in Jamf
8388 throw new RuntimeException ('Jamf API error or item no longer exists! ' );
8792 $ rules = new PluginJamfRuleImportCollection ();
8893
8994 //WTF is this, Jamf?
90- $ os_details = $ jamf_item ['ios ' ] ?? $ jamf_item ['tvos ' ];
95+ $ os_details = $ jamf_item ['ios ' ] ?? $ jamf_item ['tvos ' ] ?? '' ;
9196 $ ruleinput = [
92- 'name ' => $ jamf_item ['name ' ],
97+ 'name ' => $ jamf_item ['name ' ] ?? $ jamf_item [ ' general ' ][ ' name ' ] ,
9398 'itemtype ' => $ itemtype ,
94- 'last_inventory ' => $ jamf_item ['lastInventoryUpdateTimestamp ' ],
99+ 'last_inventory ' => $ jamf_item ['lastInventoryUpdateTimestamp ' ] ?? $ jamf_item [ ' general ' ][ ' lastContactTime ' ] ,
95100 'managed ' => $ jamf_item ['managed ' ] ?? $ os_details ['managed ' ],
96101 'supervised ' => $ jamf_item ['supervised ' ] ?? $ os_details ['supervised ' ],
97102 ];
Original file line number Diff line number Diff line change @@ -496,21 +496,14 @@ public static function getAllComputers()
496496 return $ all_results ;
497497 }
498498
499- public static function getComputerByID (int $ id , ? string $ section = null ): ? array
499+ public static function getComputerByID (int $ id , bool $ detailed = false )
500500 {
501501 if (!static ::$ connection ) {
502502 static ::$ connection = new static::$ connection_class ();
503503 }
504- $ endpoint = "/v1/computer-inventory " ;
505- $ query_params = [
506- 'section ' => $ section ,
507- 'filter ' => 'id== ' . $ id
508- ];
509- $ response = static ::$ connection ->getClient ()->get (static ::$ connection ->getAPIUrl ($ endpoint , true ) . '? ' . http_build_query ($ query_params ));
510- $ result = json_decode ($ response ->getBody ()->getContents (), true );
511- if (isset ($ result ['results ' ]) && count ($ result ['results ' ]) > 0 ) {
512- return $ result ['results ' ][0 ];
513- }
514- return null ;
504+ $ endpoint = "/v1/computer-inventory " . ($ detailed ? '-detail ' : '' ) . "/ {$ id }" ;
505+ $ response = static ::$ connection ->getClient ()->get (static ::$ connection ->getAPIUrl ($ endpoint , true ));
506+ return json_decode ($ response ->getBody ()->getContents (), true );
515507 }
508+
516509}
Original file line number Diff line number Diff line change @@ -575,7 +575,7 @@ public function apply_3_0_0_migration(): void
575575 }
576576 } else if ($ device ['jamf_type ' ] === 'Computer ' ) {
577577 // We need to query the JSS for the computer's model identifier
578- $ computer = $ this ->api ::getComputerByID ($ device ['jamf_items_id ' ], ' hardware ' );
578+ $ computer = $ this ->api ::getComputerByID ($ device ['jamf_items_id ' ], true );
579579 if ($ computer !== null ) {
580580 $ this ->db ->update (
581581 'glpi_plugin_jamf_devices ' ,
You can’t perform that action at this time.
0 commit comments