idoit_api_client package¶
Submodules¶
idoit_api_client.cli module¶
Console script for idoit_api_client.
idoit_api_client.cmdbcategory module¶
Requests for API namespace ‘cmdb.category’
- class idoit_api_client.cmdbcategory.CMDBCategory(api)[source]¶
Bases:
RequestCMDBCategories class for i-doit API client.
- archive(object_id, category_const, entry_id)[source]¶
Archive entry in a multi-value category for a specific object.
- Parameters:
object_id – Object identifier
category_const – Category constant
entry_id – Entry identifier
- batch_create(object_ids, category_const, attributes)[source]¶
Create multiple entries for a specific category and one or more objects.
:param object_ids List of object identifiers as integers :param category_const Category constant :param attributes Indexed array of attributes as key-value pairs
:return List of entry identifiers as integers
- batch_update(object_ids, category_const, attributes)[source]¶
Update single-value category for one or more objects.
:param object_ids List of object identifiers as integers :param category_const Category constant :param attributes Attributes as key-value pairs
:return returns itself
- create(object_id, category_const, attributes)[source]¶
Create new category entry for a specific object.
Suitable for multi-value categories only.
- Parameters:
object_id – Object identifier
category_const – Category constant
attributes – Attributes as key-value pairs
- Returns:
Entry identifier
- delete(object_id, category_const, entry_id)[source]¶
Mark entry in a multi-value category for a specific object as deleted.
- Parameters:
object_id – Object identifier
category_const – Category constant
entry_id – Entry identifier
:return returns itself
- purge(object_id, category_const, entry_id)[source]¶
Purge entry in a single- or multi-value category for a specific object.
- Parameters:
object_id – Object identifier
category_const – Category constant
entry_id – Entry identifier (only needed for multi-valued categories)
:return returns itself
- quick_purge(object_id, category_const, entry_id)[source]¶
Purge entry in a multi-value category for a specific object.
- Parameters:
object_id – Object identifier
category_const – Category constant
entry_id – Entry identifier
:return returns itself
- read(object_id, category_const, status=2)[source]¶
Read one or more category entries for a specific object (works with both single- and multi-valued categories).
- Parameters:
object_id – Object identifier
category_const – Category constant
status – (Optional) Filter entries by status: 2 = normal; 3 = archived; 4 = deleted; -1 = combination of all; defaults to: 2 = normal; note: a status != 2 is only suitable for multi-value categoriesd
- Returns:
Indexed array of result sets (for both single- and multi-valued categories)
- read_first(object_id, category_const)[source]¶
Read first category entry for a specific object (works with both single- and multi-valued categories).
- Parameters:
object_id – Object identifier
category_const – Category constant
- Returns:
Associative array, otherwise empty array when there is no entry
- read_one_by_id(object_id, category_const, entry_id, status=2)[source]¶
Read one category entry for a specific object (works with both single- and multi-valued categories).
- Parameters:
object_id – Object identifier
category_const – Category constant
entry_id – Entry identifier
status – (Optional) Filter entries by status: 2 = normal; 3 = archived; 4 = deleted; -1 = combination of all; defaults to: 2 = normal; note: a status != 2 is only suitable for multi-value categories
- Returns:
Associative array
- recycle(object_id, category_const, entry_id)[source]¶
Restore entry in a multi-value category for a specific object to “normal” state
- Parameters:
object_id – Object identifier
category_const – Category constant
entry_id – Entry identifier
:return returns itself
- save(object_id, category_constant, attributes, entry_id=None)[source]¶
Create new or update existing category entry for a specific object.
Suitable for single- and multi-value categories.
- Parameters:
object_id – Object identifier
category_constant – Category constant
attributes – Attributes as key-value pairs
entry_id – Entry identifier (only needed for multi-valued categories)
- update(object_id, category_const, attributes, entry_id=None)[source]¶
Update category entry for a specific object.
- Parameters:
object_id – Object identifier
category_const – Category constant
attributes – Attributes as key-value pairs
entry_id – Entry identifier (only needed for multi-valued categories)
:return returns itself
idoit_api_client.cmdbcategoryinfo module¶
- class idoit_api_client.cmdbcategoryinfo.CMDBCategoryInfo(api)[source]¶
Bases:
RequestRequests for API namespace ‘cmdb.category_info’.
- batch_read(categories)[source]¶
Fetches information about one or more categories.
- Parameters:
categories – List of category constants as strings
- Returns:
Indexed array of associative arrays
- get_virtual_category_constants()[source]¶
Get list of constants for virtual categories
“Virtual” means these categories have no attributes to call.
:return array Array of strings
idoit_api_client.cmdbobject module¶
CMDBObject class for i-doit API client.
- class idoit_api_client.cmdbobject.CMDBObject(api)[source]¶
Bases:
RequestCMDBObject class for i-doit API client.
- create(type, title, attributes={})[source]¶
Create a new object.
- Parameters:
type – Object type identifier or its constant
title – Object title
attributes – (Optional) additional common attributes: - category - cmdb_status - defaultTemplate - description - purpose - status - sysid
- Returns:
Object identifier
- create_with_categories(type, title, categories={}, attributes={})[source]¶
Create new object with category entries.
- Parameters:
type – Object type identifier or its constant
title – Object title
categories – Also create category entries Set category constant (string) as key and one (array of attributes) entry or even several entries (array of arrays) as value
attributes – (Optional) additional common attributes: - category - cmdb_status - defaultTemplate - description - purpose - status - sysid
- Returns:
Result with object identifier(‘id’) and key-value pairs of category constants and array of category entry identifiers as integers
- delete(object_id)[source]¶
Mark object as deleted (it’s still available)
- Parameters:
object_id – Object identifier
- load(object_id)[source]¶
Load all data about object
- Parameters:
object_id – Object identifier
- Returns:
Multi-dimensional array
- mark_as_mass_change_template(object_id)[source]¶
Convert object to mass change template
Works only for “normal objects” and “templates”
- Parameters:
object_id – Object identifier
- mark_as_template(object_id)[source]¶
Convert object to template
Works only for “normal objects” and “mass change templates”
- Parameters:
object_id – Object identifier
- purge(object_id)[source]¶
Purge object (delete it irrevocable)
- Parameters:
object_id – Object identifier
- read(id)[source]¶
Read common information about object
- Parameters:
id – Object identifier
- Returns:
Object information
- read_all(object_id)[source]¶
Read all information about object including category entries
- Parameters:
object_id – OObject identifier
:return:Multi-dimensional array
- recycle(object_id)[source]¶
Restore object to “normal” status
Works with archived and deleted objects, templates and mass change templates
- Parameters:
object_id – Object identifier
- update(object_id, attributes)[source]¶
Update common information about object
- Parameters:
id – Object identifier
attributes – (Optional) common attributes (only ‘title’ is supported at the moment)
- upsert(type, title, attributes={})[source]¶
Create new object or fetch existing one based on its title and type.
- Parameters:
type – Object type identifier or its constant
title – Object title
attributes – (Optional) additional common attributes (‘category’, ‘purpose’, ‘cmdb_status’, ‘description’)
:return Object identifier
idoit_api_client.cmdbobjects module¶
Requests for API namespace ‘cmdb.objects’.
- class idoit_api_client.cmdbobjects.CMDBObjects(api)[source]¶
Bases:
Request- SORT_ASCENDING = 'asc'¶
- SORT_DESCENDING = 'desc'¶
- create(objects)[source]¶
Create one or more objects
- :param list objects Mandatory attributes (‘type’, ‘title’) and optional attributes
(‘category’, ‘purpose’, ‘cmdb_status’, ‘description’)
:return array List of object identifiers
- get_id(title, type=None)[source]¶
Fetch an object identifier by object title and (optional) type.
:param str title Object title :param str type (Optional) type constant
:return int Object identifier
- read(filter={}, limit=None, offset=None, order_by=None, sort=None, categories=None)[source]¶
Fetch objects.
- :param dict filter (Optional) Filter; use any combination of ‘ids’ (array of object identifiers),
‘type’ (object type identifier), ‘type_group’, ‘status’, ‘title’ (object title), ‘type_title’ (l10n object type title), ‘location’, ‘sysid’, ‘first_name’, ‘last_name’, ‘email’
:param int limit (Optional) Limit result set :param int offset Offset :param str order_by Order result set by ‘isys_obj_type__id’, ‘isys_obj__isys_obj_type__id’, ‘type’, ‘isys_obj__title’, ‘title’, ‘isys_obj_type__title’, ‘type_title’, ‘isys_obj__sysid’, ‘sysid’, ‘isys_cats_person_list__first_name’, ‘first_name’, ‘isys_cats_person_list__last_name’, ‘last_name’, ‘isys_cats_person_list__mail_address’, ‘email’, ‘isys_obj__id’, ‘id’ :param str sort Sort ascending (‘ASC’) or descending (‘DESC’) :param bool|array categories Also fetch category entries; add a list of category constants as array of strings or true for all assigned categories, otherwise false for none; defaults to false
:return list Indexed array of associative arrays
- read_by_ids(object_ids, categories=None)[source]¶
Fetch objects by their identifiers.
:param list object_ids List of object identifiers as integers :param bool|array categories Also fetch category entries; add a list of category constants as array of strings or true for all assigned categories, otherwise false for none; defaults to false
:return list Indexed array of associative arrays
- read_by_type(object_type, categories=None)[source]¶
Fetch objects by their object type
:param int object_type Object type identifier :param bool|array categories Also fetch category entries; add a list of category constants as array of strings or true for all assigned categories, otherwise false for none; defaults to false
:return list Indexed array of associative arrays
idoit_api_client.cmdbobjecttypecategories module¶
- class idoit_api_client.cmdbobjecttypecategories.CMDBObjectTypeCategories(api)[source]¶
Bases:
RequestRequests for API namespace ‘cmdb.object_type_categories’
- batch_read_by_const(object_type_consts)[source]¶
Fetches assigned categories for one or more objects types at once identified by their constants.
- Parameters:
object_type_consts – List of object types constants as strings
- Returns:
Array
- batch_read_by_id(object_type_ids)[source]¶
Fetches assigned categories for one or more objects types at once identified by their identifiers.
- Parameters:
object_type_ids – List of object types identifiers as integers
- Returns:
Array
idoit_api_client.cmdbobjecttypes module¶
Requests for API namespace ‘cmdb.object_types
- class idoit_api_client.cmdbobjecttypes.CMDBObjectTypes(api)[source]¶
Bases:
RequestRequests for API namespace ‘cmdb.object_types’
- batch_read(object_types)[source]¶
Fetches information about multiple object types by their constants.
- Parameters:
object_types – Array of object type constants
- Returns:
Array of object type information
Module contents¶
Top-level package for i-doit API Client for Python.
- class idoit_api_client.API(config)[source]¶
Bases:
objectAPI client
- batch_request(requests)[source]¶
Sends batch request to API
- Args:
requests: List of requests
- Returns:
Result of request
- get_last_request_content()[source]¶
Returns the content of the last request
This is the last content which was sent as a request. This may be very useful for debugging.
- Returns:
dict: Last request content
- get_last_response()[source]¶
Returns the last response
This is the last response which was received from the server. This may be very useful for debugging.
- Returns:
dict: Last response
- class idoit_api_client.Constants[source]¶
Bases:
objectConfiguration: URL
- BYPASS_SECURE_CONNECTION = 'bypassSecureConnection'¶
- CURLPROTO_HTTP = 1¶
- CURLPROTO_HTTPS = 2¶
- KEY = 'key'¶
Configuration: Username
- LANGUAGE = 'language'¶
Configuration: Proxy settings
- PASSWORD = 'password'¶
Configuration: Language
- PORT = 'port'¶
Lowest allowed port number:
- PORT_MAX = 65535¶
Configuration: API key
- PORT_MIN = 1¶
Highest allowed port number
- PROXY = 'proxy'¶
Configuration: Activate proxy settings?
- PROXY_ACTIVE = 'active'¶
Configuration: Proxy type
- PROXY_HOST = 'host'¶
Configuration: Proxy port
- PROXY_PASSWORD = 'password'¶
Configuration: Disable security-related cURL options
- PROXY_PORT = 'port'¶
Configuration: Proxy username
- PROXY_TYPE = 'type'¶
HTTP proxy
- PROXY_TYPE_HTTP = 'HTTP'¶
SOCKS5 proxy
- PROXY_TYPE_SOCKS5 = 'SOCKS5'¶
Configuration: Proxy host
- PROXY_USERNAME = 'username'¶
Configuration: Proxy password
- URL = 'url'¶
Configuration: Port
- USERNAME = 'username'¶
Configuration: Password
- class idoit_api_client.Request(api)[source]¶
Bases:
object- api = None¶
- require_success_for(result)[source]¶
Check for success and return identifier.
- Parameters:
result (dict) – Response from API request
- Returns:
Identifier
- Return type:
int