Code Examples Nov 11, 2017 Usage Here we present you the code examples of the library per API Method: initSession() killSession() getMyProfiles() getActiveProfile() changeActiveProfile() getMyEntities() getActiveEntities() changeActiveEntities() getFullSession() getItem() getAllItems() getSubItems() Examples initSession(): this is an example of how to init session using the API Client. initSessionByUserToken: in this case you only require the user token GlpiRequest.initSessionByUserToken(userToken: "L8B3f4iiNIjg8W2Kla1AXFjJsYrWxVqDozMzq2G7") { data, _, _ in self.responseAPI = [AnyObject]() self.loadResponse(endpoint: "initSession", result: self.objectToString(data as Any)) } killSession(): close the user session GlpiRequest.killSession(completion: { data, _, _ in self.responseAPI = [AnyObject]() self.loadResponse(endpoint: "killSession", result: self.objectToString(data as Any)) } getMyProfiles(): return the profiles associated to the user GlpiRequest.getMyProfiles { data, _, _ in self.loadResponse(endpoint: "getMyProfiles", result: self.objectToString(data as Any)) } getActiveProfile(): return the current active profile GlpiRequest.getActiveProfile { data, _, _ in self.loadResponse(endpoint: "getActiveProfile", result: self.objectToString(data as Any)) } changeActiveProfile(): change active profile to one of the profiles obtained with ‘getMyProfiles()’ GlpiRequest.changeActiveProfile(profileID: "4", completion: { _, _, _ in self.loadResponse(endpoint: "changeActiveProfile", result: "") }) getMyEntities(): return all the possible entities of the current logged user GlpiRequest.getMyEntities { data, _, _ in self.loadResponse(endpoint: "getMyEntities", result: self.objectToString(data as Any)) } getActiveEntities(): return active entities of current logged user GlpiRequest.getActiveEntities { data, _, _ in self.loadResponse(endpoint: "getActiveEntities", result: self.objectToString(data as Any)) } changeActiveEntities(): change active entity to one of the entities obtained with ‘getMyEntities’ GlpiRequest.changeActiveEntities(entitiesID: "0", completion: { data, _, _ in self.loadResponse(endpoint: "changeActiveEntities", result: self.objectToString(data as Any)) }) getFullSession(): return the current php $_SESSION GlpiRequest.getFullSession { data, _, _ in self.loadResponse(endpoint: "getFullSession", result: self.objectToString(data as Any)) } getItem(): return the instance fields of itemtype identified by id GlpiRequest.getItem(itemType: .Computer, itemID: 3, queryString: nil) { data, _, _ in self.loadResponse(endpoint: "getAnItem", result: self.objectToString(data as Any)) } getAllItems(): return a collection of rows of the itemtype GlpiRequest.getAllItems(itemType: .Computer, queryString: nil) { data, _, _ in self.loadResponse(endpoint: "getAllItems", result: self.objectToString(data as Any)) } getSubItems(): return a collection of rows of the sub_itemtype for the identified item GlpiRequest.getSubItems(itemType: .Computer, itemID: 3, subItemType: .ComputerModel, queryString: nil) { data, _, _ in self.loadResponse(endpoint: "getSubItems", result: self.objectToString(data as Any)) } For more information about the functions check our Code Documentation section Have feedback on this post? Let @glpi_project know on Twitter. Need help or found a bug? Contact us.