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
#![warn(missing_docs)] //! Unofficial Auth0 Management API. //! //! # Connection Handling //! Authentication with Auth0 is handled for you provided you provide the values defined //! in the example below. For additional information reference the official Auth0 guide //! for obtaining auth tokens [here](https://auth0.com/docs/tokens). //! ``` //! use auth0_management::Auth0; //! //! async fn init() { //! let auth0 = Auth0::builder() //! .domain(env!("AUTH0_DOMAIN")) //! .audience(env!("AUTH0_AUDIENCE")) //! .client_id(env!("AUTH0_CLIENT_ID")) //! .client_secret(env!("AUTH0_CLIENT_SECRET")) //! .build() //! .unwrap(); //! } //! ``` //! # User Management //! ``` //! use serde::{Serialize, Deserialize}; //! use auth0_management::{Auth0, Pageable, Sortable, Ordering, Auth0Request, User}; //! //! #[derive(Serialize, Deserialize)] //! struct Metadata; //! //! async fn test_users(auth0: &Auth0) { //! // Create a user. //! auth0 //! .users //! .create() //! .email("test@example.test") //! .connection("CONNECTION_ID") //! .send::<(), ()>() //! .await //! .expect("Failed to create a user."); //! //! // Find first user user sort by email address. //! let users: Vec<User<Metadata, Metadata>> = auth0 //! .users //! .find() //! .page(0) //! .per_page(1) //! .sort("email", Ordering::Ascending) //! .send() //! .await //! .expect("Failed to fetch users."); //! //! // Update found user. //! auth0 //! .users //! .update( //! &users //! .first() //! .expect("No users found") //! .user_id //! ) //! .email("test@test.test") //! .send::<(), ()>() //! .await //! .expect("Failed to update user."); //! } //! ``` #[doc(inline)] pub use api::*; pub use builder::*; pub use client::*; pub use error::*; pub use page::*; pub use request::*; pub use sort::*; pub use users::*; use crate::client::Auth0Client; use std::sync::Arc; mod request; pub mod sort; #[allow(missing_docs)] pub mod api; pub mod builder; pub mod client; pub mod error; pub mod page; #[doc(hidden)] pub mod rate; #[doc(hidden)] pub mod token; pub mod users; /// Auth0 management client. pub struct Auth0 { /// Users manager pub users: UsersManager, } impl Auth0 { /// Create auth0 management api pub fn new(client: Auth0Client) -> Self { let client = Arc::new(client); Self { users: UsersManager::new(client), } } /// Create Auth0 client pub fn builder() -> Auth0Builder { Default::default() } }