Crate openleadr_client

Source
Expand description

§OpenADR 3.0 VEN client

This is a client library to interact with an OpenADR 3.0 complaint VTN server. It mainly wraps the HTTP REST interface into an easy-to-use Rust API.

Basic usage

let credentials =
    ClientCredentials::new("client_id".to_string(), "client_secret".to_string());
let client = Client::with_url(
    "https://your-vtn.com".parse().unwrap(),
    Some(credentials),
);
let new_program = ProgramContent::new("example-program-name".to_string());
let example_program = client.create_program(new_program).await.unwrap();
let mut new_event = example_program.new_event(vec![EventInterval {
    id: 0,
    interval_period: None,
    payloads: vec![EventValuesMap {
        value_type: EventType::Price,
        values: vec![Value::Number(1.23)],
    }],
}]);
new_event.priority = Priority::new(10);
new_event.event_name = Some("Some descriptive name".to_string());
example_program.create_event(new_event).await.unwrap();

If you want to use a separate OAuth provider that is not built into the VTN server, you can do so as well.

// optionally, you can build special configuration into the reqwest client here as well
let reqwest_client = reqwest::Client::new();
let client = Client::with_details(
    "https://your-vtn.com".parse().unwrap(),
    "https://your-oauth-provider.com".parse().unwrap(),
    reqwest_client,
    Some(credentials),
);

Structs§

Client
Client for managing top-level entities on a VTN, i.e., programs and VENs.
ClientCredentials
Credentials necessary for authentication at the VTN
EventClient
Client to manage the data of a specific event and the reports contained in that event
Interval
Holds the data stored in a Timeline.
Iter
Iterator over Timeline.
PaginationOptions
Allows setting specific skip and limit values for list queries.
ProgramClient
A client for interacting with the data in a specific program and the events contained in the program.
ReportClient
Client to manage the data of a specific report
ResourceClient
A client for interacting with the data in a specific resource stored as a child element of a VEN on the VTN.
Timeline
A sequence of ordered, non-overlapping intervals and associated values.
VenClient
A client for interacting with the data in a specific VEN and the resources contained in the VEN.

Enums§

Error
Errors that can occur using the Client
Filter
Filter based on TargetType and TargetValues as specified for various items.
Target
Target for a query to the VTN

Traits§

HttpClient
Abstracts the implementation used for actual requests.