HierarchyService
using Skipcheck.Tm1.Client.Services; Hierarchies: /Dimensions('d')/Hierarchies, a dimension's default hierarchy, and
the operations bound to a hierarchy. Elements, edges, members, levels and subsets have
services of their own.
A hierarchy PATCH that sets Elements or Edges replaces them:
TM1 deletes the elements it doesn't list. So UpdateAsync refuses such a patch, and
ReplaceStructureAsync does it by name.
Add a hierarchy to a dimension, with its elements and edges:
// A second hierarchy of Region, rolling the same leaves up by manager
return await tm1.Hierarchies.CreateAsync(
"Region",
HierarchyPatch
.Builder()
.Name("By Manager")
.Elements([
ElementPatch.Builder().Name("Smith").Type(ElementType.Consolidated).Build(),
ElementPatch.Builder().Name("North").Type(ElementType.Numeric).Build(),
ElementPatch.Builder().Name("South").Type(ElementType.Numeric).Build(),
])
.Edges([
EdgePatch.Builder().ParentName("Smith").ComponentName("North").Weight(1.0).Build(),
EdgePatch.Builder().ParentName("Smith").ComponentName("South").Weight(1.0).Build(),
])
.Build()
);
Replace a hierarchy's structure, knowing that TM1 deletes what isn't listed:
// Makes the elements and edges exactly these: TM1 deletes every other element of
// the hierarchy, with its data
var all = ElementPatch.Builder().Name("All Versions").Type(ElementType.Consolidated).Build();
var actual = ElementPatch.Builder().Name("Actual").Type(ElementType.Numeric).Build();
var budget = ElementPatch.Builder().Name("Budget").Type(ElementType.Numeric).Build();
await tm1.Hierarchies.ReplaceStructureAsync(
"Version",
"Version",
[all, actual, budget],
[
EdgePatch.Builder().ParentName("All Versions").ComponentName("Actual").Weight(1.0).Build(),
EdgePatch.Builder().ParentName("All Versions").ComponentName("Budget").Weight(1.0).Build(),
]
);
Read the roots of a hierarchy:
// The top of the hierarchy: the members with no parent, in order
return tm1.Hierarchies.RootMembersAsync("Region", "Region", ODataQuery.None().Select(Member.Fields.Name)).Select(member => member.Name!);
Members
HierarchyService constructor | A service that sends its requests through session. |
ListAsync | The dimension's hierarchies, streamed. |
GetAsync | GET Dimensions('d')/Hierarchies('h'). |
CreateAsync | Creates a hierarchy, with its elements and edges if the patch has them. |
UpdateAsync | Changes the properties the patch sets. |
UpdateAsync | PATCH Dimensions('d')/Hierarchies('h') with If-Match. |
ReplaceStructureAsync | PATCH Dimensions('d')/Hierarchies('h') with Elements and Edges. |
DeleteAsync | DELETE Dimensions('d')/Hierarchies('h'). |
DefaultHierarchyAsync | The hierarchy named after the dimension. |
DimensionAsync | The dimension the hierarchy belongs to. |
AllMemberAsync | The member that stands for the whole hierarchy. |
DefaultMemberAsync | The member MDX uses when a query names none of the hierarchy's. |
RootMembersAsync | The hierarchy's top-level members, streamed. |
SaveAsAsync | Copies a hierarchy under a new name in the same dimension, failing if one exists. |
SaveAsAsync | Copies a hierarchy under a new name. |
SetElementAsync | tm1.SetElement with no Before. |
SetElementAsync | Makes an element a root of the hierarchy, placed just before another root. |
HierarchyService
constructorHierarchyService(Tm1Session session)A service that sends its requests through session.
ListAsync
IAsyncEnumerable<Hierarchy> ListAsync(string dimension, ODataQuery? query = null, CancellationToken cancellationToken = default)GET Dimensions('d')/Hierarchies: the dimension's hierarchies, streamed.
TM1 REST Navigation Dimension/Hierarchies
GetAsync
Task<Hierarchy> GetAsync(string dimension, string hierarchy, ODataQuery? query = null, CancellationToken cancellationToken = default)GET Dimensions('d')/Hierarchies('h').
TM1 REST Navigation Dimension/Hierarchies
CreateAsync
Task<Hierarchy> CreateAsync(string dimension, HierarchyPatch hierarchy, CancellationToken cancellationToken = default)POST Dimensions('d')/Hierarchies: creates a hierarchy, with its elements and edges
if the patch has them. It needs a name; returns the hierarchy as created.
TM1 REST Navigation Dimension/Hierarchies
UpdateAsync
Task UpdateAsync(string dimension, string hierarchy, HierarchyPatch patch, CancellationToken cancellationToken = default)PATCH Dimensions('d')/Hierarchies('h'): changes the properties the patch sets.
TM1 (11.8) ignores Visible. A patch with Elements or Edges is refused
(ArgumentException): it would replace them, so use ReplaceStructureAsync.
TM1 REST Navigation Dimension/Hierarchies
UpdateAsync
Task UpdateAsync(string dimension, string hierarchy, HierarchyPatch patch, string etag, CancellationToken cancellationToken = default)PATCH Dimensions('d')/Hierarchies('h') with If-Match: changes the properties
the patch sets, unless the hierarchy changed since it was read with etag
(Hierarchy.ETag); a Tm1PreconditionFailedException if it had changed. A patch with
Elements or Edges is refused: use ReplaceStructureAsync.
TM1 REST Navigation Dimension/Hierarchies
ReplaceStructureAsync
Task ReplaceStructureAsync( string dimension, string hierarchy, IReadOnlyList<ElementPatch> elements, IReadOnlyList<EdgePatch> edges, CancellationToken cancellationToken = default )PATCH Dimensions('d')/Hierarchies('h') with Elements and Edges:
replaces the hierarchy's structure. TM1 (11.8) deletes the elements the new structure doesn't
list, and the edges with them; data in cells of a deleted element is lost.
TM1 REST Navigation Dimension/Hierarchies
DeleteAsync
Task DeleteAsync(string dimension, string hierarchy, CancellationToken cancellationToken = default)DELETE Dimensions('d')/Hierarchies('h').
TM1 REST Navigation Dimension/Hierarchies
DefaultHierarchyAsync
Task<Hierarchy> DefaultHierarchyAsync(string dimension, ODataQuery? query = null, CancellationToken cancellationToken = default)GET Dimensions('d')/DefaultHierarchy: the hierarchy named after the dimension.
TM1 REST Navigation Dimension/DefaultHierarchy
DimensionAsync
Task<Dimension> DimensionAsync(string dimension, string hierarchy, ODataQuery? query = null, CancellationToken cancellationToken = default)GET Dimensions('d')/Hierarchies('h')/Dimension: the dimension the hierarchy belongs to.
TM1 REST Navigation Hierarchy/Dimension
AllMemberAsync
Task<Member?> AllMemberAsync(string dimension, string hierarchy, ODataQuery? query = null, CancellationToken cancellationToken = default)GET Dimensions('d')/Hierarchies('h')/AllMember: the member that stands for the whole
hierarchy. TM1 (11.8) has one only when the hierarchy has a single root, which is then that root;
with several roots it sends no content, and this returns null.
TM1 REST Navigation Hierarchy/AllMember
DefaultMemberAsync
Task<Member?> DefaultMemberAsync(string dimension, string hierarchy, ODataQuery? query = null, CancellationToken cancellationToken = default)GET Dimensions('d')/Hierarchies('h')/DefaultMember: the member MDX uses when a
query names none of the hierarchy's.
TM1 REST Navigation Hierarchy/DefaultMember
RootMembersAsync
IAsyncEnumerable<Member> RootMembersAsync( string dimension, string hierarchy, ODataQuery? query = null, CancellationToken cancellationToken = default )tm1.RootMembers(): the hierarchy's top-level members, streamed.
TM1 REST Function Hierarchy/RootMembers
SaveAsAsync
Task<Hierarchy> SaveAsAsync(string dimension, string hierarchy, string newName, CancellationToken cancellationToken = default)tm1.SaveAs: copies a hierarchy under a new name in the same dimension, failing if
one exists.
TM1 REST Action Hierarchy/SaveAs
SaveAsAsync
Task<Hierarchy> SaveAsAsync( string dimension, string hierarchy, string newName, bool overwrite, bool keepExistingAttributes, CancellationToken cancellationToken = default )tm1.SaveAs: copies a hierarchy under a new name. overwrite
replaces a hierarchy that already has it; keepExistingAttributes keeps the
attributes of what's replaced.
TM1 REST Action Hierarchy/SaveAs
SetElementAsync
Task SetElementAsync(string dimension, string hierarchy, string element, CancellationToken cancellationToken = default)tm1.SetElement with no Before: makes an element a root of the hierarchy,
placed last among the roots. ($metadata says first; TM1 11.8 puts it last.)
TM1 REST Action Hierarchy/SetElement
SetElementAsync
Task SetElementAsync(string dimension, string hierarchy, string element, string before, CancellationToken cancellationToken = default)tm1.SetElement: makes an element a root of the hierarchy, placed just before another root.
TM1 REST Action Hierarchy/SetElement