remoteit_api/
operations.rs

1#![allow(missing_docs)]
2
3use std::fmt::Display;
4use chrono::Local;
5use graphql_client::GraphQLQuery;
6
7/// Define [`DateTime`] as a [`chrono::DateTime<Local>`], because it is not a built-in type in GraphQL.
8type DateTime = chrono::DateTime<Local>;
9/// Define [`Any`] as a [`serde_json::Value`], because it is not a built-in type in GraphQL.
10type Any = serde_json::Value;
11/// Define [`Object`] as a [`serde_json::Map<String, Any>`], because it is not a built-in type in GraphQL.
12type Object = serde_json::Map<String, Any>;
13
14// region Scripting
15
16/// Query, which retrieves a list of files, that were uploaded to remote.it.
17#[derive(GraphQLQuery)]
18#[graphql(
19    schema_path = "src/graphql/schema.json",
20    query_path = "src/graphql/GetFiles.graphql",
21    response_derives = "Debug"
22)]
23pub struct GetFiles;
24
25/// Mutation, which deletes a file from remote.it. Deletes all versions of the file.
26#[derive(GraphQLQuery)]
27#[graphql(
28    schema_path = "src/graphql/schema.json",
29    query_path = "src/graphql/DeleteFile.graphql",
30    response_derives = "Debug"
31)]
32pub struct DeleteFile;
33
34/// Mutation, which deletes a version of a file from remote.it. (Not the whole file)
35#[derive(GraphQLQuery)]
36#[graphql(
37    schema_path = "src/graphql/schema.json",
38    query_path = "src/graphql/DeleteFileVersion.graphql",
39    response_derives = "Debug"
40)]
41pub struct DeleteFileVersion;
42
43/// Execution, to start scripting jobs on one or more devices.
44#[derive(GraphQLQuery)]
45#[graphql(
46    schema_path = "src/graphql/schema.json",
47    query_path = "src/graphql/StartJob.graphql",
48    response_derives = "Debug"
49)]
50pub struct StartJob;
51
52/// Execution, to cancel a job. See remote.it docs on more information on when jobs can be cancelled.
53#[derive(GraphQLQuery)]
54#[graphql(
55    schema_path = "src/graphql/schema.json",
56    query_path = "src/graphql/CancelJob.graphql",
57    response_derives = "Debug"
58)]
59pub struct CancelJob;
60
61/// Query, which retrieves a list of jobs, that were started on remote.it.
62/// You can filter the jobs.
63#[derive(GraphQLQuery)]
64#[graphql(
65    schema_path = "src/graphql/schema.json",
66    query_path = "src/graphql/GetJobs.graphql",
67    response_derives = "Debug"
68)]
69pub struct GetJobs;
70// endregion
71// region Organizations
72#[derive(GraphQLQuery)]
73#[graphql(
74    schema_path = "src/graphql/schema.json",
75    query_path = "src/graphql/GetOwnedOrganization.graphql",
76    response_derives = "Debug"
77)]
78pub struct GetOwnedOrganization;
79
80#[derive(GraphQLQuery)]
81#[graphql(
82    schema_path = "src/graphql/schema.json",
83    query_path = "src/graphql/GetOrganizationSelfMembership.graphql",
84    response_derives = "Debug"
85)]
86pub struct GetOrganizationSelfMembership;
87// endregion
88// region Devices and Services
89
90/// Query, which retrieves a list of services, that are available on remote.it.
91#[derive(GraphQLQuery)]
92#[graphql(
93    schema_path = "src/graphql/schema.json",
94    query_path = "src/graphql/GetApplicationTypes.graphql",
95    response_derives = "Debug"
96)]
97pub struct GetApplicationTypes;
98
99/// Query, which retrieves a list of devices.
100/// You can use this to get the IDs of devices, for example for starting scripting jobs.
101#[derive(GraphQLQuery)]
102#[graphql(
103    schema_path = "src/graphql/schema.json",
104    query_path = "src/graphql/GetDevices.graphql",
105    response_derives = "Debug"
106)]
107pub struct GetDevices;
108/// Represents the state of a device.
109/// This is a implemented as a custom type, because in the GraphQL schema this is just a string.
110///
111/// This enum is intended to be used with the [`R3Client::get_devices`](crate::R3Client::get_devices) and [`R3Client::get_devices_async`](crate::R3Client::get_devices_async) functions.
112///
113/// - [`DeviceState::Active`] corresponds to the device being online.
114/// - [`DeviceState::Inactive`] corresponds to the device being offline.
115///
116/// The online-state of a device is also represented in the `online` field of the device. (when querying devices)
117pub enum DeviceState {
118    /// The device is online.
119    Active,
120    /// The device is offline.
121    Inactive,
122}
123impl Display for DeviceState {
124    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
125        match self {
126            DeviceState::Active => write!(f, "active"),
127            DeviceState::Inactive => write!(f, "inactive"),
128        }
129    }
130}
131
132/// Query, which retrieves a download link for a CSV file, that contains information about devices.
133#[derive(GraphQLQuery)]
134#[graphql(
135    schema_path = "src/graphql/schema.json",
136    query_path = "src/graphql/GetDevicesCSV.graphql",
137    response_derives = "Debug"
138)]
139pub struct GetDevicesCSV;
140// endregion