Rust SDK for interacting with the Nile.

Related tags

Cryptography rust
Overview

Nile API Rust Client

This is a POC Rust client for the Nile API.

Usage

Source the Nile environment variables into your environment.

export NILE_DEVELOPER_EMAIL=
export NILE_DEVELOPER_PASSWORD=
export NILE_ENTITY_NAME=
export NILE_ORGANIZATION_NAME=
export NILE_WORKSPACE=
export NILE_INSTANCE_ID=

NILE_URL=https://prod.thenile.dev
use std::env;

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

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let username = env::var("NILE_DEVELOPER_EMAIL").expect("NILE_DEVELOPER_EMAIL must be set");
    let password = env::var("NILE_DEVELOPER_PASSWORD").expect("NILE_DEVELOPER_PASSWORD must be set");
    let workspace = env::var("NILE_WORKSPACE").expect("NILE_WORKSPACE must be set");
    let entity_name = env::var("NILE_ENTITY_NAME").expect("NILE_ENTITY_NAME must be set");
    let org = env::var("NILE_ORGANIZATION_NAME").expect("NILE_ORGANIZATION_NAME must be set");


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

List all instances of an entity in a workspace

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

Poll for all events for an entity in a workspace

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

Update attributes on an existing instance

let mut updates = Vec::new();

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

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

// send the updates to the Nile
let status: EntityInstance = client
    .patch_instance(&workspace, &org, &entity_name, &instance_id, updates)
    .await?;
println!("status: {:#?}", status);
}
You might also like...
Rust for the DirectStorage SDK (unofficial)

Rust for the DirectStorage SDK (unofficial) This crate lets you call any DirectStorage SDK API using code generated from the metadata describing the A

🦀 Hop server side SDK for Rust

hop-rs (wip) Hop's Rust library. Requires Rust 1.61+ Installation [dependencies] hop = "0.0.0" Usage Create a project token or personal access token.

A Software Development Kit (SDK) for Zero-Knowledge Transactions

Aleo SDK The Aleo SDK is a developer framework to make it simple to create a new account, craft a transaction, and broadcast it to the network. Table

A Minimal Windows SDK.

Minimal Windows 10 SDK Installs only the necessary Windows 10 .lib files to save you having to download the full Visual Studio package. You can either

Rustcoin - A LightWeight SDK For Bitcoin, Ethernum

Rustcoin - A LightWeight SDK For Bitcoin, Ethernum

tulipv2 vaults and v1 lending program sdk & examples

tulipv2-sdk Warning Unaudited, possibly untested sdk Tulip Protocol takes no responsibility for any (financial, physical, emotional, etc..) damage tha

Longbridge OpenAPI SDK Base.

Longbridge OpenAPI SDK Longbridge OpenAPI provides programmatic quote trading interfaces for investors with research and development capabilities and

Open-Source Gamestreaming SDK
Open-Source Gamestreaming SDK

RhinoStream SDK OpenSource AppStream SDK aims to be (or GameStream) equivalent of FFMpeg or GStreamer aimed for use by developers. Stats for 2560x1440

Move VM for the Cosmos SDK

NovaVM Move VM for the Cosmos SDK. It allows you to compile, initialize and execute Move smart contracts from Go applications, in particular from x/mo

Comments
  • Dry error log

    Dry error log

    -single response/error-handling function outside of NileClient struct, called on by NileClient methods. -error logging and custom response according to method causing issue

    opened by EvanHStanton 0
  • derive Serialize on some event structs

    derive Serialize on some event structs

    Make it easier to serialize the data in these structs, and makes the attributes on an EntityInstance public so that they can actually be useful outside this crate.

    opened by ChuckHend 0
Owner
coredb-io
coredb-io
A simple test on interacting between languages with JS and Rust.

NODE-JS-RUST-FFI A simple test on interacting between languages with JS and Rust. How to run Requirements nodejs rustc + cargo Compile First compile t

Eder Lima 3 Aug 25, 2022
A gRPC-based scripting library for interacting with CosmWasm smart-contracts.

Cosmos Rust Script Smart contract scripting library to ease CosmWasm smart contract development and deployment. cosm-script is inspired by terra-rust-

null 11 Nov 3, 2022
flow-rust-sdk utilizes the Flow gRPC AccessAPI to make requests on the flow blockchain.

Welcome to the Flow-Rust-SDK! We're glad to have you here. There are a few important items that we should cover real quick before you dive in. Version

null 8 Jul 26, 2022
Pokémon TCG SDK - Rust

Pokémon TCG SDK - Rust This is the Pokémon TCG SDK Rust implementation. It is a wrapper around the Pokémon TCG API of pokemontcg.io. Usage Configurati

Pokémon TCG Developers 2 Dec 14, 2022
A template to build smart contracts in Rust to run inside a Cosmos SDK module on all chains that enable it.

CosmWasm Starter Pack This is a template to build smart contracts in Rust to run inside a Cosmos SDK module on all chains that enable it. To understan

null 1 Mar 7, 2022
Smart Contract built in Rust to run inside Cosmos SDK module on all chains that enable it

CoinSwap is a Smart Contract that is built on the terra blockchain and can be used to swap cryptocurrencies such as LUNA, UST, TerraUSD, Anchor, Mirror Protocol, LUNI and other CW20 tokens. The Project also contains a smart contract which works as a analysis tool for the gas fees on the Terra Blockchain.

Prajjwal Chittori 9 Oct 11, 2022
Lazerpay SDK for Rust 🦀

?? Lazerpay Rust SDK This crate integrates the Lazerpay payment gateway for accepting cryptocurrency payments. Usage Add the following to your cargo d

Lord_Sarcastic 15 Sep 21, 2022
This crate reimplements Gelato's Relay SDK in Rust

Gelato Relay SDK This crate reimplements Gelato's Relay SDK in Rust. It simply wraps Gelato Relay requests and responses to/from Gelato endpoints with

Nomad 30 Oct 20, 2022
A universal SDK for FDU. Powered by Rust.

libfdu A universal SDK for FDU. Building You need Rust Nightly installed: $ rustup default nightly Build the library by running: $ cargo build or $ ca

旦夕开发组 6 Sep 11, 2022
mirrorworld-sdk-rust

Usage Clone project code. git clone [email protected]:mirrorworld-universe/mirrorworld-sdk-rust.git cd mirrorworld-sdk-rust run. cargo run test. cargo te

Mirror World 17 Nov 12, 2022