Expand description

Microsoft Graph API Client in Rust

graph-rs is an API client for Microsoft Graph V1.0 and Graph Beta.

Installation and basic usage can be found below and there are extensive examples in the example’s directory on GitHub](https://github.com/sreeise/graph-rs).

What Api’s are available

The Api’s available are generated from Microsoft’s msgraph-metadata repository which stores OpenApi configs for the Graph Api. There may be some requests and/or Api’s not yet included in this project but in general most of them are implemented.

Feature requests or Bug reports.

For both feature requests and bug reports please file an issue on GitHub and a response or fix will be done as soon as possible.

Use

The client supports both blocking and async requests.

Blocking Client

To use the blocking client

use graph_rs_sdk::prelude::*;

let client =  Graph::new("ACCESS_TOKEN");

Async Client

To use the async client

use graph_rs_sdk::prelude::*;

let client =  Graph::new_async("ACCESS_TOKEN");
The send method and Graph types

The send() method is the main method for sending a request. If there are no errors the return value will be wrapped in a response object and the body will be one of:

  1. serde_json::Value

  2. NoContent (204 responses that return a content field) This is always represented as a serde_json::Value::String and sometimes includes some basic info depending on the request.

Basic Use:

use graph_rs_sdk::prelude::*;

let client =  Graph::new("ACCESS_TOKEN");

let response = client.v1()
    .me()
    .drive()
    .get_drive()
    .send()
    .unwrap();

// Print the value returned in the body of the response
println!("{:#?}", response.body());

Using the Async Client

use graph_rs_sdk::prelude::*;

let client =  Graph::new_async("ACCESS_TOKEN");

let response = client.v1()
    .me()
    .drive()
    .get_drive()
    .send()
    .await
    .unwrap();

println!("{:#?}", response);

Use the Graph version one or beta Api

v1() refers to the endpoint for version 1 of the Microsoft graph Api. You can also use the beta() method which uses the Microsoft graph beta Api endpoint.

use graph_rs_sdk::prelude::*;

let client =  Graph::new_async("ACCESS_TOKEN");

let _response = client.beta()
    .me()
    .get_user()
    .send()?;
  • For more information and examples please see the repository on GitHub
  • If you run into issues related to graph-rs specifically please file an issue on GitHub

Re-exports

pub extern crate serde;
pub extern crate serde_json;
pub extern crate serde_yaml;

Modules

Activities request client.

App catalogs request client.

Applications request client.

Attachments request client.

Audit logs request client.

Planner buckets request client.

Calendar request client.

Calendar groups client.

Calendar view client.

Communication call records request client.

Communication calls request client.

Certificate based auth configuration client.

Mail folders child folders request client.

Main Graph client.

Communications client.

Contact folders client (me, users, etc.).

Contacts request client.

Content types request client.

Contracts request client.

Groups conversations request client.

Types used across multiple crates.

Data policy operations request client.

Device app management request client.

Device management request client.

Directory request client.

Domain dns records request client.

Domains request client.

OneDrive request client.

Education request client.

Reexport of graph-error crate.

Events request client (Calendars).

Extended properties request client.

Group lifecycle policies request client.

Groups request client.

Reexport of reqwest headers for use with API requests.

Reexport of graph-http crate.

Identity request client.

Inference classification client (me, users, etc.).

Insights client (me, users, etc.).

Instances request client (events and calendarView).

Invitations request client.

Items request client.

Lists request client.

Mail folders request client.

Managed devices client.

Me request client.

Messages request client.

Notebooks request client.

Reexport of graph-oauth crate.

OneNote request client.

Contacts/Org Contacts request client.

Outlook request client.

Onenote pages request client.

Onenote parent notebook request client.

Onenote parent section request client.

Onenote parent section group request client.

Places request client.

Planner request client.

Planner plans request client.

Policies request client.

Groups threads posts request client.

Common structs and traits.

Reports request client.

Schema extensions request client.

Onenote section group request client.

Onenote section request client.

Service principles request client.

Communications call record sessions request client.

Settings request client (me, users, etc.).

Sites request client.

Subscribed skus request client.

Subscriptions request client.

Planner tasks request client.

Teams request client.

Teamwork request client.

Groups thread request client.

Users request client.

Statics