GlpiClient class Null safety

A client used to communicate with the GLPI API. To create a client you may use either GlpiClient.withLogin or GlpiClient.withToken. The former will create a client with a username and password, the latter with a user token and an app token.

Constructors

GlpiClient.withLogin(String baseUrl, String username, String password, {String? appToken})
Return a new instance of GlpiClient using the given baseUrl and credentials (username / password).
factory
GlpiClient.withToken(String baseUrl, String userToken, String appToken)
Return a new instance of GlpiClient using the given baseUrl and user_token userToken and app_token appToken. Unlike GlpiClient.withLogin, this method require an app_token to work.
factory

Properties

appToken String?
The app token used to authenticate the client. It's mandatory when using the GlpiClient.withToken constructor. Also if you have setup a AppToken within your GLPI configuration, the token will be mandatory for all your requests.
read / write
baseUrl String
The base url of the GLPI API. Example https//example.com/glpi/apirest.php/
final
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
session Future<Map<String, dynamic>>
The session data for the current GlpiClient Can be set using initSession with getFullSession parameter set to true or getFullSession If trying to get the session before calling initSession or getFullSession will throw an exception.
read-only
sessionToken String
The session token get whe using initSession. The session token is managed by the client automatically.
read-only

Methods

addItems(GlpiItemType itemType, String data) Future<List<Map<String, String>>>
Return the id(s) of the item(s) added using the data as input. Don't use this method to upload a document To correctly format the data, see the examples and the documentation. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#add-items
applyMassiveActions(GlpiItemType itemType, String massiveActionName, String payload) Future<Map<String, dynamic>>
Run the given massive action payload Must be a json string with the parameters for the action and the ids of the items to apply the action to. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#apply-massive-action
changeActiveEntities(dynamic entitiesId, {bool recursive = false}) Future<bool>
Allow to change the active entity for the current user. entitiesId can either be the numerical id of the entity or all to load all the entities. recursive can be set to true to load all the sub-entities. Will throw an Exception if the request fails or if the selected id is incorrect. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#change-active-entities
changeActiveProfile(int profilesId) Future<bool>
Change the active profile for the current user. Will throw an Exception if the request fails or if the selected id is incorrect. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#change-active-profile.
deleteItem(GlpiItemType itemType, int id, {bool forcePurge = false, bool history = true}) Future<Map<String, String>>
Return the id of the item deleted with true is the deletion is complete. forcePurge will delete the item permanently. history set to false will prevent the deletion from being added to the global history.
deleteItems(GlpiItemType itemType, String data) Future<List<Map<String, String>>>
Return the ids of the items deleted with true is the deletion is complete. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#delete-items
downloadDocument(int id) Future<String>
Allow to download a GlpiItemType.Document. id must be the id of the document to download. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#download-a-document-file
getActiveEntities() Future<Map<String, dynamic>>
Return the current active entity for the current user as a Map Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-active-entities
getActiveProfile() Future<Map<String, dynamic>>
Return the current active profile for the current user as a Map Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-active-profile
getAllItem(GlpiItemType itemType, {bool expandDropdowns = false, bool getHateoas = true, bool onlyId = false, int rangeStart = 0, int rangeLimit = 50, String sort = 'id', String order = 'ASC', String searchText = 'NULL', bool isDeleted = false, List? addKeysNames}) Future<List>
Return ALL the items of the given type the current user can see, depending on your server configuration and the number of items proceeded it may have unexpected results. GlpiItemType contains all the available item types according to the latest GLPI documentation. By default, only the 50 firts item will be returned. This can be changed by setting the rangeStart parameter and rangeLimit parameters. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-all-items
getFullSession() Future<Map<String, dynamic>>
Return the session data include in the php $_SESSION. For the moment it's just a Map of the json response. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-full-session.
getGlpiConfig() Future<Map<String, dynamic>>
Return the Glpi instance configuration data inside a Map. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-glpi-config
getItem(GlpiItemType itemtype, int id, {bool expandDropdowns = false, bool getHateoas = true, bool getSha1 = false, bool withDevices = false, bool withDisks = false, bool withSoftwares = false, bool withConnections = false, bool withNetworkPorts = false, bool withInfoComs = false, bool withContracts = false, bool withDocuments = false, bool withTickets = false, bool withProblems = false, bool withChanges = false, bool withNotes = false, bool withLogs = false, List<String>? addKeysNames}) Future<Map<String, dynamic>>
Return an item identified by the id and of type itemType Will throw an Exception if the request fails or if the selected id is incorrect. withDevices will be ignored if the itemtype isn't GlpiItemType.Computer,GlpiItemType.NetworkEquipment,GlpiItemType.Peripheral,GlpiItemType.Phone or GlpiItemType.Printer. withDisks, withSoftwares, withConnections will be ignored if the itemtype isn't GlpiItemType.Computer. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-an-item
getMassiveActionParameters(GlpiItemType itemType, String massiveActionName) Future<List<Map<String, String>>>
Show the availables parameters for a given massive action Warning: experimental endpoint, some required parameters may be missing from the returned content. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-massive-action-parameters
getMassiveActions(GlpiItemType itemType, {bool isDeleted = false}) Future<List<Map<String, String>>>
Return the availables massive actions for a given itemtype isDeleted (default false): Show specific actions for items in the trashbin Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-available-massive-actions-for-an-itemtype
getMassiveActionsItem(GlpiItemType itemType, int id) Future<List<Map<String, String>>>
Return the availables massive actions for a given itemType and id. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-available-massive-actions-for-an-item
getMultipleItems(List<Map<GlpiItemType, int>> items, {bool expandDropdowns = false, bool getHateoas = true, bool getSha1 = false, bool withDevices = false, bool withDisks = false, bool withSoftwares = false, bool withConnections = false, bool withNetworkPorts = false, bool withInfoComs = false, bool withContracts = false, bool withDocuments = false, bool withTickets = false, bool withProblems = false, bool withChanges = false, bool withNotes = false, bool withLogs = false, List<String>? addKeysNames}) Future<List<Map<String, dynamic>>>
Return multiples items from many types. You must pass a List of Map with the following structure a GlpiItemType as the key and the id of the item as the value. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-multiple-items.
getMyEntities({bool isRecursive = false}) Future<Map<String, dynamic>>
Return the entities list for the current user. Setting isRecursive to true will get the list of all the entities and sub-entities. Entities are under the key myentities Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-my-entities
getMyProfiles() Future<Map<String, dynamic>>
Return a Map of all the profil for the current user Profiles are under the key myprofiles Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-my-profiles.
getSubItems(GlpiItemType mainItemtype, int mainItemId, GlpiItemType subItemType, {bool expandDropdowns = false, bool getHateoas = true, bool onlyId = false, int rangeStart = 0, int rangeLimit = 50, String sort = 'id', String order = 'ASC', List? addKeysNames}) Future<List<Map<String, dynamic>>>
Return the sub-items of subItemType the item identified by the mainItemId and of type mainItemtype Will throw an Exception if the request fails or if the selected id is incorrect. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-sub-items
getUserProfilePicture(int id) Future<String>
Get a user's profile picture. id must be the id of the user to get the picture. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-a-users-profile-picture
initSession({bool getFullSession = false, bool sendInQuery = false}) Future<String>
Request a session token to uses other API endpoints. The token will be stored in the sessionToken field automatically and used for all the following requests. If getFullSession is set to true, will also return the session details in session. If sendInQuery is set to true, will send the credentials in the query string instead of the header. Will throw an Exception if the session can't be initialized. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#init-session.
killSession() Future<bool>
Return true if the client is successfully disconnected from the API. Will throw an Exception if the session can't be disconnected. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#kill-session.
listSearchOptions(GlpiItemType itemType) Future<Map<String, dynamic>>
Return all the searchOptions usable in searchItems criteria for a given GlpiItemType.
lostPassword(String email, {String? passwordForgetToken, String? newPassword}) Future<bool>
Allow to request a password reset for the account using the email address. Return true if the request is successful BUT this doesn't mean that your glpi is configured to send emails. Check the glpi's configuration to see the prerequisites (notifications need to be enabled). If passwordForgetToken AND newPassword are set, the password will be changed with the value of newPassword instead. Sending passwordForgetToken without newPassword and the opposite will throw an ArgumentError. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#lost-password.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
searchItems(GlpiItemType itemType, {List<GlpiSearchCriteria>? criteria, List<GlpiSearchCriteria>? metaCriteria, int sort = 1, String order = 'ASC', int rangeStart = 0, int rangeLimit = 50, List<String>? forceDisplay = const [], bool rawData = false, bool withIndexes = false, bool uidCols = false, bool giveItems = false}) Future<Map<String, dynamic>>
** This method is untested for the moment ** Return items found using the GLPI searchEngine Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#search-items
toString() String
A string representation of this object. [...]
inherited
updateItem(GlpiItemType itemType, int id, Map<String, dynamic> data) Future<Map<String, String>>
Return an arrray with the updated item id and a message. To correctly format the data, see the examples and the documentation. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#update-items
updateItems(GlpiItemType itemType, String data) Future<List<Map<String, String>>>
Return the id(s) of the item(s) updated using the data as input. To correctly format the data, see the examples and the documentation. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#update-items
uploadDocument(File file) Future<Map<String, dynamic>>
Allow to upload a GlpiItemType.Document. file must be a File object. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#upload-a-document-file

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited