Search code examples
wgetproduct-management

Itop export csv of functional CIs with wget / link


I want to export all the Functional CIs from a Specific Person. In the web-interface I can just click the wrench-icon and click export to csv, but when I try to do this with a link, it gets a bit more complicated. basically I'm trying to download this View:
enter image description here or in text:

"FunctionalCI->Typ","FunctionalCI->Name","ID (Primärer Schlüssel)","Voller Name (Friendly Name)","Kontakt","Kontakt->Name","Kontakt->Voller Name (Friendly Name)","Kontakt->Typ","Kontakt->Obsolet","Kontakt->Organisation","Kontakt->Organisation","Kontakt->Email"
"Peripheriegerät","USBKI08018",3747,"3090 795",795,"Sample","Ex Sample","Person",Nein,6,"oragnisation","[email protected]"
"PC","FUJIQ58003",3395,"3837 795",795,"Sample","Ex Sample","Person",Nein,6,"oragnisation","[email protected]"
"Peripheriegerät","M056-1907",3432,"3898 795",795,"Sample","Ex Sample","Person",Nein,6,"oragnisation","[email protected]"
"Peripheriegerät","YUBIKEY013",3632,"3990 795",795,"Sample","Ex Sample","Person",Nein,6,"oragnisation","[email protected]"
"Peripheriegerät","MSDOCK102",4900,"4555 795",795,"Sample","Ex Sample","Person",Nein,6,"oragnisation","[email protected]"
"PC","MSSURL348",4895,"4663 795",795,"Sample","Ex Sample","Person",Nein,6,"oragnisation","[email protected]"
"Peripheriegerät","HEADSET431",6072,"5764 795",795,"Sample","Ex Sample","Person",Nein,6,"oragnisation","[email protected]"

I have tried multiple OQL's, but I can't get the user to link with its CIs. This is what I have tried:

https://itop.tirvers.at/itop/webservices/export-v2.php?expression=SELECT Person WHERE Person.friendlyname LIKE 'Ex Sample%'&fields=friendlyname, name, status, id&format=csv

This link actually works, but it only gives me more information about the person, which is not what I need. The next thing I tried was:

https://itop.tirvers.at/itop/webservices/export-v2.php?expression=SELECT FunctionalCI WHERE FunctionalCI.name LIKE 'FUJIQ58003%'&fields=id&format=csv

which also works, but, again, only yields more information about the FunctionalCI, which is not what I need.

With a bit of tinkering I got all the classes of the Server:

AsyncTask, AsyncSendEmail, DBProperty, CMDBChange, CMDBChangeOp, CMDBChangeOpCreate, 
CMDBChangeOpDelete, CMDBChangeOpSetAttribute, CMDBChangeOpSetAttributeScalar,
CMDBChangeOpSetAttributeTagSet, CMDBChangeOpSetAttributeURL, CMDBChangeOpSetAttributeBlob, 
CMDBChangeOpSetAttributeOneWayPassword, CMDBChangeOpSetAttributeEncrypted,
CMDBChangeOpSetAttributeText, CMDBChangeOpSetAttributeLongText, CMDBChangeOpSetAttributeHTML, 
CMDBChangeOpSetAttributeCaseLog, CMDBChangeOpPlugin, CMDBChangeOpSetAttributeLinks,
CMDBChangeOpSetAttributeLinksAddRemove, CMDBChangeOpSetAttributeLinksTune, 
CMDBChangeOpSetAttributeCustomFields, AuditCategory, AuditRule, Query, QueryOQL, 
ModuleInstallation, ExtensionInstallation,
UserDashboard, Shortcut, ShortcutOQL, appUserPreferences, User, UserInternal, Event, 
EventNotification, EventNotificationEmail, EventIssue, EventWebService, EventRestService, 
EventLoginUsage,
EventOnObject, Action, ActionNotification, ActionEmail, Trigger, TriggerOnObject, 
TriggerOnPortalUpdate, TriggerOnStateChange, TriggerOnStateEnter, TriggerOnStateLeave, 
TriggerOnObjectCreate,
TriggerOnObjectDelete, TriggerOnObjectUpdate, lnkTriggerAction, TriggerOnThresholdReached, 
BulkExportResult, iTopOwnershipToken, TagSetFieldData, SynchroDataSource, SynchroAttribute, 
SynchroAttExtKey,
SynchroAttLinkSet, SynchroLog, SynchroReplica, BackgroundTask, InlineImage, KeyValueStore, 
UserExternal, UserLDAP, UserLocal, EmailReplica, TriggerOnMailUpdate, MailInboxBase, 
Attachment,
CMDBChangeOpAttachmentAdded, CMDBChangeOpAttachmentRemoved, Organization, Location, Contact, 
Person, Team, Document, DocumentFile, DocumentNote, DocumentWeb, FunctionalCI, PhysicalDevice,
ConnectableCI, DatacenterDevice, NetworkDevice, Server, ApplicationSolution, BusinessProcess, 
SoftwareInstance, Middleware, DBServer, WebServer, PCSoftware, OtherSoftware, 
MiddlewareInstance,
DatabaseSchema, WebApplication, Software, Patch, OSPatch, SoftwarePatch, Licence, OSLicence, 
SoftwareLicence, lnkDocumentToLicence, Typology, OSVersion, OSFamily, DocumentType, 
ContactType,
Brand, Model, NetworkDeviceType, IOSVersion, lnkDocumentToPatch, 
lnkSoftwareInstanceToSoftwarePatch, lnkFunctionalCIToOSPatch, lnkDocumentToSoftware, 
lnkContactToFunctionalCI,
lnkDocumentToFunctionalCI, Subnet, VLAN, lnkSubnetToVLAN, NetworkInterface, IPInterface, 
PhysicalInterface, lnkPhysicalInterfaceToVLAN, lnkConnectableCIToNetworkDevice,
lnkApplicationSolutionToFunctionalCI, lnkApplicationSolutionToBusinessProcess, l 
InkPersonToTeam, Group, lnkGroupToCI, Rack, Enclosure, PowerConnection, PowerSource, PDU, PC, 
Printer,
TelephonyCI, Phone, MobilePhone, IPPhone, Tablet, Peripheral, MailInboxStandard, 
StorageSystem, SANSwitch, TapeLibrary, NAS, FiberChannelInterface, Tape, NASFileSystem, 
LogicalVolume,
lnkServerToVolume, lnkSanToDatacenterDevice, Ticket, lnkContactToTicket, 
lnkFunctionalCIToTicket, WorkOrder, VirtualDevice, VirtualHost, Hypervisor, Farm, 
VirtualMachine, LogicalInterface,
AbstractResource, ResourceAdminMenu, ResourceRunQueriesMenu, ResourceSystemMenu, 
lnkVirtualDeviceToVolume, Change, RoutineChange, ApprovedChange, NormalChange, 
EmergencyChange, Incident,
KnownError, lnkErrorToFunctionalCI, lnkDocumentToError, FAQ, TagSetFieldDataFor_FAQ__domains, 
FAQCategory, Problem, UserRequest, ContractType, Contract, CustomerContract, ProviderContract,
lnkContactToContract, lnkContractToDocument, lnkFunctionalCIToProviderContract, ServiceFamily, 
Service, lnkDocumentToService, lnkContactToService, ServiceSubcategory, SLA, SLT, lnkSLAToSLT,
lnkCustomerContractToService, lnkProviderContractToService, lnkFunctionalCIToService, 
DeliveryModel, lnkDeliveryModelToContact, CoverageWindowInterval, Holiday, HolidayCalendar,
CoverageWindow, URP_Profiles, URP_UserProfile, URP_UserOrg

as well as the Person filter codes:

finalclass, friendlyname, obsolescence_flag, name, status, org_id, org_id_friendlyname, 
org_id_obsolescence_flag, org_name, email, phone, notify, function, first_name, employee_number,
mobile_phone, location_id, location_id_friendlyname, location_id_obsolescence_flag, 
location_name, manager_id, manager_id_friendlyname, manager_id_obsolescence_flag, 
manager_name, obsolescence_date, id

and the FunctionalCI filter codes:

finalclass, friendlyname, obsolescence_flag, obsolescence_date, name, description, org_id, org_id_friendlyname, org_id_obsolescence_flag, organization_name, business_criticity, move2production, id

And this is the Web-view of a Person:

enter image description here

I don't know if this information is helpful, but it's all I've got. The downloaded information (csv) would then be processed with python and exported to pdf.

I'm new to Itop-OQL and everything I know about it is from this page: https://www.itophub.io/wiki/page?id=2_4_0%3Aoql%3Aexample. I'm sorry if I made some stupid mistakes or the solution to this problem is super simple!


Solution

  • Context

    Functional CIs of a Person are represented as an "indirect linkedset" in iTop, which means that there is an intermediate class in between to store the relation and any data that it would contain (eg. the "role" in the Person / Team link).

    The class corresponding to this specific link is named lnkContactToFunctionalCI, you can find it in the "Datamodel viewer" (here is what it looks like on the online demo, use admin/admin credentials) which is in the "Administration" menu. It displays all classes linked to a specific class.

    Solution

    You should try with an OQL query like SELECT lnkContactToFunctionalCI WHERE contact_id_friendlyname LIKE 'Ex Sample%'