| 1 | use graph::Graph; |
| 2 | use session::{DEFAULT_ENDPOINT, Session}; |
| 3 | |
| 4 | #[tokio::main] |
| 5 | async fn main() { |
| 6 | let endpoint = std::env::var("CDP_ENDPOINT").unwrap_or_else(|_| DEFAULT_ENDPOINT.to_owned()); |
| 7 | let graph = Graph::new(Session::connect(&endpoint).await.expect("browser")); |
| 8 | match graph.recent_files_with_owners(40).await { |
| 9 | Ok((files, owners)) => println!("recent {} files, {} owners", files.len(), owners.len()), |
| 10 | Err(error) => println!("recent error: {error}"), |
| 11 | } |
| 12 | match graph.drive_root(None).await { |
| 13 | Ok(root) => match graph.list_children(&root).await { |
| 14 | Ok(children) => println!( |
| 15 | "my files {} entries, {} folders, {} with modifier", |
| 16 | children.len(), |
| 17 | children.iter().filter(|entry| entry.is_folder()).count(), |
| 18 | children.iter().filter(|entry| entry.modified_by.is_some()).count() |
| 19 | ), |
| 20 | Err(error) => println!("my files error: {error}"), |
| 21 | }, |
| 22 | Err(error) => println!("drive root error: {error}"), |
| 23 | } |
| 24 | match graph.shared_with_me().await { |
| 25 | Ok(shared) => println!( |
| 26 | "shared {} entries, {} with sharer, {} with date", |
| 27 | shared.len(), |
| 28 | shared.iter().filter(|entry| entry.modified_by.is_some()).count(), |
| 29 | shared.iter().filter(|entry| entry.modified_at.is_some()).count() |
| 30 | ), |
| 31 | Err(error) => println!("shared error: {error}"), |
| 32 | } |
| 33 | match graph.quick_access_sites().await { |
| 34 | Ok(sites) => { |
| 35 | println!("sites {}", sites.len()); |
| 36 | for site in &sites { |
| 37 | match graph.drive_root(Some(&site.id)).await { |
| 38 | Ok(root) => match graph.list_children(&root).await { |
| 39 | Ok(children) => println!("first site library: {} entries", children.len()), |
| 40 | Err(error) => println!("site library error: {error}"), |
| 41 | }, |
| 42 | Err(error) => println!("site root error: {error}"), |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | Err(error) => println!("sites error: {error}"), |
| 47 | } |
| 48 | } |