skipcheck

TM1 client · Docs · Dimensions and hierarchies

DimensionService

from skipcheck_tm1.services import DimensionService

Used in the walkthrough Test your code against a real TM1.

Dimensions: /Dimensions and the operations bound to a dimension.

A dimension's hierarchies, elements and subsets have services of their own.

List dimensions with a query: here, the names of the model dimensions.

# The names of the model dimensions, in name order
by_name = ODataQuery.none().select(Dimension.NAME).order_by(Dimension.NAME)
return [dimension.name for dimension in tm1.dimensions.model_dimensions(by_name)]

Create a dimension with its hierarchy, elements and edges in one request:

# Region, with one hierarchy of the same name: Total = North + South
total = ElementPatch.builder().name("Total").type(ElementType.CONSOLIDATED).build()
north = ElementPatch.builder().name("North").type(ElementType.NUMERIC).build()
south = ElementPatch.builder().name("South").type(ElementType.NUMERIC).build()
edges = [EdgePatch.builder().parent_name("Total").component_name(leaf).weight(1.0).build() for leaf in ("North", "South")]
hierarchy = HierarchyPatch.builder().name("Region").elements([total, north, south]).edges(edges).build()
return tm1.dimensions.create(DimensionPatch.builder().name("Region").hierarchies([hierarchy]).build())

Read a dimension with its hierarchies expanded:

# A dimension with its hierarchies' names expanded in the same request
with_hierarchies = ODataQuery.none().expand(Dimension.HIERARCHIES, lambda h: h.select(Hierarchy.NAME))
region = tm1.dimensions.get("Region", with_hierarchies)
return [hierarchy.name for hierarchy in region.hierarchies or []]

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

Members

listEvery dimension, control dimensions included.
model_dimensionsThe dimensions that aren't control dimensions (whose names start with }).
control_dimensionsThe control dimensions, such as }Clients.
getThe dimension, or a Tm1NotFoundError if there's none.
createCreates a dimension, with its hierarchies, elements and edges if the patch has them (a deep insert).
updateChanges the properties the patch sets.
deleteDELETE Dimensions('name').
save_asCopies a dimension under a new name, failing if one exists, unless overwrite.
add_all_leaves_hierarchyAdds a hierarchy of all the dimension's leaves, which makes it a multi-hierarchy dimension.
lockStops everyone else changing the dimension until it's unlocked.
unlocktm1.Unlock.
reserveStops everyone else changing the dimension until it's released.
releasetm1.Release.

list

list(query: ODataQuery | None = None, **options: Any) -> list[Dimension]

GET Dimensions: every dimension, control dimensions included.

TM1 REST EntitySet Dimensions

model_dimensions

model_dimensions(query: ODataQuery | None = None, **options: Any) -> list[Dimension]

ModelDimensions(): the dimensions that aren't control dimensions (whose names start with }).

TM1 REST FunctionImport ModelDimensions

control_dimensions

control_dimensions(query: ODataQuery | None = None, **options: Any) -> list[Dimension]

ControlDimensions(): the control dimensions, such as }Clients.

TM1 REST FunctionImport ControlDimensions

get

get(name: str, query: ODataQuery | None = None, **options: Any) -> Dimension

GET Dimensions('name'): the dimension, or a Tm1NotFoundError if there's none.

TM1 REST EntitySet Dimensions

create

create(dimension: Any) -> Dimension

POST Dimensions: creates a dimension, with its hierarchies, elements and edges if the patch has them (a deep insert). It needs a name; returns the dimension as created.

TM1 REST EntitySet Dimensions

update

update(name: str, patch: Any, etag: str | None = None) -> None

PATCH Dimensions('name'): changes the properties the patch sets. With etag (Dimension.etag, from a read), sent as If-Match: only if the dimension hasn't changed since, else a Tm1PreconditionFailedError.

TM1 (11.8) accepts Hierarchies and AllLeavesHierarchyName in a dimension PATCH and ignores them: change hierarchies through their own service, and add an all-leaves hierarchy with add_all_leaves_hierarchy.

TM1 REST EntitySet Dimensions

delete

delete(name: str) -> None

DELETE Dimensions('name').

TM1 REST EntitySet Dimensions

save_as

save_as(name: str, new_name: str, overwrite: bool | None = None, keep_existing_attributes: bool | None = None) -> Dimension

tm1.SaveAs: copies a dimension under a new name, failing if one exists, unless overwrite. When overwriting, keep_existing_attributes keeps the attributes of what's replaced; when not, true creates no attributes for the copy. Returns the copy.

TM1 REST Action Dimension/SaveAs

add_all_leaves_hierarchy

add_all_leaves_hierarchy(name: str, hierarchy_name: str | None = None, visible: bool | None = None) -> Hierarchy

tm1.AddAllLeavesHierarchy: adds a hierarchy of all the dimension's leaves, which makes it a multi-hierarchy dimension. Without a name, TM1 names it Leaves and makes it not visible. Returns the new hierarchy.

TM1 REST Action Dimension/AddAllLeavesHierarchy

lock

lock(name: str) -> None

tm1.Lock: stops everyone else changing the dimension until it's unlocked.

TM1 REST Action Dimension/Lock

unlock

unlock(name: str) -> None

tm1.Unlock.

TM1 REST Action Dimension/Unlock

reserve

reserve(name: str) -> None

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

TM1 REST Action Dimension/Reserve

release

release(name: str) -> None

tm1.Release. Needs schema 11.8.34.

TM1 REST Action Dimension/Release