ODataQuery
from skipcheck_tm1 import ODataQueryUsed in the walkthroughs Connect and list your cubes, Read and write cells, Run a process and read its result, Test your code against a real TM1, Add TM1 to a Spring Boot application.
OData query options: $select, $expand (with nested options),
$filter, $orderby, $top, $skip, $count, custom
options such as TM1's !sandbox, and parameter aliases. Immutable: each method
returns a new query.
query = (
ODataQuery.none()
.select("Name", "Type")
.expand("Hierarchies", lambda h: h.select("Name").top(5))
.filter(Filter.starts_with(ODataProperty.of("Name"), "Q"))
.to_query_string()
)
# $select=Name,Type&$expand=Hierarchies($select=Name;$top=5)&$filter=startswith(Name,'Q'), each value encoded
Options are written in a fixed order, lowercase with $ as OData 4.0 requires,
and each value is percent-encoded once by to_query_string. Nested options
inside $expand are separated by ;.
Members
__init__ constructor | |
none static | No options. |
of static | query (or none), with the keyword options added. |
select | Adds properties to $select, after any already selected. |
expand | Expands a navigation property, with nested options. |
filter | Sets $filter, replacing any set before. |
order_by | Adds an ascending $orderby key, after any keys already added. |
order_by_descending | Adds a descending $orderby key, after any keys already added. |
top | Sets $top. |
skip | Sets $skip. |
with_count | Sets $count=true. |
option | With a value, a query with a custom option (!sandbox); without, that option's value, or None (as Java's two option methods). |
alias | A parameter alias's value. |
is_empty | True if this query has no options. |
custom property | The custom options (those that are not OData system options), by name. |
aliases property | The parameter aliases, by name with its @, each with its literal or JSON value. |
params | Every option as (name, value), unencoded, in order. |
to_query_string | The encoded query string, without ?. |
__init__
constructor__init__(select: Any = None, expand: Any = None, filter: Filter | str | None = None, orderby: Any = None, top: int | None = None, skip: int | None = None, count: bool | None = None, search: str | None = None, custom: Mapping[str, str] | None = None, aliases: Mapping[str, str] | None = None)none
staticnone() -> ODataQueryNo options: the server's default response.
of
staticof(query: ODataQuery | None = None, **options: Any) -> ODataQueryquery (or none), with the keyword options added: what service methods do with their query and **options.
select
select(*properties: str | ODataProperty) -> ODataQueryAdds properties to $select, after any already selected. Like every option here it's an instance method, so it works the same at the top level and inside expand. Returns a new query.
expand
expand(navigation: str | ODataProperty, options: Callable[[ODataQuery], ODataQuery] | ODataQuery | None = None) -> ODataQueryExpands a navigation property, with nested options: a query, or a function of one (lambda h: h.select("Name")), applied to what's there for it already.
filter
filter(filter: Filter | str) -> ODataQuerySets $filter, replacing any set before. Returns a new query.
order_by
order_by(prop: str | ODataProperty) -> ODataQueryAdds an ascending $orderby key, after any keys already added. Returns a new query.
order_by_descending
order_by_descending(prop: str | ODataProperty) -> ODataQueryAdds a descending $orderby key, after any keys already added. Returns a new query.
top
top(n: int) -> ODataQuerySets $top: at most this many items, zero or more. Returns a new query.
skip
skip(n: int) -> ODataQuerySets $skip: skip this many items first, zero or more. Returns a new query.
with_count
with_count() -> ODataQuerySets $count=true: include the total number of matching items. Returns a new query.
option
option(name: str, value: str = _MISSING) -> AnyWith a value, a query with a custom option (!sandbox); without, that option's value, or None (as Java's two option methods).
alias
alias(alias: Alias | str, literal_or_json: str) -> ODataQueryA parameter alias's value: Fn(p=@p) with ?@p=….
is_empty
is_empty() -> boolTrue if this query has no options.
custom
propertycustom: dict[str, str]The custom options (those that are not OData system options), by name.
aliases
propertyaliases: dict[str, str]The parameter aliases, by name with its @, each with its literal or JSON value.
params
params() -> list[tuple[str, str]]Every option as (name, value), unencoded, in order.
to_query_string
to_query_string() -> strThe encoded query string, without ?.