Nile API Rust Client

This is a POC Rust client for the Nile API.

Usage

Source the Nile environment variables into your environment.

```bash export NILEDEVELOPEREMAIL= export NILEDEVELOPERPASSWORD= export NILEENTITYNAME= export NILEORGANIZATIONNAME= export NILEWORKSPACE= export NILEINSTANCE_ID=

NILE_URL=https://prod.thenile.dev ```

```rust use std::env;

use dotenv::dotenv; use nileclientrs::{EntityInstance, InstanceUpdate, NileClient};

[tokio::main]

async fn main() -> Result<(), Box> { let username = env::var("NILEDEVELOPEREMAIL").expect("NILEDEVELOPEREMAIL must be set"); let password = env::var("NILEDEVELOPERPASSWORD").expect("NILEDEVELOPERPASSWORD must be set"); let workspace = env::var("NILEWORKSPACE").expect("NILEWORKSPACE must be set"); let entityname = env::var("NILEENTITYNAME").expect("NILEENTITYNAME must be set"); let org = env::var("NILEORGANIZATIONNAME").expect("NILEORGANIZATION_NAME must be set");

let mut client = NileClient::default();
client
    .authenticate(username, password)
    .await?;

```

List all instances of an entity in a workspace

rust let instances = client.get_instances(&workspace, &entity_name).await?; println!("instances: {:#?}", instances);

Poll for all events for an entity in a workspace

rust let events = client.get_events(&workspace, &entity_name, 0, 20).await?; println!("events: {:#?}", events);

Update attributes on an existing instance

```rust let mut updates = Vec::new();

// update the number of pods let podct = InstanceUpdate { op: "replace".toowned(), path: "/numPods".toowned(), value: "5".toowned(), }; updates.push(pod_ct);

// update database status let statusupdate = InstanceUpdate { op: "replace".toowned(), path: "/status".toowned(), value: "Up".toowned(), }; updates.push(status_update);

// send the updates to the Nile let status: EntityInstance = client .patchinstance(&workspace, &org, &entityname, &instance_id, updates) .await?; println!("status: {:#?}", status); }

```