skipcheck

TM1 client · Docs · The client

Tm1Request

from skipcheck_tm1 import Tm1Request

One TM1 REST call, described but not sent: the method, path, query, headers and body, and how to read the response.

Every service method is built on one of these. The same request can be sent on its own (the service's ordinary methods do that) or added to a $batch, so anything the client can do one request at a time, it can also batch. Requests are immutable.

# A cube's name, read as plain JSON
cube = Tm1Request.get(ODataPath.of("Cubes").key("Sales"), ODataQuery.none().select("Name"), dict)
# An action with no answer
reserve = Tm1Request.post(ODataPath.of("Cubes").key("Sales").action("tm1.Reserve"), {})

Members

methodThe HTTP method.
pathThe resource path, relative to the service root.
queryThe query options.
headersThe headers this request adds, in the order they were added.
bodyThe body, serialized as JSON when sent, or None for none.
responseHow the response body is read.
typeThe class the response, or each item of a collection, is read as.
timeoutThis request's own timeout, if it has one; otherwise the session's applies.
capability
content_type
get staticGET of one entity or value, read as type.
list staticGET of a collection, read item by item as item_type.
bytes staticGET of raw bytes, such as a document's Content.
put staticPUT of raw bytes, as application/octet-stream unless said otherwise, such as a document's Content.
text staticGET of plain text, such as Configuration/ProductVersion/$value.
post_list staticPOST whose response is a collection, read item by item as item_type.
post staticPOST; type None means no answer is read (Java's Void).
patch staticChange the properties in body, leaving the rest as they are.
delete staticDELETE of the entity at path.
with_queryA copy with these query options instead.
with_headerA copy with a header added or replaced, such as If-Match.
with_timeoutA copy that may go seconds without receiving any data before it fails, instead of the session's request timeout.
requiresThe request, checked against the server's $metadata before it's sent.
requirementWhat this request needs the server to define, or None.
if_matchA copy sent with If-Match.
is_idempotentWhether sending it twice has the effect of sending it once.
relative_uriThe encoded path and query relative to the service root, such as Cubes('Sales')?$select=Name.
readReads the answer as the request says to.
to_callThe request as the sessions send it.

method

method: str

The HTTP method.

path

path: ODataPath

The resource path, relative to the service root.

query

query: ODataQuery

The query options.

headers

headers: Mapping[str, str]

The headers this request adds, in the order they were added.

body

body: Any

The body, serialized as JSON when sent, or None for none.

response

response: Tm1Request.Response

How the response body is read.

type

type: Any

The class the response, or each item of a collection, is read as.

timeout

timeout: float | None

This request's own timeout, if it has one; otherwise the session's applies.

capability

capability: Tm1Capability | None

content_type

content_type: str | None

get

static
get(path: ODataPath, query: ODataQuery | None, type: Any) -> Tm1Request[Any]

GET of one entity or value, read as type.

list

static
list(path: ODataPath, query: ODataQuery | None, item_type: Any) -> Tm1Request[Any]

GET of a collection, read item by item as item_type.

bytes

static
bytes(path: ODataPath) -> Tm1Request[bytes]

GET of raw bytes, such as a document's Content.

put

static
put(path: ODataPath, content: bytes, content_type: str = 'application/octet-stream') -> Tm1Request[None]

PUT of raw bytes, as application/octet-stream unless said otherwise, such as a document's Content. TM1 (11.8) refuses a chunked body (400, with no message), so the bytes are sent with their Content-Length: the whole content is held in memory while it's sent.

text

static
text(path: ODataPath) -> Tm1Request[str]

GET of plain text, such as Configuration/ProductVersion/$value.

post_list

static
post_list(path: ODataPath, body: Any, item_type: Any) -> Tm1Request[Any]

POST whose response is a collection, read item by item as item_type: an action returning Collection(...), such as tm1.CheckRules. body is the parameters, written as JSON.

post

static
post(path: ODataPath, body: Any, type: Any = None) -> Tm1Request[Any]

POST; type None means no answer is read (Java's Void).

patch

static
patch(path: ODataPath, body: Any) -> Tm1Request[None]

PATCH: change the properties in body, leaving the rest as they are.

delete

static
delete(path: ODataPath) -> Tm1Request[None]

DELETE of the entity at path.

with_query

with_query(query: ODataQuery | None) -> Tm1Request[T]

A copy with these query options instead.

with_header

with_header(name: str, value: str) -> Tm1Request[T]

A copy with a header added or replaced, such as If-Match.

with_timeout

with_timeout(seconds: float) -> Tm1Request[T]

A copy that may go seconds without receiving any data before it fails, instead of the session's request timeout. For calls TM1 only answers when the work is done, such as a long process run. Must be positive.

requires

requires(capability: Tm1Capability) -> Tm1Request[T]

The request, checked against the server's $metadata before it's sent: an skipcheck_tm1.errors.Tm1UnsupportedOperationError instead if it lacks it.

requirement

requirement() -> Tm1Capability | None

What this request needs the server to define, or None.

if_match

if_match(etag: str) -> Tm1Request[T]

A copy sent with If-Match: etag, failing with 412 if the entity has changed since.

is_idempotent

is_idempotent() -> bool

Whether sending it twice has the effect of sending it once: GET, PUT, DELETE, HEAD.

relative_uri

relative_uri() -> str

The encoded path and query relative to the service root, such as Cubes('Sales')?$select=Name.

read

read(reply: Reply) -> Any

Reads the answer as the request says to: nothing, bytes, text (without a byte order mark), one value, or a page of a collection.

to_call

to_call() -> Call

The request as the sessions send it.