Data Model
ucmdb_rest.datamodel.DataModel(server)
Service module for interacting with the UCMDB Class Model and Data Model.
This module provides methods to create, update, and delete Configuration Items (CIs) and Relationships, as well as tools to inspect the CI Type (Class) definitions and identification rules.
Initialize the service with a reference to the main level UCMDB client
Source code in ucmdb_rest\datamodel.py
addCIs(ciToCreate, isGlobalId=False, forceTemporaryID=False, ignoreExisting=False, returnIdsMap=False, ignoreWhenCantIdentify=False)
Adds or updates a bulk collection of CIs and Relationships.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ciToCreate
|
dict
|
A dictionary defining the CIs and relations. Example: { "cis": [{"ucmdbId": "1", "type": "node", "properties": {"name": "Test"}}], "relations": [{"type": "containment", "end1Id": "1", "end2Id": "2"}] } |
required |
isGlobalId
|
bool
|
Whether IDs in the payload are global UCMDB IDs. Default is False. |
False
|
forceTemporaryID
|
bool
|
Whether to treat provided IDs as temporary identifiers. Default is False. |
False
|
ignoreExisting
|
bool
|
If True, existing CIs will not be updated. Default is False. |
False
|
returnIdsMap
|
bool
|
If True, returns a mapping of temporary IDs to actual UCMDB IDs. Default is False. |
False
|
ignoreWhenCantIdentify
|
bool
|
If True, skips CIs that do not match identification rules instead of failing. Default is False. |
False
|
Returns:
| Type | Description |
|---|---|
Response
|
A response containing lists of added, removed, updated, or ignored IDs. |
Source code in ucmdb_rest\datamodel.py
convertFromBase64(stringToDecode)
staticmethod
The function takes a Base64-encoded string, converts it to bytes, decodes it using Base64 decoding, and then converts the resulting bytes back into a UTF-8 string, which is then returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stringToDecode
|
A Base 64 encoded string |
required |
Returns:
| Name | Type | Description |
|---|---|---|
decoded_string |
str
|
A UTF-8 string |
Source code in ucmdb_rest\datamodel.py
deleteCIs(id_to_delete, isGlobalId=False)
Deletes a specific CI by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_to_delete
|
str
|
The UCMDB ID (local or global) to delete. |
required |
isGlobalId
|
bool
|
Set to True if the ID provided is a Global ID. Default is False. |
False
|
Returns:
| Type | Description |
|---|---|
Response
|
A summary of the deletion result. |
Source code in ucmdb_rest\datamodel.py
getClass(CIT)
Retrieves the definition of a class (CI Type) from the UCMDB server.
This method makes a GET request to the UCMDB server to fetch the definition of the specified class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
CIT
|
str
|
The class name (e.g., "node"). |
required |
Returns:
| Type | Description |
|---|---|
Response
|
A JSON object describing the CI Type, with attributes such as: - name - displayName - superClass - description - allAttributes (list of dictionaries, each representing an attribute) - classAttributes (list of dictionaries, each representing an attribute defined in this class) - iconName - children - parents - qualifiers - classType - classQualifiers - defaultLabel - validLinks - identification (dictionary with identification details) - editable - scope - deletable - createdByFactory - modifiedByUser |
Example
CIT = 'node' class_def = getClass(CIT) print(class_def['name']) 'node'
Source code in ucmdb_rest\datamodel.py
retrieveIdentificationRule(cit='node')
Retrieves the XML identification rule for a specific CI Type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cit
|
str
|
The CI Type name. Default is 'node'. |
'node'
|
Returns:
| Type | Description |
|---|---|
Response
|
The response containing the Base64 encoded |
Examples:
>>> response = model.retrieveIdentificationRule('node')
>>> rule_b64 = response.json()["identification"]["ruleXml"]
>>> xml = model.convertFromBase64(rule_b64)
Source code in ucmdb_rest\datamodel.py
updateCI(id_to_update, update_ci)
Updates a CI by ID via a PUT REST API call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_to_update
|
str
|
The global CI identifier (or LOCAL CI identifier). |
required |
update_ci
|
dict
|
A dictionary containing the update. |
required |
Returns:
| Type | Description |
|---|---|
Response
|
The results of the update. For example: { "addedCis": [], "removedCis": [], "updatedCis": [ "44c93b1d0230dd02b013364a7b8c635f" ], "ignoredCis": [] } |