SubsetService
using Skipcheck.Tm1.Client.Services; Subsets: a hierarchy's public, private and session subsets (SubsetScope), their
elements, and the operations bound to a subset or creating a session subset.
A static subset lists its elements; a dynamic one has an MDX Expression.
Binding Elements in a subset PATCH appends to them, so UpdateAsync
refuses it: AddElementsAsync appends by name and ClearElementsAsync empties the
list.
Create a static subset, binding its elements:
// A static subset lists its elements, bound by their paths
var elements = ODataPath.Of("Dimensions").Key("Region").Nav("Hierarchies").Key("Region").Nav("Elements");
return await tm1.Subsets.CreateAsync(
"Region",
"Region",
SubsetScope.Public,
SubsetPatch.Builder().Name("Key Regions").BindElements(elements.Key("North"), elements.Key("South")).Build()
);
Create a dynamic subset from an MDX expression:
// A dynamic subset has an MDX expression, evaluated each time it's read
return await tm1.Subsets.CreateAsync(
"Region",
"Region",
SubsetScope.Public,
SubsetPatch.Builder().Name("All Leaves").Expression("{TM1FILTERBYLEVEL({TM1SUBSETALL([Region].[Region])}, 0)}").Build()
);
Replace a static subset's elements:
// A PATCH appends elements, so empty the list, then add the new ones in order
await tm1.Subsets.ClearElementsAsync("Region", "Region", SubsetScope.Public, "Key Regions");
await tm1.Subsets.AddElementsAsync("Region", "Region", SubsetScope.Public, "Key Regions", ["East", "West"]);
Create a session subset and read its elements by the name TM1 gave it:
// TM1 names a session subset itself, ignoring the name sent: read it by the name
// it gives back
var subset = await tm1.Subsets.CreateSessionSubsetAsync(
"Region",
"Region",
SubsetPatch.Builder().Name("Regions").Expression("{[Region].[Region].[Total].Children}").Build()
);
return await tm1
.Subsets.ElementsAsync("Region", "Region", SubsetScope.Session, subset.Name!, ODataQuery.None().Select(Element.Fields.Name))
.Select(element => element.Name!)
.ToListAsync();
Members
SubsetService constructor | A service that sends its requests through session. |
ListAsync | GET …/Subsets (or PrivateSubsets, SessionSubsets), streamed. |
GetAsync | GET …/Subsets('s'). |
CreateAsync | Creates a subset, static (with bound Elements) or dynamic (with an Expression); returns the subset as created. |
UpdateAsync | Changes the properties the patch sets, such as Expression. |
UpdateAsync | PATCH …/Subsets('s') with If-Match. |
AddElementsAsync | PATCH …/Subsets('s') with Elements@odata.bind. |
ClearElementsAsync | Empties a static subset. |
DeleteAsync | DELETE …/Subsets('s'). |
ElementsAsync | The subset's elements, a dynamic subset's evaluated, streamed. |
HierarchyAsync | GET …/Subsets('s')/Hierarchy. |
SaveAsAsync | Copies the subset under a new name. |
SaveAsAsync | Copies the subset under a new name, private if makePrivate, and static (its current elements, not its expression) if makeStatic. |
SetElementAsync | Adds an element to a static subset. |
SetElementBeforeAsync | tm1.SetElement with Before. |
SetElementAfterAsync | tm1.SetElement with After. |
CreateSessionSubsetAsync | A subset for this session only, from a definition. |
CreateSessionSubsetFromAsync | A subset for this session only, copied from an existing one. |
SubsetService
constructorSubsetService(Tm1Session session)A service that sends its requests through session.
ListAsync
IAsyncEnumerable<Subset> ListAsync( string dimension, string hierarchy, SubsetScope scope, ODataQuery? query = null, CancellationToken cancellationToken = default )GET …/Subsets (or PrivateSubsets, SessionSubsets), streamed.
TM1 REST Navigation Hierarchy/Subsets Navigation Hierarchy/PrivateSubsets Navigation Hierarchy/SessionSubsets
GetAsync
Task<Subset> GetAsync( string dimension, string hierarchy, SubsetScope scope, string subset, ODataQuery? query = null, CancellationToken cancellationToken = default )GET …/Subsets('s').
TM1 REST Navigation Hierarchy/Subsets Navigation Hierarchy/PrivateSubsets Navigation Hierarchy/SessionSubsets
CreateAsync
Task<Subset> CreateAsync(string dimension, string hierarchy, SubsetScope scope, SubsetPatch subset, CancellationToken cancellationToken = default)POST …/Subsets: creates a subset, static (with bound Elements) or dynamic
(with an Expression); returns the subset as created.
TM1 REST Navigation Hierarchy/Subsets Navigation Hierarchy/PrivateSubsets Navigation Hierarchy/SessionSubsets
UpdateAsync
Task UpdateAsync( string dimension, string hierarchy, SubsetScope scope, string subset, SubsetPatch patch, CancellationToken cancellationToken = default )PATCH …/Subsets('s'): changes the properties the patch sets, such as
Expression. A patch with Elements is refused (ArgumentException): TM1
appends them, so use AddElementsAsync, or ClearElementsAsync first.
TM1 REST Navigation Hierarchy/Subsets Navigation Hierarchy/PrivateSubsets Navigation Hierarchy/SessionSubsets
UpdateAsync
Task UpdateAsync( string dimension, string hierarchy, SubsetScope scope, string subset, SubsetPatch patch, string etag, CancellationToken cancellationToken = default )PATCH …/Subsets('s') with If-Match: only if the subset hasn't changed since it
was read with etag; a Tm1PreconditionFailedException if it had.
TM1 REST Navigation Hierarchy/Subsets Navigation Hierarchy/PrivateSubsets Navigation Hierarchy/SessionSubsets
AddElementsAsync
Task AddElementsAsync( string dimension, string hierarchy, SubsetScope scope, string subset, IReadOnlyList<string> elements, CancellationToken cancellationToken = default )PATCH …/Subsets('s') with Elements@odata.bind: appends elements to a static subset.
TM1 REST Navigation Hierarchy/Subsets Navigation Hierarchy/PrivateSubsets Navigation Hierarchy/SessionSubsets
ClearElementsAsync
Task ClearElementsAsync(string dimension, string hierarchy, SubsetScope scope, string subset, CancellationToken cancellationToken = default)DELETE …/Subsets('s')/Elements/$ref: empties a static subset.
TM1 REST Navigation Subset/Elements
DeleteAsync
Task DeleteAsync(string dimension, string hierarchy, SubsetScope scope, string subset, CancellationToken cancellationToken = default)DELETE …/Subsets('s').
TM1 REST Navigation Hierarchy/Subsets Navigation Hierarchy/PrivateSubsets Navigation Hierarchy/SessionSubsets
ElementsAsync
IAsyncEnumerable<Element> ElementsAsync( string dimension, string hierarchy, SubsetScope scope, string subset, ODataQuery? query = null, CancellationToken cancellationToken = default )GET …/Subsets('s')/Elements: the subset's elements, a dynamic subset's evaluated, streamed.
TM1 REST Navigation Subset/Elements
HierarchyAsync
Task<Hierarchy> HierarchyAsync( string dimension, string hierarchy, SubsetScope scope, string subset, ODataQuery? query = null, CancellationToken cancellationToken = default )GET …/Subsets('s')/Hierarchy.
TM1 REST Navigation Subset/Hierarchy
SaveAsAsync
Task<Subset> SaveAsAsync( string dimension, string hierarchy, SubsetScope scope, string subset, string newName, CancellationToken cancellationToken = default )tm1.SaveAs: copies the subset under a new name.
TM1 REST Action Subset/SaveAs
SaveAsAsync
Task<Subset> SaveAsAsync( string dimension, string hierarchy, SubsetScope scope, string subset, string newName, bool makePrivate, bool makeStatic, CancellationToken cancellationToken = default )tm1.SaveAs: copies the subset under a new name, private if makePrivate,
and static (its current elements, not its expression) if makeStatic.
TM1 REST Action Subset/SaveAs
SetElementAsync
Task SetElementAsync( string dimension, string hierarchy, SubsetScope scope, string subset, string element, CancellationToken cancellationToken = default )tm1.SetElement: adds an element to a static subset.
TM1 REST Action Subset/SetElement
SetElementBeforeAsync
Task SetElementBeforeAsync( string dimension, string hierarchy, SubsetScope scope, string subset, string element, string before, CancellationToken cancellationToken = default )tm1.SetElement with Before: adds or moves an element to just before another.
TM1 REST Action Subset/SetElement
SetElementAfterAsync
Task SetElementAfterAsync( string dimension, string hierarchy, SubsetScope scope, string subset, string element, string after, CancellationToken cancellationToken = default )tm1.SetElement with After: adds or moves an element to just after another.
TM1 REST Action Subset/SetElement
CreateSessionSubsetAsync
Task<Subset> CreateSessionSubsetAsync(string dimension, string hierarchy, SubsetPatch definition, CancellationToken cancellationToken = default)tm1.CreateSessionSubset: a subset for this session only, from a definition.
TM1 REST Action Hierarchy/CreateSessionSubset
CreateSessionSubsetFromAsync
Task<Subset> CreateSessionSubsetFromAsync( string dimension, string hierarchy, SubsetScope scope, string subset, CancellationToken cancellationToken = default )tm1.CreateSessionSubset: a subset for this session only, copied from an existing one.
TM1 REST Action Hierarchy/CreateSessionSubset