DimensionService
from skipcheck_tm1.services import DimensionServiceUsed 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
list | Every dimension, control dimensions included. |
model_dimensions | The dimensions that aren't control dimensions (whose names start with }). |
control_dimensions | The control dimensions, such as }Clients. |
get | The dimension, or a Tm1NotFoundError if there's none. |
create | Creates a dimension, with its hierarchies, elements and edges if the patch has them (a deep insert). |
update | Changes the properties the patch sets. |
delete | DELETE Dimensions('name'). |
save_as | Copies a dimension under a new name, failing if one exists, unless overwrite. |
add_all_leaves_hierarchy | Adds a hierarchy of all the dimension's leaves, which makes it a multi-hierarchy dimension. |
lock | Stops everyone else changing the dimension until it's unlocked. |
unlock | tm1.Unlock. |
reserve | Stops everyone else changing the dimension until it's released. |
release | tm1.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) -> DimensionGET Dimensions('name'): the dimension, or a Tm1NotFoundError if there's none.
TM1 REST EntitySet Dimensions
create
create(dimension: Any) -> DimensionPOST 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) -> NonePATCH 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) -> NoneDELETE 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) -> Dimensiontm1.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) -> Hierarchytm1.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) -> Nonetm1.Lock: stops everyone else changing the dimension until it's unlocked.
TM1 REST Action Dimension/Lock
unlock
unlock(name: str) -> Nonetm1.Unlock.
TM1 REST Action Dimension/Unlock
reserve
reserve(name: str) -> Nonetm1.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) -> Nonetm1.Release. Needs schema 11.8.34.
TM1 REST Action Dimension/Release