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
//! # Remote.it API Wrapper
//!
//! The most important structs are [`R3Client`] and [`Credentials`].
//!
//! To use this crate obtain your [`Credentials`] by loading them from disk using the provided methods,
//! or, if you want to store the credentials in another way, instantiate a [`Credentials`] struct directly.
//! See [`Credentials::load_from_disk`] and [`Credentials::builder`] for details and examples.
//!
//! Then instantiate an [`R3Client`] using [`R3Client::builder`] and start calling the API functions on it.
//!
//! # Features
//!
//! - Enable `blocking` to use the blocking versions of the API functions from the [`api_blocking`] module.
//! - Enable `async` to use the asynchronous versions of the API funcitons from the [`api_async`] module.
//! - Enable `credentials_loader` to use the [`Credentials::load_from_disk`] function.
//! This is gated behind a feature, because it introduces additional dependencies.
//!
// Enable all features for the documentation tests
compile_error!;
use Builder;
// If neither the `async` nor `blocking` features are enabled, then the `auth` module is not needed.
pub use Credentials;
pub use ;
/// Base path for the remote.it API.
pub const BASE_URL: &str = "https://api.remote.it";
/// Path for the GraphQL API. Append this to [`BASE_URL`] to get the full URL.
pub const GRAPHQL_PATH: &str = "/graphql/v1";
/// Path for file uploads. Append this to [`BASE_URL`] to get the full URL.
pub const FILE_UPLOAD_PATH: &str = "/graphql/v1/file/upload";
/// A client for the remote.it API.
///
/// # Example
/// You can create a new [`R3Client`] using the builder pattern:
/// ```
/// # use remoteit_api::R3Client;
/// # use remoteit_api::Credentials;
/// let credentials: Credentials = Credentials::load_from_disk()
/// .custom_credentials_path(".env.remoteit")
/// .call()
/// .expect("Couldn't load credentials!")
/// .take_profile("default")
/// .expect("Couldn't parse secret access key!")
/// .expect("Profile with given name does not exist!");
/// let client = R3Client::builder().credentials(credentials).build();
/// // Start making API calls
/// let devices = client.get_devices().call().unwrap();
/// ```