Compare commits
3 Commits
123d7d1ecf
...
1.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c780c30533 | ||
| c023fd3c10 | |||
| e8a8f31ea6 |
@@ -10,7 +10,7 @@ jobs:
|
|||||||
uses: actions/checkout@main
|
uses: actions/checkout@main
|
||||||
- name: Building the package
|
- name: Building the package
|
||||||
run: |
|
run: |
|
||||||
mv ${{ gitea.workspace }}\GLPIAPI.py ${{ gitea.workspace }}\build\src\GLPIAPI\
|
powershell mv ${{ gitea.workspace }}\GLPIAPI.py ${{ gitea.workspace }}\build\src\GLPIAPI\
|
||||||
cd ${{ gitea.workspace }}\build
|
cd ${{ gitea.workspace }}\build
|
||||||
python -m build
|
python -m build
|
||||||
- name: Publish package
|
- name: Publish package
|
||||||
|
|||||||
21
GLPIAPI.py
21
GLPIAPI.py
@@ -127,7 +127,26 @@ class GLPIAPI:
|
|||||||
"user-agent":self.UserAgent
|
"user-agent":self.UserAgent
|
||||||
}
|
}
|
||||||
return requests.post(self.Server, headers=headers, data=inventory)
|
return requests.post(self.Server, headers=headers, data=inventory)
|
||||||
|
|
||||||
|
def SetField(self, itemType, itemId, data):
|
||||||
|
'''Modify fields of a GLPI item.
|
||||||
|
Input must be a dict formatted like this :
|
||||||
|
{
|
||||||
|
"fieldName1": "fieldValue1",
|
||||||
|
"fieldName2": "fieldValue2",
|
||||||
|
...
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
body = {
|
||||||
|
"input" : {
|
||||||
|
"id" : itemId,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
body["input"] = {**body["input"], **data}
|
||||||
|
|
||||||
|
uri = f"{self.Server}/apirest.php/{itemType}/"
|
||||||
|
return requests.put(uri, headers=self.Headers, json=body)
|
||||||
|
|
||||||
def UpdateSerialNumber(self, deviceid, serialnumber):
|
def UpdateSerialNumber(self, deviceid, serialnumber):
|
||||||
|
|
||||||
body = {
|
body = {
|
||||||
@@ -150,7 +169,7 @@ class GLPIAPI:
|
|||||||
uri = f"{self.Server}/apirest.php/Computer/"
|
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 SetField(self, itemType, containerName, containerID, itemId, fieldName, data):
|
def SetCustomField(self, itemType, containerName, containerID, itemId, fieldName, data):
|
||||||
'''Requires fields plugin on GLPI server
|
'''Requires fields plugin on GLPI server
|
||||||
- containerName is block label name
|
- containerName is block label name
|
||||||
- containerID is block id
|
- containerID is block id
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "GLPIAPI"
|
name = "GLPIAPI"
|
||||||
version = "1.0.0"
|
version = "1.0.2"
|
||||||
description = "A module python to make it easier to use GLPI API"
|
description = "A module python to make it easier to use GLPI API"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.7"
|
requires-python = ">=3.7"
|
||||||
|
|||||||
1
build/src/GLPIAPI/__init__.py
Normal file
1
build/src/GLPIAPI/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
__all__ = ["GLPIAPI"]
|
||||||
Reference in New Issue
Block a user