Skip to main content

A developer friedly iTOP API Lib for Python3

  • Support all extensions;
  • Chained methods;
  • Data manipulation with NoSQL similar style;
  • Creation and updates objects containing lookup fields;
  • Parallel methods;

Install

pip install itoptop

Usage

>>> from itoptop import Itop
>>> url = 'https://itop_server_name/webservices/rest.php'
>>> ver = '1.3'
>>> usr = 'user'
>>> pwd = 'password'
>>> data_model = 'path/to/datamodel.xml' # default is itop_folder/data/datamodel-production.xml

With Data Model

>>> itop = Itop(url, ver, usr, pwd, data_model)

Get id from Organization which code is SOMECODE

>>> query = {'code': 'SOMECODE'}
>>> projection = ['id']
>>> result = itop.Organization.find(query, projection)
'1'

Insert list of person

>>> object_list = [
>>>   {'name': 'NAME', 'first_name': 'FIRST_NAME', 'org_name': 'My Company/Department'},
>>>   {'name': 'NAME', 'first_name': 'OTHER_NAME', 'org_name': 'My Company/Department'}
>>> ]
>>> itop.Person.insert(object_list)
[
 {
  'email': '',
  'employee_number': '',
  'finalclass': 'Person',
  'first_name': 'FIRST_NAME',
  'friendlyname': 'FIRST_NAME NAME',
  'function': '',
  'id': '3',
  (...)
  'org_id': '1',
  'org_id_friendlyname': 'My Company/Department',
  'org_id_obsolescence_flag': '',
  'org_name': 'My Company/Department',
  },
 {
  'email': '',
  'employee_number': '',
  'finalclass': 'Person',
  'first_name': 'OTHER_NAME',
  'friendlyname': 'OTHER_NAME NAME',
  'function': '',
  'id': '2',
  (...)
  'org_id': '1',
  'org_id_friendlyname': 'My Company/Department',
  'org_id_obsolescence_flag': '',
  'org_name': 'My Company/Department',
 }
]

Update field first_name to FIRST_NAME and Organization relationship to My Company/Department in person where name is NAME

>>> query= {'name': 'NAME'}
>>> update = {'first_name': 'FIRST_NAME', 'org_name': 'My Company/Department'}
>>> itop.Person.update(query, update, multi=True, upsert=True)
[
 {
  'email': '',
  'employee_number': '',
  'finalclass': 'Person',
  'first_name': 'FIRST_NAME',
  'friendlyname': 'FIRST_NAME NAME',
  'function': '',
  'id': '3',
  (...)
  'org_id': '1',
  'org_id_friendlyname': 'My Company/Department',
  'org_id_obsolescence_flag': '',
  'org_name': 'My Company/Department',
  },
 {
  'email': '',
  'employee_number': '',
  'finalclass': 'Person',
  'first_name': 'FIRST_NAME',
  'friendlyname': 'OTHER_NAME NAME',
  'function': '',
  'id': '2',
  (...)
  'org_id': '1',
  'org_id_friendlyname': 'My Company/Department',
  'org_id_obsolescence_flag': '',
  'org_name': 'My Company/Department',
 }
]

Remove all persons which Name is NAME and First Name is FIRST_NAME

>>> result = itop.Person.remove({'name': 'NAME', 'first_name': 'FIRST_NAME'})
[
 {'friendlyname': 'FIRST_NAME NAME', 'id': '2'},
 {'friendlyname': 'FIRST_NAME NAME', 'id': '3'}
]

Without Data Model

>>> itop = Itop(uri, ver, usr, pwd)

Get id from Organization which code is SOMECODE

>>> query = {'code': 'SOMECODE'}
>>> projection = ['id']
>>> result = itop.schema('Organization).find(query, projection)

Insert list of person

>>> object_list = [
>>>   {'name': 'NAME', 'first_name': 'FIRST_NAME', 'org_id': 1},
>>>   {'name': 'NAME', 'first_name': 'OTHER_NAME', 'org_id': 1}
>>> ]
>>> result = itop.schema('Person').insert(object_list)

Update field first_name to FIRST_NAME and org_id to 2 of objects in person where name is NAME

>>> query= {'name': 'NAME'}
>>> update = {'first_name': 'FIRST_NAME', 'org_id': 1}
>>> result = itop.schema('Person').update(query, update, multi=True, upsert=True)

Remove all persons which Name is NAME and First Name is FIRST_NAME

>>> result = itop.schema('Person').remove({'name': 'NAME', 'first_name': 'FIRST_NAME'})

Contributing

Pull requests for new features, bug fixes, and suggestions are welcome!

License

GNU General Public License v3 (GPLv3)

Release files for itoptop 1.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for itoptop 1.0.10
File Size Uploaded
itoptop-1.0.10.tar.gz 21.0 kB Details

Release files / itoptop-1.0.10.tar.gz

Download URL itoptop-1.0.10.tar.gz
Size 21.0 kB
Tags Source
SHA-256 checksum
How to use checksums
eeda21fbd9652c07e5715c41460c513acacc8d68cfcff21fc5414d95a65e227d
BLAKE2b-256 checksum
How to use checksums
9d024c153cd1fc7820cea73e2068f0d9202aa222401ee5d1f1fcad4583eef441
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.5

Release history Release notifications | RSS feed

This release

1.0.10 This release

1 release file

1.0.8

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page