Skip to content

Expose CI

ucmdb_rest.expose_ci.ExposeCI(server)

Initialize the service with a reference to the main level UCMDB server

Source code in ucmdb_rest\expose_ci.py
def __init__(self, server):
    """
    Initialize the service with a reference to the main level UCMDB server
    """
    self.server = server

getInformation(json_to_expose)

Parameters:

Name Type Description Default
json_to_expose dict

A dictionary defining the CI Type, attribute layout, sorting, and filtering conditions. { "type": "running_software", "layout": [ "display_label", "discovered_product_name", "global_id", "version", "mf_version" ], "includeSubtypes": "false", "sortBy": [ { "attribute": "version", "order": "DESC" } ], "filtering": { "logicalOperator": "and", "conditions": [ { "column": "discovered_product_name", "value": "name_to_get", "filteringAttributeCondOperator": "Like" } ] } }

required

Returns:

Type Description
Response

Can be converted to a list of dictionaries where each dictionary is representative of an element requested. For example: [ { "ucmdbId": "4e8b850822c83fdb975dc2bf899c7686", "globalId": "4e8b850822c83fdb975dc2bf899c7686", "type": "running_software", "properties": { "display_label": "OpenText UCMDB Server (bra03ucm02)", "discovered_product_name": "OpenText UCMDB Server", "global_id": "4e8b850822c83fdb975dc2bf899c7686", "version": "10.22.CUP3" }, "attributesDisplayNames": null, "attributesQualifiers": null, "attributesType": null, "classDefinition": null, "displayLabel": null } ]

Source code in ucmdb_rest\expose_ci.py
def getInformation(self, json_to_expose):
    '''
    Parameters
    ----------
    json_to_expose : dict
        A dictionary defining the CI Type, attribute layout, 
        sorting, and filtering conditions.
        {
            "type": "running_software",
            "layout": [
                "display_label",
                "discovered_product_name",
                "global_id",
                "version",
                "mf_version"
            ],
            "includeSubtypes": "false",
            "sortBy": [
                {
                    "attribute": "version",
                    "order": "DESC"
                }
            ],
            "filtering": {
                "logicalOperator": "and",
                "conditions": [
                    {
                        "column": "discovered_product_name",
                        "value": "name_to_get",
                        "filteringAttributeCondOperator": "Like"
                    }
                ]
            }
        }

    Returns
    -------
    requests.Response
        Can be converted to a list of dictionaries where each dictionary
        is representative of an element requested. For example:
        [
            {
                "ucmdbId": "4e8b850822c83fdb975dc2bf899c7686",
                "globalId": "4e8b850822c83fdb975dc2bf899c7686",
                "type": "running_software",
                "properties": {
                    "display_label": "OpenText UCMDB Server (bra03ucm02)",
                    "discovered_product_name": "OpenText UCMDB Server",
                    "global_id": "4e8b850822c83fdb975dc2bf899c7686",
                    "version": "10.22.CUP3"
                },
                "attributesDisplayNames": null,
                "attributesQualifiers": null,
                "attributesType": null,
                "classDefinition": null,
                "displayLabel": null
            }
        ]

    '''
    url = '/exposeCI/getInformation'
    return self.server._request("POST",url,json=json_to_expose)

search_by_label(label_pattern, ci_type='node', operator='LIKE', layout=None)

A flexible helper to find CIs of any type based on their display label.

Parameters:

Name Type Description Default
label_pattern str

The string to search for.

required
ci_type str

The UCMDB CI Type (e.g., 'node', 'ip_address', 'business_service'). Default is 'node'.

'node'
operator str

The filtering operator (e.g., 'LIKE', 'EQUAL'). Default is 'LIKE'.

'LIKE'
layout list of str

Specific attributes to return. If None, defaults to ['display_label', 'name', 'global_id'].

None
Source code in ucmdb_rest\expose_ci.py
def search_by_label(self, label_pattern, ci_type="node", operator="LIKE", layout=None):
    """
    A flexible helper to find CIs of any type based on their display label.

    Parameters
    ----------
    label_pattern : str
        The string to search for.
    ci_type : str, optional
        The UCMDB CI Type (e.g., 'node', 'ip_address', 'business_service'). 
        Default is 'node'.
    operator : str, optional
        The filtering operator (e.g., 'LIKE', 'EQUAL'). Default is 'LIKE'.
    layout : list of str, optional
        Specific attributes to return. If None, defaults to 
        ['display_label', 'name', 'global_id'].
    """
    if layout is None:
        layout = ["display_label", "name", "global_id"]

    payload = {
        "type": ci_type,
        "layout": layout,
        "includeSubtypes": "true",
        "filtering": {
            "logicalOperator": "and",
            "conditions": [
                {
                    "column": "display_label",
                    "value": label_pattern,
                    "filteringAttributeCondOperator": operator
                }
            ]
        }
    }
    url = '/exposeCI/getInformation'
    return self.server._request("POST",url,json=payload)