1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
//! # Microsoft Graph API Client in Rust
//! graph-rs-sdk 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-sdk).
//!
//! ## What APIs are available
//!
//! The APIs 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 not yet included in this project but in general most of them are
//! implemented.
//!
//! For any APIs missing you can make a feature request on GitHub or you can create a PR
//! to add the APIs. Contributions welcome.
//!
//! ## Crate Features
//!
//! The following features can be enabled in the crate:
//!
//! * `interactive-auth`: Interactive Authentication using web view on platforms that support it such as on a desktop. Uses the [wry](https://github.com/tauri-apps/wry)
//! and [tao](https://github.com/tauri-apps/tao) crates for webview support. Supports Linux and Windows platforms. Currently, does not support MacOS - work for this is in progress.
//! * `openssl`: Enables support for using certificates in Client Credentials and Authorization Code auth flows. Additionally, enables related types such as X509Certificate
//! for building/running certificate based auth flows.
//! * `test-util`: Enables test only features. Currently, this just enables the ability to turn off https only in the http client in order to use mocking frameworks with the crate.
//! Other test related features may be added in the future.
//! * `native-tls`: Enables feature native-tls in the reqwest http-client. See the [reqwest crate](https://crates.io/crates/reqwest) for more details.
//! * `rustls-tls`: Enables feature rustls-tls in the reqwest http-client. See the [reqwest crate](https://crates.io/crates/reqwest) for more details.
//! * `brotli`: Enables feature brotli in the reqwest http-client. See the [reqwest crate](https://crates.io/crates/reqwest) for more details.
//! * `deflate`: Enables feature deflate in the reqwest http-client. See the [reqwest crate](https://crates.io/crates/reqwest) for more details.
//! * `trust-dns`: Enables feature trust-dns in the reqwest http-client. See the [reqwest crate](https://crates.io/crates/reqwest) for more details.
//! * `socks`: Enables feature socks (socks proxy support) in the reqwest http-client. See the [reqwest crate](https://crates.io/crates/reqwest) for more details.
//!
//! ## Feature requests or Bug reports.
//!
//! For bug reports please file an issue on [GitHub](https://github.com/sreeise/graph-rs-sdk)
//! and a response or fix will be given as soon as possible.
//!
//! The [Discussions](https://github.com/sreeise/graph-rs-sdk/discussions) tab on
//! [GitHub](https://github.com/sreeise/graph-rs-sdk/discussions) is enabled so feel free to stop by
//! there with any questions or feature requests as well. For bugs, please file an issue first. Other
//! than that feel free to ask questions, provide tips to others, and talk about the project in general.
//!
//! ## Use
//!
//! ```rust,ignore
//! use graph_rs_sdk::*;
//!
//! #[tokio::main]
//! async fn main() -> GraphResult<()> {
//! let client = Graph::new("ACCESS_TOKEN");
//!
//! let response = client.users()
//! .list_user()
//! .send()
//! .await?;
//!
//! println!("{response:#?}");
//!
//! let body: serde_json::Value = response.json().await?;
//! println!("{body:#?}");
//!
//! Ok(())
//! }
//! ```
//! ### Using the blocking client
//!
//! The blocking client can be used by calling `into_blocking()` on a request.
//!
//! ```rust,ignore
//! use graph_rs_sdk::*;
//!
//! fn main() -> GraphResult<()> {
//! let client = Graph::new("ACCESS_TOKEN");
//!
//! let response = client.users()
//! .list_user()
//! .into_blocking()
//! .send()?;
//!
//! println!("{response:#?}");
//!
//! let body: serde_json::Value = response.json()?;
//! println!("{body:#?}");
//!
//! Ok(())
//! }
//! ```
//!
//! ### 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 or use
//! custom_endpoint() for those graph APIs that have custom endpoints such as in
//! countries or governments with their own endpoint.
//!
//! The Graph client must be mutable in order to change from v1 to beta or a custom endpoint.
//!
//! #### Beta
//! ```rust,ignore
//! use graph_rs_sdk::*;
//!
//! #[tokio::main]
//! async fn main() -> GraphResult<()> {
//! let mut client = Graph::new("ACCESS_TOKEN");
//!
//! let response = client.beta()
//! .users()
//! .list_user()
//! .send()
//! .await?;
//!
//! println!("{response:#?}");
//!
//! let body: serde_json::Value = response.json().await?;
//! println!("{body:#?}");
//!
//! Ok(())
//! }
//! ```
//!
//! #### Custom Endpoint
//! ```rust,ignore
//! use graph_rs_sdk::*;
//!
//! #[tokio::main]
//! async fn main() -> GraphResult<()> {
//! let mut client = Graph::new("ACCESS_TOKEN");
//!
//! let response = client.custom_endpoint("https://api.microsoft.com/api")
//! .users()
//! .list_user()
//! .send()
//! .await?;
//!
//! println!("{response:#?}");
//!
//! let body: serde_json::Value = response.json().await?;
//! println!("{body:#?}");
//!
//! Ok(())
//! }
//! ```
//!
//! #### Custom endpoint using `use_endpoint()`
//! ```rust,ignore
//! use graph_rs_sdk::*;
//!
//! #[tokio::main]
//! async fn main() -> GraphResult<()> {
//! let mut client = Graph::new("ACCESS_TOKEN");
//! client.use_endpoint("https://graph.microsoft.com");
//!
//! let response = client
//! .users()
//! .list_user()
//! .send()
//! .await?;
//!
//! println!("{response:#?}");
//!
//! let body: serde_json::Value = response.json().await?;
//! println!("{body:#?}");
//!
//! Ok(())
//! }
//! ```
//!
//! - For more information and examples please see the repository on
//! [GitHub](https://github.com/sreeise/graph-rs-sdk)
//! - If you run into issues related to graph-rs-sdk specifically please
//! file an issue on [GitHub](https://github.com/sreeise/graph-rs-sdk)
//!
//! # OAuth
//!
//! OAuth client implementing the OAuth 2.0 and OpenID Connect protocols on Microsoft identity platform
//!
//! Purpose built as OAuth client for Microsoft Graph and the [graph-rs-sdk](https://crates.io/crates/graph-rs-sdk) project.
//! This project can however be used outside [graph-rs-sdk](https://crates.io/crates/graph-rs-sdk) as an OAuth client
//! for Microsoft Identity Platform.
//!
//! ### Supported Authorization Flows
//!
//! - [Authorization Code Grant](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow)
//! - [Authorization Code Grant PKCE](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow)
//! - [Open ID Connect](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-protocols-oidc)
//! - [Implicit Grant](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-implicit-grant-flow)
//! - [Device Code Flow](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code)
//! - [Client Credentials](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow)
//! - [Resource Owner Password Credentials](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth-ropc)
// mod client needs to stay on top of all other
// client mod declarations for macro use.
/// Main Graph client.
#[macro_use]
pub(crate) mod client;
pub mod admin;
pub mod agreement_acceptances;
pub mod agreements;
pub mod app_catalogs;
pub mod applications;
pub mod audit_logs;
pub mod authentication_method_configurations;
pub mod authentication_methods_policy;
pub mod batch;
pub mod branding;
pub mod certificate_based_auth_configuration;
pub mod chats;
pub mod communications;
pub mod contracts;
pub mod data_policy_operations;
pub mod default_drive;
pub mod device_app_management;
pub mod device_management;
pub mod devices;
pub mod directory;
pub mod directory_objects;
pub mod directory_role_templates;
pub mod directory_roles;
pub mod domain_dns_records;
pub mod domains;
pub mod drives;
pub mod education;
pub mod extended_properties;
pub mod group_lifecycle_policies;
pub mod groups;
/// The main identity APIs with starting path `identity/`
pub mod identity_access;
pub mod identity_governance;
pub mod identity_providers;
pub mod invitations;
pub mod me;
pub mod oauth2_permission_grants;
pub mod organization;
pub mod permission_grants;
pub mod places;
pub mod planner;
pub mod policies;
pub mod reports;
pub mod schema_extensions;
pub mod service_principals;
pub mod sites;
pub mod solutions;
pub mod subscribed_skus;
pub mod subscriptions;
pub mod teams;
pub mod teams_templates;
pub mod teamwork;
pub mod users;
pub static GRAPH_URL: &str = "https://graph.microsoft.com/v1.0";
pub static GRAPH_URL_BETA: &str = "https://graph.microsoft.com/beta";
pub use crate::client::{Graph, GraphClient};
pub use graph_error::{GraphFailure, GraphResult};
pub use graph_http::api_impl::{GraphClientConfiguration, ODataQuery};
/// Reexport of graph-oauth crate.
pub mod identity {
pub use graph_core::identity::ClientApplication;
pub use graph_oauth::*;
}
pub mod http {
pub use graph_core::http::{HttpResponseBuilderExt, HttpResponseExt};
pub use graph_http::api_impl::{BodyRead, FileConfig, UploadSession};
pub use graph_http::traits::{
AsyncIterator, ODataDeltaLink, ODataDownloadLink, ODataMetadataLink, ODataNextLink,
ODataQuery, ResponseBlockingExt, ResponseExt, UploadSessionLink,
};
pub mod blocking {
pub use graph_http::api_impl::UploadSessionBlocking;
pub use reqwest::blocking::Body;
}
pub use reqwest::tls::Version;
pub use reqwest::{Body, Method};
pub use reqwest::{NoProxy, Proxy};
pub use url::Url;
}
/// Reexport of graph-error crate.
pub mod error {
pub use graph_error::*;
}
/// Reexport of reqwest headers for use with API requests.
pub mod header {
pub use reqwest::header::*;
}
pub(crate) mod api_default_imports {
pub(crate) use handlebars::*;
pub(crate) use reqwest::Method;
pub(crate) use url::Url;
pub(crate) use graph_core::resource::ResourceIdentity;
pub(crate) use graph_error::*;
pub(crate) use graph_http::api_impl::*;
pub(crate) use crate::client::{map_errors, map_parameters, ResourceProvisioner};
}