Fix MAJ GLPI magenta link
This commit is contained in:
@@ -112,14 +112,34 @@ class GLPIAPI:
|
|||||||
return requests.put(uri, headers=self.Headers, json=body)
|
return requests.put(uri, headers=self.Headers, json=body)
|
||||||
|
|
||||||
def UpdateAirwatchLink(self, deviceid, airwatchlink):
|
def UpdateAirwatchLink(self, deviceid, airwatchlink):
|
||||||
|
uri = f"{self.Server}/apirest.php/PluginFieldsComputermdt"
|
||||||
|
searchURI = f"{self.Server}/apirest.php/PluginFieldsComputermdt?range=0-999999999"
|
||||||
|
result = requests.get(searchURI, headers=self.Headers)
|
||||||
|
if(result.status_code == 200):
|
||||||
|
result = result.json()
|
||||||
|
fieldItem = None
|
||||||
|
# searching for field item
|
||||||
|
for entry in result:
|
||||||
|
if str(entry["items_id"]) == deviceid:
|
||||||
|
fieldItem = entry
|
||||||
|
|
||||||
|
if(fieldItem == None):
|
||||||
body = {
|
body = {
|
||||||
"input": {
|
"input": {
|
||||||
"id": deviceid,
|
"items_id": deviceid,
|
||||||
|
"itemtype": "Computer",
|
||||||
|
"plugin_fields_containers_id": 4,
|
||||||
|
"appareilsurmagentafield": airwatchlink
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return requests.post(uri, headers=self.Headers, json=body)
|
||||||
|
else:
|
||||||
|
body = {
|
||||||
|
"input": {
|
||||||
|
"id": fieldItem["id"],
|
||||||
"appareilsurmagentafield": airwatchlink
|
"appareilsurmagentafield": airwatchlink
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uri = f"{self.Server}/apirest.php/Computer/"
|
|
||||||
return requests.put(uri, headers=self.Headers, json=body)
|
return requests.put(uri, headers=self.Headers, json=body)
|
||||||
|
|
||||||
def CreateInventoryForAirwatchDevice(self, device, deviceName, apps=None):
|
def CreateInventoryForAirwatchDevice(self, device, deviceName, apps=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user