### new constructor usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/api-client-builder.md Example of constructing an ApiClientBuilder with a custom base URL. ```rust let builder = ApiClientBuilder::new("https://api.example.com"); ``` -------------------------------- ### Install via cargo add Source: https://github.com/anduril/lattice-sdk-rust/blob/master/README.md Installs the anduril-lattice-sdk crate using the cargo add command. ```sh cargo add anduril-lattice-sdk ``` -------------------------------- ### Get Ingress Stream Usage Example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/reference.md Retrieves an ingress stream by its identifier. The example builds a default client configuration and calls `client.video.get_ingress_stream` with an example ingress ID and no additional options. ```rust use anduril_lattice_sdk::prelude::*; #[tokio::main] async fn main() { let config = ClientConfig { ..Default::default() }; let client = Lattice::new(config).expect("Failed to build client"); client .video .get_ingress_stream(&"ingressId".to_string(), None) .await; } ``` -------------------------------- ### Full chain example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/api-client-builder.md Complete example showing chaining of configuration methods and building the client. Uses oauth_credentials, timeout, max_retries, custom_header, and user_agent. Requires tokio runtime. ```rust use anduril_lattice_sdk::prelude::*; #[tokio::main] async fn main() { let client = ApiClientBuilder::new("https://example.developer.anduril.com") .oauth_credentials("client-id", "client-secret") .timeout(Duration::from_secs(120)) .max_retries(5) .custom_header("X-Source", "mission-control") .user_agent("mission-app/1.0") .build() .expect("Failed to build client"); client.entities.get_entity("entity-123", None).await?; } ``` -------------------------------- ### listen_as_agent usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/tasks-client.md Example of using listen_as_agent in a loop to receive and handle task requests. Includes handling execute and cancel requests. ```rust let listener = AgentListener { agent_selector: Some(EntityIdsSelector { entity_ids: Some(vec!["agent-entity-1".to_string()]) }), }; loop { let request = client.tasks.listen_as_agent(&listener, None).await?; if let Some(exec) = request.execute_request { // execute the task, then report STATUS_EXECUTING via update_task_status } else if let Some(cancel) = request.cancel_request { if let Some(task_id) = cancel.task_id { client .tasks .update_task_status( task_id, &TaskStatusUpdate { status_version: /* current version */, new_status: /* STATUS_DONE_NOT_OK */, ..Default::default() }, None, ) .await?; } } } ``` -------------------------------- ### create_task usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/tasks-client.md Example call to create_task with a TaskCreation that sets task_id and display_name, using defaults for other fields. Prints the created task's version. ```rust let created = client .tasks .create_task( &TaskCreation { task_id: Some("task-001".to_string()), display_name: Some("survey area".to_string()), ..Default::default() }, None, ) .await?; println!("created {:?}", created.version); ``` -------------------------------- ### Downloading an object with get_object Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/objects-client.md Example of streaming a file download. Use collect() to get a Vec or try_next() per chunk. ```rust let mut stream = client.objects.get_object("missions/recording-1.mp4", None).await?; if let Some(len) = stream.content_length() { println!("{len} bytes") } let bytes = stream.collect().await?; // Vec ``` -------------------------------- ### get_entity usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/entities-client.md Example of calling get_entity with an entity ID and no options, printing the entity's aliases or the error. ```rust match client.entities.get_entity("drone-001", None).await { Ok(entity) => println!("{:?}", entity.aliases), Err(e) => eprintln!("{e}"), } ``` -------------------------------- ### Default construction example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/lattice.md Builds a Lattice client with default ClientConfig and fetches an entity. Requires tokio runtime and the prelude import. Panics if client construction or entity fetch fails. ```rust use anduril_lattice_sdk::prelude::*; #[tokio::main] async fn main() { let config = ClientConfig { ..Default::default() }; let client = Lattice::new(config).expect("Failed to build client"); let entity = client .entities .get_entity(&"entity-123".to_string(), None) .await .expect("get entity"); } ``` -------------------------------- ### get_object_metadata usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/objects-client.md Example call to fetch metadata for `missions/recording-1.mp4` with no request options. The metadata (size, expiry, `last_updated_at`) is available on the raw response headers when using lower-level `HttpClient` calls. ```rust client.objects.get_object_metadata("missions/recording-1.mp4", None).await?; ``` -------------------------------- ### list_objects usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/objects-client.md Lists objects with prefix "missions/" and max page size 100, then prints each object's path and size in bytes. ```rust let page = client .objects .list_objects( &ListObjectsQueryRequest { prefix: Some("missions/".to_string()), max_page_size: Some(100), ..Default::default() }, None, ) .await?; for meta in page.path_metadatas { println!("{} ({} bytes)", meta.content_identifier.path, meta.size_bytes); } ``` -------------------------------- ### stream_tasks usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/tasks-client.md Example of consuming the SSE stream from stream_tasks. Uses futures::StreamExt to iterate over events. ```rust use futures::StreamExt; let stream = client.tasks.stream_tasks(&TaskStreamRequest::default(), None).await?; let mut stream = std::pin::pin!(stream); while let Some(event) = stream.next().await { match event? { StreamTasksResponse::TaskEvent { data } => println!("task event"), _ => {} } } ``` -------------------------------- ### RequestOptions usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/request-options.md Shows how to build RequestOptions with chained setters and pass them to a resource client method. Demonstrates overriding API key, retries, timeout, and adding custom headers and query parameters. ```rust use anduril_lattice_sdk::prelude::*; let options = RequestOptions::new() .api_key("request-scoped-key") .max_retries(3) .timeout_seconds(30) .additional_header("X-Custom-Header", "custom-value") .additional_header("X-Another-Header", "another-value") .additional_query_param("filter", "active") .additional_query_param("sort", "desc"); client.entities.long_poll_entity_events( &EntityEventRequest { session_token: "tok".to_string(), batch_size: None }, Some(options), ).await?; ``` -------------------------------- ### Default::default() signature Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/api-client-builder.md Default implementation starts from ClientConfig::default() with base_url set to Environment::default().url() (https://example.developer.anduril.com). ```rust fn default() -> Self ``` -------------------------------- ### stream_as_agent usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/tasks-client.md Example of calling stream_as_agent with a default AgentStreamRequest and no options. The returned stream is iterated like stream_tasks. ```rust let stream = client .tasks .stream_as_agent(&AgentStreamRequest::default(), None) .await?; // iterate like stream_tasks ``` -------------------------------- ### create_egress_stream usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/video-client.md Creates an egress stream with ingress_id 'ingress-1' and RTSP settings. Returns CreateEgressStreamResponse with egress_id, rtsp, and srt fields. ```rust let created = client .video .create_egress_stream( &CreateEgressStreamRequest { ingress_id: Some("ingress-1".to_string()), rtsp: Some(RtspSettings { url: Some("rtsp://consumer/live".to_string()) }), ..Default::default() }, None, ) .await?; ``` -------------------------------- ### new constructor signature Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/api-client-builder.md Creates an ApiClientBuilder with the given base_url, starting from ClientConfig::default(). ```rust pub fn new(base_url: impl Into) -> Self ``` -------------------------------- ### Query tasks with client.tasks.query_tasks Source: https://github.com/anduril/lattice-sdk-rust/blob/master/reference.md Initializes the Lattice client with default configuration and queries tasks using a default TaskQuery. The example uses tokio's main macro and awaits the query_tasks call, which returns a result that is not handled in this snippet. ```rust use anduril_lattice_sdk::prelude::*; #[tokio::main] async fn main() { let config = ClientConfig { ..Default::default() }; let client = Lattice::new(config).expect("Failed to build client"); client .tasks .query_tasks( &TaskQuery { ..Default::default() }, None, ) .await; } ``` ```rust use anduril_lattice_sdk::prelude::*; #[tokio::main] async fn main() { let config = ClientConfig { ..Default::default() }; let client = Lattice::new(config).expect("Failed to build client"); client .tasks .stream_tasks( &TaskStreamRequest { ..Default::default() }, None, ) .await; } ``` -------------------------------- ### get_token usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/oauth-client.md Explicit client-credentials token acquisition. Constructs a GetTokenRequest with grant_type "client_credentials", client_id, and client_secret, then prints the token type and access token. Requires a Lattice client instance. ```rust let token = client .oauth .get_token( &GetTokenRequest { grant_type: "client_credentials".to_string(), client_id: Some("my-client-id".to_string()), client_secret: Some("my-client-secret".to_string()), }, None, ) .await?; println!("{} {}", token.token_type, token.access_token); ``` -------------------------------- ### list_egress_streams usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/video-client.md Calls list_egress_streams with page_size 50 and no options. Returns ListEgressStreamsResponse with egress_streams and next_page_token. ```rust let page = client .video .list_egress_streams( &ListEgressStreamsQueryRequest { page_size: Some(50), ..Default::default() }, None, ) .await?; ``` -------------------------------- ### create_ingress_stream usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/video-client.md Creates an SRT ingress stream with a passphrase and title. The resulting ingress_id is used to push video to Lattice. ```rust let created = client .video .create_ingress_stream( &CreateIngressStreamRequest { title: Some("south gate camera".to_string()), srt: Some(SrtSettings { passphrase: Some("secret".to_string()) }), ..Default::default() }, None, ) .await?; // use created.ingress_id to push video to Lattice ``` -------------------------------- ### Standalone OAuthTokenProvider usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/oauth-token-provider.md Shows standalone use: create a provider, fetch a token with a user-supplied fetcher, and force refresh when needed. The fetcher calls client.oauth.get_token with client_credentials grant. ```rust use anduril_lattice_sdk::prelude::*; let provider = OAuthTokenProvider::new("client-id", "client-secret"); // sync fetch with a user-supplied fetcher let token = provider.get_or_fetch(|| { let resp = client.oauth.get_token( &GetTokenRequest { grant_type: "client_credentials".to_string(), client_id: Some(provider.client_id().to_string()), client_secret: Some(provider.client_secret().to_string()), }, None, ).await?; Ok((resp.access_token, resp.expires_in.unwrap_or(3600))) })?; // force refresh later if provider.needs_refresh() { provider.reset(); } ``` -------------------------------- ### GET /api/v1/video/ingress_streams Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/endpoints.md Lists ingress streams with pagination. ```APIDOC ## [GET] /api/v1/video/ingress_streams ### Description Lists ingress streams with pagination. ### Method GET ### Endpoint /api/v1/video/ingress_streams ### Parameters #### Query Parameters - **pageSize** (integer) - Optional - Page size - **pageToken** (string) - Optional - Pagination token ### Response #### Success Response (200) - **ingressStreams** (Option>) - List of ingress streams - **nextPageToken** (string) - Token for next page #### Response Example { "ingressStreams": [], "nextPageToken": "string" } ``` -------------------------------- ### upload_object usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/objects-client.md Shows how to call `upload_object` with a file read into bytes and no request options. Prints the uploaded object's size on success or an error message on failure. ```rust let data: Vec = std::fs::read("recording.mp4")?; match client.objects.upload_object("missions/recording-1.mp4", &data, None).await { Ok(meta) => println!("size: {}", meta.size_bytes), Err(e) => eprintln!("upload failed: {e}"), } ``` -------------------------------- ### QueryBuilder::new Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/query-builder.md Creates a new empty QueryBuilder instance. This is the starting point for building query parameters. ```APIDOC ## QueryBuilder::new ### Description Creates a new empty QueryBuilder instance. ### Method `pub fn new() -> Self` ### Parameters None ### Returns - `Self` - A new QueryBuilder instance. ``` -------------------------------- ### SyncPaginator usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/pagination.md Shows constructing a SyncPaginator with a blocking page loader and then collecting all items or iterating. The page loader returns a PaginationResult with items and pagination metadata. ```rust let mut paginator = SyncPaginator::new( Arc::new(HttpClient::new(config)?), move |client, cursor| { // blocking page load... Ok(PaginationResult { items: vec![1, 2], next_cursor: None, has_next_page: false, response: None, status_code: 200, headers: HeaderMap::new(), }) }, None, )?; let all: Vec = paginator.collect_all()?; // explicit // or iterate: for item in paginator { let value = item?; } ``` -------------------------------- ### query_tasks usage example with pagination Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/tasks-client.md Queries tasks with default filters, then uses the returned `next_page_token` to fetch the second page. ```rust let page1 = client .tasks .query_tasks( &TaskQuery::default(), None, ) .await?; if let Some(next) = page1.next_page_token { let page2 = client .tasks .query_tasks( &TaskQuery { page_token: Some(next), ..Default::default() }, None, ) .await?; } ``` -------------------------------- ### QueryBuilder usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/query-builder.md Builds a structured query using QueryBuilder with string, datetime, bool, and int parameters. The build() method returns Option>. ```rust use anduril_lattice_sdk::prelude::*; let query: Option> = QueryBuilder::new() .string("prefix", Some("missions/".to_string())) .datetime("sinceTimestamp", Some(Utc.with_ymd_and_hms(2024, 1, 15, 9, 30, 0)?)) .bool("allObjectsInMesh", Some(true)) .int("maxPageSize", Some(100)) .build(); // Some([("prefix","missions/"), ("sinceTimestamp","2024-01-15T09:30:00Z"), // ("allObjectsInMesh","true"), ("maxPageSize","100")]) ``` -------------------------------- ### stream_manual_control_frames usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/tasks-client.md Example of calling stream_manual_control_frames with a task ID and default request. Each ManualControlFrame carries task_id, epoch_micros, sequence, and specification. ```rust let stream = client .tasks .stream_manual_control_frames( "task-001", &ManualControlStreamRequest::default(), None, ) .await?; // each ManualControlFrame carries task_id, epoch_micros, sequence, specification ``` -------------------------------- ### delete_object usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/objects-client.md Shows how to call `delete_object` with a path and no request options. The call returns `()` on success. ```rust client.objects.delete_object("missions/old-recording.mp4", None).await?; ``` -------------------------------- ### GET /api/v1/video/egress_streams Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/endpoints.md Lists egress streams with pagination. ```APIDOC ## [GET] /api/v1/video/egress_streams ### Description Lists egress streams with pagination. ### Method GET ### Endpoint /api/v1/video/egress_streams ### Parameters #### Query Parameters - **pageSize** (integer) - Optional - Default 50, cap 100 - **pageToken** (string) - Optional - Pagination token ### Response #### Success Response (200) - **egressStreams** (Option>) - List of egress streams - **nextPageToken** (string) - Token for next page #### Response Example { "egressStreams": [], "nextPageToken": "string" } ``` -------------------------------- ### GET /api/v1/objects/{objectPath} Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/endpoints.md Downloads the object at the specified path as raw bytes. ```APIDOC ## [GET] /api/v1/objects/{objectPath} ### Description Downloads the object at the specified path as raw bytes. ### Method GET ### Endpoint /api/v1/objects/{objectPath} ### Parameters #### Path Parameters - **objectPath** (string) - Required - Path to the object ### Response #### Success Response (200) - Body: raw bytes (application/octet-stream) streamed as ByteStream ``` -------------------------------- ### Get object with get_object Source: https://github.com/anduril/lattice-sdk-rust/blob/master/reference.md Fetches an object from your environment using the objectPath path parameter. ```rust use anduril_lattice_sdk::prelude::*; #[tokio::main] async fn main() { let config = ClientConfig { ..Default::default() }; let client = Lattice::new(config).expect("Failed to build client"); client .objects .get_object(&"objectPath".to_string(), None) .await; } ``` -------------------------------- ### Consuming list_objects_paginated with futures::StreamExt Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/objects-client.md Example of consuming the paginator with futures::StreamExt::next(). Each item is a serde_json::Value for one path metadata entry. ```rust use futures::StreamExt; let paginator = client.objects.list_objects_paginated(&ListObjectsQueryRequest::default(), None).await?; let mut paginator = std::pin::pin!(paginator); while let Some(item) = paginator.next().await { let meta = item?; // serde_json::Value for one path metadata entry println!("{:?}", meta); } ``` -------------------------------- ### AsyncPaginator stream usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/pagination.md Shows how to use AsyncPaginator as a futures::Stream. Creates a paginator with a page-loader that fetches objects with pageSize and pageToken query parameters, then iterates over items. Page-load errors surface as Err items from the stream. ```rust use futures::StreamExt; let client = Arc::new(HttpClient::new(config)?); let paginator = AsyncPaginator::new( client, move |client, cursor| { let mut qp: Vec<(String, String)> = vec![("pageSize".to_string(), "50".to_string())]; if let Some(cursor) = cursor { qp.push(("pageToken".to_string(), cursor)); } Box::pin(async move { let raw = client .execute_request_raw::( Method::GET, "api/v1/objects", None, Some(qp), None) .await?; let body = raw.body.clone(); let items: Vec = body .get("items") .and_then(|v| v.as_array()) .map(|arr| arr.clone()) .unwrap_or_default(); let next_cursor: Option = body .get("next") .and_then(|v| v.as_str().map(|s| s.to_string())); Ok(PaginationResult { items, next_cursor, has_next_page: next_cursor.is_some(), response: Some(body), status_code: raw.status_code, headers: raw.headers, }) }) }, None, )?; let mut paginator = std::pin::pin!(paginator); while let Some(item) = paginator.next().await { println!("{:?}", item?); } ``` -------------------------------- ### Consuming the entity stream with futures::StreamExt Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/entities-client.md Shows how to consume the SSE stream. First streams `PREEXISTING` events, then `CREATE`/`UPDATE`/`DELETED` events. The example sets `heartbeat_interval_ms` to 10000 and handles `Heartbeat`, `Entity`, and `__Unknown` variants. ```rust use futures::StreamExt; let stream = client .entities .stream_entities( &EntityStreamRequest { heartbeat_interval_ms: Some(10000), ..Default::default() }, None, ) .await?; let mut stream = std::pin::pin!(stream); while let Some(event) = stream.next().await { match event? { StreamEntitiesResponse::Heartbeat { data } => {} StreamEntitiesResponse::Entity { data } => { if let Some(entity) = data.entity_event_fields.entity { println!("entity: {:?}", entity.entity_id); } } StreamEntitiesResponse::__Unknown(v) => {} } } ``` -------------------------------- ### long_poll_entity_events usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/entities-client.md Demonstrates starting a new polling session with an empty session_token and then continuing with the returned token. The first call returns pre-existing data and a new session token; subsequent calls use that token with a batch size of 100. The server holds the connection for up to 5 minutes when idle and terminates sessions that fall more than 3× behind the total entity count. ```rust // Start a new polling session let first = client .entities .long_poll_entity_events( &EntityEventRequest { session_token: String::new(), batch_size: None }, None, ) .await?; if let Some(token) = first.session_token { let next = client .entities .long_poll_entity_events( &EntityEventRequest { session_token: token, batch_size: Some(100) }, None, ) .await?; } ``` -------------------------------- ### Configure environment with ClientConfig Source: https://github.com/anduril/lattice-sdk-rust/blob/master/README.md Sets the base URL from the Environment::Default variant and builds a client. The client creation can fail, so expect is used to panic on error. ```rust use anduril_lattice_sdk::prelude::{*}; let config = ClientConfig { base_url: Environment::Default.url().to_string(), ..Default::default() }; let client = Client::new(config).expect("Failed to build client"); ``` -------------------------------- ### Delete Ingress Stream Usage Example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/reference.md Deletes a video ingress stream, transitioning it to `STREAM_STATUS_ARCHIVED` and automatically stopping any consuming egress streams. The example uses a default client configuration and calls `client.video.delete_ingress_stream` with an example ingress ID and no additional options. ```rust use anduril_lattice_sdk::prelude::*; #[tokio::main] async fn main() { let config = ClientConfig { ..Default::default() }; let client = Lattice::new(config).expect("Failed to build client"); client .video .delete_ingress_stream(&"ingressId".to_string(), None) .await; } ``` -------------------------------- ### publish_entity usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/entities-client.md Builds an Entity with entity_id "drone-001", description, is_live true, and provenance with a source_update_time. Calls client.entities.publish_entity with no request options. The entity is owned by the originator and cannot be edited or deleted by other sources. ```rust let entity = Entity::builder() .entity_id("drone-001") .description("ISR drone") .is_live(true) .provenance(Provenance { source_update_time: Some(DateTime::parse_from_rfc3339("2024-01-15T09:30:00Z")?), ..Default::default() }) .build()?; let stored = client.entities.publish_entity(&entity, None).await?; ``` -------------------------------- ### get_task usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/tasks-client.md Calls get_task with task_id "task-001" and no options. Handles the Ok result by printing the task status, and matches on ApiError::Http with status 404 to print a not-found message. ```rust match client.tasks.get_task("task-001", None).await { Ok(task) => println!("{:?}", task.status), Err(ApiError::Http { status, message }) if status == 404 => { eprintln!("task not found: {message}") } Err(e) => eprintln!("{e}"), } ``` -------------------------------- ### override_entity usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/entities-client.md Example of overriding the mil_view.disposition field on an entity, building an EntityOverride with only the overridden field set. ```rust let override_body = EntityOverride { entity: Some(Entity::builder().mil_view(/* disposition only */).build()?), ..Default::default() }; client .entities .override_entity("drone-001", "mil_view.disposition", &override_body, None) .await?; ``` -------------------------------- ### Lattice resource client composition diagram Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/lattice.md Shows how Lattice::new wires the resource clients, each owning an HttpClient wrapping the same ClientConfig. ```text Lattice ├── config: ClientConfig ├── entities: EntitiesClient ── HttpClient{config} ├── tasks: TasksClient ── HttpClient{config} ├── objects: ObjectsClient ── HttpClient{config} ├── oauth: OauthClient ── HttpClient{config} └── video: VideoClient ── HttpClient{config} ``` -------------------------------- ### Environment enum with Default variant and url() method Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/configuration.md Defines the Environment enum with a single Default variant, serde-renamed to "default". The url() method returns the base URL string "https://example.developer.anduril.com". Environment::default().url().to_string() is used as the default base_url in ClientConfig. ```rust #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum Environment { #[serde(rename = "default")] Default, } impl Environment { pub fn url(&self) -> &'static str // "https://example.developer.anduril.com" } impl Default for Environment { fn default() -> Self { Self::Default } } ``` -------------------------------- ### Get OAuth Token with client.oauth.get_token Source: https://github.com/anduril/lattice-sdk-rust/blob/master/reference.md Gets a new short-lived token using client credentials. Requires a Lattice client and a GetTokenRequest with grant_type set to client_credentials; client_id and client_secret are optional. ```rust use anduril_lattice_sdk::prelude::*; #[tokio::main] async fn main() { let config = ClientConfig { ..Default::default() }; let client = Lattice::new(config).expect("Failed to build client"); client .oauth .get_token( &GetTokenRequest { grant_type: "client_credentials".to_string(), client_id: None, client_secret: None, }, None, ) .await; } ``` -------------------------------- ### new Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/video-client.md Builds the internal HttpClient for the VideoClient. ```APIDOC ## new ### Description Builds the internal `HttpClient` for the `VideoClient`. ### Method Constructor ### Signature ```rust pub fn new(config: ClientConfig) -> Result ``` ### Parameters - `config` (ClientConfig) - Required - Configuration for the client. ### Returns - `Result` - The constructed `VideoClient` or an error. ``` -------------------------------- ### Lattice::new Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/lattice.md Constructs the Lattice client and its five resource clients from a single ClientConfig. Returns Ok(Lattice) on success or Err(ApiError) if any of the five HttpClient constructions fails. ```APIDOC ## Lattice::new ### Description Constructs the Lattice client and its five resource clients from a single ClientConfig. Returns Ok(Lattice) on success or Err(ApiError) if any of the five HttpClient constructions fails. ### Method Constructor ### Signature pub fn new(config: ClientConfig) -> Result ### Parameters - **config** (ClientConfig) - Required - The client configuration (base URL, auth, timeouts, custom headers) ### Returns - **Ok(Lattice)** - The constructed client with all resource clients - **Err(ApiError)** - If any of the five HttpClient::new(config) constructions fails (e.g., ApiError::Network) ### Errors - **ApiError::Network** - When the internal or custom reqwest::Client cannot be built ### Example — default construction ```rust use anduril_lattice_sdk::prelude::*; #[tokio::main] async fn main() { let config = ClientConfig { ..Default::default() }; let client = Lattice::new(config).expect("Failed to build client"); let entity = client .entities .get_entity(&"entity-123".to_string(), None) .await .expect("get entity"); } ``` ### Example — construction with auth and an error path ```rust use anduril_lattice_sdk::prelude::*; #[tokio::main] async fn main() { let config = ClientConfig { base_url: Environment::default().url().to_string(), client_id: Some("my-client-id".to_string()), client_secret: Some("my-client-secret".to_string()), ..Default::default() }; match Lattice::new(config) { Ok(client) => { client .tasks .query_tasks(&TaskQuery { ..Default::default() }, None) .await; } Err(e) => { eprintln!("construction failed: {e}"); } } } ``` ``` -------------------------------- ### GET /api/v1/video/ingress_streams/{ingressId} Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/endpoints.md Retrieves details of a specific ingress stream. ```APIDOC ## [GET] /api/v1/video/ingress_streams/{ingressId} ### Description Retrieves details of a specific ingress stream. ### Method GET ### Endpoint /api/v1/video/ingress_streams/{ingressId} ### Parameters #### Path Parameters - **ingressId** (string) - Required - ID of the ingress stream ### Response #### Success Response (200) - **ingressStream** (Option) - The ingress stream details #### Response Example { "ingressStream": null } ``` -------------------------------- ### Supply custom reqwest client via ClientConfig Source: https://github.com/anduril/lattice-sdk-rust/blob/master/README.md Builds a reqwest client with a custom root certificate and passes it to ClientConfig.reqwest_client. The SDK uses the client as-is while still applying authentication, custom headers, and retries. ```rust use anduril_lattice_sdk::prelude::*; let certificate = reqwest::Certificate::from_pem(&std::fs::read("ca.pem")?)?; let reqwest_client = reqwest::Client::builder() .add_root_certificate(certificate) .build() .expect("Failed to build reqwest client"); let config = ClientConfig { reqwest_client: Some(reqwest_client), ..Default::default() }; let client = Lattice::new(config).expect("Failed to build client"); ``` -------------------------------- ### GET /api/v1/video/egress_streams/{egressId} Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/endpoints.md Retrieves details of a specific egress stream. ```APIDOC ## [GET] /api/v1/video/egress_streams/{egressId} ### Description Retrieves details of a specific egress stream. ### Method GET ### Endpoint /api/v1/video/egress_streams/{egressId} ### Parameters #### Path Parameters - **egressId** (string) - Required - ID of the egress stream ### Response #### Success Response (200) - **egressStream** (Option) - The egress stream details #### Response Example { "egressStream": null } ``` -------------------------------- ### Import and use request types Source: https://github.com/anduril/lattice-sdk-rust/blob/master/README.md Shows how to import the prelude and construct an EntityOverride request struct. The struct fields are omitted with an ellipsis in the source. ```rust use anduril_lattice_sdk::prelude::{*}; let request = EntityOverride { ... }; ``` -------------------------------- ### GET /api/v1/entities/{entityId} Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/endpoints.md Retrieves an entity by its ID. Returns a 404 if the entity is not found. ```APIDOC ## GET /api/v1/entities/{entityId} ### Description Retrieves an entity by its ID. Returns a 404 if the entity is not found. ### Method GET ### Endpoint /api/v1/entities/{entityId} ### Parameters #### Path Parameters - **entityId** (string) - Required - The ID of the entity to retrieve ### Response #### Success Response (200) - **Entity** - The requested entity #### Errors - 401/403 - Unauthorized - 404 - Not found ``` -------------------------------- ### get_egress_stream method signature Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/video-client.md GET /api/v1/video/egress_streams/{egress_id}. Returns GetEgressStreamResponse with egress_stream field. ```rust pub async fn get_egress_stream( &self, egress_id: &str, options: Option, ) -> Result ``` -------------------------------- ### delete_egress_stream usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/video-client.md Deletes an egress stream and handles the 404 NOT_FOUND error case. ```rust match client.video.delete_egress_stream("egress-1", None).await { Ok(_) => println!("deleted"), Err(ApiError::Http { status, .. }) if status == 404 => eprintln!("no such egress stream"), Err(e) => eprintln!("{e}"), } ``` -------------------------------- ### Instantiate and use the client Source: https://github.com/anduril/lattice-sdk-rust/blob/master/README.md Creates a Lattice client with default configuration and calls long_poll_entity_events with an EntityEventRequest containing a session token and optional batch size. ```rust use anduril_lattice_sdk::prelude::*; #[tokio::main] async fn main() { let config = ClientConfig { ..Default::default() }; let client = Lattice::new(config).expect("Failed to build client"); client .entities .long_poll_entity_events( &EntityEventRequest { session_token: "sessionToken".to_string(), batch_size: None, }, None, ) .await; } ``` -------------------------------- ### cancel_task usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/tasks-client.md Cancels task "task-001" with default cancellation options. ```rust client .tasks .cancel_task("task-001", &TaskCancellation::default(), None) .await?; ``` -------------------------------- ### new constructor signature Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/objects-client.md Builds the internal HttpClient. Returns Result. ```rust pub fn new(config: ClientConfig) -> Result ``` -------------------------------- ### GET /api/v1/objects Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/endpoints.md Lists objects in the mesh, with optional filters for prefix, timestamp, pagination, and scope. ```APIDOC ## [GET] /api/v1/objects ### Description Lists objects in the mesh, with optional filters for prefix, timestamp, pagination, and scope. ### Method GET ### Endpoint /api/v1/objects ### Parameters #### Query Parameters - **prefix** (Option) - Optional - Prefix filter - **sinceTimestamp** (Option>) - Optional - Only objects that arrived at/after this time - **pageToken** (Option) - Optional - Cursor; restart listing if params/scope change - **allObjectsInMesh** (Option) - Optional - List across mesh nodes - **maxPageSize** (Option) - Optional - Max items per page ### Response #### Success Response (200) - **path_metadatas** (Vec) - List of object metadata - **nextPageToken** (Option) - Cursor for next page #### Response Example { "path_metadatas": [], "nextPageToken": "string" } ``` -------------------------------- ### parse_structured_query usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/query-builder.md Parses a structured query string with mixed terms. Handles the InvalidQuerySyntax error case by printing the message. ```rust match parse_structured_query("status:active type:sensor,camera location:\"New York\"") { Ok(params) => println!("{:?}", params), Err(QueryBuilderError::InvalidQuerySyntax(msg)) => eprintln!("{msg}"), } ``` -------------------------------- ### create_ingress_stream method signature Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/video-client.md Creates an ingress stream. Exactly one of rtsp, srt, or mpeg_ts must be set. Returns CreateIngressStreamResponse with ingress_id, mpeg_ts, and srt fields. ```rust pub async fn create_ingress_stream( &self, request: &CreateIngressStreamRequest, options: Option, ) -> Result ``` -------------------------------- ### ApiClientBuilder::new Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/api-client-builder.md Creates a new ApiClientBuilder with a custom base URL. Starts from ClientConfig::default() and sets base_url to the given value. ```APIDOC ## `ApiClientBuilder::new` ### Description Creates a new `ApiClientBuilder` with a custom base URL. Starts from `ClientConfig::default()` and sets `base_url` to the given value. ### Method `pub fn new(base_url: impl Into) -> Self` ### Parameters - **base_url** (impl Into) - Required - The base URL for the API client. ### Example ```rust let builder = ApiClientBuilder::new("https://api.example.com"); ``` ``` -------------------------------- ### SyncPaginator::new constructor signature Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/pagination.md Creates a new SyncPaginator with an HTTP client, a blocking page loader, and an optional initial cursor. The loader must be Send + Sync + 'static. ```rust pub fn new( http_client: Arc, page_loader: F, initial_cursor: Option, ) -> Result where F: Fn(Arc, Option) -> Result, ApiError> + Send + Sync + 'static, ``` -------------------------------- ### delete_ingress_stream usage example Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/video-client.md Deletes the ingress stream with ID "ingress-1" using default request options. ```rust client.video.delete_ingress_stream("ingress-1", None).await?; ``` -------------------------------- ### config Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/http-client.md Returns the client configuration. ```APIDOC ## config ### Description Returns the client configuration. ### Method Accessor ### Signature `pub fn config(&self) -> &ClientConfig` ### Returns The client configuration ``` -------------------------------- ### HttpClient::new_with_oauth constructor Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/http-client.md Explicit OAuth configuration. ```rust pub fn new_with_oauth( config: ClientConfig, oauth_config: Option, ) -> Result ``` -------------------------------- ### Construction with auth and error path Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/lattice.md Builds a Lattice client with base URL, client ID, and client secret, then matches on the result to handle success or failure. On success, queries tasks; on failure, prints an error message. ```rust use anduril_lattice_sdk::prelude::*; #[tokio::main] async fn main() { let config = ClientConfig { base_url: Environment::default().url().to_string(), client_id: Some("my-client-id".to_string()), client_secret: Some("my-client-secret".to_string()), ..Default::default() }; match Lattice::new(config) { Ok(client) => { client .tasks .query_tasks(&TaskQuery { ..Default::default() }, None) .await; } Err(e) => { eprintln!("construction failed: {e}"); } } } ``` -------------------------------- ### Get egress stream with client.video.get_egress_stream Source: https://github.com/anduril/lattice-sdk-rust/blob/master/reference.md Retrieves an egress stream object and its associated metadata. The egress_id parameter is required and identifies the egress stream to retrieve. ```rust use anduril_lattice_sdk::prelude::*; #[tokio::main] async fn main() { let config = ClientConfig { ..Default::default() }; let client = Lattice::new(config).expect("Failed to build client"); client .video .get_egress_stream(&"egressId".to_string(), None) .await; } ``` -------------------------------- ### new Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/entities-client.md Constructs a new EntitiesClient instance from the provided ClientConfig. Builds the internal HttpClient used for all subsequent API calls. ```APIDOC ## `new` ### Description Constructs a new `EntitiesClient` instance from the provided `ClientConfig`. ### Method Constructor ### Parameters - **config** (`ClientConfig`) - Required - Configuration for building the internal `HttpClient`. ### Returns - `Result` - The new client instance or an error. ### Errors - `ApiError` - If the client cannot be constructed from the config. ``` -------------------------------- ### OAuthTokenProvider::get_or_fetch_async (async) Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/oauth-token-provider.md Async single-flight equivalent of get_or_fetch using an async mutex. ```rust pub async fn get_or_fetch_async(&self, fetch_func: F) -> Result where F: FnOnce() -> Fut, Fut: Future>, ``` -------------------------------- ### GET /api/v1/tasks/{taskId} Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/endpoints.md Retrieves a task by its ID. Returns the latest definition version of the task by default. Returns a 404 error if the task does not exist. ```APIDOC ## [GET] /api/v1/tasks/{taskId} ### Description Retrieves a task by its ID. Returns the latest definition version of the task by default. Returns a 404 error if the task does not exist. ### Method GET ### Endpoint /api/v1/tasks/{taskId} ### Parameters #### Path Parameters - **taskId** (string) - Required - The unique identifier of the task ### Response #### Success Response (200) - **Task** - The latest definition version of the task #### Error Handling - 404: Task not found ``` -------------------------------- ### build method signature Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/api-client-builder.md Validates and constructs the client, equivalent to Lattice::new(self.config). Returns ApiError::Network if the reqwest client cannot be built. ```rust pub fn build(self) -> Result ``` -------------------------------- ### list_ingress_streams method signature Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/video-client.md Lists top-level ingress streams (including internal Anduril streams); active streams only, ordered by creation time. Same pagination contract as list_egress_streams. Returns ListIngressStreamsResponse with ingress_streams and next_page_token. ```rust pub async fn list_ingress_streams( &self, request: &ListIngressStreamsQueryRequest, options: Option, ) -> Result ``` -------------------------------- ### Get Task with client.tasks.get_task Source: https://github.com/anduril/lattice-sdk-rust/blob/master/reference.md Retrieves a specific Task by its ID. Returns the latest definition version by default. Use when fetching task details including status, specification, and relations. ```rust use anduril_lattice_sdk::prelude::*; #[tokio::main] async fn main() { let config = ClientConfig { ..Default::default() }; let client = Lattice::new(config).expect("Failed to build client"); client.tasks.get_task(&"taskId".to_string(), None).await; } ``` -------------------------------- ### RequestOptions::new() constructor Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/request-options.md Creates an empty RequestOptions object. Equivalent to RequestOptions::default(). ```rust pub fn new() -> Self ``` -------------------------------- ### get_entity function signature Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/entities-client.md Fetches a single entity by ID via GET {base_url}/api/v1/entities/{entity_id}. Returns the Entity, or ApiError::Http with status 404 if not found. ```rust pub async fn get_entity( &self, entity_id: &str, options: Option, ) -> Result ``` -------------------------------- ### Add dependency to Cargo.toml Source: https://github.com/anduril/lattice-sdk-rust/blob/master/README.md Adds the anduril-lattice-sdk crate version 2.3.0 as a dependency in Cargo.toml. ```toml [dependencies] anduril-lattice-sdk = "2.3.0" ``` -------------------------------- ### OAuthTokenProvider::new constructor Source: https://github.com/anduril/lattice-sdk-rust/blob/master/_autodocs/api-reference/oauth-token-provider.md Creates a new OAuthTokenProvider with the given client ID and secret. ```rust pub fn new(client_id: String, client_secret: String) -> Self ```