drive_v3/objects/
app.rs

1use std::fmt;
2use serde::{Serialize, Deserialize};
3
4/// An icon for an app.
5#[derive(Default, Debug, Clone, Serialize, Deserialize)]
6#[serde(rename_all = "camelCase")]
7pub struct AppIcon {
8    /// Size of the icon.
9    ///
10    /// Represented as the maximum of the width and height.
11    #[serde(skip_serializing_if = "Option::is_none")]
12    pub size: Option<i64>,
13
14    /// Category of the icon.
15    ///
16    /// Allowed values are:
17    /// - `application`: The icon for the application.
18    /// - `document`: The icon for a file associated with the app.
19    /// - `documentShared`: The icon for a shared file associated with the app.
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub category: Option<String>,
22
23    /// URL for the icon.
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub icon_url: Option<String>,
26}
27
28impl fmt::Display for AppIcon {
29    fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
30        let json = serde_json::to_string_pretty(&self)
31            .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
32
33        write!(f, "{}", json)
34    }
35}
36
37impl AppIcon {
38    /// Creates a new, empty instance of this struct.
39    pub fn new() -> Self {
40        Self { ..Default::default() }
41    }
42}
43
44/// A list of apps which the user has installed.
45#[derive(Default, Debug, Clone, Serialize, Deserialize)]
46#[serde(rename_all = "camelCase")]
47pub struct AppList {
48    /// The list of app IDs that the user has specified to use by default.
49    ///
50    /// The list is in reverse-priority order (lowest to highest).
51    #[serde(skip_serializing_if = "Option::is_none")]
52    pub default_app_ids: Option<Vec<String>>,
53
54    /// Identifies what kind of resource this is.
55    ///
56    /// This always is `drive#appList`.
57    #[serde(skip_serializing_if = "Option::is_none")]
58    pub kind: Option<String>,
59
60    /// A link back to this list.
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub self_link: Option<String>,
63
64    /// The list of apps.
65    #[serde(skip_serializing_if = "Option::is_none")]
66    pub items: Option<Vec<App>>,
67}
68
69impl fmt::Display for AppList {
70    fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
71        let json = serde_json::to_string_pretty(&self)
72            .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
73
74        write!(f, "{}", json)
75    }
76}
77
78impl AppList {
79    /// Creates a new, empty instance of this struct.
80    pub fn new() -> Self {
81        Self { ..Default::default() }
82    }
83}
84
85/// An app that a user has installed.
86///
87/// Contains information about its supported MIME types, file extensions, and 
88/// other details.
89#[derive(Default, Debug, Clone, Serialize, Deserialize)]
90#[serde(rename_all = "camelCase")]
91pub struct App {
92    /// The name of the app.
93    #[serde(skip_serializing_if = "Option::is_none")]
94    pub name: Option<String>,
95
96    /// The type of object this app creates such as a Chart.
97    ///
98    /// If empty, the app name should be used instead.
99    #[serde(skip_serializing_if = "Option::is_none")]
100    pub object_type: Option<String>,
101
102    /// Whether this app supports creating objects.
103    #[serde(skip_serializing_if = "Option::is_none")]
104    pub supports_create: Option<bool>,
105
106    /// A link to the product listing for this app.
107    #[serde(skip_serializing_if = "Option::is_none")]
108    pub product_url: Option<String>,
109
110    /// The list of primary MIME types.
111    #[serde(skip_serializing_if = "Option::is_none")]
112    pub primary_mime_types: Option<Vec<String>>,
113
114    /// The list of secondary MIME types.
115    #[serde(skip_serializing_if = "Option::is_none")]
116    pub secondary_mime_types: Option<Vec<String>>,
117
118    /// The list of primary file extensions.
119    #[serde(skip_serializing_if = "Option::is_none")]
120    pub primary_file_extensions: Option<Vec<String>>,
121
122    /// The list of secondary file extensions.
123    #[serde(skip_serializing_if = "Option::is_none")]
124    pub secondary_file_extensions: Option<Vec<String>>,
125
126    /// The ID of the app.
127    #[serde(skip_serializing_if = "Option::is_none")]
128    pub id: Option<String>,
129
130    /// Whether this app supports importing from Google Docs.
131    #[serde(skip_serializing_if = "Option::is_none")]
132    pub supports_import: Option<bool>,
133
134    /// Whether the app is installed.
135    #[serde(skip_serializing_if = "Option::is_none")]
136    pub installed: Option<bool>,
137
138    /// Whether the app is authorized to access data on the user's Drive.
139    #[serde(skip_serializing_if = "Option::is_none")]
140    pub authorized: Option<bool>,
141
142    /// The various icons for the app.
143    #[serde(skip_serializing_if = "Option::is_none")]
144    pub icons: Option<Vec<AppIcon>>,
145
146    /// Whether the app is selected as the default handler for the types it supports.
147    #[serde(skip_serializing_if = "Option::is_none")]
148    pub use_by_default: Option<bool>,
149
150    /// Identifies what kind of resource this is.
151    ///
152    /// This always is `drive#app`.
153    #[serde(skip_serializing_if = "Option::is_none")]
154    pub kind: Option<String>,
155
156    /// A short description of the app.
157    #[serde(skip_serializing_if = "Option::is_none")]
158    pub short_description: Option<String>,
159
160    /// A long description of the app.
161    #[serde(skip_serializing_if = "Option::is_none")]
162    pub long_description: Option<String>,
163
164    /// Whether this app supports opening more than one file.
165    #[serde(skip_serializing_if = "Option::is_none")]
166    pub supports_multi_open: Option<bool>,
167
168    /// The ID of the product listing for this app.
169    #[serde(skip_serializing_if = "Option::is_none")]
170    pub product_id: Option<String>,
171
172    /// The template URL for opening files with this app.
173    ///
174    /// The template contains `{ids}` or `{exportIds}` to be replaced by the
175    /// actual file IDs.
176    ///
177    /// For more information, see Google's
178    /// [Open Files](https://developers.google.com/drive/api/guides/integrate-open)
179    /// documentation.
180    #[serde(skip_serializing_if = "Option::is_none")]
181    pub open_url_template: Option<String>,
182
183    /// The URL to create a file with this app.
184    #[serde(skip_serializing_if = "Option::is_none")]
185    pub create_url: Option<String>,
186
187    /// The template URL to create a file with this app in a given folder.
188    ///
189    /// The template contains the `{folderId}` to be replaced by the folder ID
190    /// house the new file.
191    #[serde(skip_serializing_if = "Option::is_none")]
192    pub create_in_folder_template: Option<String>,
193
194    /// Whether this app supports creating files when offline.
195    #[serde(skip_serializing_if = "Option::is_none")]
196    pub supports_offline_create: Option<bool>,
197
198    /// Whether the app has Drive-wide scope.
199    ///
200    /// An app with Drive-wide scope can access all files in the user's Drive.
201    #[serde(skip_serializing_if = "Option::is_none")]
202    pub has_drive_wide_scope: Option<bool>,
203}
204
205impl fmt::Display for App {
206    fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
207        let json = serde_json::to_string_pretty(&self)
208            .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
209
210        write!(f, "{}", json)
211    }
212}
213
214impl App {
215    /// Creates a new, empty instance of this struct.
216    pub fn new() -> Self {
217        Self { ..Default::default() }
218    }
219}