ElementService
using Skipcheck.Tm1.Client.Services; 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. UpdateAsync refuses
both, saying why.
List elements with a query: here, the consolidations.
// The names of the consolidated elements, in name order
return tm1
.Elements.ListAsync(
"Region",
"Region",
ODataQuery.None().Select(Element.Fields.Name).Filter(Element.Fields.Type.Eq(ElementType.Consolidated)).OrderBy(Element.Fields.Name)
)
.Select(element => element.Name!);
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
await tm1.Elements.CreateAsync("Region", "Region", ElementPatch.Builder().Name("West").Type(ElementType.Numeric).Build());
await tm1.Elements.SetComponentAsync("Region", "Region", "Total", "West");
Read a consolidation's children:
// The children of Total, in order
return tm1.Elements.ComponentsAsync("Region", "Region", "Total", ODataQuery.None().Select(Element.Fields.Name)).Select(element => element.Name!);
Members
ElementService constructor | A service that sends its requests through session. |
ListAsync | The hierarchy's elements, streamed. |
GetAsync | GET …/Elements('e'). |
CreateAsync | Adds an element, with its components if the patch has them; returns the element as created. |
UpdateAsync | Changes the properties the patch sets, typically Type. |
UpdateAsync | PATCH …/Elements('e') with If-Match. |
DeleteAsync | Removes the element, its edges, and its cells' data. |
ParentsAsync | The consolidations the element is under, streamed. |
ComponentsAsync | The elements directly under it, streamed. |
EdgesAsync | The edges to its components, streamed. |
HierarchyAsync | The hierarchy the element belongs to. |
SetComponentAsync | Puts child under parent, with TM1's default weight, last among its components. |
SetComponentAsync | Puts child under parent with a weight. |
SetComponentAsync | Puts child under parent with a weight, just before the component before. |
LockAsync | tm1.Lock. |
UnlockAsync | tm1.Unlock. |
ReserveAsync | No one else can change the element until it's released. |
ReleaseAsync | tm1.Release. |
ElementService
constructorElementService(Tm1Session session)A service that sends its requests through session.
ListAsync
IAsyncEnumerable<Element> ListAsync(string dimension, string hierarchy, ODataQuery? query = null, CancellationToken cancellationToken = default)GET …/Elements: the hierarchy's elements, streamed.
TM1 REST Navigation Hierarchy/Elements
GetAsync
Task<Element> GetAsync( string dimension, string hierarchy, string element, ODataQuery? query = null, CancellationToken cancellationToken = default )GET …/Elements('e').
TM1 REST Navigation Hierarchy/Elements
CreateAsync
Task<Element> CreateAsync(string dimension, string hierarchy, ElementPatch element, CancellationToken cancellationToken = default)POST …/Elements: adds an element, with its components if the patch has them;
returns the element as created.
TM1 REST Navigation Hierarchy/Elements
UpdateAsync
Task UpdateAsync(string dimension, string hierarchy, string element, ElementPatch patch, CancellationToken cancellationToken = default)PATCH …/Elements('e'): changes the properties the patch sets, typically Type.
A patch with Name (TM1 ignores it: elements can't be renamed) or Attributes (TM1
rejects it) is refused with an ArgumentException.
TM1 REST Navigation Hierarchy/Elements
UpdateAsync
Task UpdateAsync( string dimension, string hierarchy, string element, ElementPatch patch, string etag, CancellationToken cancellationToken = default )PATCH …/Elements('e') with If-Match: as UpdateAsync,
unless the element changed since it was read with etag; a
Tm1PreconditionFailedException if it had.
TM1 REST Navigation Hierarchy/Elements
DeleteAsync
Task DeleteAsync(string dimension, string hierarchy, string element, CancellationToken cancellationToken = default)DELETE …/Elements('e'): removes the element, its edges, and its cells' data.
TM1 REST Navigation Hierarchy/Elements
ParentsAsync
IAsyncEnumerable<Element> ParentsAsync( string dimension, string hierarchy, string element, ODataQuery? query = null, CancellationToken cancellationToken = default )GET …/Elements('e')/Parents: the consolidations the element is under, streamed.
TM1 REST Navigation Element/Parents
ComponentsAsync
IAsyncEnumerable<Element> ComponentsAsync( string dimension, string hierarchy, string element, ODataQuery? query = null, CancellationToken cancellationToken = default )GET …/Elements('e')/Components: the elements directly under it, streamed.
TM1 REST Navigation Element/Components
EdgesAsync
IAsyncEnumerable<Edge> EdgesAsync( string dimension, string hierarchy, string element, ODataQuery? query = null, CancellationToken cancellationToken = default )GET …/Elements('e')/Edges: the edges to its components, streamed.
TM1 REST Navigation Element/Edges
HierarchyAsync
Task<Hierarchy> HierarchyAsync( string dimension, string hierarchy, string element, ODataQuery? query = null, CancellationToken cancellationToken = default )GET …/Elements('e')/Hierarchy: the hierarchy the element belongs to.
TM1 REST Navigation Element/Hierarchy
SetComponentAsync
Task SetComponentAsync(string dimension, string hierarchy, string parent, string child, CancellationToken cancellationToken = default)tm1.SetComponent: puts child under parent, with
TM1's default weight, last among its components.
TM1 REST Action Element/SetComponent
SetComponentAsync
Task SetComponentAsync( string dimension, string hierarchy, string parent, string child, double weight, CancellationToken cancellationToken = default )tm1.SetComponent: puts child under parent with a weight.
TM1 REST Action Element/SetComponent
SetComponentAsync
Task SetComponentAsync( string dimension, string hierarchy, string parent, string child, string before, double weight, CancellationToken cancellationToken = default )tm1.SetComponent: puts child under parent with a
weight, just before the component before.
TM1 REST Action Element/SetComponent
LockAsync
Task LockAsync(string dimension, string hierarchy, string element, CancellationToken cancellationToken = default)tm1.Lock.
TM1 REST Action Element/Lock
UnlockAsync
Task UnlockAsync(string dimension, string hierarchy, string element, CancellationToken cancellationToken = default)tm1.Unlock.
TM1 REST Action Element/Unlock
ReserveAsync
Task ReserveAsync(string dimension, string hierarchy, string element, CancellationToken cancellationToken = default)tm1.Reserve: no one else can change the element until it's released.
TM1 REST Action Element/Reserve
ReleaseAsync
Task ReleaseAsync(string dimension, string hierarchy, string element, CancellationToken cancellationToken = default)tm1.Release.
TM1 REST Action Element/Release