skipcheck

TM1 client · Docs · Dimensions and hierarchies

ElementService

from skipcheck_tm1.services import ElementService

Elements: /Dimensions('d')/Hierarchies('h')/Elements, an element's parents, components and edges, and the operations bound to an element.

TM1 (11.8) ignores Name in an element PATCH, so elements can't be renamed, and rejects Attributes, whose values are cells of the }ElementAttributes_<dimension> cube. update refuses both, saying why.

List elements with a query: here, the consolidations.

# The names of the consolidated elements, in name order
consolidated = ODataQuery.none().select(Element.NAME).filter(Element.TYPE.eq(ElementType.CONSOLIDATED)).order_by(Element.NAME)
return [element.name for element in tm1.elements.list("Region", "Region", consolidated)]

Add an element under a consolidation. A new element is a root until it has a parent:

# A new element is a root; SetComponent then puts it last under Total
tm1.elements.create("Region", "Region", ElementPatch.builder().name("West").type(ElementType.NUMERIC).build())
tm1.elements.set_component("Region", "Region", "Total", "West")

Read a consolidation's children:

# The children of Total, in order
return [element.name for element in tm1.elements.components("Region", "Region", "Total", ODataQuery.none().select(Element.NAME))]

The asyncio flavor, skipcheck_tm1.aio, has the same methods to await, on AsyncElementService.

Members

listGET …/Hierarchies('h')/Elements.
getThe element, or a Tm1NotFoundError.
createAdds an element, as a root of the hierarchy.
updateChanges the properties the patch sets, such as its type; with etag, only if the element hasn't changed since it was read (If-Match).Raises ValueError if the patch sets Name, which TM1 ignores, or Attributes, which it rejects.
deleteDELETE …/Elements('e'), with the element's edges and data.
parentsGET …/Elements('e')/Parents.
componentsA consolidation's children, in order.
edgesGET …/Elements('e')/Edges.
hierarchyGET …/Elements('e')/Hierarchy.
set_componentMakes child a child of parent, with weight (TM1's default is 1), placed just before the child before, or without it *last* among its children.
lockStops everyone else changing the element until it's unlocked.
unlocktm1.Unlock.
reserveStops everyone else changing the element's data until it's released.
releasetm1.Release.

list

list(dimension: str, hierarchy: str, query: ODataQuery | None = None, **options: Any) -> list[Element]

GET …/Hierarchies('h')/Elements.

TM1 REST Navigation Hierarchy/Elements

get

get(dimension: str, hierarchy: str, element: str, query: ODataQuery | None = None, **options: Any) -> Element

GET …/Elements('e'): the element, or a Tm1NotFoundError.

TM1 REST Navigation Hierarchy/Elements

create

create(dimension: str, hierarchy: str, element: Any) -> Element

POST …/Elements: adds an element, as a root of the hierarchy.

TM1 REST Navigation Hierarchy/Elements

update

update(dimension: str, hierarchy: str, element: str, patch: Any, etag: str | None = None) -> None

PATCH …/Elements('e'): changes the properties the patch sets, such as its type; with etag, only if the element hasn't changed since it was read (If-Match).

Raises ValueError if the patch sets Name, which TM1 ignores, or Attributes, which it rejects.

TM1 REST Navigation Hierarchy/Elements

delete

delete(dimension: str, hierarchy: str, element: str) -> None

DELETE …/Elements('e'), with the element's edges and data.

TM1 REST Navigation Hierarchy/Elements

parents

parents(dimension: str, hierarchy: str, element: str, query: ODataQuery | None = None, **options: Any) -> list[Element]

GET …/Elements('e')/Parents.

TM1 REST Navigation Element/Parents

components

components(dimension: str, hierarchy: str, element: str, query: ODataQuery | None = None, **options: Any) -> list[Element]

GET …/Elements('e')/Components: a consolidation's children, in order.

TM1 REST Navigation Element/Components

edges

edges(dimension: str, hierarchy: str, element: str, query: ODataQuery | None = None, **options: Any) -> list[Edge]

GET …/Elements('e')/Edges.

TM1 REST Navigation Element/Edges

hierarchy

hierarchy(dimension: str, hierarchy: str, element: str, query: ODataQuery | None = None, **options: Any) -> Hierarchy

GET …/Elements('e')/Hierarchy.

TM1 REST Navigation Element/Hierarchy

set_component

set_component(dimension: str, hierarchy: str, parent: str, child: str, *, before: str | None = None, weight: float | None = None) -> None

tm1.SetComponent: makes child a child of parent, with weight (TM1's default is 1), placed just before the child before, or without it *last* among its children. ($metadata doesn't say; TM1 11.8 puts it last.)

TM1 REST Action Element/SetComponent

lock

lock(dimension: str, hierarchy: str, element: str) -> None

tm1.Lock: stops everyone else changing the element until it's unlocked. Needs schema 11.8.23.

TM1 REST Action Element/Lock

unlock

unlock(dimension: str, hierarchy: str, element: str) -> None

tm1.Unlock. Needs schema 11.8.23.

TM1 REST Action Element/Unlock

reserve

reserve(dimension: str, hierarchy: str, element: str) -> None

tm1.Reserve: stops everyone else changing the element's data until it's released. Needs schema 11.8.34.

TM1 REST Action Element/Reserve

release

release(dimension: str, hierarchy: str, element: str) -> None

tm1.Release. Needs schema 11.8.34.

TM1 REST Action Element/Release