skipcheck

TM1 client · Docs · Reading and writing data

SandboxService

using Skipcheck.Tm1.Client.Services;

Sandboxes: private copies of the data a user writes to before publishing. They belong to the user the session is for.

Reading and writing in a sandbox go through a session view: Tm1Session.WithSandbox or Tm1Client.WithSandbox, which add TM1's !sandbox option to every request. This service manages the sandboxes themselves.

Create a sandbox, write to it, and publish the changes to base data:

// Write to a new sandbox, leaving base data alone until the changes are published
var cell = new Dictionary<string, string>
{
    ["Version"] = "Budget",
    ["Region"] = "North",
    ["Month"] = "Jan",
    ["Measure"] = "Revenue",
};
var whatIf = tm1.WithSandbox("What If");
await tm1.Sandboxes.CreateAsync(SandboxPatch.Builder().Name("What If").Build());
await whatIf.Cells.UpdateAsync("Sales", cell, 1500);
await tm1.Sandboxes.PublishAsync("What If");

Read a cell in base data and in a sandbox:

// The same cell read in base data and in a sandbox: the same query, through a
// client for each
var mdx =
    "SELECT {[Month].[Month].[Jan]} ON 0, {[Region].[Region].[North]} ON 1 FROM [Sales]"
    + " WHERE ([Version].[Version].[Budget], [Measure].[Measure].[Revenue])";
var values = ODataQuery.None().Select(CellsetCell.Fields.Value);
var inBase = tm1.Cellsets.StreamAsync(mdx, values, 1, (cellset, cells) => cells.Select(cell => cell.Value)).FirstAsync();
var inWhatIf = tm1.WithSandbox("What If").Cellsets.StreamAsync(mdx, values, 1, (cellset, cells) => cells.Select(cell => cell.Value)).FirstAsync();
return $"base {await inBase}, what-if {await inWhatIf}";

Members

SandboxService constructorA service that sends its requests through session.
ListAsyncGET Sandboxes, streamed.
GetAsyncThe sandbox, or a Tm1NotFoundException if there's none.
CreateAsyncCreates an empty sandbox; it needs a name.
UpdateAsyncChanges the properties the patch sets, such as IncludeInSandboxDimension.
DeleteAsyncDELETE Sandboxes('name'), with its unpublished changes.
LoadAsyncLoads the sandbox into memory.
UnloadAsyncFrees the sandbox's memory, keeping its changes.
DiscardChangesAsyncThrows away the sandbox's changes, keeping the sandbox.
PublishAsyncWrites the sandbox's changes to base data.
PublishAsynctm1.Publish with options.
MergeAsyncCopies the sandbox's changes into another sandbox, target.
MergeAsynctm1.Merge with options.

SandboxService

constructor
SandboxService(Tm1Session session)

A service that sends its requests through session.

ListAsync

IAsyncEnumerable<Sandbox> ListAsync(ODataQuery? query = null, CancellationToken cancellationToken = default)

GET Sandboxes, streamed: the session user's sandboxes.

TM1 REST EntitySet Sandboxes

GetAsync

Task<Sandbox> GetAsync(string name, ODataQuery? query = null, CancellationToken cancellationToken = default)

GET Sandboxes('name'): the sandbox, or a Tm1NotFoundException if there's none.

TM1 REST EntitySet Sandboxes

CreateAsync

Task<Sandbox> CreateAsync(SandboxPatch sandbox, CancellationToken cancellationToken = default)

POST Sandboxes: creates an empty sandbox; it needs a name.

TM1 REST EntitySet Sandboxes

UpdateAsync

Task UpdateAsync(string name, SandboxPatch patch, CancellationToken cancellationToken = default)

PATCH Sandboxes('name'): changes the properties the patch sets, such as IncludeInSandboxDimension.

TM1 REST EntitySet Sandboxes

DeleteAsync

Task DeleteAsync(string name, CancellationToken cancellationToken = default)

DELETE Sandboxes('name'), with its unpublished changes.

TM1 REST EntitySet Sandboxes

LoadAsync

Task LoadAsync(string name, CancellationToken cancellationToken = default)

tm1.Load: loads the sandbox into memory.

TM1 REST Action Sandbox/Load

UnloadAsync

Task UnloadAsync(string name, CancellationToken cancellationToken = default)

tm1.Unload: frees the sandbox's memory, keeping its changes.

TM1 REST Action Sandbox/Unload

DiscardChangesAsync

Task DiscardChangesAsync(string name, CancellationToken cancellationToken = default)

tm1.DiscardChanges: throws away the sandbox's changes, keeping the sandbox.

TM1 REST Action Sandbox/DiscardChanges

PublishAsync

Task PublishAsync(string name, CancellationToken cancellationToken = default)

tm1.Publish: writes the sandbox's changes to base data.

TM1 REST Action Sandbox/Publish

PublishAsync

Task PublishAsync(string name, ConflictResolution conflicts, bool allowQueueing, bool cleanAfter, CancellationToken cancellationToken = default)

tm1.Publish with options: what to do with cells changed in base data since the sandbox's changes, whether to wait for a lock rather than fail, and whether to empty the sandbox once published.

TM1 REST Action Sandbox/Publish

MergeAsync

Task MergeAsync(string name, string target, CancellationToken cancellationToken = default)

tm1.Merge: copies the sandbox's changes into another sandbox, target.

TM1 REST Action Sandbox/Merge

MergeAsync

Task MergeAsync( string name, string target, ConflictResolution conflicts, bool allowQueueing, bool cleanAfter, CancellationToken cancellationToken = default )

tm1.Merge with options: what to do with cells the target changed too, whether to wait for a lock rather than fail, and whether to empty this sandbox once merged.

TM1 REST Action Sandbox/Merge