Tm1Request
import { Tm1Request } from "@skipcheck/tm1-client";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
const cube = Tm1Request.get(ODataPath.of("Cubes").key("Sales"), ODataQuery.none().select("Name"));
// An action with no answer
const reserve = Tm1Request.post(ODataPath.of("Cubes").key("Sales").action("tm1.Reserve"), {});
Members
method property | The HTTP method. |
path property | The resource path, relative to the service root. |
query property | The query options, possibly ODataQuery.none. |
headers property | The headers this request adds, in the order they were added. |
body property | The body, serialized as JSON when sent, or null for none. |
response property | How the response body is read. |
type property | What reads the answer (Java's Class<T>); undefined reads JSON as is. |
timeout property | How long to wait for the answer, in milliseconds, instead of the session's request timeout. |
get static | GET of one entity or value, read as type. |
list static | GET of a collection, read item by item as itemType. |
bytes static | GET of raw bytes, such as a document's Content. |
put static | PUT of raw bytes, such as a document's content. |
text static | GET of plain text, such as Configuration/ProductVersion/$value. |
postList static | POST whose response is a collection, read item by item as itemType. |
post static | POST, reading the answer as type; with no type, reading nothing (Mono<Void>). |
patch static | Change the properties in body, leaving the rest as they are. |
delete static | DELETE of the entity at path. |
isIdempotentMethod static | @internal GET, PUT, DELETE and HEAD. |
withQuery | A copy with these query options instead. |
withHeader | A copy with a header added or replaced, such as If-Match. |
withTimeout | @param timeout milliseconds |
requires | The request, checked against the server's $metadata before it's sent. |
requirement | What the server must define for the request, if anything. |
ifMatch | A copy sent with If-Match. |
isIdempotent | Whether sending the request again does what sending it once did (GET, PUT, DELETE, HEAD), so it may be retried after a response was lost. |
relativeUri | The path and query, relative to the service root. |
accept | @internal |
toString | METHOD relative-uri, unencoded, for logs. |
method
propertymethod: stringThe HTTP method.
path
propertypath: ODataPathThe resource path, relative to the service root.
query
propertyquery: ODataQueryThe query options, possibly ODataQuery.none.
headers
propertyheaders: Readonly<Record<string, string>>The headers this request adds, in the order they were added.
body
propertybody: unknownThe body, serialized as JSON when sent, or null for none.
response
propertyresponse: Tm1ResponseHow the response body is read.
type
propertytype: Tm1Model<T> | undefinedWhat reads the answer (Java's Class<T>); undefined reads JSON as is.
timeout
propertytimeout: number | undefinedHow long to wait for the answer, in milliseconds, instead of the session's request timeout.
get
staticstatic get<T = unknown>(path: ODataPath, query?: ODataQuery | null, type?: Tm1Model<T>): Tm1Request<T>GET of one entity or value, read as type.
list
staticstatic list<T = unknown>(path: ODataPath, query?: ODataQuery | null, itemType?: Tm1Model<T>): Tm1Request<T>GET of a collection, read item by item as itemType.
bytes
staticstatic bytes(path: ODataPath): Tm1Request<Uint8Array>GET of raw bytes, such as a document's Content.
put
staticstatic put(path: ODataPath, content: Uint8Array, contentType = "application/octet-stream"): Tm1Request<void>PUT of raw bytes, such as a document's content.
text
staticstatic text(path: ODataPath): Tm1Request<string>GET of plain text, such as Configuration/ProductVersion/$value.
postList
staticstatic postList<T = unknown>(path: ODataPath, body: unknown, itemType?: Tm1Model<T>): Tm1Request<T>POST whose response is a collection, read item by item as itemType: an action returning Collection(...), such as tm1.CheckRules. The body is the parameters, written as JSON.
post
staticstatic post<T = void>(path: ODataPath, body?: unknown, type?: Tm1Model<T>): Tm1Request<T>POST, reading the answer as type; with no type, reading nothing (Mono<Void>).
patch
staticstatic patch(path: ODataPath, body: unknown): Tm1Request<void>PATCH: change the properties in body, leaving the rest as they are.
delete
staticstatic delete(path: ODataPath): Tm1Request<void>DELETE of the entity at path.
isIdempotentMethod
staticstatic isIdempotentMethod(method: string): boolean@internal GET, PUT, DELETE and HEAD: sending one again does what sending it once did.
withQuery
withQuery(query: ODataQuery | null | undefined): Tm1Request<T>A copy with these query options instead.
withHeader
withHeader(name: string, value: string): Tm1Request<T>A copy with a header added or replaced, such as If-Match.
withTimeout
withTimeout(timeout: number): Tm1Request<T>@param timeout milliseconds
requires
requires(capability: Tm1Capability): Tm1Request<T>The request, checked against the server's $metadata before it's sent.
requirement
requirement(): Tm1Capability | undefinedWhat the server must define for the request, if anything.
ifMatch
ifMatch(etag: string): Tm1Request<T>A copy sent with If-Match: etag, failing with 412 if the entity has changed since.
isIdempotent
isIdempotent(): booleanWhether sending the request again does what sending it once did (GET, PUT, DELETE, HEAD), so it may be retried after a response was lost.
relativeUri
relativeUri(): stringThe path and query, relative to the service root.
accept
accept(): string@internal
toString
toString(): stringMETHOD relative-uri, unencoded, for logs.