CitraClient

Struct CitraClient 

Source
pub struct CitraClient { /* private fields */ }

Implementations§

Source§

impl CitraClient

Source

pub fn new(api_key: &str) -> Self

Examples found in repository?
examples/update_task.rs (line 13)
7async fn main() {
8    // Get API key from environment variable
9    let api_key = env::var("CITRA_PAT")
10        .expect("CITRA_PAT environment variable not set");
11
12    // Create client
13    let client = CitraClient::new(&api_key);
14
15    // Get task ID from command line argument
16    let args: Vec<String> = env::args().collect();
17    if args.len() < 2 {
18        eprintln!("Usage: cargo run --example update_task <task_id>");
19        std::process::exit(1);
20    }
21    let task_id = &args[1];
22
23    // Test update_task
24    println!("Updating task: {}", task_id);
25    let update_request = TaskUpdateRequest {
26        id: task_id.to_string(),
27        status: TaskStatus::Canceled,
28        priority: Some(5),
29        scheduled_start: None,
30        scheduled_stop: None,
31    };
32    match client.update_task(&update_request).await {
33        Ok(updated_task) => {
34            println!("\n✓ Success!");
35            println!("{:#?}", updated_task);
36        }
37        Err(err) => {
38            eprintln!("\n✗ Error updating task: {}", err);
39        }
40    }
41}
More examples
Hide additional examples
examples/get_groundstation.rs (line 11)
5async fn main() {
6    // Get API key from environment variable
7    let api_key = env::var("CITRA_PAT")
8        .expect("CITRA_PAT environment variable not set");
9
10    // Create client
11    let client = CitraClient::new(&api_key);
12
13    // Get groundstation ID from command line argument if provided
14    let args: Vec<String> = env::args().collect();
15    
16    if args.len() >= 2 {
17        let groundstation_id = &args[1];
18        
19        // Test get_groundstation
20        println!("Fetching groundstation: {}", groundstation_id);
21        match client.get_groundstation(groundstation_id).await {
22            Ok(groundstation) => {
23                println!("\n✓ Success!");
24                println!("{:#?}", groundstation);
25            }
26            Err(e) => {
27                eprintln!("\n✗ Error: {}", e);
28                std::process::exit(1);
29            }
30        }
31        
32        println!("\n");
33    }
34
35    // Test list_groundstations
36    println!("Fetching all groundstations...");
37    match client.list_groundstations().await {
38        Ok(groundstations) => {
39            println!("\n✓ Found {} groundstation(s)", groundstations.len());
40            for groundstation in groundstations {
41                println!("  - {} ({}) at {}, {}", 
42                    groundstation.name, 
43                    groundstation.id,
44                    groundstation.latitude,
45                    groundstation.longitude
46                );
47            }
48        }
49        Err(e) => {
50            eprintln!("\n✗ Error: {}", e);
51        }
52    }
53}
examples/get_antenna.rs (line 12)
6async fn main() {
7    // Get API key from environment variable
8    let api_key = env::var("CITRA_PAT")
9        .expect("CITRA_PAT environment variable not set");
10
11    // Create client
12    let client = CitraClient::new(&api_key);
13
14    // Get telescope ID from command line argument
15    let args: Vec<String> = env::args().collect();
16    if args.len() < 2 {
17        eprintln!("Usage: cargo run --example get_antenna <antenna-id>");
18        std::process::exit(1);
19    }
20    let antenna_id = &args[1];
21
22    // Test get_antenna
23    println!("Fetching antenna: {}", antenna_id);
24    match client.get_antenna(antenna_id).await {
25        Ok(antenna) => {
26            println!("\n✓ Success!");
27            println!("{:#?}", antenna);
28        }
29        Err(e) => {
30            eprintln!("\n✗ Error: {}", e);
31            std::process::exit(1);
32        }
33    }
34
35    // Test list_tasks_for_antenna
36    println!("\n\nFetching tasks for antenna: {}", antenna_id);
37    match client.list_tasks_for_antenna(antenna_id).await {
38        Ok(tasks) => {
39            println!("\n✓ Found {} task(s) for antenna {}", tasks.len(), antenna_id);
40            for task in tasks {
41                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
42            }
43        }
44        Err(e) => {
45            eprintln!("\n✗ Error fetching tasks for antenna: {}", e);
46        }
47    }
48
49    // Test get_antenna_tasks_by_status
50    let status_filter = vec![TaskStatus::Pending];
51    println!("\n\nFetching tasks for antenna: {} with status: {:?}", antenna_id, status_filter);
52    match client.get_antenna_tasks_by_status(antenna_id, status_filter).await {
53        Ok(tasks) => {
54            for task in tasks {
55                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
56            }
57        }
58        Err(e) => {
59            eprintln!("\n✗ Error fetching tasks for antenna by status: {}", e);
60        }
61    }
62
63    // Test list_antennas
64    println!("\n\nFetching all antennas...");
65    match client.list_antennas().await {
66        Ok(antennas) => {
67            println!("\n✓ Found {} antenna(s)", antennas.len());
68            for antenna in antennas {
69                println!("  - {} ({})", antenna.name, antenna.id);
70            }
71        }
72        Err(e) => {
73            eprintln!("\n✗ Error listing antennas: {}", e);
74        }
75    }
76}
examples/get_telescope.rs (line 12)
6async fn main() {
7    // Get API key from environment variable
8    let api_key = env::var("CITRA_PAT")
9        .expect("CITRA_PAT environment variable not set");
10
11    // Create client
12    let client = CitraClient::new(&api_key);
13
14    // Get telescope ID from command line argument
15    let args: Vec<String> = env::args().collect();
16    if args.len() < 2 {
17        eprintln!("Usage: cargo run --example get_telescope <telescope-id>");
18        std::process::exit(1);
19    }
20    let telescope_id = &args[1];
21
22    // Test get_telescope
23    println!("Fetching telescope: {}", telescope_id);
24    match client.get_telescope(telescope_id).await {
25        Ok(telescope) => {
26            println!("\n✓ Success!");
27            println!("{:#?}", telescope);
28        }
29        Err(e) => {
30            eprintln!("\n✗ Error: {}", e);
31            std::process::exit(1);
32        }
33    }
34
35    // Test list_tasks_for_telescope with debug
36    println!("\n\nFetching tasks for telescope: {}", telescope_id);
37    match client.list_tasks_for_telescope(telescope_id).await {
38        Ok(tasks) => {
39            println!("\n✓ Found {} task(s) for telescope {}", tasks.len(), telescope_id);
40            for task in tasks {
41                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
42            }
43        }
44        Err(e) => {
45            eprintln!("\n✗ Error fetching tasks for telescope: {}", e);
46        }
47    }
48
49    // Test get_telescope_tasks_by_status
50    let status_filter = vec![TaskStatus::Pending];
51    println!("\n\nFetching tasks for telescope: {} with status: {:?}", telescope_id, status_filter);
52    match client.get_telescope_tasks_by_status(telescope_id, status_filter).await {
53        Ok(tasks) => {
54            for task in tasks {
55                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
56            }
57        }
58        Err(e) => {
59            eprintln!("\n✗ Error fetching tasks for telescope by status: {}", e);
60        }
61    }
62
63    // Test list_telescopes
64    println!("\n\nFetching all telescopes...");
65    match client.list_telescopes().await {
66        Ok(telescopes) => {
67            println!("\n✓ Found {} telescope(s)", telescopes.len());
68            for telescope in telescopes {
69                println!("  - {} ({})", telescope.name, telescope.id);
70            }
71        }
72        Err(e) => {
73            eprintln!("\n✗ Error listing telescopes: {}", e);
74        }
75    }
76}
Source

pub async fn get_telescope( &self, telescope_id: &str, ) -> Result<Telescope, Error>

Examples found in repository?
examples/get_telescope.rs (line 24)
6async fn main() {
7    // Get API key from environment variable
8    let api_key = env::var("CITRA_PAT")
9        .expect("CITRA_PAT environment variable not set");
10
11    // Create client
12    let client = CitraClient::new(&api_key);
13
14    // Get telescope ID from command line argument
15    let args: Vec<String> = env::args().collect();
16    if args.len() < 2 {
17        eprintln!("Usage: cargo run --example get_telescope <telescope-id>");
18        std::process::exit(1);
19    }
20    let telescope_id = &args[1];
21
22    // Test get_telescope
23    println!("Fetching telescope: {}", telescope_id);
24    match client.get_telescope(telescope_id).await {
25        Ok(telescope) => {
26            println!("\n✓ Success!");
27            println!("{:#?}", telescope);
28        }
29        Err(e) => {
30            eprintln!("\n✗ Error: {}", e);
31            std::process::exit(1);
32        }
33    }
34
35    // Test list_tasks_for_telescope with debug
36    println!("\n\nFetching tasks for telescope: {}", telescope_id);
37    match client.list_tasks_for_telescope(telescope_id).await {
38        Ok(tasks) => {
39            println!("\n✓ Found {} task(s) for telescope {}", tasks.len(), telescope_id);
40            for task in tasks {
41                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
42            }
43        }
44        Err(e) => {
45            eprintln!("\n✗ Error fetching tasks for telescope: {}", e);
46        }
47    }
48
49    // Test get_telescope_tasks_by_status
50    let status_filter = vec![TaskStatus::Pending];
51    println!("\n\nFetching tasks for telescope: {} with status: {:?}", telescope_id, status_filter);
52    match client.get_telescope_tasks_by_status(telescope_id, status_filter).await {
53        Ok(tasks) => {
54            for task in tasks {
55                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
56            }
57        }
58        Err(e) => {
59            eprintln!("\n✗ Error fetching tasks for telescope by status: {}", e);
60        }
61    }
62
63    // Test list_telescopes
64    println!("\n\nFetching all telescopes...");
65    match client.list_telescopes().await {
66        Ok(telescopes) => {
67            println!("\n✓ Found {} telescope(s)", telescopes.len());
68            for telescope in telescopes {
69                println!("  - {} ({})", telescope.name, telescope.id);
70            }
71        }
72        Err(e) => {
73            eprintln!("\n✗ Error listing telescopes: {}", e);
74        }
75    }
76}
Source

pub async fn list_telescopes(&self) -> Result<Vec<Telescope>, Error>

Examples found in repository?
examples/get_telescope.rs (line 65)
6async fn main() {
7    // Get API key from environment variable
8    let api_key = env::var("CITRA_PAT")
9        .expect("CITRA_PAT environment variable not set");
10
11    // Create client
12    let client = CitraClient::new(&api_key);
13
14    // Get telescope ID from command line argument
15    let args: Vec<String> = env::args().collect();
16    if args.len() < 2 {
17        eprintln!("Usage: cargo run --example get_telescope <telescope-id>");
18        std::process::exit(1);
19    }
20    let telescope_id = &args[1];
21
22    // Test get_telescope
23    println!("Fetching telescope: {}", telescope_id);
24    match client.get_telescope(telescope_id).await {
25        Ok(telescope) => {
26            println!("\n✓ Success!");
27            println!("{:#?}", telescope);
28        }
29        Err(e) => {
30            eprintln!("\n✗ Error: {}", e);
31            std::process::exit(1);
32        }
33    }
34
35    // Test list_tasks_for_telescope with debug
36    println!("\n\nFetching tasks for telescope: {}", telescope_id);
37    match client.list_tasks_for_telescope(telescope_id).await {
38        Ok(tasks) => {
39            println!("\n✓ Found {} task(s) for telescope {}", tasks.len(), telescope_id);
40            for task in tasks {
41                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
42            }
43        }
44        Err(e) => {
45            eprintln!("\n✗ Error fetching tasks for telescope: {}", e);
46        }
47    }
48
49    // Test get_telescope_tasks_by_status
50    let status_filter = vec![TaskStatus::Pending];
51    println!("\n\nFetching tasks for telescope: {} with status: {:?}", telescope_id, status_filter);
52    match client.get_telescope_tasks_by_status(telescope_id, status_filter).await {
53        Ok(tasks) => {
54            for task in tasks {
55                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
56            }
57        }
58        Err(e) => {
59            eprintln!("\n✗ Error fetching tasks for telescope by status: {}", e);
60        }
61    }
62
63    // Test list_telescopes
64    println!("\n\nFetching all telescopes...");
65    match client.list_telescopes().await {
66        Ok(telescopes) => {
67            println!("\n✓ Found {} telescope(s)", telescopes.len());
68            for telescope in telescopes {
69                println!("  - {} ({})", telescope.name, telescope.id);
70            }
71        }
72        Err(e) => {
73            eprintln!("\n✗ Error listing telescopes: {}", e);
74        }
75    }
76}
Source

pub async fn create_telescope( &self, telescope: &Telescope, ) -> Result<Telescope, Error>

Source

pub async fn delete_telescope(&self, telescope_id: &str) -> Result<(), Error>

Source

pub async fn update_telescope( &self, telescope: &Telescope, ) -> Result<Telescope, Error>

Source

pub async fn get_groundstation( &self, groundstation_id: &str, ) -> Result<Groundstation, Error>

Examples found in repository?
examples/get_groundstation.rs (line 21)
5async fn main() {
6    // Get API key from environment variable
7    let api_key = env::var("CITRA_PAT")
8        .expect("CITRA_PAT environment variable not set");
9
10    // Create client
11    let client = CitraClient::new(&api_key);
12
13    // Get groundstation ID from command line argument if provided
14    let args: Vec<String> = env::args().collect();
15    
16    if args.len() >= 2 {
17        let groundstation_id = &args[1];
18        
19        // Test get_groundstation
20        println!("Fetching groundstation: {}", groundstation_id);
21        match client.get_groundstation(groundstation_id).await {
22            Ok(groundstation) => {
23                println!("\n✓ Success!");
24                println!("{:#?}", groundstation);
25            }
26            Err(e) => {
27                eprintln!("\n✗ Error: {}", e);
28                std::process::exit(1);
29            }
30        }
31        
32        println!("\n");
33    }
34
35    // Test list_groundstations
36    println!("Fetching all groundstations...");
37    match client.list_groundstations().await {
38        Ok(groundstations) => {
39            println!("\n✓ Found {} groundstation(s)", groundstations.len());
40            for groundstation in groundstations {
41                println!("  - {} ({}) at {}, {}", 
42                    groundstation.name, 
43                    groundstation.id,
44                    groundstation.latitude,
45                    groundstation.longitude
46                );
47            }
48        }
49        Err(e) => {
50            eprintln!("\n✗ Error: {}", e);
51        }
52    }
53}
Source

pub async fn list_groundstations(&self) -> Result<Vec<Groundstation>, Error>

Examples found in repository?
examples/get_groundstation.rs (line 37)
5async fn main() {
6    // Get API key from environment variable
7    let api_key = env::var("CITRA_PAT")
8        .expect("CITRA_PAT environment variable not set");
9
10    // Create client
11    let client = CitraClient::new(&api_key);
12
13    // Get groundstation ID from command line argument if provided
14    let args: Vec<String> = env::args().collect();
15    
16    if args.len() >= 2 {
17        let groundstation_id = &args[1];
18        
19        // Test get_groundstation
20        println!("Fetching groundstation: {}", groundstation_id);
21        match client.get_groundstation(groundstation_id).await {
22            Ok(groundstation) => {
23                println!("\n✓ Success!");
24                println!("{:#?}", groundstation);
25            }
26            Err(e) => {
27                eprintln!("\n✗ Error: {}", e);
28                std::process::exit(1);
29            }
30        }
31        
32        println!("\n");
33    }
34
35    // Test list_groundstations
36    println!("Fetching all groundstations...");
37    match client.list_groundstations().await {
38        Ok(groundstations) => {
39            println!("\n✓ Found {} groundstation(s)", groundstations.len());
40            for groundstation in groundstations {
41                println!("  - {} ({}) at {}, {}", 
42                    groundstation.name, 
43                    groundstation.id,
44                    groundstation.latitude,
45                    groundstation.longitude
46                );
47            }
48        }
49        Err(e) => {
50            eprintln!("\n✗ Error: {}", e);
51        }
52    }
53}
Source

pub async fn create_groundstation( &self, groundstation: &Groundstation, ) -> Result<Groundstation, Error>

Source

pub async fn delete_groundstation( &self, groundstation_id: &str, ) -> Result<(), Error>

Source

pub async fn update_groundstation( &self, groundstation: &Groundstation, ) -> Result<Groundstation, Error>

Source

pub async fn list_tasks_for_telescope( &self, telescope_id: &str, ) -> Result<Vec<Task>, Error>

Examples found in repository?
examples/get_telescope.rs (line 37)
6async fn main() {
7    // Get API key from environment variable
8    let api_key = env::var("CITRA_PAT")
9        .expect("CITRA_PAT environment variable not set");
10
11    // Create client
12    let client = CitraClient::new(&api_key);
13
14    // Get telescope ID from command line argument
15    let args: Vec<String> = env::args().collect();
16    if args.len() < 2 {
17        eprintln!("Usage: cargo run --example get_telescope <telescope-id>");
18        std::process::exit(1);
19    }
20    let telescope_id = &args[1];
21
22    // Test get_telescope
23    println!("Fetching telescope: {}", telescope_id);
24    match client.get_telescope(telescope_id).await {
25        Ok(telescope) => {
26            println!("\n✓ Success!");
27            println!("{:#?}", telescope);
28        }
29        Err(e) => {
30            eprintln!("\n✗ Error: {}", e);
31            std::process::exit(1);
32        }
33    }
34
35    // Test list_tasks_for_telescope with debug
36    println!("\n\nFetching tasks for telescope: {}", telescope_id);
37    match client.list_tasks_for_telescope(telescope_id).await {
38        Ok(tasks) => {
39            println!("\n✓ Found {} task(s) for telescope {}", tasks.len(), telescope_id);
40            for task in tasks {
41                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
42            }
43        }
44        Err(e) => {
45            eprintln!("\n✗ Error fetching tasks for telescope: {}", e);
46        }
47    }
48
49    // Test get_telescope_tasks_by_status
50    let status_filter = vec![TaskStatus::Pending];
51    println!("\n\nFetching tasks for telescope: {} with status: {:?}", telescope_id, status_filter);
52    match client.get_telescope_tasks_by_status(telescope_id, status_filter).await {
53        Ok(tasks) => {
54            for task in tasks {
55                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
56            }
57        }
58        Err(e) => {
59            eprintln!("\n✗ Error fetching tasks for telescope by status: {}", e);
60        }
61    }
62
63    // Test list_telescopes
64    println!("\n\nFetching all telescopes...");
65    match client.list_telescopes().await {
66        Ok(telescopes) => {
67            println!("\n✓ Found {} telescope(s)", telescopes.len());
68            for telescope in telescopes {
69                println!("  - {} ({})", telescope.name, telescope.id);
70            }
71        }
72        Err(e) => {
73            eprintln!("\n✗ Error listing telescopes: {}", e);
74        }
75    }
76}
Source

pub async fn get_telescope_tasks_by_status( &self, telescope_id: &str, statuses: Vec<TaskStatus>, ) -> Result<Vec<Task>, Error>

Examples found in repository?
examples/get_telescope.rs (line 52)
6async fn main() {
7    // Get API key from environment variable
8    let api_key = env::var("CITRA_PAT")
9        .expect("CITRA_PAT environment variable not set");
10
11    // Create client
12    let client = CitraClient::new(&api_key);
13
14    // Get telescope ID from command line argument
15    let args: Vec<String> = env::args().collect();
16    if args.len() < 2 {
17        eprintln!("Usage: cargo run --example get_telescope <telescope-id>");
18        std::process::exit(1);
19    }
20    let telescope_id = &args[1];
21
22    // Test get_telescope
23    println!("Fetching telescope: {}", telescope_id);
24    match client.get_telescope(telescope_id).await {
25        Ok(telescope) => {
26            println!("\n✓ Success!");
27            println!("{:#?}", telescope);
28        }
29        Err(e) => {
30            eprintln!("\n✗ Error: {}", e);
31            std::process::exit(1);
32        }
33    }
34
35    // Test list_tasks_for_telescope with debug
36    println!("\n\nFetching tasks for telescope: {}", telescope_id);
37    match client.list_tasks_for_telescope(telescope_id).await {
38        Ok(tasks) => {
39            println!("\n✓ Found {} task(s) for telescope {}", tasks.len(), telescope_id);
40            for task in tasks {
41                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
42            }
43        }
44        Err(e) => {
45            eprintln!("\n✗ Error fetching tasks for telescope: {}", e);
46        }
47    }
48
49    // Test get_telescope_tasks_by_status
50    let status_filter = vec![TaskStatus::Pending];
51    println!("\n\nFetching tasks for telescope: {} with status: {:?}", telescope_id, status_filter);
52    match client.get_telescope_tasks_by_status(telescope_id, status_filter).await {
53        Ok(tasks) => {
54            for task in tasks {
55                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
56            }
57        }
58        Err(e) => {
59            eprintln!("\n✗ Error fetching tasks for telescope by status: {}", e);
60        }
61    }
62
63    // Test list_telescopes
64    println!("\n\nFetching all telescopes...");
65    match client.list_telescopes().await {
66        Ok(telescopes) => {
67            println!("\n✓ Found {} telescope(s)", telescopes.len());
68            for telescope in telescopes {
69                println!("  - {} ({})", telescope.name, telescope.id);
70            }
71        }
72        Err(e) => {
73            eprintln!("\n✗ Error listing telescopes: {}", e);
74        }
75    }
76}
Source

pub async fn update_task(&self, task: &TaskUpdateRequest) -> Result<Task, Error>

Examples found in repository?
examples/update_task.rs (line 32)
7async fn main() {
8    // Get API key from environment variable
9    let api_key = env::var("CITRA_PAT")
10        .expect("CITRA_PAT environment variable not set");
11
12    // Create client
13    let client = CitraClient::new(&api_key);
14
15    // Get task ID from command line argument
16    let args: Vec<String> = env::args().collect();
17    if args.len() < 2 {
18        eprintln!("Usage: cargo run --example update_task <task_id>");
19        std::process::exit(1);
20    }
21    let task_id = &args[1];
22
23    // Test update_task
24    println!("Updating task: {}", task_id);
25    let update_request = TaskUpdateRequest {
26        id: task_id.to_string(),
27        status: TaskStatus::Canceled,
28        priority: Some(5),
29        scheduled_start: None,
30        scheduled_stop: None,
31    };
32    match client.update_task(&update_request).await {
33        Ok(updated_task) => {
34            println!("\n✓ Success!");
35            println!("{:#?}", updated_task);
36        }
37        Err(err) => {
38            eprintln!("\n✗ Error updating task: {}", err);
39        }
40    }
41}
Source

pub async fn list_antennas(&self) -> Result<Vec<Antenna>, Error>

Examples found in repository?
examples/get_antenna.rs (line 65)
6async fn main() {
7    // Get API key from environment variable
8    let api_key = env::var("CITRA_PAT")
9        .expect("CITRA_PAT environment variable not set");
10
11    // Create client
12    let client = CitraClient::new(&api_key);
13
14    // Get telescope ID from command line argument
15    let args: Vec<String> = env::args().collect();
16    if args.len() < 2 {
17        eprintln!("Usage: cargo run --example get_antenna <antenna-id>");
18        std::process::exit(1);
19    }
20    let antenna_id = &args[1];
21
22    // Test get_antenna
23    println!("Fetching antenna: {}", antenna_id);
24    match client.get_antenna(antenna_id).await {
25        Ok(antenna) => {
26            println!("\n✓ Success!");
27            println!("{:#?}", antenna);
28        }
29        Err(e) => {
30            eprintln!("\n✗ Error: {}", e);
31            std::process::exit(1);
32        }
33    }
34
35    // Test list_tasks_for_antenna
36    println!("\n\nFetching tasks for antenna: {}", antenna_id);
37    match client.list_tasks_for_antenna(antenna_id).await {
38        Ok(tasks) => {
39            println!("\n✓ Found {} task(s) for antenna {}", tasks.len(), antenna_id);
40            for task in tasks {
41                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
42            }
43        }
44        Err(e) => {
45            eprintln!("\n✗ Error fetching tasks for antenna: {}", e);
46        }
47    }
48
49    // Test get_antenna_tasks_by_status
50    let status_filter = vec![TaskStatus::Pending];
51    println!("\n\nFetching tasks for antenna: {} with status: {:?}", antenna_id, status_filter);
52    match client.get_antenna_tasks_by_status(antenna_id, status_filter).await {
53        Ok(tasks) => {
54            for task in tasks {
55                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
56            }
57        }
58        Err(e) => {
59            eprintln!("\n✗ Error fetching tasks for antenna by status: {}", e);
60        }
61    }
62
63    // Test list_antennas
64    println!("\n\nFetching all antennas...");
65    match client.list_antennas().await {
66        Ok(antennas) => {
67            println!("\n✓ Found {} antenna(s)", antennas.len());
68            for antenna in antennas {
69                println!("  - {} ({})", antenna.name, antenna.id);
70            }
71        }
72        Err(e) => {
73            eprintln!("\n✗ Error listing antennas: {}", e);
74        }
75    }
76}
Source

pub async fn get_antenna(&self, antenna_id: &str) -> Result<Antenna, Error>

Examples found in repository?
examples/get_antenna.rs (line 24)
6async fn main() {
7    // Get API key from environment variable
8    let api_key = env::var("CITRA_PAT")
9        .expect("CITRA_PAT environment variable not set");
10
11    // Create client
12    let client = CitraClient::new(&api_key);
13
14    // Get telescope ID from command line argument
15    let args: Vec<String> = env::args().collect();
16    if args.len() < 2 {
17        eprintln!("Usage: cargo run --example get_antenna <antenna-id>");
18        std::process::exit(1);
19    }
20    let antenna_id = &args[1];
21
22    // Test get_antenna
23    println!("Fetching antenna: {}", antenna_id);
24    match client.get_antenna(antenna_id).await {
25        Ok(antenna) => {
26            println!("\n✓ Success!");
27            println!("{:#?}", antenna);
28        }
29        Err(e) => {
30            eprintln!("\n✗ Error: {}", e);
31            std::process::exit(1);
32        }
33    }
34
35    // Test list_tasks_for_antenna
36    println!("\n\nFetching tasks for antenna: {}", antenna_id);
37    match client.list_tasks_for_antenna(antenna_id).await {
38        Ok(tasks) => {
39            println!("\n✓ Found {} task(s) for antenna {}", tasks.len(), antenna_id);
40            for task in tasks {
41                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
42            }
43        }
44        Err(e) => {
45            eprintln!("\n✗ Error fetching tasks for antenna: {}", e);
46        }
47    }
48
49    // Test get_antenna_tasks_by_status
50    let status_filter = vec![TaskStatus::Pending];
51    println!("\n\nFetching tasks for antenna: {} with status: {:?}", antenna_id, status_filter);
52    match client.get_antenna_tasks_by_status(antenna_id, status_filter).await {
53        Ok(tasks) => {
54            for task in tasks {
55                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
56            }
57        }
58        Err(e) => {
59            eprintln!("\n✗ Error fetching tasks for antenna by status: {}", e);
60        }
61    }
62
63    // Test list_antennas
64    println!("\n\nFetching all antennas...");
65    match client.list_antennas().await {
66        Ok(antennas) => {
67            println!("\n✓ Found {} antenna(s)", antennas.len());
68            for antenna in antennas {
69                println!("  - {} ({})", antenna.name, antenna.id);
70            }
71        }
72        Err(e) => {
73            eprintln!("\n✗ Error listing antennas: {}", e);
74        }
75    }
76}
Source

pub async fn create_antenna(&self, antenna: &Antenna) -> Result<Antenna, Error>

Source

pub async fn delete_antenna(&self, antenna_id: &str) -> Result<(), Error>

Source

pub async fn update_antenna(&self, antenna: &Antenna) -> Result<Antenna, Error>

Source

pub async fn list_tasks_for_antenna( &self, antenna_id: &str, ) -> Result<Vec<Task>, Error>

Examples found in repository?
examples/get_antenna.rs (line 37)
6async fn main() {
7    // Get API key from environment variable
8    let api_key = env::var("CITRA_PAT")
9        .expect("CITRA_PAT environment variable not set");
10
11    // Create client
12    let client = CitraClient::new(&api_key);
13
14    // Get telescope ID from command line argument
15    let args: Vec<String> = env::args().collect();
16    if args.len() < 2 {
17        eprintln!("Usage: cargo run --example get_antenna <antenna-id>");
18        std::process::exit(1);
19    }
20    let antenna_id = &args[1];
21
22    // Test get_antenna
23    println!("Fetching antenna: {}", antenna_id);
24    match client.get_antenna(antenna_id).await {
25        Ok(antenna) => {
26            println!("\n✓ Success!");
27            println!("{:#?}", antenna);
28        }
29        Err(e) => {
30            eprintln!("\n✗ Error: {}", e);
31            std::process::exit(1);
32        }
33    }
34
35    // Test list_tasks_for_antenna
36    println!("\n\nFetching tasks for antenna: {}", antenna_id);
37    match client.list_tasks_for_antenna(antenna_id).await {
38        Ok(tasks) => {
39            println!("\n✓ Found {} task(s) for antenna {}", tasks.len(), antenna_id);
40            for task in tasks {
41                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
42            }
43        }
44        Err(e) => {
45            eprintln!("\n✗ Error fetching tasks for antenna: {}", e);
46        }
47    }
48
49    // Test get_antenna_tasks_by_status
50    let status_filter = vec![TaskStatus::Pending];
51    println!("\n\nFetching tasks for antenna: {} with status: {:?}", antenna_id, status_filter);
52    match client.get_antenna_tasks_by_status(antenna_id, status_filter).await {
53        Ok(tasks) => {
54            for task in tasks {
55                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
56            }
57        }
58        Err(e) => {
59            eprintln!("\n✗ Error fetching tasks for antenna by status: {}", e);
60        }
61    }
62
63    // Test list_antennas
64    println!("\n\nFetching all antennas...");
65    match client.list_antennas().await {
66        Ok(antennas) => {
67            println!("\n✓ Found {} antenna(s)", antennas.len());
68            for antenna in antennas {
69                println!("  - {} ({})", antenna.name, antenna.id);
70            }
71        }
72        Err(e) => {
73            eprintln!("\n✗ Error listing antennas: {}", e);
74        }
75    }
76}
Source

pub async fn get_antenna_tasks_by_status( &self, antenna_id: &str, statuses: Vec<TaskStatus>, ) -> Result<Vec<Task>, Error>

Examples found in repository?
examples/get_antenna.rs (line 52)
6async fn main() {
7    // Get API key from environment variable
8    let api_key = env::var("CITRA_PAT")
9        .expect("CITRA_PAT environment variable not set");
10
11    // Create client
12    let client = CitraClient::new(&api_key);
13
14    // Get telescope ID from command line argument
15    let args: Vec<String> = env::args().collect();
16    if args.len() < 2 {
17        eprintln!("Usage: cargo run --example get_antenna <antenna-id>");
18        std::process::exit(1);
19    }
20    let antenna_id = &args[1];
21
22    // Test get_antenna
23    println!("Fetching antenna: {}", antenna_id);
24    match client.get_antenna(antenna_id).await {
25        Ok(antenna) => {
26            println!("\n✓ Success!");
27            println!("{:#?}", antenna);
28        }
29        Err(e) => {
30            eprintln!("\n✗ Error: {}", e);
31            std::process::exit(1);
32        }
33    }
34
35    // Test list_tasks_for_antenna
36    println!("\n\nFetching tasks for antenna: {}", antenna_id);
37    match client.list_tasks_for_antenna(antenna_id).await {
38        Ok(tasks) => {
39            println!("\n✓ Found {} task(s) for antenna {}", tasks.len(), antenna_id);
40            for task in tasks {
41                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
42            }
43        }
44        Err(e) => {
45            eprintln!("\n✗ Error fetching tasks for antenna: {}", e);
46        }
47    }
48
49    // Test get_antenna_tasks_by_status
50    let status_filter = vec![TaskStatus::Pending];
51    println!("\n\nFetching tasks for antenna: {} with status: {:?}", antenna_id, status_filter);
52    match client.get_antenna_tasks_by_status(antenna_id, status_filter).await {
53        Ok(tasks) => {
54            for task in tasks {
55                println!("  - Task ID: {}, Status: {:?}", task.id, task.status);
56            }
57        }
58        Err(e) => {
59            eprintln!("\n✗ Error fetching tasks for antenna by status: {}", e);
60        }
61    }
62
63    // Test list_antennas
64    println!("\n\nFetching all antennas...");
65    match client.list_antennas().await {
66        Ok(antennas) => {
67            println!("\n✓ Found {} antenna(s)", antennas.len());
68            for antenna in antennas {
69                println!("  - {} ({})", antenna.name, antenna.id);
70            }
71        }
72        Err(e) => {
73            eprintln!("\n✗ Error listing antennas: {}", e);
74        }
75    }
76}

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more