DimensionService
using Skipcheck.Tm1.Client.Services;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
return tm1
.Dimensions.ModelDimensionsAsync(ODataQuery.None().Select(Dimension.Fields.Name).OrderBy(Dimension.Fields.Name))
.Select(dimension => dimension.Name!);
Create a dimension with its hierarchy, elements and edges in one request:
// Region, with one hierarchy of the same name: Total = North + South
var total = ElementPatch.Builder().Name("Total").Type(ElementType.Consolidated).Build();
var north = ElementPatch.Builder().Name("North").Type(ElementType.Numeric).Build();
var south = ElementPatch.Builder().Name("South").Type(ElementType.Numeric).Build();
return await tm1.Dimensions.CreateAsync(
DimensionPatch
.Builder()
.Name("Region")
.Hierarchies([
HierarchyPatch
.Builder()
.Name("Region")
.Elements([total, north, south])
.Edges([
EdgePatch.Builder().ParentName("Total").ComponentName("North").Weight(1.0).Build(),
EdgePatch.Builder().ParentName("Total").ComponentName("South").Weight(1.0).Build(),
])
.Build(),
])
.Build()
);
Read a dimension with its hierarchies expanded:
// A dimension with its hierarchies' names expanded in the same request
var region = await tm1.Dimensions.GetAsync(
"Region",
ODataQuery.None().Expand(Dimension.Fields.Hierarchies, hierarchies => hierarchies.Select(Hierarchy.Fields.Name))
);
return region.Hierarchies!.Select(hierarchy => hierarchy.Name!).ToList();
Members
DimensionService constructor | A service that sends its requests through session. |
ListAsync | Every dimension, control dimensions included, streamed. |
ModelDimensionsAsync | The dimensions that aren't control dimensions (whose names start with }), streamed. |
ControlDimensionsAsync | The control dimensions, such as }Clients, streamed. |
GetAsync | The dimension, or a Tm1NotFoundException if there's none. |
CreateAsync | Creates a dimension, with its hierarchies, elements and edges if the patch has them (a deep insert). |
UpdateAsync | Changes the properties the patch sets. |
UpdateAsync | PATCH Dimensions('name') with If-Match. |
DeleteAsync | DELETE Dimensions('name'). |
SaveAsAsync | Copies a dimension under a new name, failing if one exists. |
SaveAsAsync | Copies a dimension under a new name. |
AddAllLeavesHierarchyAsync | Adds a hierarchy of all the dimension's leaves, named Leaves and not visible, which makes it a multi-hierarchy dimension; returns the new hierarchy. |
AddAllLeavesHierarchyAsync | Adds a hierarchy of all the dimension's leaves, named hierarchyName, which makes it a multi-hierarchy dimension. |
LockAsync | Stops everyone else changing the dimension until it's unlocked. |
UnlockAsync | tm1.Unlock. |
ReserveAsync | Stops everyone else changing the dimension until it's released. |
ReleaseAsync | tm1.Release. |
DimensionService
constructorDimensionService(Tm1Session session)A service that sends its requests through session.
ListAsync
IAsyncEnumerable<Dimension> ListAsync(ODataQuery? query = null, CancellationToken cancellationToken = default)GET Dimensions: every dimension, control dimensions included, streamed.
TM1 REST EntitySet Dimensions
ModelDimensionsAsync
IAsyncEnumerable<Dimension> ModelDimensionsAsync(ODataQuery? query = null, CancellationToken cancellationToken = default)ModelDimensions(): the dimensions that aren't control dimensions (whose names start with }), streamed.
TM1 REST FunctionImport ModelDimensions
ControlDimensionsAsync
IAsyncEnumerable<Dimension> ControlDimensionsAsync(ODataQuery? query = null, CancellationToken cancellationToken = default)ControlDimensions(): the control dimensions, such as }Clients, streamed.
TM1 REST FunctionImport ControlDimensions
GetAsync
Task<Dimension> GetAsync(string name, ODataQuery? query = null, CancellationToken cancellationToken = default)GET Dimensions('name'): the dimension, or a Tm1NotFoundException if there's none.
TM1 REST EntitySet Dimensions
CreateAsync
Task<Dimension> CreateAsync(DimensionPatch dimension, CancellationToken cancellationToken = default)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
UpdateAsync
Task UpdateAsync(string name, DimensionPatch patch, CancellationToken cancellationToken = default)PATCH Dimensions('name'): changes the properties the patch sets.
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 AddAllLeavesHierarchyAsync.
TM1 REST EntitySet Dimensions
UpdateAsync
Task UpdateAsync(string name, DimensionPatch patch, string etag, CancellationToken cancellationToken = default)PATCH Dimensions('name') with If-Match: changes the properties the patch
sets, unless the dimension changed since it was read with etag
(Dimension.ETag); a Tm1PreconditionFailedException if it had changed.
TM1 REST EntitySet Dimensions
DeleteAsync
Task DeleteAsync(string name, CancellationToken cancellationToken = default)DELETE Dimensions('name').
TM1 REST EntitySet Dimensions
SaveAsAsync
Task<Dimension> SaveAsAsync(string name, string newName, CancellationToken cancellationToken = default)tm1.SaveAs: copies a dimension under a new name, failing if one exists.
TM1 REST Action Dimension/SaveAs
SaveAsAsync
Task<Dimension> SaveAsAsync( string name, string newName, bool overwrite, bool keepExistingAttributes, CancellationToken cancellationToken = default )tm1.SaveAs: copies a dimension under a new name. overwrite
replaces a dimension that already has the new name; when overwriting,
keepExistingAttributes keeps the attributes of what's replaced, and when not,
true creates no attributes for the copy.
TM1 REST Action Dimension/SaveAs
AddAllLeavesHierarchyAsync
Task<Hierarchy> AddAllLeavesHierarchyAsync(string name, CancellationToken cancellationToken = default)tm1.AddAllLeavesHierarchy: adds a hierarchy of all the dimension's leaves, named
Leaves and not visible, which makes it a multi-hierarchy dimension; returns the new hierarchy.
TM1 REST Action Dimension/AddAllLeavesHierarchy
AddAllLeavesHierarchyAsync
Task<Hierarchy> AddAllLeavesHierarchyAsync(string name, string hierarchyName, bool visible, CancellationToken cancellationToken = default)tm1.AddAllLeavesHierarchy: adds a hierarchy of all the dimension's leaves, named
hierarchyName, which makes it a multi-hierarchy dimension.
TM1 REST Action Dimension/AddAllLeavesHierarchy
LockAsync
Task LockAsync(string name, CancellationToken cancellationToken = default)tm1.Lock: stops everyone else changing the dimension until it's unlocked.
TM1 REST Action Dimension/Lock
UnlockAsync
Task UnlockAsync(string name, CancellationToken cancellationToken = default)tm1.Unlock.
TM1 REST Action Dimension/Unlock
ReserveAsync
Task ReserveAsync(string name, CancellationToken cancellationToken = default)tm1.Reserve: stops everyone else changing the dimension until it's released. Needs schema 11.8.34.
TM1 REST Action Dimension/Reserve
ReleaseAsync
Task ReleaseAsync(string name, CancellationToken cancellationToken = default)tm1.Release. Needs schema 11.8.34.
TM1 REST Action Dimension/Release