ContentService
using Skipcheck.Tm1.Client.Services; The contents tree, where Planning Analytics keeps applications: folders, documents,
links, and references to cubes, dimensions, subsets, views, processes and chores.
Entries are addressed by ContentPath.
What TM1 (11.8) does here that you might not expect:
- Entries are found by
ID, notName(seeContentPath). - A document made in an application becomes a
DocumentReferencethere, to aDocumentTM1 makes inBlobswith a timestamp in its name, such asnotes_20261122125939.txt. Its content goes through the reference (ContentAsync,UploadAsync). A copy of the reference refers to the same document; deleting a reference leaves the document while another refers to it. - Entries can't be changed: TM1 refuses a PATCH ("PATCH not supported on this resource"), so there's no update. To rename one, copy it with a new name and delete the original.
Build an application: a folder, a link and a cube reference:
// An application: a folder with a link and a reference to a cube
var planning = ContentPath.Applications().Child("Planning");
await tm1.Contents.CreateAsync(ContentPath.Applications(), ContentScope.Public, FolderPatch.Builder().Name("Planning").Build());
await tm1.Contents.CreateAsync(planning, ContentScope.Public, LinkPatch.Builder().Name("Guide").Url("https://example.com/planning-guide").Build());
return await tm1.Contents.CreateAsync(
planning,
ContentScope.Public,
CubeReferencePatch.Builder().Name("Sales").BindCube(ODataPath.Of("Cubes").Key("Sales")).Build()
);
Upload a document from a file:
// A document made in an application is a reference to one TM1 keeps in Blobs; the
// reference, as CreateAsync returns it, is where its content goes
var planning = ContentPath.Applications().Child("Planning");
var reference = await tm1.Contents.CreateAsync(planning, ContentScope.Public, DocumentPatch.Builder().Name("notes.txt").Build());
await tm1.Contents.UploadAsync(planning.Child(reference), await File.ReadAllBytesAsync(file));
Download a document's content to a file:
// The document's bytes, read whole and written to the file
var notes = ContentPath.Applications().Child("Planning").Child("notes.txt.blob");
await File.WriteAllBytesAsync(file, await tm1.Contents.ContentAsync(notes));
List the cubes an application refers to:
// The cubes an application refers to, by a cast expand
return tm1
.Contents.ContentsAsync(
ContentPath.Applications().Child("Planning"),
ContentScope.Public,
ODataQuery.None().Expand("tm1.CubeReference/Cube($select=Name)")
)
.OfType<CubeReference>()
.Where(reference => reference.Cube?.Name is not null)
.Select(reference => reference.Cube!.Name!);
Members
ContentService constructor | A service that sends its requests through session. |
RootsAsync | GET Contents, streamed. |
GetAsync | GET of one entry. |
ContentsAsync | A folder's entries, streamed, each of its own kind. |
CreateAsync | Makes an entry in a folder. |
DeleteAsync | DELETE of an entry, and everything in it if it's a folder. |
ContainedByAsync | The folder an entry is in. |
LocalizedAttributesAsync | LocalizedAttributes, streamed. |
CopyAsync | Copies an entry into the folder target, public or private, named name or, if null, as the entry is. |
MoveAsync | Moves an entry into the folder target, public or private there, renamed name unless it's null. |
DocumentAsync | The document a reference refers to, in Blobs, with its Size and LastUpdated. |
ContentAsync | A document's Content, read whole. |
UploadAsync | Replaces a document's Content. |
ContentService
constructorContentService(Tm1Session session)A service that sends its requests through session.
RootsAsync
IAsyncEnumerable<Entry> RootsAsync(ODataQuery? query = null, CancellationToken cancellationToken = default)GET Contents, streamed: the root folders, Applications and Blobs.
TM1 REST EntitySet Contents
GetAsync
Task<Entry> GetAsync(ContentPath entry, ODataQuery? query = null, CancellationToken cancellationToken = default)GET of one entry. A reference's object comes by a cast expand, such as
Expand("tm1.CubeReference/Cube"). Returns the entry, of its own kind (Folder,
Link, CubeReference …), or a Tm1NotFoundException if there's none.
TM1 REST EntitySet Contents
ContentsAsync
IAsyncEnumerable<Entry> ContentsAsync( ContentPath folder, ContentScope scope, ODataQuery? query = null, CancellationToken cancellationToken = default )A folder's entries, streamed, each of its own kind. References' objects come by a cast
expand, such as Expand("tm1.CubeReference/Cube($select=Name)").
TM1 REST Navigation Folder/Contents Navigation Folder/PrivateContents Navigation ChoreReference/Chore Navigation CubeReference/Cube Navigation DimensionReference/Dimension Navigation ProcessReference/Process Navigation SubsetReference/Subset Navigation ViewReference/View
CreateAsync
Task<Entry> CreateAsync(ContentPath folder, ContentScope scope, EntryPatch entry, CancellationToken cancellationToken = default)Makes an entry in a folder: a FolderPatch, DocumentPatch, LinkPatch
or a reference, such as a CubeReferencePatch with
BindCube(ODataPath.Of("Cubes").Key("Sales")). A document made outside Blobs comes
back as a DocumentReference, with an empty document behind it; UploadAsync
gives it content. Returns the entry as made, with the ID to find it by.
TM1 REST Navigation Folder/Contents Navigation Folder/PrivateContents
DeleteAsync
Task DeleteAsync(ContentPath entry, CancellationToken cancellationToken = default)DELETE of an entry, and everything in it if it's a folder.
TM1 REST EntitySet Contents
ContainedByAsync
Task<Folder> ContainedByAsync(ContentPath entry, ODataQuery? query = null, CancellationToken cancellationToken = default)ContainedBy: the folder an entry is in.
TM1 REST Navigation Entry/ContainedBy
LocalizedAttributesAsync
IAsyncEnumerable<LocalizedAttributes> LocalizedAttributesAsync( ContentPath entry, ODataQuery? query = null, CancellationToken cancellationToken = default )LocalizedAttributes, streamed: an entry's attributes in each locale.
TM1 REST Navigation Entry/LocalizedAttributes
CopyAsync
Task<Entry> CopyAsync( ContentPath entry, ContentPath target, ContentScope scope, string? name = null, CancellationToken cancellationToken = default )tm1.Copy: copies an entry into the folder target, public or
private, named name or, if null, as the entry is. A copied document reference
refers to the same document. Returns the copy.
TM1 REST Action Entry/Copy
MoveAsync
Task<Entry> MoveAsync( ContentPath entry, ContentPath target, ContentScope scope, string? name = null, CancellationToken cancellationToken = default )tm1.Move: moves an entry into the folder target, public or
private there, renamed name unless it's null. Returns the entry where it is now.
TM1 REST Action Entry/Move
DocumentAsync
Task<Document> DocumentAsync(ContentPath reference, ODataQuery? query = null, CancellationToken cancellationToken = default)Document: the document a reference refers to, in Blobs, with its
Size and LastUpdated.
TM1 REST Navigation DocumentReference/Document
ContentAsync
Task<byte[]> ContentAsync(ContentPath document, CancellationToken cancellationToken = default)A document's Content, read whole. The path is a document reference, or a
document in Blobs.
TM1 REST Navigation DocumentReference/Document
UploadAsync
Task UploadAsync(ContentPath document, byte[] content, CancellationToken cancellationToken = default)Replaces a document's Content. The path is a document reference, or a document in
Blobs. TM1 (11.8) refuses a chunked upload, so the content is sent whole, with its length.
TM1 REST Navigation DocumentReference/Document