pub struct CitraClient { /* private fields */ }Implementations§
Source§impl CitraClient
impl CitraClient
Sourcepub fn new(api_key: &str) -> Self
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
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}Sourcepub async fn get_telescope(
&self,
telescope_id: &str,
) -> Result<Telescope, Error>
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}Sourcepub async fn list_telescopes(&self) -> Result<Vec<Telescope>, Error>
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}pub async fn create_telescope( &self, telescope: &Telescope, ) -> Result<Telescope, Error>
pub async fn delete_telescope(&self, telescope_id: &str) -> Result<(), Error>
pub async fn update_telescope( &self, telescope: &Telescope, ) -> Result<Telescope, Error>
Sourcepub async fn get_groundstation(
&self,
groundstation_id: &str,
) -> Result<Groundstation, Error>
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}Sourcepub async fn list_groundstations(&self) -> Result<Vec<Groundstation>, Error>
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}pub async fn create_groundstation( &self, groundstation: &Groundstation, ) -> Result<Groundstation, Error>
pub async fn delete_groundstation( &self, groundstation_id: &str, ) -> Result<(), Error>
pub async fn update_groundstation( &self, groundstation: &Groundstation, ) -> Result<Groundstation, Error>
Sourcepub async fn list_tasks_for_telescope(
&self,
telescope_id: &str,
) -> Result<Vec<Task>, Error>
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}Sourcepub async fn get_telescope_tasks_by_status(
&self,
telescope_id: &str,
statuses: Vec<TaskStatus>,
) -> Result<Vec<Task>, Error>
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}Sourcepub async fn update_task(&self, task: &TaskUpdateRequest) -> Result<Task, Error>
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}Sourcepub async fn list_antennas(&self) -> Result<Vec<Antenna>, Error>
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}Sourcepub async fn get_antenna(&self, antenna_id: &str) -> Result<Antenna, Error>
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}pub async fn create_antenna(&self, antenna: &Antenna) -> Result<Antenna, Error>
pub async fn delete_antenna(&self, antenna_id: &str) -> Result<(), Error>
pub async fn update_antenna(&self, antenna: &Antenna) -> Result<Antenna, Error>
Sourcepub async fn list_tasks_for_antenna(
&self,
antenna_id: &str,
) -> Result<Vec<Task>, Error>
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}Sourcepub async fn get_antenna_tasks_by_status(
&self,
antenna_id: &str,
statuses: Vec<TaskStatus>,
) -> Result<Vec<Task>, Error>
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§
impl Freeze for CitraClient
impl RefUnwindSafe for CitraClient
impl Send for CitraClient
impl Sync for CitraClient
impl Unpin for CitraClient
impl UnwindSafe for CitraClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more