diff --git a/README.md b/README.md index 14478e1..c1745cc 100644 --- a/README.md +++ b/README.md @@ -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 +. It describes this repository's `main`. ## Installation @@ -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 @@ -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:` 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 @@ -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 diff --git a/src/blocking.rs b/src/blocking.rs index 4719394..bb8a223 100644 --- a/src/blocking.rs +++ b/src/blocking.rs @@ -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, diff --git a/src/datahub.rs b/src/datahub.rs index 9d2f94c..ba944fb 100644 --- a/src/datahub.rs +++ b/src/datahub.rs @@ -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"; @@ -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), diff --git a/src/filters.rs b/src/filters.rs index bf60796..5978fed 100644 --- a/src/filters.rs +++ b/src/filters.rs @@ -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 { @@ -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) -> &mut Self { self.advanced_filter = Some(expression.into()); self diff --git a/src/functions/mod.rs b/src/functions/mod.rs index 557a246..c73bbf9 100644 --- a/src/functions/mod.rs +++ b/src/functions/mod.rs @@ -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`. diff --git a/src/resources/mod.rs b/src/resources/mod.rs index 3eed3bd..74c4fc3 100644 --- a/src/resources/mod.rs +++ b/src/resources/mod.rs @@ -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