GlpiClient class abstract
An abstract client which hold the common clients methods and parameters.
- Implementers
Constructors
- GlpiClient(String host, {String? appToken, String? sessionToken})
-
Create a GlpiClient .
host
is the server address, it should end with/apirest.php/
or be redirected to it.appToken
is the app token used to authenticate the client.sessionToken
is the session token used to authenticate the client which can be used from a previous session.factory
Properties
- appToken ↔ String?
-
The appToken used to authenticate the requests.
Can be set either a construction or later
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- host → String
-
The server host should either end with
apirest.php
or redirect on it.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sessionToken ↔ String?
-
The sessionToken used to authenticate the requests.
Can be stored between session and used to construct a new client without calling initSessionUserToken or initSessionUserToken.
Can be set either a construction or later
getter/setter pair
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 orall
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 firsts item will be returned. This can be changed by setting the
rangeStart
parameter andrangeLimit
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 typeitemType
Will throw an Exception if the request fails or if the selected id is incorrect.withDevices
will be ignored if theitemtype
isn't GlpiItemType.Computer,GlpiItemType.NetworkEquipment,GlpiItemType.Peripheral,GlpiItemType.Phone or GlpiItemType.Printer.withDisks
,withSoftwares
,withConnections
will be ignored if theitemtype
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 awaitables 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 available massive actions for a given
itemtype
isDeleted
(default false): Show specific actions for items in the trash bin 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 awaitables massive actions for a given
itemType
andid
. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-available-massive-actions-for-an-item -
getMultipleItems(
List< Map< 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<GlpiItemType, int> >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 keymyentities
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 profile for the current user Profiles are under the keymyprofiles
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 themainItemId
and of typemainItemtype
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 -
initSessionUsernamePassword(
String username, String password, {bool getFullSession = false, bool sendInQuery = false}) → Future< Map< String, dynamic> > -
Request a session token to uses other API endpoints using a
username
andpassword
. IfgetFullSession
is set to true, will also return the session details in session. IfsendInQuery
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. -
initSessionUserToken(
String userToken, {bool getFullSession = false, bool sendInQuery = false}) → Future< Map< String, dynamic> > -
Request a session token to uses other API endpoints using a
userToken
. IfgetFullSession
is set to true, will also return the session details in session. IfsendInQuery
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 search 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). IfpasswordForgetToken
ANDnewPassword
are set, the password will be changed with the value ofnewPassword
instead. SendingpasswordForgetToken
withoutnewPassword
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 nonexistent method or property is accessed.
inherited
-
search(
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 array 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(
covariant dynamic file) → Future< Map< String, dynamic> > -
Allow to upload a GlpiItemType.Document.
file
must be a File object. Unsupported on the web. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#upload-a-document-file
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited