Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ An async Rust client (reqwest + Tokio) for the **DataHub Platform** REST API, wi
optional blocking client and Python bindings built from the same core.

Services are fields on the `ApiService` returned by `create_api_service()`:
`time_series` (including datapoint ingestion), `units`, `events`, `resources`, `datasets`,
`files`, `subscriptions` (including WebSocket listening), and `functions`.
`time_series` (including datapoint ingestion and the live datapoint tail), `units`, `events`,
`resources`, `assets`, `edges`, `datasets`, `files`, `subscriptions` (including WebSocket
listening), `functions`, `labels` and `tenant`.

The developer documentation, with Python, Rust and Java examples for every endpoint, is at
<https://intellistream.ai/sdk-documentation/>. It describes this repository's `main`.

## Installation

Expand All @@ -18,7 +22,7 @@ alias then applies across the whole crate, with no `use` line in any module:

```toml
[dependencies]
dh = { package = "intellistream-datahub-sdk", version = "0.2" }
dh = { package = "intellistream-datahub-sdk", version = "1.0" }
```

```rust
Expand Down Expand Up @@ -69,7 +73,7 @@ environment:
- Either `TOKEN` (bearer token used as-is, never considered expired), **or** the OAuth2
client-credentials set: `CLIENT_ID`, `CLIENT_SECRET`, `TOKEN_URI`
- `PROJECT_NAME` — optional
- `SCOPE` — against DataHub, needed when the realm uses Keycloak Organizations: that claim comes
- `SCOPE` — added to `openid`, which every token request carries. Against DataHub, needed when the realm uses Keycloak Organizations: that claim comes
from a dynamic client scope, so the request must name it (`organization:*`, or
`organization:<alias>` to pin one tenant). Without it the token carries no tenant and every call
fails `401 invalid_token`, which looks like bad credentials but is not. Not needed where the
Expand Down Expand Up @@ -217,8 +221,13 @@ half a second of the download itself.
## Python bindings

`datahub_python_bindings/` wraps this SDK as the Python package `intellistream-datahub-sdk` (import name
`intellistream_datahub_sdk`) using PyO3 and maturin. The Python test suite in `python_tests/` runs against
the **compiled** module — always use the wrapper script, which rebuilds the bindings first:
`intellistream_datahub_sdk`) using PyO3 and maturin:

```bash
pip install intellistream-datahub-sdk
```

The Python test suite in `python_tests/` runs against the **compiled** module — always use the wrapper script, which rebuilds the bindings first:

```bash
./run_python_tests.sh # build + run the whole suite
Expand Down
2 changes: 1 addition & 1 deletion src/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl TimeSeriesService {
}

/// A binary read frame by frame; see
/// [`BinaryDatapointStream`](crate::timeseries::BinaryDatapointStream) for what an item is and how
/// [`BinaryDatapointStream`] for what an item is and how
/// a response that breaks off shows up.
pub struct BinaryDatapointIter {
stream: BinaryDatapointStream,
Expand Down
5 changes: 3 additions & 2 deletions src/datahub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ pub const DEFAULT_BUFFER_DIR: &str = ".datahub-spool";
/// Default number of datapoint insert requests in flight at once. Each carries up to 100 000 points,
/// which the api holds in memory while it parses them, so this bounds what one insert costs its heap.
pub const DEFAULT_DATAPOINT_INSERT_PARALLELISM: usize = 4;
/// Scope sent with a token request when none is configured. See [`OAuthConfig::effective_scope`].
/// Scope sent with every token request to `TOKEN_URI`. A configured `SCOPE` is added to it, never
/// substituted for it.
pub const DEFAULT_SCOPE: &str = "openid";
/// RFC 7523 grant type: exchange an externally-issued JWT assertion for a token.
const JWT_BEARER_GRANT: &str = "urn:ietf:params:oauth:grant-type:jwt-bearer";
Expand Down Expand Up @@ -119,7 +120,7 @@ impl OAuthConfig {
/// `token_uri` — the identity provider issuing the API's own tokens, which must be the issuer
/// the API validates against and calls UserInfo on. A provider that rejects `openid` alongside
/// other scopes (Entra ID and its `.default`) appears in the assertion flow instead, where it is
/// governed by [`assertion_scope`](Self::effective_scope) and untouched by this.
/// governed by `assertion_scope` and untouched by this.
pub(crate) fn effective_scope(&self) -> Cow<'_, str> {
match self.scope.as_deref() {
None => Cow::Borrowed(DEFAULT_SCOPE),
Expand Down
6 changes: 4 additions & 2 deletions src/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ impl DataSort {
///
/// Flattened into each of them, so `sort` and `cursor` sit beside `filter` and `limit` on the wire.
/// Events carry the same two fields but declare them directly on
/// [`EventFilterForm`](crate::filters::EventFilterForm), which also has `advancedFilter`.
/// [`EventFilterForm`], which also has `advancedFilter`.
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct PageRequest {
Expand Down Expand Up @@ -457,7 +457,9 @@ impl EventFilterForm {
self.limit = limit;
self
}
/// Set the boolean filter expression. See [`EventFilterForm::advanced_filter`].
/// Set the boolean filter expression, such as
/// `type NOT LIKE 'pump' AND (subType = 'water' OR subType = 'gas')`. The api parses and
/// validates it, so an invalid one is a 400 rather than an error here.
pub fn set_advanced_filter(&mut self, expression: impl Into<String>) -> &mut Self {
self.advanced_filter = Some(expression.into());
self
Expand Down
2 changes: 1 addition & 1 deletion src/functions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl FunctionsService {
/// `POST /functions/filter` — functions matching every supplied criterion, newest created
/// first unless the form sorts otherwise.
///
/// The shared [`NodeFilter`](crate::filters::NodeFilter) rules apply — wildcards,
/// The shared [`NodeFilter`] rules apply — wildcards,
/// case-insensitivity, what an empty list means — plus
/// [`data_set_id`](FunctionFilter::data_set_id). Pages: the form carries `sort` and `cursor`,
/// and the response carries `next_cursor`.
Expand Down
2 changes: 1 addition & 1 deletion src/resources/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl ResourceService {
///
/// The cheap "what have I got" read: no body, no criteria. Like every read under
/// `/resources` it spans **every** node type and answers each row in the shape of its own
/// kind — see [`Node`](crate::nodes::Node) — and it is narrowed to the data sets you may read
/// kind — see [`Node`] — and it is narrowed to the data sets you may read
/// exactly as [`filter`](Self::filter) is.
///
/// Resources are the bulk of a tenant, so treat this as a sample rather than an inventory: it
Expand Down
Loading