drive_v3/objects/
drive.rs

1use std::fmt;
2use serde::{Serialize, Deserialize};
3
4use super::DriveCapabilities;
5
6/// Background image for a shared drive.
7#[derive(Default, Debug, Clone, Serialize, Deserialize)]
8#[serde(rename_all = "camelCase")]
9pub struct BackgroundImageFile {
10    /// The ID of an image file in Google Drive to use for the background image.
11    #[serde(skip_serializing_if = "Option::is_none")]
12    pub id: Option<String>,
13
14    /// The X coordinate of the upper left corner of the cropping area in the
15    /// background image.
16    ///
17    /// This is a value in the closed range of 0 to 1. This value represents the
18    /// horizontal distance from the left side of the entire image to the left
19    /// side of the cropping area divided by the width of the entire image.
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub x_coordinate: Option<f32>,
22
23    /// The Y coordinate of the upper left corner of the cropping area in the
24    /// background image.
25    ///
26    /// This is a value in the closed range of 0 to 1. This value represents the
27    /// vertical distance from the top side of the entire image to the top side
28    /// of the cropping area divided by the height of the entire image.
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub y_coordinate: Option<f32>,
31
32    /// The width of the cropped image in the closed range of 0 to 1.
33    ///
34    /// This value represents the width of the cropped image divided by the
35    /// width of the entire image. The height is computed by applying a width to
36    /// height aspect ratio of 80 to 9. The resulting image must be at least
37    /// 1280 pixels wide and 144 pixels high.
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub width: Option<f32>,
40}
41
42impl fmt::Display for BackgroundImageFile {
43    fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
44        let json = serde_json::to_string_pretty(&self)
45            .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
46
47        write!(f, "{}", json)
48    }
49}
50
51impl BackgroundImageFile {
52    /// Creates a new, empty instance of this struct.
53    pub fn new() -> Self {
54        Self { ..Default::default() }
55    }
56}
57
58/// A set of restrictions that apply to a shared drive or items inside a shared
59/// drive.
60#[derive(Default, Debug, Clone, Serialize, Deserialize)]
61#[serde(rename_all = "camelCase")]
62pub struct DriveRestrictions {
63    /// Whether the options to copy, print, or download files inside this shared
64    /// drive, should be disabled for readers and commenters.
65    ///
66    /// When this restriction is set to `true`, it will override the similarly
67    /// named field to `true` for any file inside this shared drive.
68    #[serde(skip_serializing_if = "Option::is_none")]
69    pub copy_requires_writer_permission: Option<bool>,
70
71    /// Whether access to this shared drive and items inside this shared drive
72    /// is restricted to users of the domain to which this shared drive belongs.
73    ///
74    /// This restriction may be overridden by other sharing policies controlled
75    /// outside of this shared drive.
76    #[serde(skip_serializing_if = "Option::is_none")]
77    pub domain_users_only: Option<bool>,
78
79    /// Whether access to items inside this shared drive is restricted to its
80    /// members.
81    #[serde(skip_serializing_if = "Option::is_none")]
82    pub drive_members_only: Option<bool>,
83
84    /// Whether administrative privileges on this shared drive are required to
85    /// modify restrictions.
86    #[serde(skip_serializing_if = "Option::is_none")]
87    pub admin_managed_restrictions: Option<bool>,
88
89    /// If `true`, only users with the organizer role can share folders. If
90    /// `false`, users with either the organizer role or the file organizer role
91    /// can share folders.
92    #[serde(skip_serializing_if = "Option::is_none")]
93    pub sharing_folders_requires_organizer_permission: Option<bool>,
94}
95
96impl fmt::Display for DriveRestrictions {
97    fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
98        let json = serde_json::to_string_pretty(&self)
99            .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
100
101        write!(f, "{}", json)
102    }
103}
104
105impl DriveRestrictions {
106    /// Creates a new, empty instance of this struct.
107    pub fn new() -> Self {
108        Self { ..Default::default() }
109    }
110}
111
112/// Representation of a shared drive.
113///
114/// Some resource methods (such as
115/// [`drives.update`](crate::resources::Drives::update)) require a driveId.
116/// Use the [`drives.list`](crate::resources::Drives::list) method to retrieve
117/// the ID for a shared drive.
118#[derive(Default, Debug, Clone, Serialize, Deserialize)]
119#[serde(rename_all = "camelCase")]
120pub struct DriveInfo {
121    /// The ID of this shared drive which is also the ID of the top level folder
122    /// of this shared drive.
123    #[serde(skip_serializing_if = "Option::is_none")]
124    pub id: Option<String>,
125
126    /// The name of this shared drive.
127    #[serde(skip_serializing_if = "Option::is_none")]
128    pub name: Option<String>,
129
130    /// The color of this shared drive as an RGB hex string.
131    ///
132    /// It can only be set on a
133    /// [`drives.update`](crate::resources::Drives::update) request that does
134    /// not set `themeId`.
135    #[serde(skip_serializing_if = "Option::is_none")]
136    pub color_rgb: Option<String>,
137
138    /// Identifies what kind of resource this is.
139    ///
140    /// This is always `drive#drive`.
141    #[serde(skip_serializing_if = "Option::is_none")]
142    pub kind: Option<String>,
143
144    /// A short-lived link to this shared drive's background image.
145    #[serde(skip_serializing_if = "Option::is_none")]
146    pub background_image_link: Option<String>,
147
148    /// Capabilities the current user has on this shared drive.
149    #[serde(skip_serializing_if = "Option::is_none")]
150    pub capabilities: Option<DriveCapabilities>,
151
152    /// The ID of the theme from which the background image and color will be
153    /// set.
154    ///
155    /// The set of possible `driveThemes` can be retrieved from a
156    /// [`about.get`](crate::resources::About::get) response. When not specified
157    /// on a [`drives.create`](crate::resources::Drives::create) request, a
158    /// random theme is chosen from which the background image and color are
159    /// set. This is a write-only field; it can only be set on requests that
160    /// don't set [`color_rgb`](DriveInfo::color_rgb) or
161    /// [`background_image_file`](DriveInfo::background_image_file).
162    #[serde(skip_serializing_if = "Option::is_none")]
163    pub theme_id: Option<String>,
164
165    /// An image file and cropping parameters from which a background image for
166    /// this shared drive is set.
167    ///
168    /// This is a write only field; it can only be set on
169    /// [`drives.update`](crate::resources::Drives::update) requests that don't
170    /// set [`theme_id`](DriveInfo::theme_id). When specified, all fields of the
171    /// [`BackgroundImageFile`](BackgroundImageFile) must be set.
172    #[serde(skip_serializing_if = "Option::is_none")]
173    pub background_image_file: Option<BackgroundImageFile>,
174
175    /// The time at which the shared drive was created (RFC 3339 date-time).
176    #[serde(skip_serializing_if = "Option::is_none")]
177    pub created_time: Option<String>,
178
179    /// Whether the shared drive is hidden from default view.
180    #[serde(skip_serializing_if = "Option::is_none")]
181    pub hidden: Option<bool>,
182
183    /// A set of restrictions that apply to this shared drive or items inside
184    /// this shared drive.
185    ///
186    /// Note that restrictions can't be set when creating a shared drive. To add
187    /// a restriction, first create a shared drive and then use
188    /// [`drives.update`](crate::resources::Drives::update) to add restrictions.
189    #[serde(skip_serializing_if = "Option::is_none")]
190    pub restrictions: Option<DriveRestrictions>,
191
192    /// The organizational unit of this shared drive.
193    ///
194    /// This field is only populated on
195    /// [`drives.list`](crate::resources::Drives::list) responses when the
196    /// `useDomainAdminAccess` parameter is set to `true`.
197    #[serde(skip_serializing_if = "Option::is_none")]
198    pub org_unit_id: Option<String>,
199}
200
201#[doc(hidden)]
202impl From<&Self> for DriveInfo {
203    fn from( reference: &Self ) -> Self {
204        reference.clone()
205    }
206}
207
208impl fmt::Display for DriveInfo {
209    fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
210        let json = serde_json::to_string_pretty(&self)
211            .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
212
213        write!(f, "{}", json)
214    }
215}
216
217impl DriveInfo {
218    /// Creates a new, empty instance of this struct.
219    pub fn new() -> Self {
220        Self { ..Default::default() }
221    }
222}
223
224/// A list of shared drives.
225#[derive(Default, Debug, Clone, Serialize, Deserialize)]
226#[serde(rename_all = "camelCase")]
227pub struct DriveInfoList {
228    /// The page token for the next page of shared drives.
229    ///
230    /// This will be absent if the end of the list has been reached. If the
231    /// token is rejected for any reason, it should be discarded, and
232    /// pagination should be restarted from the first page of results. The page
233    /// token is typically valid for several hours. However, if new items are
234    /// added or removed, your expected results might differ.
235    #[serde(skip_serializing_if = "Option::is_none")]
236    pub next_page_token: Option<String>,
237
238    /// Identifies what kind of resource this is.
239    ///
240    /// This is always `drive#driveList`.
241    #[serde(skip_serializing_if = "Option::is_none")]
242    pub kind: Option<String>,
243
244    /// The list of shared drives.
245    ///
246    /// If [`next_page_token`](DriveInfoList::next_page_token) is populated,
247    /// then this list may be incomplete and an additional page of results
248    /// should be fetched.
249    #[serde(skip_serializing_if = "Option::is_none")]
250    pub drives: Option<Vec<DriveInfo>>,
251}
252
253impl fmt::Display for DriveInfoList {
254    fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
255        let json = serde_json::to_string_pretty(&self)
256            .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
257
258        write!(f, "{}", json)
259    }
260}
261
262impl DriveInfoList {
263    /// Creates a new, empty instance of this struct.
264    pub fn new() -> Self {
265        Self { ..Default::default() }
266    }
267}