BlueGit

ict rusty-teams

Files

rusty-teams / crates / graph / examples / cloud_picker_probe.rs

cloud_picker_probe.rs

chore: cargo fmt the workspace
metis Daniel Däschle · pushed by metis · 2 weeks ago
a6592765 History
cloud_picker_probe.rs 2.2 KiB Download Raw
1use graph::Graph;
2use session::{DEFAULT_ENDPOINT, Session};
3
4#[tokio::main]
5async 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
19 .iter()
20 .filter(|entry| entry.modified_by.is_some())
21 .count()
22 ),
23 Err(error) => println!("my files error: {error}"),
24 },
25 Err(error) => println!("drive root error: {error}"),
26 }
27 match graph.shared_with_me().await {
28 Ok(shared) => println!(
29 "shared {} entries, {} with sharer, {} with date",
30 shared.len(),
31 shared
32 .iter()
33 .filter(|entry| entry.modified_by.is_some())
34 .count(),
35 shared
36 .iter()
37 .filter(|entry| entry.modified_at.is_some())
38 .count()
39 ),
40 Err(error) => println!("shared error: {error}"),
41 }
42 match graph.quick_access_sites().await {
43 Ok(sites) => {
44 println!("sites {}", sites.len());
45 for site in &sites {
46 match graph.drive_root(Some(&site.id)).await {
47 Ok(root) => match graph.list_children(&root).await {
48 Ok(children) => println!("first site library: {} entries", children.len()),
49 Err(error) => println!("site library error: {error}"),
50 },
51 Err(error) => println!("site root error: {error}"),
52 }
53 }
54 }
55 Err(error) => println!("sites error: {error}"),
56 }
57}