You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2024-04-03 07:19:10

tobrein
Member
Registered: 2024-03-27
Posts: 5

cretae a computer asset with the full set of information with the API

Hello,

how can I create a computer asset with the full feature of inforamtion like
"Operating System", "Components", "IP Addresses" and so on , with the API with a curl command in one curl command.

E.g I can create a computer asset with the entries, shown in the first computers tab in computers:
uuid_glpi=$(uuidgen); curl -vv -u glpi:glpi -X POST -H 'Content-Type: application/json' -H "App-Token: <ID>" -H "Session-Token: <ID>" -d '{"input": [{"name": "test01","uuid": "'$uuid_glpi'" ,"serial": "'100$RANDOM'" , "locations_id": "1", "states_id": "1", "comment": "COMMENT 123", "users_id_tech": "2", "groups_id_tech":"4", "networks_id":"1", "computertypes_id":"1", "manufacturers_id":"1", "computermodels_id":"1"}] }' 'http://<glpi server>/apirest.php/Computer/' | jq

Best regards
TobRein

Offline

#2 2024-04-03 15:01:07

cconard96
Moderator
Registered: 2018-07-31
Posts: 2,807
Website

Re: cretae a computer asset with the full set of information with the API

The OS, components and IP addresses are all linked data rather than data that exists within the Computer itself. So, you need to create the data separately and then link them.

Related item types:
- OperatingSystem: The OS item
- Item_OperatingSystem: The link between an asset and an OS
- Device*: The "model" for the component (Example DeviceProcessor, DeviceMemory, etc)
- Item_Device*: The individual component which may or may not be linked to an asset. If not linked, the itemtype and items_id fields are null and 0 respectively.
IP addresses are more complicated and I am not confident enough in how everything with them and ports are related to give an answer currently.

Maybe there is a better way to do this though. You could use the GLPI Agent to automatically send inventory information to GLPI (supported natively starting in GLPI 10).


GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.

Offline

Board footer

Powered by FluxBB