xplain.Xobject

class xplain.Xobject(object_name: str, ref_session)

Bases: object

Represents a Xobject with methods to interact with its child objects, dimensions, and to add aggregation dimensions.

Attributes:

object_name (str): The name of the Xobject. _ref_session: The session object used for API interactions.

add_aggregation_dimension(dimension_name: str, aggregation: dict, selections: list = None, floating_semantics: bool = False) dict

adds an aggregation dimension to the given target dimension. The aggregation dimension aggregates data from a child object (or any deeper descendant objects) according to the given aggregation definition.

Parameters
  • dimension_name (string) – the name of new dimension

  • aggregation (json or aggregation object) – aggregation of the new dimension

  • selections (array of json or selection object) – the selections shall be considered

  • floating_semantics – If set to true the resulting dimension will

have a floating semantics. :type floating_semantics: boolean

Returns:

dict: Response from the session’s run method.

Raises:

ValueError: If required arguments are missing or invalid. RuntimeError: If the API call fails.

Example:
>>> xobject = session.get_object("Krankengeld")
>>> xobject.add_aggregation_dimension(
                                 dimension_name="newDim",
                                 aggregation={
                                         "object": "Krankengeld",
                                         "dimension":"Anzahl_Tage",
                                         "type": "AVG"
                                        }
                                )
get_child_objects() list

Retrieve the child Xobjects of the current Xobject.

Returns:

list: A list of child Xobject names (strings).

Raises:

RuntimeError: If fetching child objects fails.

get_dimension(dimension_name: str) str

Retrieve a specific dimension by its name.

Args:

dimension_name (str): The name of the dimension to retrieve.

Returns:

str: The name of the dimension if found, otherwise None.

Raises:

ValueError: If the dimension name is invalid. RuntimeError: If fetching dimensions fails.

get_dimensions() list

Retrieve the list of dimensions attached to the current Xobject.

Returns:

list: A list of dimension names (strings).

Raises:

RuntimeError: If fetching dimensions fails.

get_name() str

Return the name of the Xobject.